| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "cc/test/fake_content_layer_client.h" | 7 #include "cc/test/fake_content_layer_client.h" |
| 8 #include "cc/test/fake_picture_layer.h" | 8 #include "cc/test/fake_picture_layer.h" |
| 9 #include "cc/test/layer_tree_test.h" | 9 #include "cc/test/layer_tree_test.h" |
| 10 #include "cc/trees/proxy_impl.h" | 10 #include "cc/trees/thread_proxy.h" |
| 11 #include "cc/trees/proxy_main.h" | |
| 12 | 11 |
| 13 #define PROXY_MAIN_THREADED_TEST_F(TEST_FIXTURE_NAME) \ | 12 #define THREAD_PROXY_TEST_F(TEST_FIXTURE_NAME) \ |
| 14 TEST_F(TEST_FIXTURE_NAME, MultiThread) { Run(true); } | 13 TEST_F(TEST_FIXTURE_NAME, MultiThread) { Run(true); } |
| 15 | 14 |
| 16 // Do common tests for single thread proxy and proxy main in threaded mode. | 15 // Do common tests for single thread proxy and thread proxy. |
| 17 // TODO(simonhong): Add SINGLE_THREAD_PROXY_TEST_F | 16 // TODO(simonhong): Add SINGLE_THREAD_PROXY_TEST_F |
| 18 #define PROXY_TEST_SCHEDULED_ACTION(TEST_FIXTURE_NAME) \ | 17 #define PROXY_TEST_SCHEDULED_ACTION(TEST_FIXTURE_NAME) \ |
| 19 PROXY_MAIN_THREADED_TEST_F(TEST_FIXTURE_NAME); | 18 THREAD_PROXY_TEST_F(TEST_FIXTURE_NAME); |
| 20 | 19 |
| 21 namespace cc { | 20 namespace cc { |
| 22 | 21 |
| 23 class ProxyTest : public LayerTreeTest { | 22 class ProxyTest : public LayerTreeTest { |
| 24 protected: | 23 protected: |
| 25 ProxyTest() {} | 24 ProxyTest() {} |
| 26 ~ProxyTest() override {} | 25 ~ProxyTest() override {} |
| 27 | 26 |
| 28 void Run(bool threaded) { | 27 void Run(bool threaded) { |
| 29 // We don't need to care about delegating mode. | 28 // We don't need to care about delegating mode. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 ~ProxyTestScheduledActionsBasic() override {} | 66 ~ProxyTestScheduledActionsBasic() override {} |
| 68 | 67 |
| 69 private: | 68 private: |
| 70 int action_phase_; | 69 int action_phase_; |
| 71 | 70 |
| 72 DISALLOW_COPY_AND_ASSIGN(ProxyTestScheduledActionsBasic); | 71 DISALLOW_COPY_AND_ASSIGN(ProxyTestScheduledActionsBasic); |
| 73 }; | 72 }; |
| 74 | 73 |
| 75 PROXY_TEST_SCHEDULED_ACTION(ProxyTestScheduledActionsBasic); | 74 PROXY_TEST_SCHEDULED_ACTION(ProxyTestScheduledActionsBasic); |
| 76 | 75 |
| 77 class ProxyMainThreaded : public ProxyTest { | 76 class ThreadProxyTest : public ProxyTest { |
| 78 protected: | 77 protected: |
| 79 ProxyMainThreaded() | 78 ThreadProxyTest() |
| 80 : update_check_layer_( | 79 : update_check_layer_( |
| 81 FakePictureLayer::Create(layer_settings(), &client_)) {} | 80 FakePictureLayer::Create(layer_settings(), &client_)) {} |
| 82 ~ProxyMainThreaded() override {} | 81 ~ThreadProxyTest() override {} |
| 83 | 82 |
| 84 void SetupTree() override { | 83 void SetupTree() override { |
| 85 layer_tree_host()->SetRootLayer(update_check_layer_); | 84 layer_tree_host()->SetRootLayer(update_check_layer_); |
| 86 ProxyTest::SetupTree(); | 85 ProxyTest::SetupTree(); |
| 87 client_.set_bounds(update_check_layer_->bounds()); | 86 client_.set_bounds(update_check_layer_->bounds()); |
| 88 } | 87 } |
| 89 | 88 |
| 89 const ThreadProxy::MainThreadOnly& ThreadProxyMainOnly() const { |
| 90 DCHECK(task_runner_provider()); |
| 91 DCHECK(task_runner_provider()->HasImplThread()); |
| 92 DCHECK(proxy()); |
| 93 return static_cast<const ThreadProxy*>(proxy())->main(); |
| 94 } |
| 95 |
| 96 const ThreadProxy::CompositorThreadOnly& ThreadProxyImplOnly() const { |
| 97 DCHECK(task_runner_provider()); |
| 98 DCHECK(task_runner_provider()->HasImplThread()); |
| 99 DCHECK(proxy()); |
| 100 return static_cast<const ThreadProxy*>(proxy())->impl(); |
| 101 } |
| 102 |
| 90 protected: | 103 protected: |
| 91 FakeContentLayerClient client_; | 104 FakeContentLayerClient client_; |
| 92 scoped_refptr<FakePictureLayer> update_check_layer_; | 105 scoped_refptr<FakePictureLayer> update_check_layer_; |
| 93 | 106 |
| 94 private: | 107 private: |
| 95 DISALLOW_COPY_AND_ASSIGN(ProxyMainThreaded); | 108 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTest); |
| 96 }; | 109 }; |
| 97 | 110 |
| 98 class ProxyMainThreadedSetNeedsCommit : public ProxyMainThreaded { | 111 class ThreadProxyTestSetNeedsCommit : public ThreadProxyTest { |
| 99 protected: | 112 protected: |
| 100 ProxyMainThreadedSetNeedsCommit() {} | 113 ThreadProxyTestSetNeedsCommit() {} |
| 101 ~ProxyMainThreadedSetNeedsCommit() override {} | 114 ~ThreadProxyTestSetNeedsCommit() override {} |
| 102 | 115 |
| 103 void BeginTest() override { | 116 void BeginTest() override { |
| 104 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 117 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 105 GetProxyMainForTest()->max_requested_pipeline_stage()); | 118 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 106 | 119 |
| 107 proxy()->SetNeedsCommit(); | 120 proxy()->SetNeedsCommit(); |
| 108 | 121 |
| 109 EXPECT_EQ(ProxyMain::COMMIT_PIPELINE_STAGE, | 122 EXPECT_EQ(ThreadProxy::COMMIT_PIPELINE_STAGE, |
| 110 GetProxyMainForTest()->max_requested_pipeline_stage()); | 123 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 111 } | 124 } |
| 112 | 125 |
| 113 void DidBeginMainFrame() override { | 126 void DidBeginMainFrame() override { |
| 114 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 127 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 115 GetProxyMainForTest()->max_requested_pipeline_stage()); | 128 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 116 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 129 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 117 GetProxyMainForTest()->current_pipeline_stage()); | 130 ThreadProxyMainOnly().current_pipeline_stage); |
| 118 } | 131 } |
| 119 | 132 |
| 120 void DidCommit() override { | 133 void DidCommit() override { |
| 121 EXPECT_EQ(1, update_check_layer_->update_count()); | 134 EXPECT_EQ(1, update_check_layer_->update_count()); |
| 122 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 135 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 123 GetProxyMainForTest()->current_pipeline_stage()); | 136 ThreadProxyMainOnly().current_pipeline_stage); |
| 124 EndTest(); | 137 EndTest(); |
| 125 } | 138 } |
| 126 | 139 |
| 127 private: | 140 private: |
| 128 DISALLOW_COPY_AND_ASSIGN(ProxyMainThreadedSetNeedsCommit); | 141 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsCommit); |
| 129 }; | 142 }; |
| 130 | 143 |
| 131 PROXY_MAIN_THREADED_TEST_F(ProxyMainThreadedSetNeedsCommit); | 144 THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsCommit); |
| 132 | 145 |
| 133 class ProxyMainThreadedSetNeedsAnimate : public ProxyMainThreaded { | 146 class ThreadProxyTestSetNeedsAnimate : public ThreadProxyTest { |
| 134 protected: | 147 protected: |
| 135 ProxyMainThreadedSetNeedsAnimate() {} | 148 ThreadProxyTestSetNeedsAnimate() {} |
| 136 ~ProxyMainThreadedSetNeedsAnimate() override {} | 149 ~ThreadProxyTestSetNeedsAnimate() override {} |
| 137 | 150 |
| 138 void BeginTest() override { | 151 void BeginTest() override { |
| 139 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 152 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 140 GetProxyMainForTest()->max_requested_pipeline_stage()); | 153 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 141 | 154 |
| 142 proxy()->SetNeedsAnimate(); | 155 proxy()->SetNeedsAnimate(); |
| 143 | 156 |
| 144 EXPECT_EQ(ProxyMain::ANIMATE_PIPELINE_STAGE, | 157 EXPECT_EQ(ThreadProxy::ANIMATE_PIPELINE_STAGE, |
| 145 GetProxyMainForTest()->max_requested_pipeline_stage()); | 158 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 146 } | 159 } |
| 147 | 160 |
| 148 void DidBeginMainFrame() override { | 161 void DidBeginMainFrame() override { |
| 149 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 162 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 150 GetProxyMainForTest()->max_requested_pipeline_stage()); | 163 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 151 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 164 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 152 GetProxyMainForTest()->current_pipeline_stage()); | 165 ThreadProxyMainOnly().current_pipeline_stage); |
| 153 } | 166 } |
| 154 | 167 |
| 155 void DidCommit() override { | 168 void DidCommit() override { |
| 156 EXPECT_EQ(0, update_check_layer_->update_count()); | 169 EXPECT_EQ(0, update_check_layer_->update_count()); |
| 157 EndTest(); | 170 EndTest(); |
| 158 } | 171 } |
| 159 | 172 |
| 160 private: | 173 private: |
| 161 DISALLOW_COPY_AND_ASSIGN(ProxyMainThreadedSetNeedsAnimate); | 174 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsAnimate); |
| 162 }; | 175 }; |
| 163 | 176 |
| 164 PROXY_MAIN_THREADED_TEST_F(ProxyMainThreadedSetNeedsAnimate); | 177 THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsAnimate); |
| 165 | 178 |
| 166 class ProxyMainThreadedSetNeedsUpdateLayers : public ProxyMainThreaded { | 179 class ThreadProxyTestSetNeedsUpdateLayers : public ThreadProxyTest { |
| 167 protected: | 180 protected: |
| 168 ProxyMainThreadedSetNeedsUpdateLayers() {} | 181 ThreadProxyTestSetNeedsUpdateLayers() {} |
| 169 ~ProxyMainThreadedSetNeedsUpdateLayers() override {} | 182 ~ThreadProxyTestSetNeedsUpdateLayers() override {} |
| 170 | 183 |
| 171 void BeginTest() override { | 184 void BeginTest() override { |
| 172 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 185 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 173 GetProxyMainForTest()->max_requested_pipeline_stage()); | 186 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 174 | 187 |
| 175 proxy()->SetNeedsUpdateLayers(); | 188 proxy()->SetNeedsUpdateLayers(); |
| 176 | 189 |
| 177 EXPECT_EQ(ProxyMain::UPDATE_LAYERS_PIPELINE_STAGE, | 190 EXPECT_EQ(ThreadProxy::UPDATE_LAYERS_PIPELINE_STAGE, |
| 178 GetProxyMainForTest()->max_requested_pipeline_stage()); | 191 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 179 } | 192 } |
| 180 | 193 |
| 181 void DidBeginMainFrame() override { | 194 void DidBeginMainFrame() override { |
| 182 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 195 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 183 GetProxyMainForTest()->max_requested_pipeline_stage()); | 196 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 184 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 197 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 185 GetProxyMainForTest()->current_pipeline_stage()); | 198 ThreadProxyMainOnly().current_pipeline_stage); |
| 186 } | 199 } |
| 187 | 200 |
| 188 void DidCommit() override { | 201 void DidCommit() override { |
| 189 EXPECT_EQ(1, update_check_layer_->update_count()); | 202 EXPECT_EQ(1, update_check_layer_->update_count()); |
| 190 EndTest(); | 203 EndTest(); |
| 191 } | 204 } |
| 192 | 205 |
| 193 private: | 206 private: |
| 194 DISALLOW_COPY_AND_ASSIGN(ProxyMainThreadedSetNeedsUpdateLayers); | 207 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsUpdateLayers); |
| 195 }; | 208 }; |
| 196 | 209 |
| 197 PROXY_MAIN_THREADED_TEST_F(ProxyMainThreadedSetNeedsUpdateLayers); | 210 THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsUpdateLayers); |
| 198 | 211 |
| 199 class ProxyMainThreadedSetNeedsUpdateLayersWhileAnimating | 212 class ThreadProxyTestSetNeedsUpdateLayersWhileAnimating |
| 200 : public ProxyMainThreaded { | 213 : public ThreadProxyTest { |
| 201 protected: | 214 protected: |
| 202 ProxyMainThreadedSetNeedsUpdateLayersWhileAnimating() {} | 215 ThreadProxyTestSetNeedsUpdateLayersWhileAnimating() {} |
| 203 ~ProxyMainThreadedSetNeedsUpdateLayersWhileAnimating() override {} | 216 ~ThreadProxyTestSetNeedsUpdateLayersWhileAnimating() override {} |
| 204 | 217 |
| 205 void BeginTest() override { proxy()->SetNeedsAnimate(); } | 218 void BeginTest() override { proxy()->SetNeedsAnimate(); } |
| 206 | 219 |
| 207 void WillBeginMainFrame() override { | 220 void WillBeginMainFrame() override { |
| 208 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 221 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 209 GetProxyMainForTest()->max_requested_pipeline_stage()); | 222 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 210 EXPECT_EQ(ProxyMain::ANIMATE_PIPELINE_STAGE, | 223 EXPECT_EQ(ThreadProxy::ANIMATE_PIPELINE_STAGE, |
| 211 GetProxyMainForTest()->current_pipeline_stage()); | 224 ThreadProxyMainOnly().current_pipeline_stage); |
| 212 EXPECT_EQ(ProxyMain::ANIMATE_PIPELINE_STAGE, | 225 EXPECT_EQ(ThreadProxy::ANIMATE_PIPELINE_STAGE, |
| 213 GetProxyMainForTest()->final_pipeline_stage()); | 226 ThreadProxyMainOnly().final_pipeline_stage); |
| 214 | 227 |
| 215 proxy()->SetNeedsUpdateLayers(); | 228 proxy()->SetNeedsUpdateLayers(); |
| 216 | 229 |
| 217 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 230 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 218 GetProxyMainForTest()->max_requested_pipeline_stage()); | 231 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 219 EXPECT_EQ(ProxyMain::UPDATE_LAYERS_PIPELINE_STAGE, | 232 EXPECT_EQ(ThreadProxy::UPDATE_LAYERS_PIPELINE_STAGE, |
| 220 GetProxyMainForTest()->final_pipeline_stage()); | 233 ThreadProxyMainOnly().final_pipeline_stage); |
| 221 } | 234 } |
| 222 | 235 |
| 223 void DidBeginMainFrame() override { | 236 void DidBeginMainFrame() override { |
| 224 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 237 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 225 GetProxyMainForTest()->max_requested_pipeline_stage()); | 238 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 226 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 239 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 227 GetProxyMainForTest()->current_pipeline_stage()); | 240 ThreadProxyMainOnly().current_pipeline_stage); |
| 228 } | 241 } |
| 229 | 242 |
| 230 void DidCommit() override { | 243 void DidCommit() override { |
| 231 EXPECT_EQ(1, update_check_layer_->update_count()); | 244 EXPECT_EQ(1, update_check_layer_->update_count()); |
| 232 EndTest(); | 245 EndTest(); |
| 233 } | 246 } |
| 234 | 247 |
| 235 private: | 248 private: |
| 236 DISALLOW_COPY_AND_ASSIGN(ProxyMainThreadedSetNeedsUpdateLayersWhileAnimating); | 249 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsUpdateLayersWhileAnimating); |
| 237 }; | 250 }; |
| 238 | 251 |
| 239 PROXY_MAIN_THREADED_TEST_F(ProxyMainThreadedSetNeedsUpdateLayersWhileAnimating); | 252 THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsUpdateLayersWhileAnimating); |
| 240 | 253 |
| 241 class ProxyMainThreadedSetNeedsCommitWhileAnimating : public ProxyMainThreaded { | 254 class ThreadProxyTestSetNeedsCommitWhileAnimating : public ThreadProxyTest { |
| 242 protected: | 255 protected: |
| 243 ProxyMainThreadedSetNeedsCommitWhileAnimating() {} | 256 ThreadProxyTestSetNeedsCommitWhileAnimating() {} |
| 244 ~ProxyMainThreadedSetNeedsCommitWhileAnimating() override {} | 257 ~ThreadProxyTestSetNeedsCommitWhileAnimating() override {} |
| 245 | 258 |
| 246 void BeginTest() override { proxy()->SetNeedsAnimate(); } | 259 void BeginTest() override { proxy()->SetNeedsAnimate(); } |
| 247 | 260 |
| 248 void WillBeginMainFrame() override { | 261 void WillBeginMainFrame() override { |
| 249 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 262 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 250 GetProxyMainForTest()->max_requested_pipeline_stage()); | 263 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 251 EXPECT_EQ(ProxyMain::ANIMATE_PIPELINE_STAGE, | 264 EXPECT_EQ(ThreadProxy::ANIMATE_PIPELINE_STAGE, |
| 252 GetProxyMainForTest()->current_pipeline_stage()); | 265 ThreadProxyMainOnly().current_pipeline_stage); |
| 253 EXPECT_EQ(ProxyMain::ANIMATE_PIPELINE_STAGE, | 266 EXPECT_EQ(ThreadProxy::ANIMATE_PIPELINE_STAGE, |
| 254 GetProxyMainForTest()->final_pipeline_stage()); | 267 ThreadProxyMainOnly().final_pipeline_stage); |
| 255 | 268 |
| 256 proxy()->SetNeedsCommit(); | 269 proxy()->SetNeedsCommit(); |
| 257 | 270 |
| 258 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 271 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 259 GetProxyMainForTest()->max_requested_pipeline_stage()); | 272 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 260 EXPECT_EQ(ProxyMain::COMMIT_PIPELINE_STAGE, | 273 EXPECT_EQ(ThreadProxy::COMMIT_PIPELINE_STAGE, |
| 261 GetProxyMainForTest()->final_pipeline_stage()); | 274 ThreadProxyMainOnly().final_pipeline_stage); |
| 262 } | 275 } |
| 263 | 276 |
| 264 void DidBeginMainFrame() override { | 277 void DidBeginMainFrame() override { |
| 265 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 278 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 266 GetProxyMainForTest()->max_requested_pipeline_stage()); | 279 ThreadProxyMainOnly().max_requested_pipeline_stage); |
| 267 EXPECT_EQ(ProxyMain::NO_PIPELINE_STAGE, | 280 EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, |
| 268 GetProxyMainForTest()->current_pipeline_stage()); | 281 ThreadProxyMainOnly().current_pipeline_stage); |
| 269 } | 282 } |
| 270 | 283 |
| 271 void DidCommit() override { | 284 void DidCommit() override { |
| 272 EXPECT_EQ(1, update_check_layer_->update_count()); | 285 EXPECT_EQ(1, update_check_layer_->update_count()); |
| 273 EndTest(); | 286 EndTest(); |
| 274 } | 287 } |
| 275 | 288 |
| 276 private: | 289 private: |
| 277 DISALLOW_COPY_AND_ASSIGN(ProxyMainThreadedSetNeedsCommitWhileAnimating); | 290 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsCommitWhileAnimating); |
| 278 }; | 291 }; |
| 279 | 292 |
| 280 PROXY_MAIN_THREADED_TEST_F(ProxyMainThreadedSetNeedsCommitWhileAnimating); | 293 THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsCommitWhileAnimating); |
| 281 | 294 |
| 282 class ProxyMainThreadedCommitWaitsForActivation : public ProxyMainThreaded { | 295 class ThreadProxyTestCommitWaitsForActivation : public ThreadProxyTest { |
| 283 protected: | 296 protected: |
| 284 ProxyMainThreadedCommitWaitsForActivation() : commits_completed_(0) {} | 297 ThreadProxyTestCommitWaitsForActivation() : commits_completed_(0) {} |
| 285 ~ProxyMainThreadedCommitWaitsForActivation() override {} | 298 ~ThreadProxyTestCommitWaitsForActivation() override {} |
| 286 | 299 |
| 287 void BeginTest() override { proxy()->SetNeedsCommit(); } | 300 void BeginTest() override { proxy()->SetNeedsCommit(); } |
| 288 | 301 |
| 289 void ScheduledActionCommit() override { | 302 void ScheduledActionCommit() override { |
| 290 switch (commits_completed_) { | 303 switch (commits_completed_) { |
| 291 case 0: | 304 case 0: |
| 292 // The first commit does not wait for activation. Verify that the | 305 // The first commit does not wait for activation. Verify that the |
| 293 // completion event is cleared. | 306 // completion event is cleared. |
| 294 EXPECT_FALSE(GetProxyImplForTest()->HasCommitCompletionEvent()); | 307 EXPECT_FALSE(ThreadProxyImplOnly().commit_completion_event); |
| 295 EXPECT_FALSE(GetProxyImplForTest()->GetNextCommitWaitsForActivation()); | 308 EXPECT_FALSE(ThreadProxyImplOnly().next_commit_waits_for_activation); |
| 296 break; | 309 break; |
| 297 case 1: | 310 case 1: |
| 298 // The second commit should be held until activation. | 311 // The second commit should be held until activation. |
| 299 EXPECT_TRUE(GetProxyImplForTest()->HasCommitCompletionEvent()); | 312 EXPECT_TRUE(ThreadProxyImplOnly().commit_completion_event); |
| 300 EXPECT_TRUE(GetProxyImplForTest()->GetNextCommitWaitsForActivation()); | 313 EXPECT_TRUE(ThreadProxyImplOnly().next_commit_waits_for_activation); |
| 301 break; | 314 break; |
| 302 case 2: | 315 case 2: |
| 303 // The third commit should not wait for activation. | 316 // The third commit should not wait for activation. |
| 304 EXPECT_FALSE(GetProxyImplForTest()->HasCommitCompletionEvent()); | 317 EXPECT_FALSE(ThreadProxyImplOnly().commit_completion_event); |
| 305 EXPECT_FALSE(GetProxyImplForTest()->GetNextCommitWaitsForActivation()); | 318 EXPECT_FALSE(ThreadProxyImplOnly().next_commit_waits_for_activation); |
| 306 } | 319 } |
| 307 } | 320 } |
| 308 | 321 |
| 309 void DidActivateSyncTree() override { | 322 void DidActivateSyncTree() override { |
| 310 // The next_commit_waits_for_activation should have been cleared after the | 323 // The next_commit_waits_for_activation should have been cleared after the |
| 311 // sync tree is activated. | 324 // sync tree is activated. |
| 312 EXPECT_FALSE(GetProxyImplForTest()->GetNextCommitWaitsForActivation()); | 325 EXPECT_FALSE(ThreadProxyImplOnly().next_commit_waits_for_activation); |
| 313 } | 326 } |
| 314 | 327 |
| 315 void DidCommit() override { | 328 void DidCommit() override { |
| 316 switch (commits_completed_) { | 329 switch (commits_completed_) { |
| 317 case 0: | 330 case 0: |
| 318 // The first commit has been completed. Set next commit waits for | 331 // The first commit has been completed. Set next commit waits for |
| 319 // activation and start another commit. | 332 // activation and start another commit. |
| 320 commits_completed_++; | 333 commits_completed_++; |
| 321 proxy()->SetNextCommitWaitsForActivation(); | 334 proxy()->SetNextCommitWaitsForActivation(); |
| 322 proxy()->SetNeedsCommit(); | 335 proxy()->SetNeedsCommit(); |
| 323 case 1: | 336 case 1: |
| 324 // Start another commit to verify that this is not held until | 337 // Start another commit to verify that this is not held until |
| 325 // activation. | 338 // activation. |
| 326 commits_completed_++; | 339 commits_completed_++; |
| 327 proxy()->SetNeedsCommit(); | 340 proxy()->SetNeedsCommit(); |
| 328 case 2: | 341 case 2: |
| 329 commits_completed_++; | 342 commits_completed_++; |
| 330 EndTest(); | 343 EndTest(); |
| 331 } | 344 } |
| 332 } | 345 } |
| 333 | 346 |
| 334 void AfterTest() override { EXPECT_EQ(3, commits_completed_); } | 347 void AfterTest() override { EXPECT_EQ(3, commits_completed_); } |
| 335 | 348 |
| 336 private: | 349 private: |
| 337 int commits_completed_; | 350 int commits_completed_; |
| 338 | 351 |
| 339 DISALLOW_COPY_AND_ASSIGN(ProxyMainThreadedCommitWaitsForActivation); | 352 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestCommitWaitsForActivation); |
| 340 }; | 353 }; |
| 341 | 354 |
| 342 PROXY_MAIN_THREADED_TEST_F(ProxyMainThreadedCommitWaitsForActivation); | 355 THREAD_PROXY_TEST_F(ThreadProxyTestCommitWaitsForActivation); |
| 343 | 356 |
| 344 } // namespace cc | 357 } // namespace cc |
| OLD | NEW |