summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-07 23:56:31 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-07 23:56:31 +0000
commit973d44a198f2fa9314ecbe43b06f0a7d622dfc7e (patch)
tree4065dfa54da57bfc46f7f7fbcbd13001a31eafb6 /ui
parent023caca1556db34fef0b98bb484b39c653758755 (diff)
downloadchromium_src-973d44a198f2fa9314ecbe43b06f0a7d622dfc7e.zip
chromium_src-973d44a198f2fa9314ecbe43b06f0a7d622dfc7e.tar.gz
chromium_src-973d44a198f2fa9314ecbe43b06f0a7d622dfc7e.tar.bz2
Revert 113470 - 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.
BUG=104360 TEST=none Review URL: http://codereview.chromium.org/8805033 TBR=sky@chromium.org Review URL: http://codereview.chromium.org/8873001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113507 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, 31 insertions, 143 deletions
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index f6e03a6..735f067 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -60,6 +60,7 @@
'dependencies': [
'../../skia/skia.gyp:skia',
'../../testing/gtest.gyp:gtest',
+ '../gfx/compositor/compositor.gyp:test_compositor',
'../ui.gyp:ui',
'aura',
],
@@ -80,13 +81,6 @@
'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',
@@ -122,6 +116,7 @@
'../../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',
@@ -149,15 +144,6 @@
'<(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 8fb8d2e..bbf3428 100644
--- a/ui/aura/test/test_suite.cc
+++ b/ui/aura/test/test_suite.cc
@@ -12,12 +12,7 @@
#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 {
@@ -35,12 +30,7 @@ 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 fc4f0d1..2e1d430 100644
--- a/ui/aura_shell/aura_shell.gyp
+++ b/ui/aura_shell/aura_shell.gyp
@@ -135,6 +135,7 @@
'../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',
@@ -169,17 +170,6 @@
'<(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 3c1eab9..d1168b9 100644
--- a/ui/aura_shell/test_suite.cc
+++ b/ui/aura_shell/test_suite.cc
@@ -11,12 +11,7 @@
#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 {
@@ -34,11 +29,7 @@ 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 2c3ae46..f5c6f35 100644
--- a/ui/gfx/compositor/compositor.gyp
+++ b/ui/gfx/compositor/compositor.gyp
@@ -42,7 +42,6 @@
'compositor_cc.cc',
'compositor_cc.h',
'compositor_observer.h',
- 'compositor_setup.h',
'compositor_stub.cc',
'compositor_switches.cc',
'compositor_switches.h',
@@ -108,7 +107,6 @@
'sources!': [
'compositor_cc.cc',
'compositor_cc.h',
- 'compositor_setup.h',
'test_web_graphics_context_3d.cc',
'test_web_graphics_context_3d.h',
],
@@ -159,6 +157,7 @@
'<(DEPTH)/ui/ui.gyp:ui_resources',
'compositor',
'compositor_test_support',
+ 'test_compositor',
],
'sources': [
'layer_animation_element_unittest.cc',
@@ -188,11 +187,6 @@
'<(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 3b44124..2ebed68 100644
--- a/ui/gfx/compositor/compositor_cc.cc
+++ b/ui/gfx/compositor/compositor_cc.cc
@@ -22,12 +22,7 @@
#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 {
@@ -126,6 +121,9 @@ 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)
@@ -174,6 +172,12 @@ 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;
@@ -243,7 +247,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 =
@@ -282,15 +286,4 @@ 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 3216f9e..def2181 100644
--- a/ui/gfx/compositor/compositor_cc.h
+++ b/ui/gfx/compositor/compositor_cc.h
@@ -90,6 +90,10 @@ 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;
@@ -119,6 +123,9 @@ 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
deleted file mode 100644
index a339ede..0000000
--- a/ui/gfx/compositor/compositor_setup.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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 77fea77..b2bb0b7 100644
--- a/ui/gfx/compositor/compositor_switches.cc
+++ b/ui/gfx/compositor/compositor_switches.cc
@@ -6,8 +6,6 @@
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 9040cb0..805468b 100644
--- a/ui/gfx/compositor/compositor_switches.h
+++ b/ui/gfx/compositor/compositor_switches.h
@@ -10,7 +10,6 @@
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 5bf8b69..253683c 100644
--- a/ui/gfx/compositor/layer_unittest.cc
+++ b/ui/gfx/compositor/layer_unittest.cc
@@ -15,15 +15,10 @@
#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 {
@@ -111,9 +106,10 @@ std::string GetLayerChildrenNames(const Layer& layer) {
// There are three test classes in here that configure the Compositor and
// Layer's slightly differently:
-// - LayerWithNullDelegateTest uses NullLayerDelegate as the LayerDelegate. This
-// is typically the base class you want to use.
-// - LayerWithDelegateTest uses LayerDelegate on the delegates.
+// - 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.
// - 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.
@@ -150,9 +146,6 @@ 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();
@@ -366,12 +359,7 @@ 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 {
@@ -425,7 +413,7 @@ class LayerWithDelegateTest : public testing::Test, public CompositorDelegate {
bool schedule_draw_invoked_;
private:
- scoped_refptr<ui::Compositor> compositor_;
+ scoped_refptr<TestCompositor> compositor_;
DISALLOW_COPY_AND_ASSIGN(LayerWithDelegateTest);
};
diff --git a/ui/views/run_all_unittests.cc b/ui/views/run_all_unittests.cc
index 9273994..e675291 100644
--- a/ui/views/run_all_unittests.cc
+++ b/ui/views/run_all_unittests.cc
@@ -6,13 +6,8 @@
#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/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
+#include "ui/views/view.h"
class ViewTestSuite : public base::TestSuite {
public:
@@ -26,11 +21,7 @@ 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 0752eb1..0fd4c21 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -17,6 +17,8 @@
#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"
@@ -42,9 +44,6 @@
#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::_;
@@ -2532,9 +2531,7 @@ 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 cefa162..3b60864 100644
--- a/ui/views/views.gyp
+++ b/ui/views/views.gyp
@@ -498,6 +498,7 @@
'../../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',
@@ -593,15 +594,6 @@
['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
{