First draft to enable turning off compositor for unit tests.

Tests will be re-enabled when appropriate changes are made to support GL compositor testing.

BUG=unit tests not ready for GL compositor at this time.
TEST=unit tests run to completion.

Review URL: http://codereview.chromium.org/7104039

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88521 0039d316-1c4b-4281-b951-d872f2087c98
parent d65beda3
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_paths.h"
#if defined(TOOLKIT_VIEWS)
#include "views/view.h"
#endif
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
#include "base/mac/mac_util.h" #include "base/mac/mac_util.h"
...@@ -141,6 +144,11 @@ void ChromeTestSuite::Initialize() { ...@@ -141,6 +144,11 @@ void ChromeTestSuite::Initialize() {
RemoveSharedMemoryFile(stats_filename_); RemoveSharedMemoryFile(stats_filename_);
stats_table_ = new base::StatsTable(stats_filename_, 20, 200); stats_table_ = new base::StatsTable(stats_filename_, 20, 200);
base::StatsTable::set_current(stats_table_); base::StatsTable::set_current(stats_table_);
#if defined(TOUCH_UI)
// Turn of GPU compositing in browser during unit tests.
views::View::set_use_acceleration_when_possible(false);
#endif
} }
void ChromeTestSuite::Shutdown() { void ChromeTestSuite::Shutdown() {
......
...@@ -357,9 +357,9 @@ bool CompositorGL::InitShaders() { ...@@ -357,9 +357,9 @@ bool CompositorGL::InitShaders() {
// static // static
Compositor* Compositor::Create(gfx::AcceleratedWidget widget) { Compositor* Compositor::Create(gfx::AcceleratedWidget widget) {
gfx::GLSurface::InitializeOneOff(); gfx::GLSurface::InitializeOneOff();
if (gfx::GetGLImplementation() != gfx::kGLImplementationNone) if (gfx::GetGLImplementation() != gfx::kGLImplementationNone)
return new glHidden::CompositorGL(widget); return new glHidden::CompositorGL(widget);
return NULL; return NULL;
} }
#else #else
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/test/test_suite.h" #include "base/test/test_suite.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_paths.h"
#include "views/view.h"
class ViewTestSuite : public base::TestSuite { class ViewTestSuite : public base::TestSuite {
public: public:
...@@ -17,6 +18,11 @@ class ViewTestSuite : public base::TestSuite { ...@@ -17,6 +18,11 @@ class ViewTestSuite : public base::TestSuite {
ui::RegisterPathProvider(); ui::RegisterPathProvider();
base::TestSuite::Initialize(); base::TestSuite::Initialize();
ResourceBundle::InitSharedInstance("en-US"); ResourceBundle::InitSharedInstance("en-US");
#if defined(TOUCH_UI)
// Disable GPU browser compositor during unit tests.
views::View::set_use_acceleration_when_possible(false);
#endif
} }
}; };
......
...@@ -762,6 +762,11 @@ void View::set_use_acceleration_when_possible(bool use) { ...@@ -762,6 +762,11 @@ void View::set_use_acceleration_when_possible(bool use) {
use_acceleration_when_possible = use; use_acceleration_when_possible = use;
} }
// static
bool View::get_use_acceleration_when_possible() {
return use_acceleration_when_possible;
}
// Input ----------------------------------------------------------------------- // Input -----------------------------------------------------------------------
View* View::GetEventHandlerForPoint(const gfx::Point& point) { View* View::GetEventHandlerForPoint(const gfx::Point& point) {
......
...@@ -546,6 +546,7 @@ class View : public AcceleratorTarget { ...@@ -546,6 +546,7 @@ class View : public AcceleratorTarget {
// Enable/Disable accelerated compositing. // Enable/Disable accelerated compositing.
static void set_use_acceleration_when_possible(bool use); static void set_use_acceleration_when_possible(bool use);
static bool get_use_acceleration_when_possible();
// Input --------------------------------------------------------------------- // Input ---------------------------------------------------------------------
// The points (and mouse locations) in the following functions are in the // The points (and mouse locations) in the following functions are in the
......
...@@ -757,7 +757,8 @@ void Widget::EnsureCompositor() { ...@@ -757,7 +757,8 @@ void Widget::EnsureCompositor() {
// TODO(sad): If there is a parent Widget, then use the same compositor // TODO(sad): If there is a parent Widget, then use the same compositor
// instead of creating a new one here. // instead of creating a new one here.
gfx::AcceleratedWidget widget = native_widget_->GetAcceleratedWidget(); gfx::AcceleratedWidget widget = native_widget_->GetAcceleratedWidget();
if (widget != gfx::kNullAcceleratedWidget) if (widget != gfx::kNullAcceleratedWidget &&
View::get_use_acceleration_when_possible())
compositor_ = ui::Compositor::Create(widget); compositor_ = ui::Compositor::Create(widget);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment