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

Unified Diff: cc/trees/layer_tree_host_unittest_proxy.cc

Issue 242783003: cc: Add testing stubs for proxy test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Makes proxy test more general for single & threaded proxy 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/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

Powered by Google App Engine
This is Rietveld 408576698