Chromium Code Reviews| Index: cc/test/layer_tree_test_common.cc |
| diff --git a/cc/test/layer_tree_test_common.cc b/cc/test/layer_tree_test_common.cc |
| index 69e99471b849c5a3003324c8fd39d6c37b6ba3d4..a601df95cce1186f6dc8b02f271c7f5bdf6b2708 100644 |
| --- a/cc/test/layer_tree_test_common.cc |
| +++ b/cc/test/layer_tree_test_common.cc |
| @@ -26,6 +26,7 @@ |
| #include "cc/thread_task.h" |
| #include "cc/timing_function.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| +#include "webkit/compositor_bindings/ccthread_impl.h" |
|
jamesr
2012/10/25 19:42:39
this is also not good
|
| #include <public/Platform.h> |
| #include <public/WebCompositorSupport.h> |
| #include <public/WebFilterOperation.h> |
| @@ -94,9 +95,9 @@ scoped_ptr<WebCompositorOutputSurface> TestHooks::createOutputSurface() |
| return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsContext3DWithTextureTracking::create(WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSurface>(); |
| } |
| -scoped_ptr<MockLayerTreeHostImpl> MockLayerTreeHostImpl::create(TestHooks* testHooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* client) |
| +scoped_ptr<MockLayerTreeHostImpl> MockLayerTreeHostImpl::create(TestHooks* testHooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy) |
| { |
| - return make_scoped_ptr(new MockLayerTreeHostImpl(testHooks, settings, client)); |
| + return make_scoped_ptr(new MockLayerTreeHostImpl(testHooks, settings, client, proxy)); |
| } |
| void MockLayerTreeHostImpl::beginCommit() |
| @@ -137,8 +138,8 @@ base::TimeDelta MockLayerTreeHostImpl::lowFrequencyAnimationInterval() const |
| return base::TimeDelta::FromMilliseconds(16); |
| } |
| -MockLayerTreeHostImpl::MockLayerTreeHostImpl(TestHooks* testHooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* client) |
| - : LayerTreeHostImpl(settings, client) |
| +MockLayerTreeHostImpl::MockLayerTreeHostImpl(TestHooks* testHooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy) |
| + : LayerTreeHostImpl(settings, client, proxy) |
| , m_testHooks(testHooks) |
| { |
| } |
| @@ -146,10 +147,10 @@ MockLayerTreeHostImpl::MockLayerTreeHostImpl(TestHooks* testHooks, const LayerTr |
| // Adapts LayerTreeHost for test. Injects MockLayerTreeHostImpl. |
| class MockLayerTreeHost : public cc::LayerTreeHost { |
| public: |
| - static scoped_ptr<MockLayerTreeHost> create(TestHooks* testHooks, cc::LayerTreeHostClient* client, scoped_refptr<cc::Layer> rootLayer, const cc::LayerTreeSettings& settings) |
| + static scoped_ptr<MockLayerTreeHost> create(TestHooks* testHooks, cc::LayerTreeHostClient* client, scoped_refptr<cc::Layer> rootLayer, const cc::LayerTreeSettings& settings, cc::Thread* implThread) |
| { |
| scoped_ptr<MockLayerTreeHost> layerTreeHost(new MockLayerTreeHost(testHooks, client, settings)); |
| - bool success = layerTreeHost->initialize(); |
| + bool success = layerTreeHost->initialize(implThread); |
| EXPECT_TRUE(success); |
| layerTreeHost->setRootLayer(rootLayer); |
| @@ -163,7 +164,7 @@ public: |
| virtual scoped_ptr<cc::LayerTreeHostImpl> createLayerTreeHostImpl(cc::LayerTreeHostImplClient* client) |
| { |
| - return MockLayerTreeHostImpl::create(m_testHooks, settings(), client).PassAs<cc::LayerTreeHostImpl>(); |
| + return MockLayerTreeHostImpl::create(m_testHooks, settings(), client, proxy()).PassAs<cc::LayerTreeHostImpl>(); |
| } |
| virtual void didAddAnimation() OVERRIDE |
| @@ -319,6 +320,7 @@ ThreadedTest::ThreadedTest() |
| , m_finished(false) |
| , m_scheduled(false) |
| , m_started(false) |
| + , m_implThread(0) |
| { |
| } |
| @@ -390,11 +392,10 @@ void ThreadedTest::postDidAddAnimationToMainThread() |
| void ThreadedTest::doBeginTest() |
| { |
| - DCHECK(Proxy::isMainThread()); |
| m_client = ThreadedMockLayerTreeHostClient::create(this); |
| scoped_refptr<Layer> rootLayer = Layer::create(); |
| - m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer, m_settings); |
| + m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer, m_settings, m_implThread); |
| ASSERT_TRUE(m_layerTreeHost.get()); |
| rootLayer->setLayerTreeHost(m_layerTreeHost.get()); |
| m_layerTreeHost->setSurfaceReady(); |
| @@ -428,13 +429,12 @@ void ThreadedTest::scheduleComposite() |
| void ThreadedTest::realEndTest() |
| { |
| - DCHECK(Proxy::isMainThread()); |
| WebKit::Platform::current()->currentThread()->exitRunLoop(); |
| } |
| void ThreadedTest::dispatchSetNeedsAnimate() |
| { |
| - DCHECK(Proxy::isMainThread()); |
| + DCHECK(!proxy() || proxy()->isMainThread()); |
| if (m_finished) |
| return; |
| @@ -445,7 +445,7 @@ void ThreadedTest::dispatchSetNeedsAnimate() |
| void ThreadedTest::dispatchAddInstantAnimation() |
| { |
| - DCHECK(Proxy::isMainThread()); |
| + DCHECK(!proxy() || proxy()->isMainThread()); |
| if (m_finished) |
| return; |
| @@ -456,7 +456,7 @@ void ThreadedTest::dispatchAddInstantAnimation() |
| void ThreadedTest::dispatchAddAnimation() |
| { |
| - DCHECK(Proxy::isMainThread()); |
| + DCHECK(!proxy() || proxy()->isMainThread()); |
| if (m_finished) |
| return; |
| @@ -467,7 +467,7 @@ void ThreadedTest::dispatchAddAnimation() |
| void ThreadedTest::dispatchSetNeedsAnimateAndCommit() |
| { |
| - DCHECK(Proxy::isMainThread()); |
| + DCHECK(!proxy() || proxy()->isMainThread()); |
| if (m_finished) |
| return; |
| @@ -480,7 +480,7 @@ void ThreadedTest::dispatchSetNeedsAnimateAndCommit() |
| void ThreadedTest::dispatchSetNeedsCommit() |
| { |
| - DCHECK(Proxy::isMainThread()); |
| + DCHECK(!proxy() || proxy()->isMainThread()); |
| if (m_finished) |
| return; |
| @@ -491,7 +491,7 @@ void ThreadedTest::dispatchSetNeedsCommit() |
| void ThreadedTest::dispatchAcquireLayerTextures() |
| { |
| - DCHECK(Proxy::isMainThread()); |
| + DCHECK(!proxy() || proxy()->isMainThread()); |
| if (m_finished) |
| return; |
| @@ -502,7 +502,7 @@ void ThreadedTest::dispatchAcquireLayerTextures() |
| void ThreadedTest::dispatchSetNeedsRedraw() |
| { |
| - DCHECK(Proxy::isMainThread()); |
| + DCHECK(!proxy() || proxy()->isMainThread()); |
| if (m_finished) |
| return; |
| @@ -513,7 +513,7 @@ void ThreadedTest::dispatchSetNeedsRedraw() |
| void ThreadedTest::dispatchSetVisible(bool visible) |
| { |
| - DCHECK(Proxy::isMainThread()); |
| + DCHECK(!proxy() || proxy()->isMainThread()); |
| if (m_finished) |
| return; |
| @@ -531,7 +531,7 @@ void ThreadedTest::dispatchComposite() |
| void ThreadedTest::dispatchDidAddAnimation() |
| { |
| - DCHECK(Proxy::isMainThread()); |
| + DCHECK(!proxy() || proxy()->isMainThread()); |
| if (m_finished) |
| return; |
| @@ -547,13 +547,11 @@ void ThreadedTest::runTest(bool threaded) |
| Settings::setAcceleratedAnimationEnabled(true); |
| if (threaded) { |
| - m_webThread.reset(WebKit::Platform::current()->createThread("ThreadedTest")); |
| - Platform::current()->compositorSupport()->initialize(m_webThread.get()); |
| - } else |
| - Platform::current()->compositorSupport()->initialize(0); |
| + m_webImplThread.reset(WebKit::Platform::current()->createThread("ThreadedTest")); |
| + m_implThread = CCThreadImpl::createForDifferentThread(m_webImplThread.get()).release(); |
|
jamesr
2012/10/25 19:42:39
instead of relying on WebKit::Platform to get a We
|
| + } |
| - DCHECK(Proxy::isMainThread()); |
| - m_mainThreadProxy = ScopedThreadProxy::create(Proxy::mainThread()); |
| + m_mainThreadProxy = ScopedThreadProxy::create(WebKit::CCThreadImpl::createForCurrentThread().release()); |
| initializeSettings(m_settings); |
| @@ -574,11 +572,9 @@ void ThreadedTest::runTest(bool threaded) |
| m_client.reset(); |
| if (m_timedOut) { |
| FAIL() << "Test timed out"; |
| - Platform::current()->compositorSupport()->shutdown(); |
| return; |
| } |
| afterTest(); |
| - Platform::current()->compositorSupport()->shutdown(); |
| } |
| } // namespace WebKitTests |