| 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 "blimp/engine/renderer/blimp_remote_compositor_bridge.h" | 5 #include "blimp/engine/renderer/blimp_remote_compositor_bridge.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "cc/blimp/compositor_proto_state.h" | 10 #include "cc/blimp/compositor_proto_state.h" |
| 11 #include "cc/blimp/remote_compositor_bridge_client.h" | 11 #include "cc/blimp/remote_compositor_bridge_client.h" |
| 12 #include "cc/proto/compositor_message.pb.h" | 12 #include "cc/proto/compositor_message.pb.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace blimp { | 15 namespace blimp { |
| 16 namespace engine { | 16 namespace engine { |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 class BlimpRemoteCompositorBridgeTest : public testing::Test, | 19 class BlimpRemoteCompositorBridgeTest : public testing::Test, |
| 20 public cc::RemoteCompositorBridgeClient, | 20 public cc::RemoteCompositorBridgeClient, |
| 21 public cc::RemoteProtoChannel { | 21 public content::RemoteProtoChannel { |
| 22 public: | 22 public: |
| 23 BlimpRemoteCompositorBridgeTest() = default; | 23 BlimpRemoteCompositorBridgeTest() = default; |
| 24 ~BlimpRemoteCompositorBridgeTest() override = default; | 24 ~BlimpRemoteCompositorBridgeTest() override = default; |
| 25 | 25 |
| 26 void SetUp() override { | 26 void SetUp() override { |
| 27 remote_compositor_bridge_ = base::MakeUnique<BlimpRemoteCompositorBridge>( | 27 remote_compositor_bridge_ = base::MakeUnique<BlimpRemoteCompositorBridge>( |
| 28 this, base::ThreadTaskRunnerHandle::Get()); | 28 this, base::ThreadTaskRunnerHandle::Get()); |
| 29 DCHECK(proto_receiver_); | 29 DCHECK(proto_receiver_); |
| 30 | 30 |
| 31 remote_compositor_bridge_->BindToClient(this); | 31 remote_compositor_bridge_->BindToClient(this); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 void SendClientStateUpdate() { | 88 void SendClientStateUpdate() { |
| 89 std::unique_ptr<cc::proto::CompositorMessage> message = | 89 std::unique_ptr<cc::proto::CompositorMessage> message = |
| 90 base::MakeUnique<cc::proto::CompositorMessage>(); | 90 base::MakeUnique<cc::proto::CompositorMessage>(); |
| 91 message->mutable_client_state_update()->set_page_scale_delta(0.2f); | 91 message->mutable_client_state_update()->set_page_scale_delta(0.2f); |
| 92 proto_receiver_->OnProtoReceived(std::move(message)); | 92 proto_receiver_->OnProtoReceived(std::move(message)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 protected: | 95 protected: |
| 96 base::MessageLoop loop_; | 96 base::MessageLoop loop_; |
| 97 std::unique_ptr<BlimpRemoteCompositorBridge> remote_compositor_bridge_; | 97 std::unique_ptr<BlimpRemoteCompositorBridge> remote_compositor_bridge_; |
| 98 cc::RemoteProtoChannel::ProtoReceiver* proto_receiver_ = nullptr; | 98 content::RemoteProtoChannel::ProtoReceiver* proto_receiver_ = nullptr; |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 int num_of_frames_sent_ = 0; | 101 int num_of_frames_sent_ = 0; |
| 102 int num_of_client_state_acks_sent_ = 0; | 102 int num_of_client_state_acks_sent_ = 0; |
| 103 int num_of_client_updates_ = 0; | 103 int num_of_client_updates_ = 0; |
| 104 bool send_frame_ = false; | 104 bool send_frame_ = false; |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 TEST_F(BlimpRemoteCompositorBridgeTest, FrameAndFrameAck) { | 107 TEST_F(BlimpRemoteCompositorBridgeTest, FrameAndFrameAck) { |
| 108 // Request a frame with an update. | 108 // Request a frame with an update. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 EXPECT_EQ(2, num_of_client_state_acks_sent()); | 146 EXPECT_EQ(2, num_of_client_state_acks_sent()); |
| 147 EXPECT_EQ(0, num_of_frames_sent()); | 147 EXPECT_EQ(0, num_of_frames_sent()); |
| 148 base::RunLoop().RunUntilIdle(); | 148 base::RunLoop().RunUntilIdle(); |
| 149 EXPECT_EQ(3, num_of_client_state_acks_sent()); | 149 EXPECT_EQ(3, num_of_client_state_acks_sent()); |
| 150 EXPECT_EQ(1, num_of_frames_sent()); | 150 EXPECT_EQ(1, num_of_frames_sent()); |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace | 153 } // namespace |
| 154 } // namespace engine | 154 } // namespace engine |
| 155 } // namespace blimp | 155 } // namespace blimp |
| OLD | NEW |