summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--build/all.gyp1
-rw-r--r--chrome/browser/chrome_browser_main_extra_parts_aura.cc17
-rw-r--r--chrome/chrome_dll.gypi9
-rw-r--r--chrome/chrome_exe.gypi5
-rw-r--r--chrome/chrome_tests.gypi8
-rw-r--r--chrome/common/chrome_switches.cc5
-rw-r--r--chrome/common/chrome_switches.h4
-rw-r--r--chrome/test/base/chrome_test_suite.cc11
-rw-r--r--chrome/test/ui/ui_test.cc9
-rw-r--r--content/content_tests.gypi10
-rw-r--r--content/test/content_test_suite.cc10
-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
25 files changed, 227 insertions, 36 deletions
diff --git a/build/all.gyp b/build/all.gyp
index 3480d6b..6c0fd82 100644
--- a/build/all.gyp
+++ b/build/all.gyp
@@ -617,6 +617,7 @@
'dependencies': [
'../chrome/chrome.gyp:chrome',
'../chrome/chrome.gyp:unit_tests',
+ '../chrome/chrome.gyp:ui_tests',
'../ui/aura_shell/aura_shell.gyp:aura_shell_exe',
'../ui/aura_shell/aura_shell.gyp:aura_shell_unittests',
'../ui/aura/aura.gyp:*',
diff --git a/chrome/browser/chrome_browser_main_extra_parts_aura.cc b/chrome/browser/chrome_browser_main_extra_parts_aura.cc
index 97e8340..020c5a4 100644
--- a/chrome/browser/chrome_browser_main_extra_parts_aura.cc
+++ b/chrome/browser/chrome_browser_main_extra_parts_aura.cc
@@ -3,6 +3,9 @@
// found in the LICENSE file.
#include "chrome/browser/chrome_browser_main_extra_parts_aura.h"
+
+#include "base/command_line.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/browser/ui/views/aura/chrome_shell_delegate.h"
#include "chrome/browser/ui/views/aura/screen_orientation_listener.h"
#include "ui/aura/root_window.h"
@@ -12,11 +15,25 @@
#include "chrome/browser/chromeos/system/runtime_environment.h"
#endif
+#if defined(USE_WEBKIT_COMPOSITOR)
+#include "ui/gfx/compositor/compositor_setup.h"
+#else
+#include "ui/gfx/test/gfx_test_utils.h"
+#endif
+
ChromeBrowserMainExtraPartsAura::ChromeBrowserMainExtraPartsAura()
: ChromeBrowserMainExtraParts() {
}
void ChromeBrowserMainExtraPartsAura::PostBrowserProcessInit() {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestCompositor)) {
+#if defined(USE_WEBKIT_COMPOSITOR)
+ ui::SetupTestCompositor();
+#else
+ ui::gfx_test_utils::SetupTestCompositor();
+#endif
+ }
+
#if defined(OS_CHROMEOS)
if (chromeos::system::runtime_environment::IsRunningOnChromeOS())
aura::RootWindow::set_use_fullscreen_host_window(true);
diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi
index 75c0164..aa4ac07 100644
--- a/chrome/chrome_dll.gypi
+++ b/chrome/chrome_dll.gypi
@@ -16,6 +16,15 @@
'app/policy/cloud_policy_codegen.gyp:policy',
],
'conditions': [
+ ['use_webkit_compositor==1', {
+ 'dependencies': [
+ '../ui/gfx/compositor/compositor.gyp:compositor',
+ ],
+ }, { # use_webkit_compositor!=1
+ 'dependencies': [
+ '../ui/gfx/compositor/compositor.gyp:test_compositor',
+ ],
+ }],
['OS=="win"', {
'product_name': 'chrome',
'dependencies': [
diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi
index 4f7edcc..d2f2206 100644
--- a/chrome/chrome_exe.gypi
+++ b/chrome/chrome_exe.gypi
@@ -42,6 +42,11 @@
'INFOPLIST_FILE': 'app/app-Info.plist',
},
'conditions': [
+ ['use_aura==1 and use_webkit_compositor==0', {
+ 'dependencies': [
+ '../ui/gfx/compositor/compositor.gyp:test_compositor',
+ ],
+ }],
['OS == "android"', {
# Don't put the 'chrome' target in 'all' on android
'suppress_wildcard': 1,
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index c329517..c8b3b0b 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -65,8 +65,6 @@
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
'../third_party/leveldatabase/leveldatabase.gyp:leveldatabase',
- '../ui/gfx/compositor/compositor.gyp:test_compositor',
- '../ui/gfx/compositor/compositor.gyp:compositor_test_support',
],
'export_dependent_settings': [
'renderer',
@@ -279,6 +277,12 @@
['exclude', 'test/base/ui_test_utils_win.cc'],
],
}],
+ ['use_webkit_compositor==0', {
+ 'dependencies': [
+ '../ui/gfx/compositor/compositor.gyp:compositor_test_support',
+ '../ui/gfx/compositor/compositor.gyp:test_compositor',
+ ],
+ }],
],
},
{
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 1b488e1..cf14a50 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -1286,6 +1286,11 @@ const char kEnablePrintPreview[] = "enable-print-preview";
// Enables the benchmarking extensions.
const char kEnableBenchmarking[] = "enable-benchmarking";
+#if defined(USE_AURA)
+// Forces usage of the test compositor. Needed to run ui tests on bots.
+extern const char kTestCompositor[] = "test-compositor";
+#endif
+
bool IsPrintPreviewEnabled() {
if (CommandLine::ForCurrentProcess()->HasSwitch(kDisablePrintPreview))
return false;
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 8616552..7323148 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -374,6 +374,10 @@ extern const char kDisablePrintPreview[];
extern const char kEnablePrintPreview[];
extern const char kEnableBenchmarking[];
+#if defined(USE_AURA)
+extern const char kTestCompositor[];
+#endif
+
bool IsPrintPreviewEnabled();
bool IsInBrowserThumbnailingEnabled();
diff --git a/chrome/test/base/chrome_test_suite.cc b/chrome/test/base/chrome_test_suite.cc
index 18d76ff..0612fd4 100644
--- a/chrome/test/base/chrome_test_suite.cc
+++ b/chrome/test/base/chrome_test_suite.cc
@@ -26,7 +26,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
-#include "ui/gfx/test/gfx_test_utils.h"
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
@@ -38,6 +37,12 @@
#include "base/shared_memory.h"
#endif
+#if defined(USE_WEBKIT_COMPOSITOR)
+#include "ui/gfx/compositor/compositor_setup.h"
+#else
+#include "ui/gfx/test/gfx_test_utils.h"
+#endif
+
namespace {
void RemoveSharedMemoryFile(const std::string& filename) {
@@ -193,7 +198,11 @@ void ChromeTestSuite::Initialize() {
ResourceBundle::AddDataPackToSharedInstance(resources_pack_path);
// Mock out the compositor on platforms that use it.
+#if defined(USE_WEBKIT_COMPOSITOR)
+ ui::SetupTestCompositor();
+#else
ui::gfx_test_utils::SetupTestCompositor();
+#endif
stats_filename_ = base::StringPrintf("unit_tests-%d",
base::GetCurrentProcId());
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index 7f1fe05a..29a1b46 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -56,6 +56,9 @@
#include "base/win/windows_version.h"
#endif
+#if defined(USE_AURA)
+#include "ui/gfx/compositor/compositor_switches.h"
+#endif
using base::Time;
using base::TimeDelta;
@@ -199,6 +202,12 @@ void UITestBase::SetLaunchSwitches() {
launch_arguments_.AppendSwitchASCII(switches::kHomePage, homepage_);
if (!test_name_.empty())
launch_arguments_.AppendSwitchASCII(switches::kTestName, test_name_);
+#if defined(USE_AURA)
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableTestCompositor)) {
+ launch_arguments_.AppendSwitch(switches::kTestCompositor);
+ }
+#endif
}
void UITestBase::SetUpProfile() {
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 60c76263..38e858d 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -21,7 +21,6 @@
'../third_party/webrtc/system_wrappers/source/system_wrappers.gyp:system_wrappers',
'../third_party/webrtc/video_engine/video_engine.gyp:video_engine_core',
'../third_party/webrtc/voice_engine/voice_engine.gyp:voice_engine_core',
- '../ui/gfx/compositor/compositor.gyp:test_compositor',
'../ui/gfx/surface/surface.gyp:surface',
'../ui/ui.gyp:ui_test_support',
'../webkit/support/webkit_support.gyp:appcache',
@@ -121,6 +120,15 @@
'../build/linux/system.gyp:glib',
],
}],
+ ['use_webkit_compositor==1', {
+ 'dependencies': [
+ '../ui/gfx/compositor/compositor.gyp:compositor',
+ ],
+ }, {
+ 'dependencies': [
+ '../ui/gfx/compositor/compositor.gyp:test_compositor',
+ ],
+ }],
],
},
{
diff --git a/content/test/content_test_suite.cc b/content/test/content_test_suite.cc
index 7a87809..ef67f6d 100644
--- a/content/test/content_test_suite.cc
+++ b/content/test/content_test_suite.cc
@@ -13,11 +13,15 @@
#include "content/test/test_content_client.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ui_base_paths.h"
-#include "ui/gfx/test/gfx_test_utils.h"
#if defined(OS_MACOSX)
#include "base/mac/scoped_nsautorelease_pool.h"
#endif
+#if defined(USE_WEBKIT_COMPOSITOR)
+#include "ui/gfx/compositor/compositor_setup.h"
+#else
+#include "ui/gfx/test/gfx_test_utils.h"
+#endif
namespace {
@@ -75,7 +79,11 @@ void ContentTestSuite::Initialize() {
ui::RegisterPathProvider();
// Mock out the compositor on platforms that use it.
+#if defined(USE_WEBKIT_COMPOSITOR)
+ ui::SetupTestCompositor();
+#else
ui::gfx_test_utils::SetupTestCompositor();
+#endif
testing::TestEventListeners& listeners =
testing::UnitTest::GetInstance()->listeners();
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
{