Chromium Code Reviews| 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 "cc/test/begin_frame_args_test.h" | 5 #include "cc/test/begin_frame_args_test.h" |
| 6 #include "cc/test/layer_tree_test.h" | 6 #include "cc/test/layer_tree_test.h" |
| 7 | 7 |
| 8 namespace cc { | 8 namespace cc { |
| 9 | 9 |
| 10 class RemoteChannelTest : public LayerTreeTest { | 10 class RemoteChannelTest : public LayerTreeTest { |
| 11 protected: | 11 protected: |
| 12 RemoteChannelTest() : calls_received_(0) {} | 12 RemoteChannelTest() |
| 13 : calls_received_(0), calls_received_on_both_server_and_client_(0) {} | |
|
Khushal
2016/05/06 21:37:54
How about splitting this into calls_received_on_cl
shaktisahu
2016/05/07 00:46:12
Yea, but it is hard to know if the call is receive
Khushal
2016/05/09 09:06:33
Sorry, I meant we could split it into calls_expect
vmpstr
2016/05/10 18:27:32
I would prefer that we don't have any "server and
Khushal
2016/05/10 19:11:31
The LayerTreeTests keep an instance of both the se
| |
| 13 | 14 |
| 14 ~RemoteChannelTest() override {} | 15 ~RemoteChannelTest() override {} |
| 15 | 16 |
| 16 void BeginTest() override { | 17 void BeginTest() override { |
| 17 DCHECK(IsRemoteTest()); | 18 DCHECK(IsRemoteTest()); |
| 18 BeginChannelTest(); | 19 BeginChannelTest(); |
| 19 } | 20 } |
| 20 virtual void BeginChannelTest() {} | 21 virtual void BeginChannelTest() {} |
| 21 | 22 |
| 22 int calls_received_; | 23 int calls_received_; |
| 23 | 24 |
| 25 // Since LayerTreeHost on engine and client share a common LayerTreeHostClient | |
| 26 // for unit tests, there are some functions called twice. This variable keep | |
| 27 // tracks of those function calls. | |
| 28 int calls_received_on_both_server_and_client_; | |
| 29 | |
| 24 private: | 30 private: |
| 25 DISALLOW_COPY_AND_ASSIGN(RemoteChannelTest); | 31 DISALLOW_COPY_AND_ASSIGN(RemoteChannelTest); |
| 26 }; | 32 }; |
| 27 | 33 |
| 28 class RemoteChannelTestInitializationAndShutdown : public RemoteChannelTest { | 34 class RemoteChannelTestInitializationAndShutdown : public RemoteChannelTest { |
| 29 void SetVisibleOnImpl(bool visible) override { calls_received_++; } | 35 void SetVisibleOnImpl(bool visible) override { calls_received_++; } |
| 30 | 36 |
| 31 void RequestNewOutputSurface() override { | 37 void RequestNewOutputSurface() override { |
| 32 LayerTreeTest::RequestNewOutputSurface(); | 38 LayerTreeTest::RequestNewOutputSurface(); |
| 33 calls_received_++; | 39 calls_received_++; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 | 139 |
| 134 void SetNeedsCommitOnImpl() override { EXPECT_EQ(0, calls_received_++); } | 140 void SetNeedsCommitOnImpl() override { EXPECT_EQ(0, calls_received_++); } |
| 135 | 141 |
| 136 void ReceivedBeginMainFrame() override { EXPECT_EQ(1, calls_received_++); } | 142 void ReceivedBeginMainFrame() override { EXPECT_EQ(1, calls_received_++); } |
| 137 | 143 |
| 138 void StartCommitOnImpl() override { EXPECT_EQ(2, calls_received_++); } | 144 void StartCommitOnImpl() override { EXPECT_EQ(2, calls_received_++); } |
| 139 | 145 |
| 140 void DidCommitAndDrawFrame() override { EXPECT_EQ(3, calls_received_++); } | 146 void DidCommitAndDrawFrame() override { EXPECT_EQ(3, calls_received_++); } |
| 141 | 147 |
| 142 void DidCompleteSwapBuffers() override { | 148 void DidCompleteSwapBuffers() override { |
| 143 EXPECT_EQ(4, calls_received_++); | 149 if (++calls_received_on_both_server_and_client_ == 2) |
| 144 EndTest(); | 150 EndTest(); |
| 145 } | 151 } |
| 146 | 152 |
| 147 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 153 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 148 // Ensure that we serialized and deserialized the LayerTreeHost for the | 154 // Ensure that we serialized and deserialized the LayerTreeHost for the |
| 149 // commit. | 155 // commit. |
| 150 EXPECT_EQ(viewport_size_, host_impl->device_viewport_size()); | 156 EXPECT_EQ(viewport_size_, host_impl->device_viewport_size()); |
| 151 } | 157 } |
| 152 | 158 |
| 153 void AfterTest() override { | 159 void AfterTest() override { |
| 154 EXPECT_EQ(5, calls_received_); | 160 EXPECT_EQ(4, calls_received_); |
| 161 EXPECT_EQ(2, calls_received_on_both_server_and_client_); | |
| 155 } | 162 } |
| 156 | 163 |
| 157 const gfx::Size viewport_size_ = gfx::Size(5, 3); | 164 const gfx::Size viewport_size_ = gfx::Size(5, 3); |
| 158 }; | 165 }; |
| 159 | 166 |
| 160 REMOTE_DIRECT_RENDERER_TEST_F(RemoteChannelTestCommit); | 167 REMOTE_DIRECT_RENDERER_TEST_F(RemoteChannelTestCommit); |
| 161 | 168 |
| 162 class RemoteChannelTestBeginMainFrameAborted : public RemoteChannelTest { | 169 class RemoteChannelTestBeginMainFrameAborted : public RemoteChannelTest { |
| 163 void BeginChannelTest() override { PostSetNeedsCommitToMainThread(); } | 170 void BeginChannelTest() override { PostSetNeedsCommitToMainThread(); } |
| 164 | 171 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 } | 224 } |
| 218 | 225 |
| 219 int output_surface_initialized_count_; | 226 int output_surface_initialized_count_; |
| 220 int commit_count_; | 227 int commit_count_; |
| 221 }; | 228 }; |
| 222 | 229 |
| 223 REMOTE_DIRECT_RENDERER_TEST_F( | 230 REMOTE_DIRECT_RENDERER_TEST_F( |
| 224 RemoteChannelTestReleaseOutputSurfaceDuringCommit); | 231 RemoteChannelTestReleaseOutputSurfaceDuringCommit); |
| 225 | 232 |
| 226 } // namespace cc | 233 } // namespace cc |
| OLD | NEW |