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

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: Use NON_EXPORTED_BASE for non-exported base class 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
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/trees/layer_tree_host_unittest_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/test/layer_tree_test.cc
diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc
index 8a80f89121f978c542c7152fb43738f91ac0acc5..2aab75cca9d38c0cfe57d27586c15e2f36149f6e 100644
--- a/cc/test/layer_tree_test.cc
+++ b/cc/test/layer_tree_test.cc
@@ -25,6 +25,7 @@
#include "cc/trees/layer_tree_host_single_thread_client.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/single_thread_proxy.h"
+#include "cc/trees/thread_proxy.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/gfx/frame_time.h"
#include "ui/gfx/size_conversions.h"
@@ -46,6 +47,58 @@ 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>();
+ }
+
+ virtual ~ThreadProxyForTest() {}
+
+ void test() {
+ test_hooks_->Layout();
+ }
+
+ private:
+ TestHooks* test_hooks_;
+
+ virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {
+ ThreadProxy::ScheduledActionBeginOutputSurfaceCreation();
+ test_hooks_->ScheduledActionBeginOutputSurfaceCreation();
+ }
+
+ virtual void ScheduledActionSendBeginMainFrame() OVERRIDE {
+ ThreadProxy::ScheduledActionSendBeginMainFrame();
+ test_hooks_->ScheduledActionSendBeginMainFrame();
+ }
+
+ virtual void ScheduledActionCommit() OVERRIDE {
+ ThreadProxy::ScheduledActionCommit();
+ test_hooks_->ScheduledActionCommit();
+ }
+
+ virtual DrawResult ScheduledActionDrawAndSwapIfPossible() OVERRIDE {
+ DrawResult result = ThreadProxy::ScheduledActionDrawAndSwapIfPossible();
+ test_hooks_->ScheduledActionDrawAndSwapIfPossible();
+ return result;
+ }
+
+ 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:
@@ -285,10 +338,15 @@ class LayerTreeHostForTesting : public LayerTreeHost {
scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
new LayerTreeHostForTesting(test_hooks, client, settings));
- if (impl_task_runner.get())
- layer_tree_host->InitializeThreaded(impl_task_runner);
- else
- layer_tree_host->InitializeSingleThreaded(client);
+ if (impl_task_runner.get()) {
+ layer_tree_host->InitializeForTesting(
+ ThreadProxyForTest::Create(test_hooks,
+ layer_tree_host.get(),
+ impl_task_runner));
+ } else {
+ layer_tree_host->InitializeForTesting(
+ SingleThreadProxy::Create(layer_tree_host.get(), client));
+ }
return layer_tree_host.Pass();
}
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/trees/layer_tree_host_unittest_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698