summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-08 22:27:21 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-08 22:27:21 +0000
commit207ff6675717b341d3c78d305762cd6d7a9888e1 (patch)
treebe0cd36338515ddc69935e6f2966f59b181d08aa /ui
parentafaf073bb190f4e3becd8e1cd60dde6324f7ae15 (diff)
downloadchromium_src-207ff6675717b341d3c78d305762cd6d7a9888e1.zip
chromium_src-207ff6675717b341d3c78d305762cd6d7a9888e1.tar.gz
chromium_src-207ff6675717b341d3c78d305762cd6d7a9888e1.tar.bz2
Attempt 2 at : Makes tests either use mock compositor or mock
WebGraphicsContext3D depending upon which compositor we're running. This is needed to enable ui tests on the bots. I reverted first attempt as it broke some browser_tests. I've straightened that out in another patch, so this should be good go again. TBR since it's the same patch as before. BUG=104360 TEST=none TBR=ben@chromium.org Review URL: http://codereview.chromium.org/8889022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113676 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/aura.gyp18
-rw-r--r--ui/aura/test/test_suite.cc10
-rw-r--r--ui/aura_shell/aura_shell.gyp12
-rw-r--r--ui/aura_shell/test_suite.cc9
-rw-r--r--ui/gfx/compositor/compositor.gyp8
-rw-r--r--ui/gfx/compositor/compositor_cc.cc27
-rw-r--r--ui/gfx/compositor/compositor_cc.h7
-rw-r--r--ui/gfx/compositor/compositor_setup.h28
-rw-r--r--ui/gfx/compositor/compositor_switches.cc2
-rw-r--r--ui/gfx/compositor/compositor_switches.h1
-rw-r--r--ui/gfx/compositor/layer_unittest.cc24
-rw-r--r--ui/views/run_all_unittests.cc11
-rw-r--r--ui/views/view_unittest.cc7
-rw-r--r--ui/views/views.gyp10
14 files changed, 143 insertions, 31 deletions
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index 735f067..f6e03a6 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -60,7 +60,6 @@
'dependencies': [
'../../skia/skia.gyp:skia',
'../../testing/gtest.gyp:gtest',
- '../gfx/compositor/compositor.gyp:test_compositor',
'../ui.gyp:ui',
'aura',
],
@@ -81,6 +80,13 @@
'test/test_window_delegate.cc',
'test/test_window_delegate.h',
],
+ 'conditions': [
+ ['use_webkit_compositor==0', {
+ 'dependencies': [
+ '../gfx/compositor/compositor.gyp:test_compositor',
+ ],
+ }],
+ ],
},
{
'target_name': 'aura_demo',
@@ -116,7 +122,6 @@
'../../skia/skia.gyp:skia',
'../../testing/gtest.gyp:gtest',
'../gfx/compositor/compositor.gyp:compositor_test_support',
- '../gfx/compositor/compositor.gyp:test_compositor',
'../gfx/gl/gl.gyp:gl',
'../ui.gyp:gfx_resources',
'../ui.gyp:ui',
@@ -144,6 +149,15 @@
'<(DEPTH)/third_party/mesa/mesa.gyp:osmesa',
],
}],
+ ['use_webkit_compositor==1', {
+ 'dependencies': [
+ '../gfx/compositor/compositor.gyp:compositor',
+ ],
+ }, { # use_webkit_compositor!=1
+ 'dependencies': [
+ '../gfx/compositor/compositor.gyp:test_compositor',
+ ],
+ }],
],
},
],
diff --git a/ui/aura/test/test_suite.cc b/ui/aura/test/test_suite.cc
index bbf3428..8fb8d2e 100644
--- a/ui/aura/test/test_suite.cc
+++ b/ui/aura/test/test_suite.cc
@@ -12,7 +12,12 @@
#include "ui/gfx/compositor/test/compositor_test_support.h"
#include "ui/gfx/gfx_paths.h"
#include "ui/gfx/gl/gl_implementation.h"
+
+#if defined(USE_WEBKIT_COMPOSITOR)
+#include "ui/gfx/compositor/compositor_setup.h"
+#else
#include "ui/gfx/test/gfx_test_utils.h"
+#endif
namespace aura {
namespace test {
@@ -30,7 +35,12 @@ void AuraTestSuite::Initialize() {
// output, it'll pass regardless of the system language.
ui::ResourceBundle::InitSharedInstance("en-US");
ui::CompositorTestSupport::Initialize();
+
+#if defined(USE_WEBKIT_COMPOSITOR)
+ ui::SetupTestCompositor();
+#else
ui::gfx_test_utils::SetupTestCompositor();
+#endif
}
void AuraTestSuite::Shutdown() {
diff --git a/ui/aura_shell/aura_shell.gyp b/ui/aura_shell/aura_shell.gyp
index 2e1d430..fc4f0d1 100644
--- a/ui/aura_shell/aura_shell.gyp
+++ b/ui/aura_shell/aura_shell.gyp
@@ -135,7 +135,6 @@
'../aura/aura.gyp:aura',
'../aura/aura.gyp:test_support_aura',
'../gfx/compositor/compositor.gyp:compositor_test_support',
- '../gfx/compositor/compositor.gyp:test_compositor',
'../ui.gyp:gfx_resources',
'../ui.gyp:ui',
'../ui.gyp:ui_resources',
@@ -170,6 +169,17 @@
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/ui_resources_standard.rc',
],
+ 'conditions': [
+ ['use_webkit_compositor==1', {
+ 'dependencies': [
+ '../gfx/compositor/compositor.gyp:compositor',
+ ],
+ }, { # use_webkit_compositor!=1
+ 'dependencies': [
+ '../gfx/compositor/compositor.gyp:test_compositor',
+ ],
+ }],
+ ],
},
{
'target_name': 'aura_shell_exe',
diff --git a/ui/aura_shell/test_suite.cc b/ui/aura_shell/test_suite.cc
index d1168b9..3c1eab9 100644
--- a/ui/aura_shell/test_suite.cc
+++ b/ui/aura_shell/test_suite.cc
@@ -11,7 +11,12 @@
#include "ui/base/ui_base_paths.h"
#include "ui/gfx/compositor/test/compositor_test_support.h"
#include "ui/gfx/gfx_paths.h"
+
+#if defined(USE_WEBKIT_COMPOSITOR)
+#include "ui/gfx/compositor/compositor_setup.h"
+#else
#include "ui/gfx/test/gfx_test_utils.h"
+#endif
namespace aura_shell {
namespace test {
@@ -29,7 +34,11 @@ void AuraShellTestSuite::Initialize() {
// output, it'll pass regardless of the system language.
ui::ResourceBundle::InitSharedInstance("en-US");
ui::CompositorTestSupport::Initialize();
+#if defined(USE_WEBKIT_COMPOSITOR)
+ ui::SetupTestCompositor();
+#else
ui::gfx_test_utils::SetupTestCompositor();
+#endif
}
void AuraShellTestSuite::Shutdown() {
diff --git a/ui/gfx/compositor/compositor.gyp b/ui/gfx/compositor/compositor.gyp
index f5c6f35..2c3ae46 100644
--- a/ui/gfx/compositor/compositor.gyp
+++ b/ui/gfx/compositor/compositor.gyp
@@ -42,6 +42,7 @@
'compositor_cc.cc',
'compositor_cc.h',
'compositor_observer.h',
+ 'compositor_setup.h',
'compositor_stub.cc',
'compositor_switches.cc',
'compositor_switches.h',
@@ -107,6 +108,7 @@
'sources!': [
'compositor_cc.cc',
'compositor_cc.h',
+ 'compositor_setup.h',
'test_web_graphics_context_3d.cc',
'test_web_graphics_context_3d.h',
],
@@ -157,7 +159,6 @@
'<(DEPTH)/ui/ui.gyp:ui_resources',
'compositor',
'compositor_test_support',
- 'test_compositor',
],
'sources': [
'layer_animation_element_unittest.cc',
@@ -187,6 +188,11 @@
'<(DEPTH)/third_party/mesa/mesa.gyp:osmesa',
],
}],
+ ['use_webkit_compositor==0', {
+ 'dependencies': [
+ 'test_compositor',
+ ],
+ }],
],
},
{
diff --git a/ui/gfx/compositor/compositor_cc.cc b/ui/gfx/compositor/compositor_cc.cc
index 2ebed68..3b44124 100644
--- a/ui/gfx/compositor/compositor_cc.cc
+++ b/ui/gfx/compositor/compositor_cc.cc
@@ -22,7 +22,12 @@
#include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
namespace {
+
webkit_glue::WebThreadImpl* g_compositor_thread = NULL;
+
+// If true a context is used that results in no rendering to the screen.
+bool test_context_enabled = false;
+
} // anonymous namespace
namespace ui {
@@ -121,9 +126,6 @@ void TextureCC::Draw(const ui::TextureDrawParams& params,
NOTREACHED();
}
-// static
-bool CompositorCC::test_context_enabled_ = false;
-
CompositorCC::CompositorCC(CompositorDelegate* delegate,
gfx::AcceleratedWidget widget,
const gfx::Size& size)
@@ -172,12 +174,6 @@ void CompositorCC::Terminate() {
}
}
-// static
-void CompositorCC::EnableTestContextIfNecessary() {
- // TODO: only do this if command line param not set.
- test_context_enabled_ = true;
-}
-
Texture* CompositorCC::CreateTexture() {
NOTREACHED();
return NULL;
@@ -247,7 +243,7 @@ void CompositorCC::applyScrollDelta(const WebKit::WebSize&) {
WebKit::WebGraphicsContext3D* CompositorCC::createContext3D() {
WebKit::WebGraphicsContext3D* context;
- if (test_context_enabled_) {
+ if (test_context_enabled) {
context = new TestWebGraphicsContext3D();
} else {
gfx::GLShareGroup* share_group =
@@ -286,4 +282,15 @@ Compositor* Compositor::Create(CompositorDelegate* owner,
return new CompositorCC(owner, widget, size);
}
+COMPOSITOR_EXPORT void SetupTestCompositor() {
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableTestCompositor)) {
+ test_context_enabled = true;
+ }
+}
+
+COMPOSITOR_EXPORT void DisableTestCompositor() {
+ test_context_enabled = false;
+}
+
} // namespace ui
diff --git a/ui/gfx/compositor/compositor_cc.h b/ui/gfx/compositor/compositor_cc.h
index def2181..3216f9e 100644
--- a/ui/gfx/compositor/compositor_cc.h
+++ b/ui/gfx/compositor/compositor_cc.h
@@ -90,10 +90,6 @@ class COMPOSITOR_EXPORT CompositorCC
static void Initialize(bool useThread);
static void Terminate();
- // If necessary enables the test context. If the test context is enabled the
- // compositor does not render anything to screen.
- static void EnableTestContextIfNecessary();
-
protected:
// Compositor implementation.
virtual Texture* CreateTexture() OVERRIDE;
@@ -123,9 +119,6 @@ class COMPOSITOR_EXPORT CompositorCC
WebKit::WebLayer root_web_layer_;
WebKit::WebLayerTreeView host_;
- // See description above SetTestContextEnabled.
- static bool test_context_enabled_;
-
DISALLOW_COPY_AND_ASSIGN(CompositorCC);
};
diff --git a/ui/gfx/compositor/compositor_setup.h b/ui/gfx/compositor/compositor_setup.h
new file mode 100644
index 0000000..a339ede
--- /dev/null
+++ b/ui/gfx/compositor/compositor_setup.h
@@ -0,0 +1,28 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GFX_COMPOSITOR_COMPOSITOR_SETUP_H_
+#define UI_GFX_COMPOSITOR_COMPOSITOR_SETUP_H_
+#pragma once
+
+#include "ui/gfx/compositor/compositor_export.h"
+
+namespace ui {
+
+// Configures the compositor in such a way that it doesn't render anything.
+// Does nothing on platforms that aren't using the compositor.
+#if !defined(VIEWS_COMPOSITOR)
+// To centralize the ifdef to this file we define the function as doing nothing
+// on all platforms that don't use a compositor.
+COMPOSITOR_EXPORT void SetupTestCompositor() {}
+#else
+COMPOSITOR_EXPORT void SetupTestCompositor();
+
+// Disables the test compositor so that the normal compositor is used.
+COMPOSITOR_EXPORT void DisableTestCompositor();
+#endif
+
+} // namespace ui
+
+#endif // UI_GFX_COMPOSITOR_COMPOSITOR_SETUP_H_
diff --git a/ui/gfx/compositor/compositor_switches.cc b/ui/gfx/compositor/compositor_switches.cc
index b2bb0b7..77fea77 100644
--- a/ui/gfx/compositor/compositor_switches.cc
+++ b/ui/gfx/compositor/compositor_switches.cc
@@ -6,6 +6,8 @@
namespace switches {
+const char kDisableTestCompositor[] = "disable-test-compositor";
+
const char kDisableUIVsync[] = "disable-ui-vsync";
const char kEnableCompositorOverdrawDebugging[] =
diff --git a/ui/gfx/compositor/compositor_switches.h b/ui/gfx/compositor/compositor_switches.h
index 805468b..9040cb0 100644
--- a/ui/gfx/compositor/compositor_switches.h
+++ b/ui/gfx/compositor/compositor_switches.h
@@ -10,6 +10,7 @@
namespace switches {
+COMPOSITOR_EXPORT extern const char kDisableTestCompositor[];
COMPOSITOR_EXPORT extern const char kDisableUIVsync[];
COMPOSITOR_EXPORT extern const char kEnableCompositorOverdrawDebugging[];
COMPOSITOR_EXPORT extern const char kUIShowFPSCounter[];
diff --git a/ui/gfx/compositor/layer_unittest.cc b/ui/gfx/compositor/layer_unittest.cc
index 253683c..5bf8b69 100644
--- a/ui/gfx/compositor/layer_unittest.cc
+++ b/ui/gfx/compositor/layer_unittest.cc
@@ -15,10 +15,15 @@
#include "ui/gfx/compositor/compositor_observer.h"
#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/compositor/layer_animation_sequence.h"
-#include "ui/gfx/compositor/test/test_compositor.h"
#include "ui/gfx/compositor/test/test_compositor_host.h"
#include "ui/gfx/gfx_paths.h"
+#if defined(USE_WEBKIT_COMPOSITOR)
+#include "ui/gfx/compositor/compositor_setup.h"
+#else
+#include "ui/gfx/compositor/test/test_compositor.h"
+#endif
+
namespace ui {
namespace {
@@ -106,10 +111,9 @@ std::string GetLayerChildrenNames(const Layer& layer) {
// There are three test classes in here that configure the Compositor and
// Layer's slightly differently:
-// - LayerWithNullDelegateTest uses TestCompositor and NullLayerDelegate as the
-// LayerDelegate. This is typically the base class you want to use.
-// - LayerWithDelegateTest uses TestCompositor and does not set a LayerDelegate
-// on the delegates.
+// - LayerWithNullDelegateTest uses NullLayerDelegate as the LayerDelegate. This
+// is typically the base class you want to use.
+// - LayerWithDelegateTest uses LayerDelegate on the delegates.
// - LayerWithRealCompositorTest when a real compositor is required for testing.
// - Slow because they bring up a window and run the real compositor. This
// is typically not what you want.
@@ -146,6 +150,9 @@ class LayerWithRealCompositorTest : public testing::Test {
// Overridden from testing::Test:
virtual void SetUp() OVERRIDE {
+#if defined(USE_WEBKIT_COMPOSITOR)
+ ui::DisableTestCompositor();
+#endif
const gfx::Rect host_bounds(10, 10, 500, 500);
window_.reset(TestCompositorHost::Create(host_bounds));
window_->Show();
@@ -359,7 +366,12 @@ class LayerWithDelegateTest : public testing::Test, public CompositorDelegate {
// Overridden from testing::Test:
virtual void SetUp() OVERRIDE {
+#if defined(USE_WEBKIT_COMPOSITOR)
+ ui::SetupTestCompositor();
+ compositor_ = ui::Compositor::Create(this, NULL, gfx::Size(1000, 1000));
+#else
compositor_ = new TestCompositor(this);
+#endif
}
virtual void TearDown() OVERRIDE {
@@ -413,7 +425,7 @@ class LayerWithDelegateTest : public testing::Test, public CompositorDelegate {
bool schedule_draw_invoked_;
private:
- scoped_refptr<TestCompositor> compositor_;
+ scoped_refptr<ui::Compositor> compositor_;
DISALLOW_COPY_AND_ASSIGN(LayerWithDelegateTest);
};
diff --git a/ui/views/run_all_unittests.cc b/ui/views/run_all_unittests.cc
index e675291..9273994 100644
--- a/ui/views/run_all_unittests.cc
+++ b/ui/views/run_all_unittests.cc
@@ -6,9 +6,14 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
#include "ui/gfx/compositor/test/compositor_test_support.h"
-#include "ui/gfx/test/gfx_test_utils.h"
#include "ui/views/view.h"
+#if defined(USE_WEBKIT_COMPOSITOR)
+#include "ui/gfx/compositor/compositor_setup.h"
+#else
+#include "ui/gfx/test/gfx_test_utils.h"
+#endif
+
class ViewTestSuite : public base::TestSuite {
public:
ViewTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {}
@@ -21,7 +26,11 @@ class ViewTestSuite : public base::TestSuite {
ui::ResourceBundle::InitSharedInstance("en-US");
ui::CompositorTestSupport::Initialize();
+#if defined(USE_WEBKIT_COMPOSITOR)
+ ui::SetupTestCompositor();
+#else
ui::gfx_test_utils::SetupTestCompositor();
+#endif
}
virtual void Shutdown() {
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index 0fd4c21..0752eb1 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -17,8 +17,6 @@
#include "ui/gfx/compositor/compositor.h"
#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/compositor/layer_animator.h"
-#include "ui/gfx/compositor/test/test_compositor.h"
-#include "ui/gfx/compositor/test/test_texture.h"
#include "ui/gfx/path.h"
#include "ui/gfx/transform.h"
#include "ui/views/background.h"
@@ -44,6 +42,9 @@
#if defined(USE_AURA)
#include "ui/aura/root_window.h"
#endif
+#if !defined(USE_WEBKIT_COMPOSITOR)
+#include "ui/gfx/compositor/test/test_texture.h"
+#endif
using ::testing::_;
@@ -2531,7 +2532,9 @@ class ViewLayerTest : public ViewsTestBase {
old_use_acceleration_ = View::get_use_acceleration_when_possible();
View::set_use_acceleration_when_possible(true);
+#if !defined(USE_WEBKIT_COMPOSITOR)
ui::TestTexture::reset_live_count();
+#endif
widget_ = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
diff --git a/ui/views/views.gyp b/ui/views/views.gyp
index 3b60864..cefa162 100644
--- a/ui/views/views.gyp
+++ b/ui/views/views.gyp
@@ -498,7 +498,6 @@
'../../third_party/icu/icu.gyp:icuuc',
'../base/strings/ui_strings.gyp:ui_strings',
'../gfx/compositor/compositor.gyp:compositor_test_support',
- '../gfx/compositor/compositor.gyp:test_compositor',
'../ui.gyp:gfx_resources',
'../ui.gyp:ui',
'../ui.gyp:ui_resources',
@@ -594,6 +593,15 @@
['exclude', 'test/test_tooltip_client.cc'],
],
}],
+ ['use_webkit_compositor==1', {
+ 'dependencies': [
+ '../gfx/compositor/compositor.gyp:compositor',
+ ],
+ }, { # use_webkit_compositor!=1
+ 'dependencies': [
+ '../gfx/compositor/compositor.gyp:test_compositor',
+ ],
+ }],
],
}, # target_name: views_unittests
{