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

Unified Diff: cc/test/layer_tree_test.cc

Issue 242783003: cc: Add testing stubs for proxy test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 7 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
Index: cc/test/layer_tree_test.cc
diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc
index 2a0762d39cccda553f015b318ba79ea8711e8bd5..eebf51466747dcb0250a3f79fc2c9a0cc1088991 100644
--- a/cc/test/layer_tree_test.cc
+++ b/cc/test/layer_tree_test.cc
@@ -46,6 +46,41 @@ base::TimeDelta TestHooks::LowFrequencyAnimationInterval() const {
return base::TimeDelta::FromMilliseconds(16);
}
+// Adapts ThreadProxy for test. Injects test hooks for testing.
+class ThreadProxyForTest : public ThreadProxy {
+ public:
+ static scoped_ptr<Proxy> Create(
+ TestHooks* test_hooks,
+ LayerTreeHost* host,
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
+ return make_scoped_ptr(
+ new ThreadProxyForTest(test_hooks,
+ host,
+ impl_task_runner)).PassAs<Proxy>();
+ }
+
+ const ThreadProxy::MainThreadOnly& main() const {
+ return ThreadProxy::main();
+ }
+
+ const ThreadProxy::CompositorThreadOnly& impl() const {
+ return ThreadProxy::impl();
+ }
+
+ virtual ~ThreadProxyForTest() {}
+
+ private:
+ TestHooks* test_hooks_;
+
+ ThreadProxyForTest(
+ TestHooks* test_hooks,
+ LayerTreeHost* host,
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner)
+ : ThreadProxy(host, impl_task_runner),
+ test_hooks_(test_hooks) {
+ }
+};
+
// Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks.
class LayerTreeHostImplForTesting : public LayerTreeHostImpl {
public:
@@ -315,6 +350,12 @@ class LayerTreeHostForTesting : public LayerTreeHost {
virtual void DidDeferCommit() OVERRIDE { test_hooks_->DidDeferCommit(); }
+ virtual void InitializeThreaded(
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) OVERRIDE {
+ InitializeProxy(
+ ThreadProxyForTest::Create(test_hooks_, this, impl_task_runner));
+ }
+
private:
LayerTreeHostForTesting(TestHooks* test_hooks,
LayerTreeHostClient* client,
@@ -662,6 +703,18 @@ void LayerTreeTest::RunTestWithImplSidePainting() {
RunTest(true, false, true);
}
+const ThreadProxy::MainThreadOnly&
+LayerTreeTest::ThreadProxyMainOnly() const {
+ DCHECK(proxy() && proxy()->HasImplThread());
brianderson 2014/05/14 21:12:07 Please split DCHECK into two separate DCHECKs.
simonhong 2014/05/15 01:32:07 Done.
+ return static_cast<ThreadProxyForTest*>(proxy())->main();
+}
+
+const ThreadProxy::CompositorThreadOnly&
+LayerTreeTest::ThreadProxyImplOnly() const {
+ DCHECK(proxy() && proxy()->HasImplThread());
brianderson 2014/05/14 21:12:07 Please split DCHECK into two separate DCHECKs.
simonhong 2014/05/15 01:32:07 Done.
+ return static_cast<ThreadProxyForTest*>(proxy())->impl();
+}
+
scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface(bool fallback) {
scoped_ptr<FakeOutputSurface> output_surface =
CreateFakeOutputSurface(fallback);

Powered by Google App Engine
This is Rietveld 408576698