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/thread_proxy.h" | 10 #include "cc/trees/thread_proxy.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 EXPECT_EQ(1, update_check_layer_->update_count()); | 280 EXPECT_EQ(1, update_check_layer_->update_count()); |
281 EndTest(); | 281 EndTest(); |
282 } | 282 } |
283 | 283 |
284 private: | 284 private: |
285 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsCommitWhileAnimating); | 285 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsCommitWhileAnimating); |
286 }; | 286 }; |
287 | 287 |
288 THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsCommitWhileAnimating); | 288 THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsCommitWhileAnimating); |
289 | 289 |
| 290 class ThreadProxyTestCommitWaitsForActivation : public ThreadProxyTest { |
| 291 protected: |
| 292 ThreadProxyTestCommitWaitsForActivation() : commits_completed_(0) {} |
| 293 ~ThreadProxyTestCommitWaitsForActivation() override {} |
| 294 |
| 295 void BeginTest() override { proxy()->SetNeedsCommit(); } |
| 296 |
| 297 void ScheduledActionCommit() override { |
| 298 switch (commits_completed_) { |
| 299 case 0: |
| 300 // The first commit does not wait for activation. Verify that the |
| 301 // completion event is cleared. |
| 302 EXPECT_FALSE(ThreadProxyImplOnly().commit_completion_event); |
| 303 EXPECT_FALSE(ThreadProxyImplOnly().next_commit_waits_for_activation); |
| 304 break; |
| 305 case 1: |
| 306 // The second commit should be held until activation. |
| 307 EXPECT_TRUE(ThreadProxyImplOnly().commit_completion_event); |
| 308 EXPECT_TRUE(ThreadProxyImplOnly().next_commit_waits_for_activation); |
| 309 break; |
| 310 case 2: |
| 311 // The third commit should not wait for activation. |
| 312 EXPECT_FALSE(ThreadProxyImplOnly().commit_completion_event); |
| 313 EXPECT_FALSE(ThreadProxyImplOnly().next_commit_waits_for_activation); |
| 314 } |
| 315 } |
| 316 |
| 317 void DidActivateSyncTree() override { |
| 318 // The next_commit_waits_for_activation should have been cleared after the |
| 319 // sync tree is activated. |
| 320 EXPECT_FALSE(ThreadProxyImplOnly().next_commit_waits_for_activation); |
| 321 } |
| 322 |
| 323 void DidCommit() override { |
| 324 switch (commits_completed_) { |
| 325 case 0: |
| 326 // The first commit has been completed. Set next commit waits for |
| 327 // activation and start another commit. |
| 328 commits_completed_++; |
| 329 proxy()->SetNextCommitWaitsForActivation(); |
| 330 proxy()->SetNeedsCommit(); |
| 331 case 1: |
| 332 // Start another commit to verify that this is not held until |
| 333 // activation. |
| 334 commits_completed_++; |
| 335 proxy()->SetNeedsCommit(); |
| 336 case 2: |
| 337 commits_completed_++; |
| 338 EndTest(); |
| 339 } |
| 340 } |
| 341 |
| 342 void AfterTest() override { EXPECT_EQ(3, commits_completed_); } |
| 343 |
| 344 private: |
| 345 int commits_completed_; |
| 346 |
| 347 DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestCommitWaitsForActivation); |
| 348 }; |
| 349 |
| 350 THREAD_PROXY_TEST_F(ThreadProxyTestCommitWaitsForActivation); |
| 351 |
290 } // namespace cc | 352 } // namespace cc |
OLD | NEW |