Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: cc/trees/layer_tree_host_unittest_proxy.cc

Issue 2778223005: Plumb activation time to main (Closed)
Patch Set: add baseline test in layer_tree_host_unittest_proxy; initialize source_frame_number is all ctors Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/compiler_specific.h" 5 #include "base/compiler_specific.h"
6 #include "base/macros.h" 6 #include "base/macros.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/proxy_impl.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 private: 312 private:
313 base::Lock activate_blocked_lock_; 313 base::Lock activate_blocked_lock_;
314 bool activate_blocked_ = false; 314 bool activate_blocked_ = false;
315 315
316 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostProxyTestCommitWaitsForActivation); 316 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostProxyTestCommitWaitsForActivation);
317 }; 317 };
318 318
319 MULTI_THREAD_TEST_F(LayerTreeHostProxyTestCommitWaitsForActivation); 319 MULTI_THREAD_TEST_F(LayerTreeHostProxyTestCommitWaitsForActivation);
320 320
321 // Test for a corner case of main frame before activation (MFBA) and commit
322 // waits for activation. If a commit (with wait for activation flag set)
323 // is ready before the activation for a previous commit then the activation
324 // should not signal the completion event of the second commit.
325 class LayerTreeHostProxyTestCommitWaitsForActivationMFBA 321 class LayerTreeHostProxyTestCommitWaitsForActivationMFBA
326 : public LayerTreeHostProxyTest { 322 : public LayerTreeHostProxyTest {
327 protected: 323 protected:
328 LayerTreeHostProxyTestCommitWaitsForActivationMFBA() = default; 324 LayerTreeHostProxyTestCommitWaitsForActivationMFBA() = default;
329 325
330 void InitializeSettings(LayerTreeSettings* settings) override { 326 void InitializeSettings(LayerTreeSettings* settings) override {
331 settings->main_frame_before_activation_enabled = true; 327 settings->main_frame_before_activation_enabled = true;
332 LayerTreeHostProxyTest::InitializeSettings(settings); 328 LayerTreeHostProxyTest::InitializeSettings(settings);
333 } 329 }
334 330
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 409
414 private: 410 private:
415 base::Lock activate_blocked_lock_; 411 base::Lock activate_blocked_lock_;
416 bool activate_blocked_ = false; 412 bool activate_blocked_ = false;
417 413
418 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostProxyTestCommitWaitsForActivationMFBA); 414 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostProxyTestCommitWaitsForActivationMFBA);
419 }; 415 };
420 416
421 MULTI_THREAD_TEST_F(LayerTreeHostProxyTestCommitWaitsForActivationMFBA); 417 MULTI_THREAD_TEST_F(LayerTreeHostProxyTestCommitWaitsForActivationMFBA);
422 418
419 // Test for activation time passed in BeginFrameArgs.
420 class LayerTreeHostProxyTestActivationTime : public LayerTreeHostProxyTest {
brianderson 2017/04/13 22:36:37 I think you'll want to delay activation until afte
panicker 2017/04/14 22:02:45 Not sure how this would work, when activation is b
brianderson 2017/04/14 23:34:28 ============ Re: test for two ready_to_activate_ti
421 protected:
422 LayerTreeHostProxyTestActivationTime() = default;
423
424 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
425
426 void DidBeginMainFrame() override {
427 BeginFrameArgs bfargs = GetProxyMain()->BeginFrameArgsForTesting();
428 switch (bfargs.source_frame_number) {
429 case 0:
430 // Initial frame, no activation yet.
431 EXPECT_EQ(0UL, bfargs.ready_to_activate_time.size());
432 break;
433 case 1:
434 // Frame #1, since activation was delayed, nothing here yet.
panicker 2017/04/13 22:09:22 I didn't actually delay this (I removed the delay
brianderson 2017/04/13 22:36:37 It could be since there's a race between whether a
panicker 2017/04/14 22:02:45 I've added back the explicit delay to make this de
435 EXPECT_EQ(0UL, bfargs.ready_to_activate_time.size());
436 break;
437 case 2:
438 // Frame #2, activation for Frame #1
439 EXPECT_EQ(1UL, bfargs.ready_to_activate_time.size());
440 EXPECT_EQ(1UL, bfargs.ready_to_activate_time.begin()->first);
441 break;
442 case 3:
443 // Frame #3, activation for Frame #2
444 EXPECT_EQ(1UL, bfargs.ready_to_activate_time.size());
445 EXPECT_EQ(2UL, bfargs.ready_to_activate_time.begin()->first);
446 EndTest();
447 }
448 }
449
450 void DidCommit() override {
451 switch (layer_tree_host()->SourceFrameNumber()) {
452 case 1:
453 // Request a new commit.
454 layer_tree_host()->SetNeedsCommit();
455 break;
456 case 2:
457 // Request a new commit.
458 layer_tree_host()->SetNeedsCommit();
459 break;
460 case 3:
461 layer_tree_host()->SetNeedsCommit();
462 break;
463 }
464 }
465
466 void AfterTest() override {}
467
468 private:
469 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostProxyTestActivationTime);
470 };
471
472 MULTI_THREAD_TEST_F(LayerTreeHostProxyTestActivationTime);
473
423 } // namespace cc 474 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698