Index: cc/test/layer_tree_test.cc |
diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc |
index 7d968a32fe449009fff1734e631d060932603b18..5e72d9ab8bc06ea6235de62014d28ec8a6ef5671 100644 |
--- a/cc/test/layer_tree_test.cc |
+++ b/cc/test/layer_tree_test.cc |
@@ -30,8 +30,10 @@ |
#include "cc/trees/layer_tree_host_impl.h" |
#include "cc/trees/layer_tree_host_single_thread_client.h" |
#include "cc/trees/layer_tree_impl.h" |
+#include "cc/trees/proxy_impl.h" |
+#include "cc/trees/proxy_main.h" |
#include "cc/trees/single_thread_proxy.h" |
-#include "cc/trees/thread_proxy.h" |
+#include "cc/trees/threaded_channel.h" |
#include "testing/gmock/include/gmock/gmock.h" |
#include "ui/gfx/geometry/size_conversions.h" |
@@ -112,212 +114,257 @@ void TestHooks::CreateResourceAndTileTaskWorkerPool( |
tile_task_worker_pool, resource_pool); |
} |
-// Adapts ThreadProxy for test. Injects test hooks for testing. |
-class ThreadProxyForTest : public ThreadProxy { |
+// Adapts ProxyImpl for test. Injects test hooks for testing. |
Wez
2015/11/10 01:41:50
nit: Suggest "Creates a ProxyImpl that notifies th
Khushal
2015/11/11 04:17:47
Yeah, that makes it clearer. Done.
|
+class ProxyImplForTest : public ProxyImpl { |
public: |
- static scoped_ptr<Proxy> Create( |
+ static scoped_ptr<ProxyImpl> Create( |
TestHooks* test_hooks, |
- LayerTreeHost* host, |
- scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
- scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
+ ChannelImpl* channel_impl, |
+ LayerTreeHost* layer_tree_host, |
+ TaskRunnerProvider* task_runner_provider, |
scoped_ptr<BeginFrameSource> external_begin_frame_source) { |
- return make_scoped_ptr(new ThreadProxyForTest( |
- test_hooks, |
- host, |
- main_task_runner, |
- impl_task_runner, |
+ return make_scoped_ptr(new ProxyImplForTest( |
+ test_hooks, channel_impl, layer_tree_host, task_runner_provider, |
external_begin_frame_source.Pass())); |
} |
- ~ThreadProxyForTest() override {} |
- |
private: |
TestHooks* test_hooks_; |
- void SetNeedsUpdateLayers() override { |
- ThreadProxy::SetNeedsUpdateLayers(); |
- test_hooks_->DidSetNeedsUpdateLayers(); |
- } |
- |
void ScheduledActionSendBeginMainFrame() override { |
test_hooks_->ScheduledActionWillSendBeginMainFrame(); |
- ThreadProxy::ScheduledActionSendBeginMainFrame(); |
+ ProxyImpl::ScheduledActionSendBeginMainFrame(); |
test_hooks_->ScheduledActionSendBeginMainFrame(); |
} |
DrawResult ScheduledActionDrawAndSwapIfPossible() override { |
- DrawResult result = ThreadProxy::ScheduledActionDrawAndSwapIfPossible(); |
+ DrawResult result = ProxyImpl::ScheduledActionDrawAndSwapIfPossible(); |
test_hooks_->ScheduledActionDrawAndSwapIfPossible(); |
return result; |
} |
void ScheduledActionAnimate() override { |
- ThreadProxy::ScheduledActionAnimate(); |
+ ProxyImpl::ScheduledActionAnimate(); |
test_hooks_->ScheduledActionAnimate(); |
} |
void ScheduledActionCommit() override { |
- ThreadProxy::ScheduledActionCommit(); |
+ ProxyImpl::ScheduledActionCommit(); |
test_hooks_->ScheduledActionCommit(); |
} |
void ScheduledActionBeginOutputSurfaceCreation() override { |
- ThreadProxy::ScheduledActionBeginOutputSurfaceCreation(); |
+ ProxyImpl::ScheduledActionBeginOutputSurfaceCreation(); |
test_hooks_->ScheduledActionBeginOutputSurfaceCreation(); |
} |
void ScheduledActionPrepareTiles() override { |
- ThreadProxy::ScheduledActionPrepareTiles(); |
+ ProxyImpl::ScheduledActionPrepareTiles(); |
test_hooks_->ScheduledActionPrepareTiles(); |
} |
void ScheduledActionInvalidateOutputSurface() override { |
- ThreadProxy::ScheduledActionInvalidateOutputSurface(); |
+ ProxyImpl::ScheduledActionInvalidateOutputSurface(); |
test_hooks_->ScheduledActionInvalidateOutputSurface(); |
} |
void SendBeginMainFrameNotExpectedSoon() override { |
- ThreadProxy::SendBeginMainFrameNotExpectedSoon(); |
+ ProxyImpl::SendBeginMainFrameNotExpectedSoon(); |
test_hooks_->SendBeginMainFrameNotExpectedSoon(); |
} |
void DidActivateSyncTree() override { |
- ThreadProxy::DidActivateSyncTree(); |
+ ProxyImpl::DidActivateSyncTree(); |
test_hooks_->DidActivateSyncTree(); |
} |
void SetThrottleFrameProductionOnImpl(bool throttle) override { |
test_hooks_->SetThrottleFrameProductionOnImpl(throttle); |
- ThreadProxy::SetThrottleFrameProductionOnImpl(throttle); |
+ ProxyImpl::SetThrottleFrameProductionOnImpl(throttle); |
} |
void InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) override { |
test_hooks_->InitializeOutputSurfaceOnImpl(output_surface); |
- ThreadProxy::InitializeOutputSurfaceOnImpl(output_surface); |
+ ProxyImpl::InitializeOutputSurfaceOnImpl(output_surface); |
} |
void MainThreadHasStoppedFlingingOnImpl() override { |
test_hooks_->MainThreadHasStoppedFlingingOnImpl(); |
- ThreadProxy::MainThreadHasStoppedFlingingOnImpl(); |
+ ProxyImpl::MainThreadHasStoppedFlingingOnImpl(); |
} |
void SetInputThrottledUntilCommitOnImpl(bool is_throttled) override { |
test_hooks_->SetInputThrottledUntilCommitOnImpl(is_throttled); |
- ThreadProxy::SetInputThrottledUntilCommitOnImpl(is_throttled); |
+ ProxyImpl::SetInputThrottledUntilCommitOnImpl(is_throttled); |
} |
void UpdateTopControlsStateOnImpl(TopControlsState constraints, |
TopControlsState current, |
bool animate) override { |
test_hooks_->UpdateTopControlsStateOnImpl(constraints, current, animate); |
- ThreadProxy::UpdateTopControlsStateOnImpl(constraints, current, animate); |
+ ProxyImpl::UpdateTopControlsStateOnImpl(constraints, current, animate); |
} |
void SetDeferCommitsOnImpl(bool defer_commits) const override { |
test_hooks_->SetDeferCommitsOnImpl(defer_commits); |
- ThreadProxy::SetDeferCommitsOnImpl(defer_commits); |
+ ProxyImpl::SetDeferCommitsOnImpl(defer_commits); |
} |
void BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) override { |
test_hooks_->BeginMainFrameAbortedOnImpl(reason); |
- ThreadProxy::BeginMainFrameAbortedOnImpl(reason); |
+ ProxyImpl::BeginMainFrameAbortedOnImpl(reason); |
} |
void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) override { |
test_hooks_->SetNeedsRedrawOnImpl(damage_rect); |
- ThreadProxy::SetNeedsRedrawOnImpl(damage_rect); |
+ ProxyImpl::SetNeedsRedrawOnImpl(damage_rect); |
}; |
void SetNeedsCommitOnImpl() override { |
test_hooks_->SetNeedsCommitOnImpl(); |
- ThreadProxy::SetNeedsCommitOnImpl(); |
+ ProxyImpl::SetNeedsCommitOnImpl(); |
} |
void FinishAllRenderingOnImpl(CompletionEvent* completion) override { |
test_hooks_->FinishAllRenderingOnImpl(); |
- ThreadProxy::FinishAllRenderingOnImpl(completion); |
+ ProxyImpl::FinishAllRenderingOnImpl(completion); |
}; |
void SetVisibleOnImpl(bool visible) override { |
test_hooks_->SetVisibleOnImpl(visible); |
- ThreadProxy::SetVisibleOnImpl(visible); |
+ ProxyImpl::SetVisibleOnImpl(visible); |
} |
void ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) override { |
test_hooks_->ReleaseOutputSurfaceOnImpl(); |
- ThreadProxy::ReleaseOutputSurfaceOnImpl(completion); |
+ ProxyImpl::ReleaseOutputSurfaceOnImpl(completion); |
} |
void FinishGLOnImpl(CompletionEvent* completion) override { |
test_hooks_->FinishGLOnImpl(); |
- ThreadProxy::FinishGLOnImpl(completion); |
+ ProxyImpl::FinishGLOnImpl(completion); |
} |
void StartCommitOnImpl(CompletionEvent* completion, |
LayerTreeHost* layer_tree_host, |
bool hold_commit_for_activation) override { |
test_hooks_->StartCommitOnImpl(); |
- ThreadProxy::StartCommitOnImpl(completion, layer_tree_host, |
- hold_commit_for_activation); |
+ ProxyImpl::StartCommitOnImpl(completion, layer_tree_host, |
+ hold_commit_for_activation); |
} |
- void InitializeImplOnImpl(CompletionEvent* completion, |
- LayerTreeHost* layer_tree_host) override { |
- ThreadProxy::InitializeImplOnImpl(completion, layer_tree_host); |
- test_hooks_->InitializeImplOnImpl(); |
+ void LayerTreeHostClosedOnImpl() override { |
+ test_hooks_->WillCloseLayerTreeHostOnImpl(); |
+ ProxyImpl::LayerTreeHostClosedOnImpl(); |
+ } |
+ |
+ ProxyImplForTest(TestHooks* test_hooks, |
+ ChannelImpl* channel_impl, |
+ LayerTreeHost* layer_tree_host, |
+ TaskRunnerProvider* task_runner_provider, |
+ scoped_ptr<BeginFrameSource> external_begin_frame_source) |
+ : ProxyImpl(channel_impl, |
+ layer_tree_host, |
+ task_runner_provider, |
+ external_begin_frame_source.Pass()), |
+ test_hooks_(test_hooks) {} |
+}; |
+ |
+// Injects ProxyImplForTest for testing. |
Wez
2015/11/10 01:41:50
Suggest "ThreadedChannel that will notify |test_ho
Khushal
2015/11/11 04:17:47
Done.
|
+class ThreadedChannelForTest : public ThreadedChannel { |
+ public: |
+ static scoped_ptr<ThreadedChannel> Create(TestHooks* test_hooks, |
+ ProxyMain* proxy_main) { |
+ return make_scoped_ptr(new ThreadedChannelForTest(test_hooks, proxy_main)); |
} |
- void LayerTreeHostClosedOnImpl(CompletionEvent* completion) override { |
- test_hooks_->WillCloseLayerTreeHostOnImpl(); |
- ThreadProxy::LayerTreeHostClosedOnImpl(completion); |
+ private: |
+ TestHooks* test_hooks_; |
+ |
+ scoped_ptr<ProxyImpl> CreateProxyImpl( |
+ ChannelImpl* channel_impl, |
+ LayerTreeHost* layer_tree_host, |
+ TaskRunnerProvider* task_runner_provider, |
+ scoped_ptr<BeginFrameSource> external_begin_frame_source) override { |
+ return ProxyImplForTest::Create(test_hooks_, channel_impl, layer_tree_host, |
+ task_runner_provider, |
+ external_begin_frame_source.Pass()); |
+ } |
+ |
+ ThreadedChannelForTest(TestHooks* test_hooks, ProxyMain* proxy_main) |
+ : ThreadedChannel(proxy_main), test_hooks_(test_hooks) {} |
+}; |
+ |
+// Adapts ProxyMain for test. Injects test hooks for testing. |
Wez
2015/11/10 01:41:50
See suggestions above.
Khushal
2015/11/11 04:17:47
Done.
|
+class ProxyMainForTest : public ProxyMain { |
+ public: |
+ static scoped_ptr<ProxyMain> Create( |
+ TestHooks* test_hooks, |
+ LayerTreeHost* host, |
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
+ scoped_ptr<BeginFrameSource> external_begin_frame_source) { |
+ return make_scoped_ptr(new ProxyMainForTest( |
+ test_hooks, host, main_task_runner, impl_task_runner, |
+ external_begin_frame_source.Pass())); |
+ } |
+ |
+ ~ProxyMainForTest() override {} |
+ |
+ private: |
+ TestHooks* test_hooks_; |
+ |
+ void SetNeedsUpdateLayers() override { |
+ ProxyMain::SetNeedsUpdateLayers(); |
+ test_hooks_->DidSetNeedsUpdateLayers(); |
} |
void DidCompleteSwapBuffers() override { |
test_hooks_->ReceivedDidCompleteSwapBuffers(); |
- ThreadProxy::DidCompleteSwapBuffers(); |
+ ProxyMain::DidCompleteSwapBuffers(); |
} |
void SetRendererCapabilitiesMainCopy( |
const RendererCapabilities& capabilities) override { |
test_hooks_->ReceivedSetRendererCapabilitiesMainCopy(capabilities); |
- ThreadProxy::SetRendererCapabilitiesMainCopy(capabilities); |
+ ProxyMain::SetRendererCapabilitiesMainCopy(capabilities); |
} |
void BeginMainFrameNotExpectedSoon() override { |
test_hooks_->ReceivedBeginMainFrameNotExpectedSoon(); |
- ThreadProxy::BeginMainFrameNotExpectedSoon(); |
+ ProxyMain::BeginMainFrameNotExpectedSoon(); |
} |
void DidCommitAndDrawFrame() override { |
test_hooks_->ReceivedDidCommitAndDrawFrame(); |
- ThreadProxy::DidCommitAndDrawFrame(); |
+ ProxyMain::DidCommitAndDrawFrame(); |
} |
void SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) override { |
test_hooks_->ReceivedSetAnimationEvents(); |
- ThreadProxy::SetAnimationEvents(events.Pass()); |
+ ProxyMain::SetAnimationEvents(events.Pass()); |
} |
void DidLoseOutputSurface() override { |
test_hooks_->ReceivedDidLoseOutputSurface(); |
- ThreadProxy::DidLoseOutputSurface(); |
+ ProxyMain::DidLoseOutputSurface(); |
} |
void RequestNewOutputSurface() override { |
test_hooks_->ReceivedRequestNewOutputSurface(); |
- ThreadProxy::RequestNewOutputSurface(); |
+ ProxyMain::RequestNewOutputSurface(); |
} |
void DidInitializeOutputSurface( |
bool success, |
const RendererCapabilities& capabilities) override { |
test_hooks_->ReceivedDidInitializeOutputSurface(success, capabilities); |
- ThreadProxy::DidInitializeOutputSurface(success, capabilities); |
+ ProxyMain::DidInitializeOutputSurface(success, capabilities); |
} |
void DidCompletePageScaleAnimation() override { |
test_hooks_->ReceivedDidCompletePageScaleAnimation(); |
- ThreadProxy::DidCompletePageScaleAnimation(); |
+ ProxyMain::DidCompletePageScaleAnimation(); |
} |
void PostFrameTimingEventsOnMain( |
@@ -325,29 +372,29 @@ class ThreadProxyForTest : public ThreadProxy { |
scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) |
override { |
test_hooks_->ReceivedPostFrameTimingEventsOnMain(); |
- ThreadProxy::PostFrameTimingEventsOnMain(composite_events.Pass(), |
- main_frame_events.Pass()); |
+ ProxyMain::PostFrameTimingEventsOnMain(composite_events.Pass(), |
+ main_frame_events.Pass()); |
} |
void BeginMainFrame(scoped_ptr<BeginMainFrameAndCommitState> |
begin_main_frame_state) override { |
test_hooks_->ReceivedBeginMainFrame(); |
- ThreadProxy::BeginMainFrame(begin_main_frame_state.Pass()); |
+ ProxyMain::BeginMainFrame(begin_main_frame_state.Pass()); |
}; |
- ThreadProxyForTest( |
- TestHooks* test_hooks, |
- LayerTreeHost* host, |
- scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
- scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
- scoped_ptr<BeginFrameSource> external_begin_frame_source) |
- : ThreadProxy(host, main_task_runner, |
- impl_task_runner, |
- external_begin_frame_source.Pass()), |
+ ProxyMainForTest(TestHooks* test_hooks, |
+ LayerTreeHost* host, |
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
+ scoped_ptr<BeginFrameSource> external_begin_frame_source) |
+ : ProxyMain(host, |
+ main_task_runner, |
+ impl_task_runner, |
+ external_begin_frame_source.Pass()), |
test_hooks_(test_hooks) {} |
}; |
-// Adapts ThreadProxy for test. Injects test hooks for testing. |
+// Adapts SingleThreadProxy for test. Injects test hooks for testing. |
Wez
2015/11/10 01:41:50
See suggestions above re comment style.
Khushal
2015/11/11 04:17:47
Done.
|
class SingleThreadProxyForTest : public SingleThreadProxy { |
public: |
static scoped_ptr<Proxy> Create( |
@@ -704,12 +751,13 @@ class LayerTreeHostForTesting : public LayerTreeHost { |
scoped_ptr<LayerTreeHostForTesting> layer_tree_host( |
new LayerTreeHostForTesting(test_hooks, ¶ms)); |
if (impl_task_runner.get()) { |
- layer_tree_host->InitializeForTesting( |
- ThreadProxyForTest::Create(test_hooks, |
- layer_tree_host.get(), |
- main_task_runner, |
- impl_task_runner, |
- external_begin_frame_source.Pass())); |
+ scoped_ptr<ProxyMain> proxy_main = ProxyMainForTest::Create( |
+ test_hooks, layer_tree_host.get(), main_task_runner, impl_task_runner, |
+ external_begin_frame_source.Pass()); |
+ scoped_ptr<ThreadedChannel> threaded_channel = |
+ ThreadedChannelForTest::Create(test_hooks, proxy_main.get()); |
+ proxy_main->SetChannel(threaded_channel.Pass()); |
+ layer_tree_host->InitializeForTesting(proxy_main.Pass()); |
} else { |
layer_tree_host->InitializeForTesting( |
SingleThreadProxyForTest::Create( |
@@ -1160,4 +1208,19 @@ LayerTreeHost* LayerTreeTest::layer_tree_host() { |
return layer_tree_host_.get(); |
} |
+ProxyMain* LayerTreeTest::GetProxyMain() const { |
+ DCHECK(HasImplThread()); |
+ return static_cast<ProxyMain*>(proxy()); |
+} |
+ |
+ProxyImpl* LayerTreeTest::GetProxyImpl() const { |
+ // Verify that the channel has been initialized since proxy impl exists in the |
+ // channel only after it is initialized. |
+ DCHECK(HasImplThread()); |
+ DCHECK(GetProxyMain()->channel_main()->IsInitialized()); |
+ ThreadedChannel* threaded_channel = |
+ static_cast<ThreadedChannel*>(GetProxyMain()->channel_main()); |
+ return threaded_channel->proxy_impl(); |
+} |
+ |
} // namespace cc |