Chromium Code Reviews| 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..2ffc04fbbd1305fe9e4244dcfcde319984132b7a |
| --- /dev/null |
| +++ b/cc/trees/layer_tree_host_unittest_proxy.cc |
| @@ -0,0 +1,93 @@ |
| +// 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" |
| + |
| +namespace cc { |
| + |
| +// Helper class to access private data in ThreadProxy. |
| +class ThreadProxyTestAPI { |
|
danakj
2014/04/24 16:03:15
You could also make accessors for these on the Lay
simonhong
2014/04/25 00:42:35
Done.
|
| + public: |
| + explicit ThreadProxyTestAPI(ThreadProxy* proxy) : proxy_(proxy) {} |
| + virtual ~ThreadProxyTestAPI() {} |
| + |
| + ThreadProxy::MainThreadOnly& main() { |
|
danakj
2014/04/24 16:03:15
const&?
simonhong
2014/04/25 00:42:35
Done.
|
| + return proxy_->main(); |
| + } |
| + |
| + ThreadProxy::CompositorThreadOnly& impl() { |
|
danakj
2014/04/24 16:03:15
const&
simonhong
2014/04/25 00:42:35
Done.
|
| + return proxy_->impl(); |
| + } |
| + |
| + private: |
| + ThreadProxy* proxy_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestAPI); |
| +}; |
| + |
| +class ThreadProxyTest : public LayerTreeTest { |
| + public: |
| + virtual void WillBeginTest() OVERRIDE { |
| + LayerTreeTest::WillBeginTest(); |
| + test_api_.reset(new ThreadProxyTestAPI( |
| + static_cast<ThreadProxy*>(proxy()))); |
| + } |
| + |
| + protected: |
| + scoped_ptr<ThreadProxyTestAPI> test_api_; |
| + |
| + ThreadProxyTest() {} |
| + virtual ~ThreadProxyTest() {} |
| + |
| + void RunTest() { |
| + // We don't need to care about delegating, impl side painting because |
| + // ThreadProxyTest only cover ThreadProxy itself. |
| + // So, true is passed to all parameters. |
| + bool threaded = true; |
| + bool delegating_renderer = true; |
| + bool impl_side_painting = true; |
| + LayerTreeTest::RunTest(threaded, delegating_renderer, impl_side_painting); |
| + } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ThreadProxyTest); |
| +}; |
| + |
| +class ThreadProxyTestSetNeedsCommit : public ThreadProxyTest { |
| + public: |
| + void BeginTest() OVERRIDE { |
| + EXPECT_FALSE(test_api_->main().commit_requested); |
| + EXPECT_FALSE(test_api_->main().commit_request_sent_to_impl_thread); |
| + |
| + proxy()->SetNeedsCommit(); |
| + |
| + EXPECT_TRUE(test_api_->main().commit_requested); |
| + EXPECT_TRUE(test_api_->main().commit_request_sent_to_impl_thread); |
| + } |
| + |
| + void DidBeginMainFrame() OVERRIDE { |
| + EXPECT_FALSE(test_api_->main().commit_requested); |
| + EXPECT_FALSE(test_api_->main().commit_request_sent_to_impl_thread); |
| + |
| + EndTest(); |
| + } |
| + |
| + void AfterTest() OVERRIDE {} |
| + |
| + protected: |
| + ThreadProxyTestSetNeedsCommit() {} |
| + virtual ~ThreadProxyTestSetNeedsCommit() {} |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsCommit); |
| +}; |
| + |
| +TEST_F(ThreadProxyTestSetNeedsCommit, SetNeedsCommitTest) { |
| + RunTest(); |
| +} |
| + |
| +} // namespace cc |