| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "cc/animation/animation_host.h" | 9 #include "cc/animation/animation_host.h" |
| 10 #include "cc/test/fake_image_serialization_processor.h" | 10 #include "cc/test/fake_image_serialization_processor.h" |
| 11 #include "cc/test/test_task_graph_runner.h" | 11 #include "cc/test/test_task_graph_runner.h" |
| 12 #include "cc/trees/layer_tree_host.h" | |
| 13 #include "cc/trees/layer_tree_host_client.h" | 12 #include "cc/trees/layer_tree_host_client.h" |
| 13 #include "cc/trees/layer_tree_host_in_process.h" |
| 14 #include "cc/trees/proxy_common.h" | 14 #include "cc/trees/proxy_common.h" |
| 15 #include "cc/trees/proxy_main.h" | 15 #include "cc/trees/proxy_main.h" |
| 16 #include "cc/trees/remote_proto_channel.h" | 16 #include "cc/trees/remote_proto_channel.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class LayerTreeHostTestRemoteServer : public testing::Test, | 22 class LayerTreeHostTestRemoteServer : public testing::Test, |
| 23 public RemoteProtoChannel, | 23 public RemoteProtoChannel, |
| 24 public LayerTreeHostClient { | 24 public LayerTreeHostClient { |
| 25 public: | 25 public: |
| 26 LayerTreeHostTestRemoteServer() | 26 LayerTreeHostTestRemoteServer() |
| 27 : calls_received_(0), | 27 : calls_received_(0), |
| 28 image_serialization_processor_( | 28 image_serialization_processor_( |
| 29 base::WrapUnique(new FakeImageSerializationProcessor)) { | 29 base::WrapUnique(new FakeImageSerializationProcessor)) { |
| 30 LayerTreeHost::InitParams params; | 30 LayerTreeHostInProcess::InitParams params; |
| 31 params.client = this; | 31 params.client = this; |
| 32 params.task_graph_runner = &task_graph_runner_; | 32 params.task_graph_runner = &task_graph_runner_; |
| 33 params.settings = &settings_; | 33 params.settings = &settings_; |
| 34 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); | 34 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
| 35 params.image_serialization_processor = image_serialization_processor_.get(); | 35 params.image_serialization_processor = image_serialization_processor_.get(); |
| 36 params.animation_host = | 36 params.animation_host = |
| 37 AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 37 AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
| 38 layer_tree_host_ = LayerTreeHost::CreateRemoteServer(this, ¶ms); | 38 layer_tree_host_ = |
| 39 LayerTreeHostInProcess::CreateRemoteServer(this, ¶ms); |
| 39 } | 40 } |
| 40 | 41 |
| 41 ~LayerTreeHostTestRemoteServer() override {} | 42 ~LayerTreeHostTestRemoteServer() override {} |
| 42 | 43 |
| 43 // LayerTreeHostClient implementation | 44 // LayerTreeHostClient implementation |
| 44 void WillBeginMainFrame() override {} | 45 void WillBeginMainFrame() override {} |
| 45 void BeginMainFrame(const BeginFrameArgs& args) override {} | 46 void BeginMainFrame(const BeginFrameArgs& args) override {} |
| 46 void BeginMainFrameNotExpectedSoon() override {} | 47 void BeginMainFrameNotExpectedSoon() override {} |
| 47 void DidBeginMainFrame() override {} | 48 void DidBeginMainFrame() override {} |
| 48 void UpdateLayerTreeHost() override {} | 49 void UpdateLayerTreeHost() override {} |
| (...skipping 13 matching lines...) Expand all Loading... |
| 62 | 63 |
| 63 // RemoteProtoChannel implementation | 64 // RemoteProtoChannel implementation |
| 64 void SetProtoReceiver(RemoteProtoChannel::ProtoReceiver* receiver) override { | 65 void SetProtoReceiver(RemoteProtoChannel::ProtoReceiver* receiver) override { |
| 65 receiver_ = receiver; | 66 receiver_ = receiver; |
| 66 } | 67 } |
| 67 void SendCompositorProto(const proto::CompositorMessage& proto) override {} | 68 void SendCompositorProto(const proto::CompositorMessage& proto) override {} |
| 68 | 69 |
| 69 int calls_received_; | 70 int calls_received_; |
| 70 TestTaskGraphRunner task_graph_runner_; | 71 TestTaskGraphRunner task_graph_runner_; |
| 71 LayerTreeSettings settings_; | 72 LayerTreeSettings settings_; |
| 72 std::unique_ptr<LayerTreeHostInterface> layer_tree_host_; | 73 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host_; |
| 73 RemoteProtoChannel::ProtoReceiver* receiver_; | 74 RemoteProtoChannel::ProtoReceiver* receiver_; |
| 74 std::unique_ptr<FakeImageSerializationProcessor> | 75 std::unique_ptr<FakeImageSerializationProcessor> |
| 75 image_serialization_processor_; | 76 image_serialization_processor_; |
| 76 | 77 |
| 77 private: | 78 private: |
| 78 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostTestRemoteServer); | 79 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostTestRemoteServer); |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 class LayerTreeHostTestRemoteServerBeginMainFrame | 82 class LayerTreeHostTestRemoteServerBeginMainFrame |
| 82 : public LayerTreeHostTestRemoteServer { | 83 : public LayerTreeHostTestRemoteServer { |
| 83 protected: | 84 protected: |
| 84 void BeginMainFrame(const BeginFrameArgs& args) override { | 85 void BeginMainFrame(const BeginFrameArgs& args) override { |
| 85 calls_received_++; | 86 calls_received_++; |
| 86 } | 87 } |
| 87 }; | 88 }; |
| 88 | 89 |
| 89 // Makes sure that the BeginMainFrame call is not aborted on the server. | 90 // Makes sure that the BeginMainFrame call is not aborted on the server. |
| 90 // See crbug.com/577301. | 91 // See crbug.com/577301. |
| 91 TEST_F(LayerTreeHostTestRemoteServerBeginMainFrame, BeginMainFrameNotAborted) { | 92 TEST_F(LayerTreeHostTestRemoteServerBeginMainFrame, BeginMainFrameNotAborted) { |
| 92 layer_tree_host_->SetVisible(true); | 93 layer_tree_host_->SetVisible(true); |
| 93 | 94 |
| 94 std::unique_ptr<BeginMainFrameAndCommitState> begin_frame_state; | 95 std::unique_ptr<BeginMainFrameAndCommitState> begin_frame_state; |
| 95 begin_frame_state.reset(new BeginMainFrameAndCommitState()); | 96 begin_frame_state.reset(new BeginMainFrameAndCommitState()); |
| 96 begin_frame_state->scroll_info.reset(new ScrollAndScaleSet()); | 97 begin_frame_state->scroll_info.reset(new ScrollAndScaleSet()); |
| 97 | 98 |
| 98 LayerTreeHost* layer_tree_host = | 99 static_cast<ProxyMain*>(layer_tree_host_->proxy()) |
| 99 static_cast<LayerTreeHost*>(layer_tree_host_.get()); | |
| 100 static_cast<ProxyMain*>(layer_tree_host->proxy()) | |
| 101 ->BeginMainFrame(std::move(begin_frame_state)); | 100 ->BeginMainFrame(std::move(begin_frame_state)); |
| 102 EXPECT_EQ(calls_received_, 1); | 101 EXPECT_EQ(calls_received_, 1); |
| 103 } | 102 } |
| 104 | 103 |
| 105 } // namespace | 104 } // namespace |
| 106 } // namespace cc | 105 } // namespace cc |
| OLD | NEW |