Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Unified Diff: cc/test/layer_tree_test_common.cc

Issue 11344004: Remove WebKit::Platform dependencies from cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix webkit_compositor_bindings_unittests Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/test/layer_tree_test_common.h ('k') | cc/test/run_all_unittests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2bb5d41ba5176758c09d417cb403c9548211551b..4fee06ca83fb029b34883ea998265ea98e2eeddb 100644
--- a/cc/test/layer_tree_test_common.cc
+++ b/cc/test/layer_tree_test_common.cc
@@ -17,17 +17,15 @@
#include "cc/scoped_thread_proxy.h"
#include "cc/settings.h"
#include "cc/single_thread_proxy.h"
+#include "cc/thread_impl.h"
#include "cc/test/animation_test_common.h"
#include "cc/test/fake_web_compositor_output_surface.h"
#include "cc/test/fake_web_graphics_context_3d.h"
#include "cc/test/occlusion_tracker_test_common.h"
#include "cc/test/test_common.h"
#include "cc/test/tiled_layer_test_common.h"
-#include "cc/thread_task.h"
#include "cc/timing_function.h"
#include "testing/gmock/include/gmock/gmock.h"
-#include <public/Platform.h>
-#include <public/WebCompositorSupport.h>
#include <public/WebFilterOperation.h>
#include <public/WebFilterOperations.h>
#include <public/WebThread.h>
@@ -270,50 +268,6 @@ private:
TestHooks* m_testHooks;
};
-class TimeoutTask : public WebThread::Task {
-public:
- explicit TimeoutTask(ThreadedTest* test)
- : m_test(test)
- {
- }
-
- void clearTest()
- {
- m_test = 0;
- }
-
- virtual ~TimeoutTask()
- {
- if (m_test)
- m_test->clearTimeout();
- }
-
- virtual void run()
- {
- if (m_test)
- m_test->timeout();
- }
-
-private:
- ThreadedTest* m_test;
-};
-
-class BeginTask : public WebThread::Task {
-public:
- explicit BeginTask(ThreadedTest* test)
- : m_test(test)
- {
- }
-
- virtual ~BeginTask() { }
- virtual void run()
- {
- m_test->doBeginTest();
- }
-private:
- ThreadedTest* m_test;
-};
-
ThreadedTest::ThreadedTest()
: m_beginning(false)
, m_endWhenBeginReturns(false)
@@ -337,57 +291,57 @@ void ThreadedTest::endTest()
if (m_beginning)
m_endWhenBeginReturns = true;
else
- m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::realEndTest));
+ m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::realEndTest, base::Unretained(this)));
}
void ThreadedTest::endTestAfterDelay(int delayMilliseconds)
{
- m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::endTest));
+ m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::endTest, base::Unretained(this)));
}
void ThreadedTest::postSetNeedsAnimateToMainThread()
{
- m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::dispatchSetNeedsAnimate));
+ m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSetNeedsAnimate, base::Unretained(this)));
}
void ThreadedTest::postAddAnimationToMainThread()
{
- m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::dispatchAddAnimation));
+ m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchAddAnimation, base::Unretained(this)));
}
void ThreadedTest::postAddInstantAnimationToMainThread()
{
- m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::dispatchAddInstantAnimation));
+ m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchAddInstantAnimation, base::Unretained(this)));
}
void ThreadedTest::postSetNeedsCommitToMainThread()
{
- m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::dispatchSetNeedsCommit));
+ m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSetNeedsCommit, base::Unretained(this)));
}
void ThreadedTest::postAcquireLayerTextures()
{
- m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::dispatchAcquireLayerTextures));
+ m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchAcquireLayerTextures, base::Unretained(this)));
}
void ThreadedTest::postSetNeedsRedrawToMainThread()
{
- m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::dispatchSetNeedsRedraw));
+ m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSetNeedsRedraw, base::Unretained(this)));
}
void ThreadedTest::postSetNeedsAnimateAndCommitToMainThread()
{
- m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::dispatchSetNeedsAnimateAndCommit));
+ m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSetNeedsAnimateAndCommit, base::Unretained(this)));
}
void ThreadedTest::postSetVisibleToMainThread(bool visible)
{
- m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::dispatchSetVisible, visible));
+ m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSetVisible, base::Unretained(this), visible));
}
void ThreadedTest::postDidAddAnimationToMainThread()
{
- m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::dispatchDidAddAnimation));
+ m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchDidAddAnimation, base::Unretained(this)));
}
void ThreadedTest::doBeginTest()
@@ -425,13 +379,13 @@ void ThreadedTest::scheduleComposite()
if (!m_started || m_scheduled || m_finished)
return;
m_scheduled = true;
- m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::dispatchComposite));
+ m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchComposite, base::Unretained(this)));
}
void ThreadedTest::realEndTest()
{
DCHECK(Proxy::isMainThread());
- WebKit::Platform::current()->currentThread()->exitRunLoop();
+ MessageLoop::current()->Quit();
}
void ThreadedTest::dispatchSetNeedsAnimate()
@@ -549,38 +503,36 @@ 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_implThread.reset(new base::Thread("ThreadedTest"));
+ ASSERT_TRUE(m_implThread->Start());
+ m_implCCThread = cc::ThreadImpl::createForDifferentThread(m_implThread->message_loop_proxy());
+ cc::Proxy::setImplThread(m_implCCThread.get());
+ }
DCHECK(Proxy::isMainThread());
m_mainThreadProxy = ScopedThreadProxy::create(Proxy::mainThread());
initializeSettings(m_settings);
- m_beginTask = new BeginTask(this);
- WebKit::Platform::current()->currentThread()->postDelayedTask(m_beginTask, 0); // postDelayedTask takes ownership of the task
- m_timeoutTask = new TimeoutTask(this);
- WebKit::Platform::current()->currentThread()->postDelayedTask(m_timeoutTask, 5000);
- WebKit::Platform::current()->currentThread()->enterRunLoop();
-
+ cc::Proxy::mainThread()->postTask(base::Bind(&ThreadedTest::doBeginTest, base::Unretained(this)));
+ m_timeout.Reset(base::Bind(&ThreadedTest::timeout, base::Unretained(this)));
+ cc::Proxy::mainThread()->postDelayedTask(m_timeout.callback(), 5000);
+ MessageLoop::current()->Run();
if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer())
m_layerTreeHost->rootLayer()->setLayerTreeHost(0);
m_layerTreeHost.reset();
- if (m_timeoutTask)
- m_timeoutTask->clearTest();
+ cc::Proxy::setImplThread(0);
+
+ m_timeout.Cancel();
ASSERT_FALSE(m_layerTreeHost.get());
m_client.reset();
if (m_timedOut) {
FAIL() << "Test timed out";
- Platform::current()->compositorSupport()->shutdown();
return;
}
afterTest();
- Platform::current()->compositorSupport()->shutdown();
}
} // namespace WebKitTests
« no previous file with comments | « cc/test/layer_tree_test_common.h ('k') | cc/test/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698