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

Side by Side Diff: cc/scheduler/scheduler_unittest.cc

Issue 619843002: cc: Make separate interface for BeginFrame ipc from OutputSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 #include "cc/scheduler/scheduler.h" 4 #include "cc/scheduler/scheduler.h"
5 5
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 27 matching lines...) Expand all
38 namespace cc { 38 namespace cc {
39 namespace { 39 namespace {
40 40
41 class FakeSchedulerClient; 41 class FakeSchedulerClient;
42 42
43 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, 43 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler,
44 FakeSchedulerClient* client); 44 FakeSchedulerClient* client);
45 45
46 class FakeSchedulerClient : public SchedulerClient { 46 class FakeSchedulerClient : public SchedulerClient {
47 public: 47 public:
48 struct FakeBeginFrameSourceForFakeSchedulerClient 48 class FakeExternalBeginFrameSourceForFakeSchedulerClient
49 : public FakeBeginFrameSource { 49 : public ExternalBeginFrameSource {
50 FakeSchedulerClient* client_; 50 public:
51 51 explicit FakeExternalBeginFrameSourceForFakeSchedulerClient(
52 explicit FakeBeginFrameSourceForFakeSchedulerClient(
53 FakeSchedulerClient* client) 52 FakeSchedulerClient* client)
54 : client_(client) {} 53 : client_(client) {}
55 54
56 virtual void OnNeedsBeginFramesChange(bool needs_begin_frames) override { 55 virtual void OnNeedsBeginFramesChange(bool needs_begin_frames) override {
57 if (needs_begin_frames) { 56 if (needs_begin_frames) {
58 client_->actions_.push_back("SetNeedsBeginFrames(true)"); 57 client_->actions_.push_back("SetNeedsBeginFrames(true)");
59 } else { 58 } else {
60 client_->actions_.push_back("SetNeedsBeginFrames(false)"); 59 client_->actions_.push_back("SetNeedsBeginFrames(false)");
61 } 60 }
62 client_->states_.push_back(client_->scheduler_->AsValue()); 61 client_->states_.push_back(client_->scheduler_->AsValue());
63 } 62 }
63
64 void TestOnBeginFrame(const BeginFrameArgs& args) {
65 return CallOnBeginFrame(args);
66 }
67
68 private:
69 virtual ~FakeExternalBeginFrameSourceForFakeSchedulerClient() {}
70
71 FakeSchedulerClient* client_;
64 }; 72 };
65 73
66 FakeSchedulerClient() 74 FakeSchedulerClient()
67 : automatic_swap_ack_(true), 75 : automatic_swap_ack_(true),
68 swap_contains_incomplete_tile_(false), 76 swap_contains_incomplete_tile_(false),
69 redraw_will_happen_if_update_visible_tiles_happens_(false), 77 redraw_will_happen_if_update_visible_tiles_happens_(false),
70 now_src_(TestNowSource::Create()), 78 now_src_(TestNowSource::Create()) {
71 fake_frame_source_(this) {
72 Reset(); 79 Reset();
73 } 80 }
74 81
75 void Reset() { 82 void Reset() {
76 actions_.clear(); 83 actions_.clear();
77 states_.clear(); 84 states_.clear();
78 draw_will_happen_ = true; 85 draw_will_happen_ = true;
79 swap_will_happen_if_draw_happens_ = true; 86 swap_will_happen_if_draw_happens_ = true;
80 num_draws_ = 0; 87 num_draws_ = 0;
81 log_anticipated_draw_time_change_ = false; 88 log_anticipated_draw_time_change_ = false;
82 } 89 }
83 90
84 TestScheduler* CreateScheduler(const SchedulerSettings& settings) { 91 TestScheduler* CreateScheduler(const SchedulerSettings& settings) {
85 scheduler_ = TestScheduler::Create(now_src_, this, settings, 0); 92 if (settings.begin_frame_scheduling_enabled) {
93 fake_external_frame_source_ =
94 new FakeExternalBeginFrameSourceForFakeSchedulerClient(this);
95 }
96 scheduler_ = TestScheduler::Create(
97 now_src_, this, settings, 0, fake_external_frame_source_);
86 DCHECK(scheduler_); 98 DCHECK(scheduler_);
87 // Fail if we need to run 100 tasks in a row. 99 // Fail if we need to run 100 tasks in a row.
88 task_runner().SetRunTaskLimit(100); 100 task_runner().SetRunTaskLimit(100);
89 return scheduler_.get(); 101 return scheduler_.get();
90 } 102 }
91 103
92 // Most tests don't care about DidAnticipatedDrawTimeChange, so only record it 104 // Most tests don't care about DidAnticipatedDrawTimeChange, so only record it
93 // for tests that do. 105 // for tests that do.
94 void set_log_anticipated_draw_time_change(bool log) { 106 void set_log_anticipated_draw_time_change(bool log) {
95 log_anticipated_draw_time_change_ = log; 107 log_anticipated_draw_time_change_ = log;
96 } 108 }
97 bool needs_begin_frames() { return fake_frame_source_.NeedsBeginFrames(); } 109 bool needs_begin_frames() { return scheduler_->NeedsBeginFrames(); }
98 int num_draws() const { return num_draws_; } 110 int num_draws() const { return num_draws_; }
99 int num_actions_() const { return static_cast<int>(actions_.size()); } 111 int num_actions_() const { return static_cast<int>(actions_.size()); }
100 const char* Action(int i) const { return actions_[i]; } 112 const char* Action(int i) const { return actions_[i]; }
101 std::string StateForAction(int i) const { return states_[i]->ToString(); } 113 std::string StateForAction(int i) const { return states_[i]->ToString(); }
102 base::TimeTicks posted_begin_impl_frame_deadline() const { 114 base::TimeTicks posted_begin_impl_frame_deadline() const {
103 return posted_begin_impl_frame_deadline_; 115 return posted_begin_impl_frame_deadline_;
104 } 116 }
105 117
106 bool ExternalBeginFrame() { 118 bool ExternalBeginFrame() {
107 return scheduler_->settings().begin_frame_scheduling_enabled && 119 return scheduler_->settings().begin_frame_scheduling_enabled &&
108 scheduler_->settings().throttle_frame_production; 120 scheduler_->settings().throttle_frame_production;
109 } 121 }
110 virtual FakeBeginFrameSource* ExternalBeginFrameSource() override { 122
111 return &fake_frame_source_; 123 FakeExternalBeginFrameSourceForFakeSchedulerClient*
124 ExternalBeginFrameSource() {
125 DCHECK(ExternalBeginFrame());
126 return fake_external_frame_source_.get();
112 } 127 }
113 128
114 void AdvanceFrame() { 129 void AdvanceFrame() {
115 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), 130 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"),
116 "FakeSchedulerClient::AdvanceFrame"); 131 "FakeSchedulerClient::AdvanceFrame");
117 // EXPECT_TRUE(needs_begin_frames());
118 if (ExternalBeginFrame()) { 132 if (ExternalBeginFrame()) {
119 // Creep the time forward so that any BeginFrameArgs is not equal to the 133 // Creep the time forward so that any BeginFrameArgs is not equal to the
120 // last one otherwise we violate the BeginFrameSource contract. 134 // last one otherwise we violate the BeginFrameSource contract.
121 now_src_->AdvanceNowMicroseconds(1); 135 now_src_->AdvanceNowMicroseconds(1);
122 fake_frame_source_.TestOnBeginFrame( 136 fake_external_frame_source_->TestOnBeginFrame(
123 CreateBeginFrameArgsForTesting(now_src_)); 137 CreateBeginFrameArgsForTesting(now_src_));
124 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 138 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
125 } 139 }
126 140
127 EXPECT_TRUE(task_runner().RunTasksWhile(ImplFrameDeadlinePending(false))); 141 EXPECT_TRUE(task_runner().RunTasksWhile(ImplFrameDeadlinePending(false)));
128 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 142 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
129 } 143 }
130 144
131 OrderedSimpleTaskRunner& task_runner() { return scheduler_->task_runner(); } 145 OrderedSimpleTaskRunner& task_runner() { return scheduler_->task_runner(); }
132 TestNowSource* now_src() { return now_src_.get(); } 146 TestNowSource* now_src() { return now_src_.get(); }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 bool automatic_swap_ack_; 266 bool automatic_swap_ack_;
253 int num_draws_; 267 int num_draws_;
254 bool log_anticipated_draw_time_change_; 268 bool log_anticipated_draw_time_change_;
255 bool swap_contains_incomplete_tile_; 269 bool swap_contains_incomplete_tile_;
256 bool redraw_will_happen_if_update_visible_tiles_happens_; 270 bool redraw_will_happen_if_update_visible_tiles_happens_;
257 base::TimeTicks posted_begin_impl_frame_deadline_; 271 base::TimeTicks posted_begin_impl_frame_deadline_;
258 std::vector<const char*> actions_; 272 std::vector<const char*> actions_;
259 std::vector<scoped_refptr<base::debug::ConvertableToTraceFormat> > states_; 273 std::vector<scoped_refptr<base::debug::ConvertableToTraceFormat> > states_;
260 scoped_ptr<TestScheduler> scheduler_; 274 scoped_ptr<TestScheduler> scheduler_;
261 scoped_refptr<TestNowSource> now_src_; 275 scoped_refptr<TestNowSource> now_src_;
262 FakeBeginFrameSourceForFakeSchedulerClient fake_frame_source_; 276 scoped_refptr<FakeExternalBeginFrameSourceForFakeSchedulerClient>
277 fake_external_frame_source_;
263 }; 278 };
264 279
265 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, 280 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler,
266 FakeSchedulerClient* client) { 281 FakeSchedulerClient* client) {
267 TRACE_EVENT0("cc", 282 TRACE_EVENT0("cc",
268 "SchedulerUnitTest::InitializeOutputSurfaceAndFirstCommit"); 283 "SchedulerUnitTest::InitializeOutputSurfaceAndFirstCommit");
269 284
270 scheduler->DidCreateAndInitializeOutputSurface(); 285 scheduler->DidCreateAndInitializeOutputSurface();
271 scheduler->SetNeedsCommit(); 286 scheduler->SetNeedsCommit();
272 scheduler->NotifyBeginMainFrameStarted(); 287 scheduler->NotifyBeginMainFrameStarted();
(...skipping 15 matching lines...) Expand all
288 SCOPED_TRACE( 303 SCOPED_TRACE(
289 "We need another BeginImplFrame so Scheduler calls " 304 "We need another BeginImplFrame so Scheduler calls "
290 "SetNeedsBeginFrame(false)."); 305 "SetNeedsBeginFrame(false).");
291 client->AdvanceFrame(); 306 client->AdvanceFrame();
292 } 307 }
293 308
294 // Run the posted deadline task. 309 // Run the posted deadline task.
295 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 310 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
296 client->task_runner().RunTasksWhile(client->ImplFrameDeadlinePending(true)); 311 client->task_runner().RunTasksWhile(client->ImplFrameDeadlinePending(true));
297 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 312 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
298
299 // EXPECT_FALSE(client->needs_begin_frames());
300 } 313 }
301 314
302 TEST(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { 315 TEST(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) {
303 FakeSchedulerClient client; 316 FakeSchedulerClient client;
304 SchedulerSettings default_scheduler_settings; 317 SchedulerSettings default_scheduler_settings;
305 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 318 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
306 scheduler->SetCanStart(); 319 scheduler->SetCanStart();
307 scheduler->SetVisible(true); 320 scheduler->SetVisible(true);
308 scheduler->SetCanDraw(true); 321 scheduler->SetCanDraw(true);
309 322
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings); 1391 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings);
1379 scheduler->SetCanStart(); 1392 scheduler->SetCanStart();
1380 scheduler->SetVisible(true); 1393 scheduler->SetVisible(true);
1381 scheduler->SetCanDraw(true); 1394 scheduler->SetCanDraw(true);
1382 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1395 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1383 1396
1384 // SetNeedsCommit should begin the frame on the next BeginImplFrame 1397 // SetNeedsCommit should begin the frame on the next BeginImplFrame
1385 // without calling SetNeedsBeginFrame. 1398 // without calling SetNeedsBeginFrame.
1386 client.Reset(); 1399 client.Reset();
1387 scheduler->SetNeedsCommit(); 1400 scheduler->SetNeedsCommit();
1388 EXPECT_FALSE(client.needs_begin_frames()); 1401 EXPECT_TRUE(client.needs_begin_frames());
1389 EXPECT_NO_ACTION(client); 1402 EXPECT_NO_ACTION(client);
1390 client.Reset(); 1403 client.Reset();
1391 1404
1392 // When the client-driven BeginFrame are disabled, the scheduler posts it's 1405 // When the client-driven BeginFrame are disabled, the scheduler posts it's
1393 // own BeginFrame tasks. 1406 // own BeginFrame tasks.
1394 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. 1407 client.task_runner().RunPendingTasks(); // Run posted BeginFrame.
1395 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1408 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1396 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1409 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1397 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1410 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1398 EXPECT_FALSE(client.needs_begin_frames()); 1411 EXPECT_TRUE(client.needs_begin_frames());
1399 client.Reset(); 1412 client.Reset();
1400 1413
1401 // If we don't swap on the deadline, we wait for the next BeginFrame. 1414 // If we don't swap on the deadline, we wait for the next BeginFrame.
1402 client.task_runner().RunPendingTasks(); // Run posted deadline. 1415 client.task_runner().RunPendingTasks(); // Run posted deadline.
1403 EXPECT_NO_ACTION(client); 1416 EXPECT_NO_ACTION(client);
1404 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1417 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1405 EXPECT_FALSE(client.needs_begin_frames()); 1418 EXPECT_TRUE(client.needs_begin_frames());
1406 client.Reset(); 1419 client.Reset();
1407 1420
1408 // NotifyReadyToCommit should trigger the commit. 1421 // NotifyReadyToCommit should trigger the commit.
1409 scheduler->NotifyBeginMainFrameStarted(); 1422 scheduler->NotifyBeginMainFrameStarted();
1410 scheduler->NotifyReadyToCommit(); 1423 scheduler->NotifyReadyToCommit();
1411 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 1424 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
1412 EXPECT_FALSE(client.needs_begin_frames()); 1425 EXPECT_TRUE(client.needs_begin_frames());
1413 client.Reset(); 1426 client.Reset();
1414 1427
1415 // BeginImplFrame should prepare the draw. 1428 // BeginImplFrame should prepare the draw.
1416 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. 1429 client.task_runner().RunPendingTasks(); // Run posted BeginFrame.
1417 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1430 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1418 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 1431 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
1419 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1432 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1420 EXPECT_FALSE(client.needs_begin_frames()); 1433 EXPECT_TRUE(client.needs_begin_frames());
1421 client.Reset(); 1434 client.Reset();
1422 1435
1423 // BeginImplFrame deadline should draw. 1436 // BeginImplFrame deadline should draw.
1424 client.task_runner().RunTasksWhile(client.ImplFrameDeadlinePending(true)); 1437 client.task_runner().RunTasksWhile(client.ImplFrameDeadlinePending(true));
1425 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); 1438 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1);
1426 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1439 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1427 EXPECT_FALSE(client.needs_begin_frames()); 1440 EXPECT_TRUE(client.needs_begin_frames());
1428 client.Reset(); 1441 client.Reset();
1429 1442
1430 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) 1443 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false)
1431 // to avoid excessive toggles. 1444 // to avoid excessive toggles.
1432 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. 1445 client.task_runner().RunPendingTasks(); // Run posted BeginFrame.
1433 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 1446 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client);
1434 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1447 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1435 client.Reset(); 1448 client.Reset();
1436 1449
1437 // Make sure SetNeedsBeginFrame isn't called on the client 1450 // Make sure SetNeedsBeginFrame isn't called on the client
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 scheduler->SetCanDraw(true); 1489 scheduler->SetCanDraw(true);
1477 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1490 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1478 1491
1479 // To test swap ack throttling, this test disables automatic swap acks. 1492 // To test swap ack throttling, this test disables automatic swap acks.
1480 scheduler->SetMaxSwapsPending(1); 1493 scheduler->SetMaxSwapsPending(1);
1481 client.SetAutomaticSwapAck(false); 1494 client.SetAutomaticSwapAck(false);
1482 1495
1483 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1496 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1484 client.Reset(); 1497 client.Reset();
1485 scheduler->SetNeedsCommit(); 1498 scheduler->SetNeedsCommit();
1486 EXPECT_FALSE(client.needs_begin_frames()); 1499 EXPECT_TRUE(client.needs_begin_frames());
1487 EXPECT_NO_ACTION(client); 1500 EXPECT_NO_ACTION(client);
1488 client.Reset(); 1501 client.Reset();
1489 1502
1490 // Trigger the first BeginImplFrame and BeginMainFrame 1503 // Trigger the first BeginImplFrame and BeginMainFrame
1491 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. 1504 client.task_runner().RunPendingTasks(); // Run posted BeginFrame.
1492 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1505 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1493 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1506 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1494 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1507 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1495 EXPECT_FALSE(client.needs_begin_frames()); 1508 EXPECT_TRUE(client.needs_begin_frames());
1496 client.Reset(); 1509 client.Reset();
1497 1510
1498 // NotifyReadyToCommit should trigger the pending commit and draw. 1511 // NotifyReadyToCommit should trigger the pending commit and draw.
1499 scheduler->NotifyBeginMainFrameStarted(); 1512 scheduler->NotifyBeginMainFrameStarted();
1500 scheduler->NotifyReadyToCommit(); 1513 scheduler->NotifyReadyToCommit();
1501 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 1514 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
1502 EXPECT_FALSE(client.needs_begin_frames()); 1515 EXPECT_TRUE(client.needs_begin_frames());
1503 client.Reset(); 1516 client.Reset();
1504 1517
1505 // Swapping will put us into a swap throttled state. 1518 // Swapping will put us into a swap throttled state.
1506 client.task_runner().RunPendingTasks(); // Run posted deadline. 1519 client.task_runner().RunPendingTasks(); // Run posted deadline.
1507 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); 1520 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2);
1508 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); 1521 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2);
1509 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1522 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1510 EXPECT_FALSE(client.needs_begin_frames()); 1523 EXPECT_TRUE(client.needs_begin_frames());
1511 client.Reset(); 1524 client.Reset();
1512 1525
1513 // While swap throttled, BeginFrames should trigger BeginImplFrames, 1526 // While swap throttled, BeginFrames should trigger BeginImplFrames,
1514 // but not a BeginMainFrame or draw. 1527 // but not a BeginMainFrame or draw.
1515 scheduler->SetNeedsCommit(); 1528 scheduler->SetNeedsCommit();
1516 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. 1529 client.task_runner().RunPendingTasks(); // Run posted BeginFrame.
1517 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1); 1530 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1);
1518 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1531 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1519 EXPECT_FALSE(client.needs_begin_frames()); 1532 EXPECT_TRUE(client.needs_begin_frames());
1520 client.Reset(); 1533 client.Reset();
1521 1534
1522 // Take us out of a swap throttled state. 1535 // Take us out of a swap throttled state.
1523 scheduler->DidSwapBuffersComplete(); 1536 scheduler->DidSwapBuffersComplete();
1524 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1); 1537 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1);
1525 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1538 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1526 EXPECT_FALSE(client.needs_begin_frames()); 1539 EXPECT_TRUE(client.needs_begin_frames());
1527 client.Reset(); 1540 client.Reset();
1528 1541
1529 // BeginImplFrame deadline should draw. 1542 // BeginImplFrame deadline should draw.
1530 scheduler->SetNeedsRedraw(); 1543 scheduler->SetNeedsRedraw();
1531 client.task_runner().RunPendingTasks(); // Run posted deadline. 1544 client.task_runner().RunPendingTasks(); // Run posted deadline.
1532 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); 1545 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2);
1533 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); 1546 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2);
1534 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1547 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1535 EXPECT_FALSE(client.needs_begin_frames()); 1548 EXPECT_TRUE(client.needs_begin_frames());
1536 client.Reset(); 1549 client.Reset();
1537 } 1550 }
1538 1551
1539 TEST(SchedulerTest, SyntheticBeginFrames_SwapThrottled) { 1552 TEST(SchedulerTest, SyntheticBeginFrames_SwapThrottled) {
1540 bool begin_frame_scheduling_enabled = false; 1553 bool begin_frame_scheduling_enabled = false;
1541 bool throttle_frame_production = true; 1554 bool throttle_frame_production = true;
1542 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, 1555 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled,
1543 throttle_frame_production); 1556 throttle_frame_production);
1544 } 1557 }
1545 1558
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 1975
1963 client.Reset(); 1976 client.Reset();
1964 scheduler->SetVisible(false); 1977 scheduler->SetVisible(false);
1965 // Sync tree should be forced to activate. 1978 // Sync tree should be forced to activate.
1966 EXPECT_ACTION("SetNeedsBeginFrames(false)", client, 0, 2); 1979 EXPECT_ACTION("SetNeedsBeginFrames(false)", client, 0, 2);
1967 EXPECT_ACTION("ScheduledActionActivateSyncTree", client, 1, 2); 1980 EXPECT_ACTION("ScheduledActionActivateSyncTree", client, 1, 2);
1968 } 1981 }
1969 1982
1970 } // namespace 1983 } // namespace
1971 } // namespace cc 1984 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698