Index: cc/trees/layer_tree_host_unittest_proxy.cc |
diff --git a/cc/trees/layer_tree_host_unittest_proxy.cc b/cc/trees/layer_tree_host_unittest_proxy.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..83cd0be3d5777f3d93c3482850ece150b8b721db |
--- /dev/null |
+++ b/cc/trees/layer_tree_host_unittest_proxy.cc |
@@ -0,0 +1,123 @@ |
+// Copyright 2014 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 "base/basictypes.h" |
+#include "base/compiler_specific.h" |
+#include "cc/test/layer_tree_test.h" |
+#include "cc/trees/thread_proxy.h" |
+ |
+#define THREAD_PROXY_NO_IMPL_TEST_F(TEST_FIXTURE_NAME) \ |
+ TEST_F(TEST_FIXTURE_NAME, Run_MainThreadPaint) { \ |
+ Run(true, false); \ |
+ } |
+ |
+#define THREAD_PROXY_TEST_F(TEST_FIXTURE_NAME) \ |
+ THREAD_PROXY_NO_IMPL_TEST_F(TEST_FIXTURE_NAME); \ |
+ TEST_F(TEST_FIXTURE_NAME, Run_ImplSidePaint) { \ |
+ Run(true, true); \ |
+ } |
+ |
+namespace cc { |
+ |
+class ProxyTest : public LayerTreeTest { |
+ public: |
+ ProxyTest() : threaded_(false) {} |
+ virtual ~ProxyTest() {} |
+ |
+ void Run(bool threaded, bool impl_side_painting) { |
+ // We don't need to care about delegating mode. |
+ bool delegating_renderer = true; |
+ |
+ threaded_ = threaded; |
+ RunTest(threaded, delegating_renderer, impl_side_painting); |
+ } |
+ |
+ const ThreadProxy::MainThreadOnly& ThreadProxyMainOnly() const { |
+ DCHECK(proxy()); |
+ DCHECK(proxy()->HasImplThread()); |
+ return static_cast<const ThreadProxy*>(proxy())->main(); |
+ } |
+ |
+ const ThreadProxy::CompositorThreadOnly& ThreadProxyImplOnly() const { |
+ DCHECK(proxy()); |
+ DCHECK(proxy()->HasImplThread()); |
+ return static_cast<const ThreadProxy*>(proxy())->impl(); |
+ } |
+ |
+ bool threaded () const { return threaded_; } |
+ |
+ private: |
+ bool threaded_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ProxyTest); |
+}; |
+ |
+class ProxyTestOutputSurfaceCreationRequest : public ProxyTest { |
+ public: |
+ virtual void BeginTest() OVERRIDE { |
+ EXPECT_FALSE(has_sent_output_surface_creation_request_); |
+ proxy()->SetNeedsCommit(); |
+ } |
+ |
+ virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE { |
+ has_sent_output_surface_creation_request_ = true; |
+ EndTest(); |
+ } |
+ |
+ virtual void AfterTest() OVERRIDE { |
+ EXPECT_TRUE(has_sent_output_surface_creation_request_); |
+ } |
+ |
+ protected: |
+ ProxyTestOutputSurfaceCreationRequest() |
+ : has_sent_output_surface_creation_request_(false) { |
+ } |
+ virtual ~ProxyTestOutputSurfaceCreationRequest() {} |
+ |
+ private: |
+ bool has_sent_output_surface_creation_request_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ProxyTestOutputSurfaceCreationRequest); |
+}; |
+ |
+THREAD_PROXY_TEST_F(ProxyTestOutputSurfaceCreationRequest); |
+ |
+class ProxyTestSetNeedsCommit : public ProxyTest { |
+ public: |
+ virtual void BeginTest() OVERRIDE { |
+ if (threaded()) { |
+ EXPECT_FALSE(ThreadProxyMainOnly().commit_requested); |
+ EXPECT_FALSE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread); |
+ } |
+ |
+ proxy()->SetNeedsCommit(); |
+ |
+ if (threaded()) { |
+ EXPECT_TRUE(ThreadProxyMainOnly().commit_requested); |
+ EXPECT_TRUE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread); |
+ } |
+ } |
+ |
+ virtual void DidBeginMainFrame() OVERRIDE { |
+ if (threaded()) { |
+ EXPECT_FALSE(ThreadProxyMainOnly().commit_requested); |
+ EXPECT_FALSE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread); |
+ } |
+ |
+ EndTest(); |
+ } |
+ |
+ virtual void AfterTest() OVERRIDE {} |
+ |
+ protected: |
+ ProxyTestSetNeedsCommit() {} |
+ virtual ~ProxyTestSetNeedsCommit() {} |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ProxyTestSetNeedsCommit); |
+}; |
+ |
+THREAD_PROXY_TEST_F(ProxyTestSetNeedsCommit); |
+ |
+} // namespace cc |