summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-27 13:49:35 +0000
committerbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-27 13:49:35 +0000
commit5c975ed62853fee34c8600cd47138816ee936fe0 (patch)
tree646c5a923876ce914b6110c7b71c4e8f5721ad35
parentc144060968bce7873e4079bd2293272fe03b520f (diff)
downloadchromium_src-5c975ed62853fee34c8600cd47138816ee936fe0.zip
chromium_src-5c975ed62853fee34c8600cd47138816ee936fe0.tar.gz
chromium_src-5c975ed62853fee34c8600cd47138816ee936fe0.tar.bz2
Fix up compositor mocking.
Two changes: a) detangle the mock compositor from compositor_test_support a) pull in compositor when using a mock compositor Rationale: a) this target was meant to support using use_webkit_compositor=1 when WK isn't initialized; sometimes we will want to use the mock compositor when WK is initialized b) we can imagine scenarios where we want to switch between mock and real compositors in the same executable, and it's one less target to update BUG=101477 TEST=bots stay green Review URL: http://codereview.chromium.org/8395043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107563 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/chrome_tests.gypi2
-rw-r--r--chrome/test/base/chrome_test_suite.cc4
-rw-r--r--content/content_plugin.gypi7
-rw-r--r--content/content_tests.gypi2
-rw-r--r--content/test/content_test_suite.cc4
-rw-r--r--ui/aura/aura.gyp3
-rw-r--r--ui/aura/demo/demo_main.cc5
-rw-r--r--ui/aura/test/test_suite.cc3
-rw-r--r--ui/aura_shell/aura_shell.gyp2
-rw-r--r--ui/aura_shell/test_suite.cc3
-rw-r--r--ui/gfx/compositor/compositor.gyp42
-rw-r--r--ui/gfx/compositor/compositor_test_support.cc20
-rw-r--r--ui/gfx/compositor/compositor_test_support.h3
-rw-r--r--ui/gfx/test/gfx_test_utils.cc24
-rw-r--r--ui/gfx/test/gfx_test_utils.h19
-rw-r--r--views/run_all_unittests.cc3
-rw-r--r--views/views.gyp2
17 files changed, 97 insertions, 51 deletions
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index a494626..122d055 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -63,7 +63,7 @@
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
'../third_party/leveldatabase/leveldatabase.gyp:leveldatabase',
- '../ui/gfx/compositor/compositor.gyp:compositor_test_support',
+ '../ui/gfx/compositor/compositor.gyp:test_compositor',
],
'export_dependent_settings': [
'renderer',
diff --git a/chrome/test/base/chrome_test_suite.cc b/chrome/test/base/chrome_test_suite.cc
index e5b3e70..6bba2b2 100644
--- a/chrome/test/base/chrome_test_suite.cc
+++ b/chrome/test/base/chrome_test_suite.cc
@@ -27,7 +27,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
-#include "ui/gfx/compositor/compositor_test_support.h"
+#include "ui/gfx/test/gfx_test_utils.h"
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
@@ -194,7 +194,7 @@ void ChromeTestSuite::Initialize() {
ResourceBundle::AddDataPackToSharedInstance(resources_pack_path);
// Mock out the compositor on platforms that use it.
- ui::CompositorTestSupport::SetupMockCompositor();
+ ui::gfx_test_utils::SetupTestCompositor();
stats_filename_ = base::StringPrintf("unit_tests-%d",
base::GetCurrentProcId());
diff --git a/content/content_plugin.gypi b/content/content_plugin.gypi
index 22532b9..734c497 100644
--- a/content/content_plugin.gypi
+++ b/content/content_plugin.gypi
@@ -54,5 +54,12 @@
],
},
}],
+ ['use_aura==1 and OS!="win"', {
+ 'link_settings': {
+ 'libraries': [
+ '-lXext',
+ ],
+ },
+ }],
],
}
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 5b5219b..5044aca 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -15,7 +15,7 @@
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
'../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:webkit',
- '../ui/gfx/compositor/compositor.gyp:compositor_test_support',
+ '../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',
diff --git a/content/test/content_test_suite.cc b/content/test/content_test_suite.cc
index 1307aaa..2ac62be 100644
--- a/content/test/content_test_suite.cc
+++ b/content/test/content_test_suite.cc
@@ -13,7 +13,7 @@
#include "content/test/test_content_client.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ui_base_paths.h"
-#include "ui/gfx/compositor/compositor_test_support.h"
+#include "ui/gfx/test/gfx_test_utils.h"
namespace {
@@ -67,7 +67,7 @@ void ContentTestSuite::Initialize() {
ui::RegisterPathProvider();
// Mock out the compositor on platforms that use it.
- ui::CompositorTestSupport::SetupMockCompositor();
+ ui::gfx_test_utils::SetupTestCompositor();
testing::TestEventListeners& listeners =
testing::UnitTest::GetInstance()->listeners();
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index a1d8704..4e453c2 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -89,6 +89,7 @@
'../../third_party/icu/icu.gyp:icui18n',
'../../third_party/icu/icu.gyp:icuuc',
'../gfx/compositor/compositor.gyp:compositor',
+ '../gfx/compositor/compositor.gyp:compositor_test_support',
'../ui.gyp:gfx_resources',
'../ui.gyp:ui',
'../ui.gyp:ui_resources',
@@ -110,8 +111,8 @@
'../../base/base.gyp:test_support_base',
'../../skia/skia.gyp:skia',
'../../testing/gtest.gyp:gtest',
- '../gfx/compositor/compositor.gyp:compositor',
'../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',
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc
index 5c64b0c..61d7d7a 100644
--- a/ui/aura/demo/demo_main.cc
+++ b/ui/aura/demo/demo_main.cc
@@ -16,6 +16,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
#include "ui/gfx/canvas_skia.h"
+#include "ui/gfx/compositor/compositor_test_support.h"
#include "ui/gfx/rect.h"
#if defined(USE_X11)
@@ -81,6 +82,7 @@ int main(int argc, char** argv) {
// Create the message-loop here before creating the desktop.
MessageLoop message_loop(MessageLoop::TYPE_UI);
+ ui::CompositorTestSupport::Initialize();
aura::Desktop::GetInstance();
@@ -110,6 +112,9 @@ int main(int argc, char** argv) {
window3.SetParent(&window2);
aura::Desktop::GetInstance()->Run();
+
+ ui::CompositorTestSupport::Terminate();
+
return 0;
}
diff --git a/ui/aura/test/test_suite.cc b/ui/aura/test/test_suite.cc
index 4c4faa6..10cef93 100644
--- a/ui/aura/test/test_suite.cc
+++ b/ui/aura/test/test_suite.cc
@@ -12,6 +12,7 @@
#include "ui/gfx/compositor/compositor_test_support.h"
#include "ui/gfx/gfx_paths.h"
#include "ui/gfx/gl/gl_implementation.h"
+#include "ui/gfx/test/gfx_test_utils.h"
namespace aura {
namespace test {
@@ -29,7 +30,7 @@ void AuraTestSuite::Initialize() {
// output, it'll pass regardless of the system language.
ui::ResourceBundle::InitSharedInstance("en-US");
ui::CompositorTestSupport::Initialize();
- ui::CompositorTestSupport::SetupMockCompositor();
+ ui::gfx_test_utils::SetupTestCompositor();
}
void AuraTestSuite::Shutdown() {
diff --git a/ui/aura_shell/aura_shell.gyp b/ui/aura_shell/aura_shell.gyp
index 1b5885d..02df21a 100644
--- a/ui/aura_shell/aura_shell.gyp
+++ b/ui/aura_shell/aura_shell.gyp
@@ -84,8 +84,8 @@
'../../third_party/icu/icu.gyp:icui18n',
'../../third_party/icu/icu.gyp:icuuc',
'../../views/views.gyp:views',
- '../gfx/compositor/compositor.gyp:compositor',
'../gfx/compositor/compositor.gyp:compositor_test_support',
+ '../gfx/compositor/compositor.gyp:test_compositor',
'../ui.gyp:gfx_resources',
'../ui.gyp:ui',
'../ui.gyp:ui_resources',
diff --git a/ui/aura_shell/test_suite.cc b/ui/aura_shell/test_suite.cc
index 07fcddc..557bd95 100644
--- a/ui/aura_shell/test_suite.cc
+++ b/ui/aura_shell/test_suite.cc
@@ -11,6 +11,7 @@
#include "ui/base/ui_base_paths.h"
#include "ui/gfx/compositor/compositor_test_support.h"
#include "ui/gfx/gfx_paths.h"
+#include "ui/gfx/test/gfx_test_utils.h"
AuraShellTestSuite::AuraShellTestSuite(int argc, char** argv)
: TestSuite(argc, argv) {}
@@ -25,7 +26,7 @@ void AuraShellTestSuite::Initialize() {
// output, it'll pass regardless of the system language.
ui::ResourceBundle::InitSharedInstance("en-US");
ui::CompositorTestSupport::Initialize();
- ui::CompositorTestSupport::SetupMockCompositor();
+ ui::gfx_test_utils::SetupTestCompositor();
}
void AuraShellTestSuite::Shutdown() {
diff --git a/ui/gfx/compositor/compositor.gyp b/ui/gfx/compositor/compositor.gyp
index d4ce8d5..e20c17e 100644
--- a/ui/gfx/compositor/compositor.gyp
+++ b/ui/gfx/compositor/compositor.gyp
@@ -107,7 +107,6 @@
'type': 'static_library',
'dependencies': [
'<(DEPTH)/base/base.gyp:base',
- '<(DEPTH)/skia/skia.gyp:skia',
],
'sources': [
'compositor_test_support.cc',
@@ -120,21 +119,6 @@
'<(DEPTH)/third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:webkit',
],
}],
- ['views_compositor==1', {
- 'sources': [
- 'compositor.cc',
- 'compositor.h',
- 'layer.cc',
- 'layer.h',
- 'layer_animator.cc',
- 'layer_animator.h',
- 'layer_animator_delegate.h',
- 'test_compositor.cc',
- 'test_compositor.h',
- 'test_texture.cc',
- 'test_texture.h',
- ],
- }],
],
},
{
@@ -151,6 +135,7 @@
'<(DEPTH)/ui/ui.gyp:ui_resources',
'compositor',
'compositor_test_support',
+ 'test_compositor',
],
'sources': [
'layer_animation_element_unittest.cc',
@@ -186,5 +171,30 @@
}],
],
},
+ {
+ 'target_name': 'test_compositor',
+ 'type': 'static_library',
+ 'dependencies': [
+ '<(DEPTH)/base/base.gyp:base',
+ ],
+ 'sources': [
+ '../test/gfx_test_utils.cc',
+ '../test/gfx_test_utils.h',
+ ],
+ 'conditions': [
+ ['views_compositor == 1', {
+ 'dependencies': [
+ '<(DEPTH)/skia/skia.gyp:skia',
+ 'compositor',
+ ],
+ 'sources': [
+ 'test_compositor.cc',
+ 'test_compositor.h',
+ 'test_texture.cc',
+ 'test_texture.h',
+ ],
+ }],
+ ],
+ },
],
}
diff --git a/ui/gfx/compositor/compositor_test_support.cc b/ui/gfx/compositor/compositor_test_support.cc
index d9e88e2..e72bd0c 100644
--- a/ui/gfx/compositor/compositor_test_support.cc
+++ b/ui/gfx/compositor/compositor_test_support.cc
@@ -9,11 +9,6 @@
#include "webkit/glue/webkitplatformsupport_impl.h"
#endif
-#if defined(VIEWS_COMPOSITOR)
-#include "ui/gfx/compositor/compositor.h"
-#include "ui/gfx/compositor/test_compositor.h"
-#endif
-
namespace ui {
#if defined(USE_WEBKIT_COMPOSITOR)
@@ -37,19 +32,4 @@ void CompositorTestSupport::Terminate() {
#endif
}
-void CompositorTestSupport::SetupMockCompositor() {
-#if defined(USE_WEBKIT_COMPOSITOR)
- // TODO(backer): We've got dependencies in Layer that require
- // WebKit support even though we're mocking the Compositor. We
- // would ideally mock out these unnecessary dependencies as well.
- DCHECK(g_webkit_support);
-#endif
-
-#if defined(VIEWS_COMPOSITOR)
- // Use a mock compositor that noops draws.
- ui::Compositor::set_compositor_factory_for_testing(
- ui::TestCompositor::Create);
-#endif
-}
-
} // namespace ui
diff --git a/ui/gfx/compositor/compositor_test_support.h b/ui/gfx/compositor/compositor_test_support.h
index cd7ea2e..06a7ee8 100644
--- a/ui/gfx/compositor/compositor_test_support.h
+++ b/ui/gfx/compositor/compositor_test_support.h
@@ -14,9 +14,6 @@ class CompositorTestSupport {
// but skip the typical initialization of browser_main.cc.
static void Initialize();
static void Terminate();
-
- // Called by tests that want to use a mocked compositor.
- static void SetupMockCompositor();
};
} // namespace ui
diff --git a/ui/gfx/test/gfx_test_utils.cc b/ui/gfx/test/gfx_test_utils.cc
new file mode 100644
index 0000000..342ec4f
--- /dev/null
+++ b/ui/gfx/test/gfx_test_utils.cc
@@ -0,0 +1,24 @@
+// 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.
+
+#include "ui/gfx/test/gfx_test_utils.h"
+
+#if defined(VIEWS_COMPOSITOR)
+#include "ui/gfx/compositor/compositor.h"
+#include "ui/gfx/compositor/test_compositor.h"
+#endif
+
+namespace ui {
+namespace gfx_test_utils {
+
+void SetupTestCompositor() {
+#if defined(VIEWS_COMPOSITOR)
+ // Use a mock compositor that noops draws.
+ ui::Compositor::set_compositor_factory_for_testing(
+ ui::TestCompositor::Create);
+#endif
+}
+
+} // namespace gfx_test_utils
+} // namespace ui
diff --git a/ui/gfx/test/gfx_test_utils.h b/ui/gfx/test/gfx_test_utils.h
new file mode 100644
index 0000000..da2b2be
--- /dev/null
+++ b/ui/gfx/test/gfx_test_utils.h
@@ -0,0 +1,19 @@
+// 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_GFX_TEST_UTILS_H_
+#define UI_GFX_GFX_TEST_UTILS_H_
+#pragma once
+
+namespace ui {
+namespace gfx_test_utils {
+
+// Called by tests that want to use a mocked compositor.
+// Implementation is no-oped on platforms that don't use a compositor.
+void SetupTestCompositor();
+
+} // namespace gfx_test_utils
+} // namespace ui
+
+#endif // UI_GFX_GFX_TEST_UTILS_H_
diff --git a/views/run_all_unittests.cc b/views/run_all_unittests.cc
index 631db9e..20522efe 100644
--- a/views/run_all_unittests.cc
+++ b/views/run_all_unittests.cc
@@ -6,6 +6,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
#include "ui/gfx/compositor/compositor_test_support.h"
+#include "ui/gfx/test/gfx_test_utils.h"
#include "views/view.h"
class ViewTestSuite : public base::TestSuite {
@@ -20,7 +21,7 @@ class ViewTestSuite : public base::TestSuite {
ui::ResourceBundle::InitSharedInstance("en-US");
ui::CompositorTestSupport::Initialize();
- ui::CompositorTestSupport::SetupMockCompositor();
+ ui::gfx_test_utils::SetupTestCompositor();
}
virtual void Shutdown() {
diff --git a/views/views.gyp b/views/views.gyp
index 467d196..2a5563d 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -555,8 +555,8 @@
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
'../ui/base/strings/ui_strings.gyp:ui_strings',
- '../ui/gfx/compositor/compositor.gyp:compositor',
'../ui/gfx/compositor/compositor.gyp:compositor_test_support',
+ '../ui/gfx/compositor/compositor.gyp:test_compositor',
'../ui/ui.gyp:gfx_resources',
'../ui/ui.gyp:ui',
'../ui/ui.gyp:ui_resources',