Commit 5c975ed6 authored by backer@chromium.org's avatar backer@chromium.org

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
parent c1440609
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
'../testing/gmock.gyp:gmock', '../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest', '../testing/gtest.gyp:gtest',
'../third_party/leveldatabase/leveldatabase.gyp:leveldatabase', '../third_party/leveldatabase/leveldatabase.gyp:leveldatabase',
'../ui/gfx/compositor/compositor.gyp:compositor_test_support', '../ui/gfx/compositor/compositor.gyp:test_compositor',
], ],
'export_dependent_settings': [ 'export_dependent_settings': [
'renderer', 'renderer',
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.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 "ui/gfx/compositor/compositor_test_support.h" #include "ui/gfx/test/gfx_test_utils.h"
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
#include "base/mac/mac_util.h" #include "base/mac/mac_util.h"
...@@ -194,7 +194,7 @@ void ChromeTestSuite::Initialize() { ...@@ -194,7 +194,7 @@ void ChromeTestSuite::Initialize() {
ResourceBundle::AddDataPackToSharedInstance(resources_pack_path); ResourceBundle::AddDataPackToSharedInstance(resources_pack_path);
// Mock out the compositor on platforms that use it. // Mock out the compositor on platforms that use it.
ui::CompositorTestSupport::SetupMockCompositor(); ui::gfx_test_utils::SetupTestCompositor();
stats_filename_ = base::StringPrintf("unit_tests-%d", stats_filename_ = base::StringPrintf("unit_tests-%d",
base::GetCurrentProcId()); base::GetCurrentProcId());
......
...@@ -54,5 +54,12 @@ ...@@ -54,5 +54,12 @@
], ],
}, },
}], }],
['use_aura==1 and OS!="win"', {
'link_settings': {
'libraries': [
'-lXext',
],
},
}],
], ],
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
'../testing/gmock.gyp:gmock', '../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest', '../testing/gtest.gyp:gtest',
'../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:webkit', '../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/gfx/surface/surface.gyp:surface',
'../ui/ui.gyp:ui_test_support', '../ui/ui.gyp:ui_test_support',
'../webkit/support/webkit_support.gyp:appcache', '../webkit/support/webkit_support.gyp:appcache',
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "content/test/test_content_client.h" #include "content/test/test_content_client.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ui_base_paths.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 { namespace {
...@@ -67,7 +67,7 @@ void ContentTestSuite::Initialize() { ...@@ -67,7 +67,7 @@ void ContentTestSuite::Initialize() {
ui::RegisterPathProvider(); ui::RegisterPathProvider();
// Mock out the compositor on platforms that use it. // Mock out the compositor on platforms that use it.
ui::CompositorTestSupport::SetupMockCompositor(); ui::gfx_test_utils::SetupTestCompositor();
testing::TestEventListeners& listeners = testing::TestEventListeners& listeners =
testing::UnitTest::GetInstance()->listeners(); testing::UnitTest::GetInstance()->listeners();
......
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
'../../third_party/icu/icu.gyp:icui18n', '../../third_party/icu/icu.gyp:icui18n',
'../../third_party/icu/icu.gyp:icuuc', '../../third_party/icu/icu.gyp:icuuc',
'../gfx/compositor/compositor.gyp:compositor', '../gfx/compositor/compositor.gyp:compositor',
'../gfx/compositor/compositor.gyp:compositor_test_support',
'../ui.gyp:gfx_resources', '../ui.gyp:gfx_resources',
'../ui.gyp:ui', '../ui.gyp:ui',
'../ui.gyp:ui_resources', '../ui.gyp:ui_resources',
...@@ -110,8 +111,8 @@ ...@@ -110,8 +111,8 @@
'../../base/base.gyp:test_support_base', '../../base/base.gyp:test_support_base',
'../../skia/skia.gyp:skia', '../../skia/skia.gyp:skia',
'../../testing/gtest.gyp:gtest', '../../testing/gtest.gyp:gtest',
'../gfx/compositor/compositor.gyp:compositor',
'../gfx/compositor/compositor.gyp:compositor_test_support', '../gfx/compositor/compositor.gyp:compositor_test_support',
'../gfx/compositor/compositor.gyp:test_compositor',
'../gfx/gl/gl.gyp:gl', '../gfx/gl/gl.gyp:gl',
'../ui.gyp:gfx_resources', '../ui.gyp:gfx_resources',
'../ui.gyp:ui', '../ui.gyp:ui',
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#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 "ui/gfx/canvas_skia.h" #include "ui/gfx/canvas_skia.h"
#include "ui/gfx/compositor/compositor_test_support.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#if defined(USE_X11) #if defined(USE_X11)
...@@ -81,6 +82,7 @@ int main(int argc, char** argv) { ...@@ -81,6 +82,7 @@ int main(int argc, char** argv) {
// Create the message-loop here before creating the desktop. // Create the message-loop here before creating the desktop.
MessageLoop message_loop(MessageLoop::TYPE_UI); MessageLoop message_loop(MessageLoop::TYPE_UI);
ui::CompositorTestSupport::Initialize();
aura::Desktop::GetInstance(); aura::Desktop::GetInstance();
...@@ -110,6 +112,9 @@ int main(int argc, char** argv) { ...@@ -110,6 +112,9 @@ int main(int argc, char** argv) {
window3.SetParent(&window2); window3.SetParent(&window2);
aura::Desktop::GetInstance()->Run(); aura::Desktop::GetInstance()->Run();
ui::CompositorTestSupport::Terminate();
return 0; return 0;
} }
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "ui/gfx/compositor/compositor_test_support.h" #include "ui/gfx/compositor/compositor_test_support.h"
#include "ui/gfx/gfx_paths.h" #include "ui/gfx/gfx_paths.h"
#include "ui/gfx/gl/gl_implementation.h" #include "ui/gfx/gl/gl_implementation.h"
#include "ui/gfx/test/gfx_test_utils.h"
namespace aura { namespace aura {
namespace test { namespace test {
...@@ -29,7 +30,7 @@ void AuraTestSuite::Initialize() { ...@@ -29,7 +30,7 @@ void AuraTestSuite::Initialize() {
// output, it'll pass regardless of the system language. // output, it'll pass regardless of the system language.
ui::ResourceBundle::InitSharedInstance("en-US"); ui::ResourceBundle::InitSharedInstance("en-US");
ui::CompositorTestSupport::Initialize(); ui::CompositorTestSupport::Initialize();
ui::CompositorTestSupport::SetupMockCompositor(); ui::gfx_test_utils::SetupTestCompositor();
} }
void AuraTestSuite::Shutdown() { void AuraTestSuite::Shutdown() {
......
...@@ -84,8 +84,8 @@ ...@@ -84,8 +84,8 @@
'../../third_party/icu/icu.gyp:icui18n', '../../third_party/icu/icu.gyp:icui18n',
'../../third_party/icu/icu.gyp:icuuc', '../../third_party/icu/icu.gyp:icuuc',
'../../views/views.gyp:views', '../../views/views.gyp:views',
'../gfx/compositor/compositor.gyp:compositor',
'../gfx/compositor/compositor.gyp:compositor_test_support', '../gfx/compositor/compositor.gyp:compositor_test_support',
'../gfx/compositor/compositor.gyp:test_compositor',
'../ui.gyp:gfx_resources', '../ui.gyp:gfx_resources',
'../ui.gyp:ui', '../ui.gyp:ui',
'../ui.gyp:ui_resources', '../ui.gyp:ui_resources',
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_paths.h"
#include "ui/gfx/compositor/compositor_test_support.h" #include "ui/gfx/compositor/compositor_test_support.h"
#include "ui/gfx/gfx_paths.h" #include "ui/gfx/gfx_paths.h"
#include "ui/gfx/test/gfx_test_utils.h"
AuraShellTestSuite::AuraShellTestSuite(int argc, char** argv) AuraShellTestSuite::AuraShellTestSuite(int argc, char** argv)
: TestSuite(argc, argv) {} : TestSuite(argc, argv) {}
...@@ -25,7 +26,7 @@ void AuraShellTestSuite::Initialize() { ...@@ -25,7 +26,7 @@ void AuraShellTestSuite::Initialize() {
// output, it'll pass regardless of the system language. // output, it'll pass regardless of the system language.
ui::ResourceBundle::InitSharedInstance("en-US"); ui::ResourceBundle::InitSharedInstance("en-US");
ui::CompositorTestSupport::Initialize(); ui::CompositorTestSupport::Initialize();
ui::CompositorTestSupport::SetupMockCompositor(); ui::gfx_test_utils::SetupTestCompositor();
} }
void AuraShellTestSuite::Shutdown() { void AuraShellTestSuite::Shutdown() {
......
...@@ -107,7 +107,6 @@ ...@@ -107,7 +107,6 @@
'type': 'static_library', 'type': 'static_library',
'dependencies': [ 'dependencies': [
'<(DEPTH)/base/base.gyp:base', '<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/skia/skia.gyp:skia',
], ],
'sources': [ 'sources': [
'compositor_test_support.cc', 'compositor_test_support.cc',
...@@ -120,21 +119,6 @@ ...@@ -120,21 +119,6 @@
'<(DEPTH)/third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:webkit', '<(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 @@ ...@@ -151,6 +135,7 @@
'<(DEPTH)/ui/ui.gyp:ui_resources', '<(DEPTH)/ui/ui.gyp:ui_resources',
'compositor', 'compositor',
'compositor_test_support', 'compositor_test_support',
'test_compositor',
], ],
'sources': [ 'sources': [
'layer_animation_element_unittest.cc', 'layer_animation_element_unittest.cc',
...@@ -186,5 +171,30 @@ ...@@ -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',
],
}],
],
},
], ],
} }
...@@ -9,11 +9,6 @@ ...@@ -9,11 +9,6 @@
#include "webkit/glue/webkitplatformsupport_impl.h" #include "webkit/glue/webkitplatformsupport_impl.h"
#endif #endif
#if defined(VIEWS_COMPOSITOR)
#include "ui/gfx/compositor/compositor.h"
#include "ui/gfx/compositor/test_compositor.h"
#endif
namespace ui { namespace ui {
#if defined(USE_WEBKIT_COMPOSITOR) #if defined(USE_WEBKIT_COMPOSITOR)
...@@ -37,19 +32,4 @@ void CompositorTestSupport::Terminate() { ...@@ -37,19 +32,4 @@ void CompositorTestSupport::Terminate() {
#endif #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 } // namespace ui
...@@ -14,9 +14,6 @@ class CompositorTestSupport { ...@@ -14,9 +14,6 @@ class CompositorTestSupport {
// but skip the typical initialization of browser_main.cc. // but skip the typical initialization of browser_main.cc.
static void Initialize(); static void Initialize();
static void Terminate(); static void Terminate();
// Called by tests that want to use a mocked compositor.
static void SetupMockCompositor();
}; };
} // namespace ui } // namespace ui
......
// 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
// 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_
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#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 "ui/gfx/compositor/compositor_test_support.h" #include "ui/gfx/compositor/compositor_test_support.h"
#include "ui/gfx/test/gfx_test_utils.h"
#include "views/view.h" #include "views/view.h"
class ViewTestSuite : public base::TestSuite { class ViewTestSuite : public base::TestSuite {
...@@ -20,7 +21,7 @@ class ViewTestSuite : public base::TestSuite { ...@@ -20,7 +21,7 @@ class ViewTestSuite : public base::TestSuite {
ui::ResourceBundle::InitSharedInstance("en-US"); ui::ResourceBundle::InitSharedInstance("en-US");
ui::CompositorTestSupport::Initialize(); ui::CompositorTestSupport::Initialize();
ui::CompositorTestSupport::SetupMockCompositor(); ui::gfx_test_utils::SetupTestCompositor();
} }
virtual void Shutdown() { virtual void Shutdown() {
......
...@@ -555,8 +555,8 @@ ...@@ -555,8 +555,8 @@
'../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc', '../third_party/icu/icu.gyp:icuuc',
'../ui/base/strings/ui_strings.gyp:ui_strings', '../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:compositor_test_support',
'../ui/gfx/compositor/compositor.gyp:test_compositor',
'../ui/ui.gyp:gfx_resources', '../ui/ui.gyp:gfx_resources',
'../ui/ui.gyp:ui', '../ui/ui.gyp:ui',
'../ui/ui.gyp:ui_resources', '../ui/ui.gyp:ui_resources',
......
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