OLD | NEW |
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 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCScheduler.h" | 7 #include "CCScheduler.h" |
8 | 8 |
9 #include "CCSchedulerTestCommon.h" | 9 #include "CCSchedulerTestCommon.h" |
10 #include <gmock/gmock.h> | 10 #include <gmock/gmock.h> |
11 #include <gtest/gtest.h> | 11 #include <gtest/gtest.h> |
12 #include <wtf/OwnPtr.h> | 12 #include <wtf/OwnPtr.h> |
13 | 13 |
14 using namespace WTF; | 14 using namespace WTF; |
15 using namespace WebCore; | 15 using namespace WebCore; |
16 using namespace WebKitTests; | 16 using namespace WebKitTests; |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 class FakeCCSchedulerClient : public CCSchedulerClient { | 20 class FakeCCSchedulerClient : public CCSchedulerClient { |
21 public: | 21 public: |
22 FakeCCSchedulerClient() { reset(); } | 22 FakeCCSchedulerClient() { reset(); } |
23 void reset() | 23 void reset() |
24 { | 24 { |
25 m_actions.clear(); | 25 m_actions.clear(); |
26 m_hasMoreResourceUpdates = false; | 26 m_hasMoreResourceUpdates = false; |
27 m_canDraw = true; | |
28 m_drawWillHappen = true; | 27 m_drawWillHappen = true; |
29 m_swapWillHappenIfDrawHappens = true; | 28 m_swapWillHappenIfDrawHappens = true; |
30 m_numDraws = 0; | 29 m_numDraws = 0; |
31 } | 30 } |
32 | 31 |
33 void setHasMoreResourceUpdates(bool b) { m_hasMoreResourceUpdates = b; } | 32 void setHasMoreResourceUpdates(bool b) { m_hasMoreResourceUpdates = b; } |
34 void setCanDraw(bool b) { m_canDraw = b; } | |
35 | 33 |
36 int numDraws() const { return m_numDraws; } | 34 int numDraws() const { return m_numDraws; } |
37 int numActions() const { return static_cast<int>(m_actions.size()); } | 35 int numActions() const { return static_cast<int>(m_actions.size()); } |
38 const char* action(int i) const { return m_actions[i]; } | 36 const char* action(int i) const { return m_actions[i]; } |
39 | 37 |
40 bool hasAction(const char* action) const | 38 bool hasAction(const char* action) const |
41 { | 39 { |
42 for (size_t i = 0; i < m_actions.size(); i++) | 40 for (size_t i = 0; i < m_actions.size(); i++) |
43 if (!strcmp(m_actions[i], action)) | 41 if (!strcmp(m_actions[i], action)) |
44 return true; | 42 return true; |
45 return false; | 43 return false; |
46 } | 44 } |
47 | 45 |
48 virtual bool canDraw() OVERRIDE { return m_canDraw; } | |
49 virtual bool hasMoreResourceUpdates() const OVERRIDE { return m_hasMoreResou
rceUpdates; } | 46 virtual bool hasMoreResourceUpdates() const OVERRIDE { return m_hasMoreResou
rceUpdates; } |
| 47 |
50 virtual void scheduledActionBeginFrame() OVERRIDE { m_actions.push_back("sch
eduledActionBeginFrame"); } | 48 virtual void scheduledActionBeginFrame() OVERRIDE { m_actions.push_back("sch
eduledActionBeginFrame"); } |
51 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapIfPossi
ble() OVERRIDE | 49 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapIfPossi
ble() OVERRIDE |
52 { | 50 { |
53 m_actions.push_back("scheduledActionDrawAndSwapIfPossible"); | 51 m_actions.push_back("scheduledActionDrawAndSwapIfPossible"); |
54 m_numDraws++; | 52 m_numDraws++; |
55 return CCScheduledActionDrawAndSwapResult(m_drawWillHappen, m_drawWillHa
ppen && m_swapWillHappenIfDrawHappens); | 53 return CCScheduledActionDrawAndSwapResult(m_drawWillHappen, m_drawWillHa
ppen && m_swapWillHappenIfDrawHappens); |
56 } | 54 } |
57 | 55 |
58 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapForced(
) OVERRIDE | 56 virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapForced(
) OVERRIDE |
59 { | 57 { |
60 m_actions.push_back("scheduledActionDrawAndSwapForced"); | 58 m_actions.push_back("scheduledActionDrawAndSwapForced"); |
61 return CCScheduledActionDrawAndSwapResult(true, m_swapWillHappenIfDrawHa
ppens); | 59 return CCScheduledActionDrawAndSwapResult(true, m_swapWillHappenIfDrawHa
ppens); |
62 } | 60 } |
63 | 61 |
64 virtual void scheduledActionUpdateMoreResources(double) OVERRIDE { m_actions
.push_back("scheduledActionUpdateMoreResources"); } | 62 virtual void scheduledActionUpdateMoreResources(double) OVERRIDE { m_actions
.push_back("scheduledActionUpdateMoreResources"); } |
65 virtual void scheduledActionCommit() OVERRIDE { m_actions.push_back("schedul
edActionCommit"); } | 63 virtual void scheduledActionCommit() OVERRIDE { m_actions.push_back("schedul
edActionCommit"); } |
66 virtual void scheduledActionBeginContextRecreation() OVERRIDE { m_actions.pu
sh_back("scheduledActionBeginContextRecreation"); } | 64 virtual void scheduledActionBeginContextRecreation() OVERRIDE { m_actions.pu
sh_back("scheduledActionBeginContextRecreation"); } |
67 virtual void scheduledActionAcquireLayerTexturesForMainThread() OVERRIDE { m
_actions.push_back("scheduledActionAcquireLayerTexturesForMainThread"); } | 65 virtual void scheduledActionAcquireLayerTexturesForMainThread() OVERRIDE { m
_actions.push_back("scheduledActionAcquireLayerTexturesForMainThread"); } |
68 | 66 |
69 void setDrawWillHappen(bool drawWillHappen) { m_drawWillHappen = drawWillHap
pen; } | 67 void setDrawWillHappen(bool drawWillHappen) { m_drawWillHappen = drawWillHap
pen; } |
70 void setSwapWillHappenIfDrawHappens(bool swapWillHappenIfDrawHappens) { m_sw
apWillHappenIfDrawHappens = swapWillHappenIfDrawHappens; } | 68 void setSwapWillHappenIfDrawHappens(bool swapWillHappenIfDrawHappens) { m_sw
apWillHappenIfDrawHappens = swapWillHappenIfDrawHappens; } |
71 | 69 |
72 protected: | 70 protected: |
73 bool m_hasMoreResourceUpdates; | 71 bool m_hasMoreResourceUpdates; |
74 bool m_canDraw; | |
75 bool m_drawWillHappen; | 72 bool m_drawWillHappen; |
76 bool m_swapWillHappenIfDrawHappens; | 73 bool m_swapWillHappenIfDrawHappens; |
77 int m_numDraws; | 74 int m_numDraws; |
78 std::vector<const char*> m_actions; | 75 std::vector<const char*> m_actions; |
79 }; | 76 }; |
80 | 77 |
81 TEST(CCSchedulerTest, RequestCommit) | 78 TEST(CCSchedulerTest, RequestCommit) |
82 { | 79 { |
83 FakeCCSchedulerClient client; | 80 FakeCCSchedulerClient client; |
84 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); | 81 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); |
85 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); | 82 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); |
86 scheduler->setCanBeginFrame(true); | 83 scheduler->setCanBeginFrame(true); |
87 scheduler->setVisible(true); | 84 scheduler->setVisible(true); |
| 85 scheduler->setCanDraw(true); |
88 | 86 |
89 // SetNeedsCommit should begin the frame. | 87 // SetNeedsCommit should begin the frame. |
90 scheduler->setNeedsCommit(); | 88 scheduler->setNeedsCommit(); |
91 EXPECT_EQ(1, client.numActions()); | 89 EXPECT_EQ(1, client.numActions()); |
92 EXPECT_STREQ("scheduledActionBeginFrame", client.action(0)); | 90 EXPECT_STREQ("scheduledActionBeginFrame", client.action(0)); |
93 EXPECT_FALSE(timeSource->active()); | 91 EXPECT_FALSE(timeSource->active()); |
94 client.reset(); | 92 client.reset(); |
95 | 93 |
96 // Since, hasMoreResourceUpdates is set to false, | 94 // Since, hasMoreResourceUpdates is set to false, |
97 // beginFrameComplete should commit | 95 // beginFrameComplete should commit |
(...skipping 14 matching lines...) Expand all Loading... |
112 EXPECT_FALSE(timeSource->active()); | 110 EXPECT_FALSE(timeSource->active()); |
113 } | 111 } |
114 | 112 |
115 TEST(CCSchedulerTest, RequestCommitAfterBeginFrame) | 113 TEST(CCSchedulerTest, RequestCommitAfterBeginFrame) |
116 { | 114 { |
117 FakeCCSchedulerClient client; | 115 FakeCCSchedulerClient client; |
118 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); | 116 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); |
119 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); | 117 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); |
120 scheduler->setCanBeginFrame(true); | 118 scheduler->setCanBeginFrame(true); |
121 scheduler->setVisible(true); | 119 scheduler->setVisible(true); |
| 120 scheduler->setCanDraw(true); |
122 | 121 |
123 // SetNedsCommit should begin the frame. | 122 // SetNedsCommit should begin the frame. |
124 scheduler->setNeedsCommit(); | 123 scheduler->setNeedsCommit(); |
125 EXPECT_EQ(1, client.numActions()); | 124 EXPECT_EQ(1, client.numActions()); |
126 EXPECT_STREQ("scheduledActionBeginFrame", client.action(0)); | 125 EXPECT_STREQ("scheduledActionBeginFrame", client.action(0)); |
127 client.reset(); | 126 client.reset(); |
128 | 127 |
129 // Now setNeedsCommit again. Calling here means we need a second frame. | 128 // Now setNeedsCommit again. Calling here means we need a second frame. |
130 scheduler->setNeedsCommit(); | 129 scheduler->setNeedsCommit(); |
131 | 130 |
(...skipping 13 matching lines...) Expand all Loading... |
145 client.reset(); | 144 client.reset(); |
146 } | 145 } |
147 | 146 |
148 TEST(CCSchedulerTest, TextureAcquisitionCollision) | 147 TEST(CCSchedulerTest, TextureAcquisitionCollision) |
149 { | 148 { |
150 FakeCCSchedulerClient client; | 149 FakeCCSchedulerClient client; |
151 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); | 150 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); |
152 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); | 151 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); |
153 scheduler->setCanBeginFrame(true); | 152 scheduler->setCanBeginFrame(true); |
154 scheduler->setVisible(true); | 153 scheduler->setVisible(true); |
| 154 scheduler->setCanDraw(true); |
155 | 155 |
156 scheduler->setNeedsCommit(); | 156 scheduler->setNeedsCommit(); |
157 scheduler->setMainThreadNeedsLayerTextures(); | 157 scheduler->setMainThreadNeedsLayerTextures(); |
158 EXPECT_EQ(2, client.numActions()); | 158 EXPECT_EQ(2, client.numActions()); |
159 EXPECT_STREQ("scheduledActionBeginFrame", client.action(0)); | 159 EXPECT_STREQ("scheduledActionBeginFrame", client.action(0)); |
160 EXPECT_STREQ("scheduledActionAcquireLayerTexturesForMainThread", client.acti
on(1)); | 160 EXPECT_STREQ("scheduledActionAcquireLayerTexturesForMainThread", client.acti
on(1)); |
161 client.reset(); | 161 client.reset(); |
162 | 162 |
163 // Compositor not scheduled to draw because textures are locked by main thre
ad | 163 // Compositor not scheduled to draw because textures are locked by main thre
ad |
164 EXPECT_FALSE(timeSource->active()); | 164 EXPECT_FALSE(timeSource->active()); |
(...skipping 18 matching lines...) Expand all Loading... |
183 client.reset(); | 183 client.reset(); |
184 } | 184 } |
185 | 185 |
186 TEST(CCSchedulerTest, VisibilitySwitchWithTextureAcquisition) | 186 TEST(CCSchedulerTest, VisibilitySwitchWithTextureAcquisition) |
187 { | 187 { |
188 FakeCCSchedulerClient client; | 188 FakeCCSchedulerClient client; |
189 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); | 189 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); |
190 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); | 190 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); |
191 scheduler->setCanBeginFrame(true); | 191 scheduler->setCanBeginFrame(true); |
192 scheduler->setVisible(true); | 192 scheduler->setVisible(true); |
| 193 scheduler->setCanDraw(true); |
193 | 194 |
194 scheduler->setNeedsCommit(); | 195 scheduler->setNeedsCommit(); |
195 scheduler->beginFrameComplete(); | 196 scheduler->beginFrameComplete(); |
196 scheduler->setMainThreadNeedsLayerTextures(); | 197 scheduler->setMainThreadNeedsLayerTextures(); |
197 client.reset(); | 198 client.reset(); |
198 // Verify that pending texture acquisition fires when visibility | 199 // Verify that pending texture acquisition fires when visibility |
199 // is lost in order to avoid a deadlock. | 200 // is lost in order to avoid a deadlock. |
200 scheduler->setVisible(false); | 201 scheduler->setVisible(false); |
201 EXPECT_EQ(1, client.numActions()); | 202 EXPECT_EQ(1, client.numActions()); |
202 EXPECT_STREQ("scheduledActionAcquireLayerTexturesForMainThread", client.acti
on(0)); | 203 EXPECT_STREQ("scheduledActionAcquireLayerTexturesForMainThread", client.acti
on(0)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // a scheduledActionDrawAndSwap | 247 // a scheduledActionDrawAndSwap |
247 // 2. the scheduler drawing twice inside a single tick | 248 // 2. the scheduler drawing twice inside a single tick |
248 TEST(CCSchedulerTest, RequestRedrawInsideDraw) | 249 TEST(CCSchedulerTest, RequestRedrawInsideDraw) |
249 { | 250 { |
250 SchedulerClientThatSetNeedsDrawInsideDraw client; | 251 SchedulerClientThatSetNeedsDrawInsideDraw client; |
251 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); | 252 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); |
252 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); | 253 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); |
253 client.setScheduler(scheduler.get()); | 254 client.setScheduler(scheduler.get()); |
254 scheduler->setCanBeginFrame(true); | 255 scheduler->setCanBeginFrame(true); |
255 scheduler->setVisible(true); | 256 scheduler->setVisible(true); |
| 257 scheduler->setCanDraw(true); |
256 | 258 |
257 scheduler->setNeedsRedraw(); | 259 scheduler->setNeedsRedraw(); |
258 EXPECT_TRUE(scheduler->redrawPending()); | 260 EXPECT_TRUE(scheduler->redrawPending()); |
259 EXPECT_TRUE(timeSource->active()); | 261 EXPECT_TRUE(timeSource->active()); |
260 EXPECT_EQ(0, client.numDraws()); | 262 EXPECT_EQ(0, client.numDraws()); |
261 | 263 |
262 timeSource->tick(); | 264 timeSource->tick(); |
263 EXPECT_EQ(1, client.numDraws()); | 265 EXPECT_EQ(1, client.numDraws()); |
264 EXPECT_TRUE(scheduler->redrawPending()); | 266 EXPECT_TRUE(scheduler->redrawPending()); |
265 EXPECT_TRUE(timeSource->active()); | 267 EXPECT_TRUE(timeSource->active()); |
266 | 268 |
267 timeSource->tick(); | 269 timeSource->tick(); |
268 EXPECT_EQ(2, client.numDraws()); | 270 EXPECT_EQ(2, client.numDraws()); |
269 EXPECT_FALSE(scheduler->redrawPending()); | 271 EXPECT_FALSE(scheduler->redrawPending()); |
270 EXPECT_FALSE(timeSource->active()); | 272 EXPECT_FALSE(timeSource->active()); |
271 } | 273 } |
272 | 274 |
273 // Test that requesting redraw inside a failed draw doesn't lose the request. | 275 // Test that requesting redraw inside a failed draw doesn't lose the request. |
274 TEST(CCSchedulerTest, RequestRedrawInsideFailedDraw) | 276 TEST(CCSchedulerTest, RequestRedrawInsideFailedDraw) |
275 { | 277 { |
276 SchedulerClientThatSetNeedsDrawInsideDraw client; | 278 SchedulerClientThatSetNeedsDrawInsideDraw client; |
277 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); | 279 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); |
278 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); | 280 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); |
279 client.setScheduler(scheduler.get()); | 281 client.setScheduler(scheduler.get()); |
280 scheduler->setCanBeginFrame(true); | 282 scheduler->setCanBeginFrame(true); |
281 scheduler->setVisible(true); | 283 scheduler->setVisible(true); |
| 284 scheduler->setCanDraw(true); |
282 client.setDrawWillHappen(false); | 285 client.setDrawWillHappen(false); |
283 | 286 |
284 scheduler->setNeedsRedraw(); | 287 scheduler->setNeedsRedraw(); |
285 EXPECT_TRUE(scheduler->redrawPending()); | 288 EXPECT_TRUE(scheduler->redrawPending()); |
286 EXPECT_TRUE(timeSource->active()); | 289 EXPECT_TRUE(timeSource->active()); |
287 EXPECT_EQ(0, client.numDraws()); | 290 EXPECT_EQ(0, client.numDraws()); |
288 | 291 |
289 // Fail the draw. | 292 // Fail the draw. |
290 timeSource->tick(); | 293 timeSource->tick(); |
291 EXPECT_EQ(1, client.numDraws()); | 294 EXPECT_EQ(1, client.numDraws()); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 // Tests for the scheduler infinite-looping on setNeedsCommit requests that | 347 // Tests for the scheduler infinite-looping on setNeedsCommit requests that |
345 // happen inside a scheduledActionDrawAndSwap | 348 // happen inside a scheduledActionDrawAndSwap |
346 TEST(CCSchedulerTest, RequestCommitInsideDraw) | 349 TEST(CCSchedulerTest, RequestCommitInsideDraw) |
347 { | 350 { |
348 SchedulerClientThatSetNeedsCommitInsideDraw client; | 351 SchedulerClientThatSetNeedsCommitInsideDraw client; |
349 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); | 352 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); |
350 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); | 353 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); |
351 client.setScheduler(scheduler.get()); | 354 client.setScheduler(scheduler.get()); |
352 scheduler->setCanBeginFrame(true); | 355 scheduler->setCanBeginFrame(true); |
353 scheduler->setVisible(true); | 356 scheduler->setVisible(true); |
| 357 scheduler->setCanDraw(true); |
354 | 358 |
355 scheduler->setNeedsRedraw(); | 359 scheduler->setNeedsRedraw(); |
356 EXPECT_TRUE(scheduler->redrawPending()); | 360 EXPECT_TRUE(scheduler->redrawPending()); |
357 EXPECT_EQ(0, client.numDraws()); | 361 EXPECT_EQ(0, client.numDraws()); |
358 EXPECT_TRUE(timeSource->active()); | 362 EXPECT_TRUE(timeSource->active()); |
359 | 363 |
360 timeSource->tick(); | 364 timeSource->tick(); |
361 EXPECT_FALSE(timeSource->active()); | 365 EXPECT_FALSE(timeSource->active()); |
362 EXPECT_EQ(1, client.numDraws()); | 366 EXPECT_EQ(1, client.numDraws()); |
363 EXPECT_TRUE(scheduler->commitPending()); | 367 EXPECT_TRUE(scheduler->commitPending()); |
364 scheduler->beginFrameComplete(); | 368 scheduler->beginFrameComplete(); |
365 | 369 |
366 timeSource->tick(); | 370 timeSource->tick(); |
367 EXPECT_EQ(2, client.numDraws()); | 371 EXPECT_EQ(2, client.numDraws()); |
368 EXPECT_FALSE(timeSource->active()); | 372 EXPECT_FALSE(timeSource->active()); |
369 EXPECT_FALSE(scheduler->redrawPending()); | 373 EXPECT_FALSE(scheduler->redrawPending()); |
370 } | 374 } |
371 | 375 |
372 // Tests that when a draw fails then the pending commit should not be dropped. | 376 // Tests that when a draw fails then the pending commit should not be dropped. |
373 TEST(CCSchedulerTest, RequestCommitInsideFailedDraw) | 377 TEST(CCSchedulerTest, RequestCommitInsideFailedDraw) |
374 { | 378 { |
375 SchedulerClientThatSetNeedsDrawInsideDraw client; | 379 SchedulerClientThatSetNeedsDrawInsideDraw client; |
376 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); | 380 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); |
377 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); | 381 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, adoptPtr(new CC
FrameRateController(timeSource))); |
378 client.setScheduler(scheduler.get()); | 382 client.setScheduler(scheduler.get()); |
379 scheduler->setCanBeginFrame(true); | 383 scheduler->setCanBeginFrame(true); |
380 scheduler->setVisible(true); | 384 scheduler->setVisible(true); |
| 385 scheduler->setCanDraw(true); |
381 client.setDrawWillHappen(false); | 386 client.setDrawWillHappen(false); |
382 | 387 |
383 scheduler->setNeedsRedraw(); | 388 scheduler->setNeedsRedraw(); |
384 EXPECT_TRUE(scheduler->redrawPending()); | 389 EXPECT_TRUE(scheduler->redrawPending()); |
385 EXPECT_TRUE(timeSource->active()); | 390 EXPECT_TRUE(timeSource->active()); |
386 EXPECT_EQ(0, client.numDraws()); | 391 EXPECT_EQ(0, client.numDraws()); |
387 | 392 |
388 // Fail the draw. | 393 // Fail the draw. |
389 timeSource->tick(); | 394 timeSource->tick(); |
390 EXPECT_EQ(1, client.numDraws()); | 395 EXPECT_EQ(1, client.numDraws()); |
(...skipping 22 matching lines...) Expand all Loading... |
413 TEST(CCSchedulerTest, NoBeginFrameWhenDrawFails) | 418 TEST(CCSchedulerTest, NoBeginFrameWhenDrawFails) |
414 { | 419 { |
415 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); | 420 RefPtr<FakeCCTimeSource> timeSource = adoptRef(new FakeCCTimeSource()); |
416 SchedulerClientThatSetNeedsCommitInsideDraw client; | 421 SchedulerClientThatSetNeedsCommitInsideDraw client; |
417 OwnPtr<FakeCCFrameRateController> controller = adoptPtr(new FakeCCFrameRateC
ontroller(timeSource)); | 422 OwnPtr<FakeCCFrameRateController> controller = adoptPtr(new FakeCCFrameRateC
ontroller(timeSource)); |
418 FakeCCFrameRateController* controllerPtr = controller.get(); | 423 FakeCCFrameRateController* controllerPtr = controller.get(); |
419 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, controller.rele
ase()); | 424 OwnPtr<CCScheduler> scheduler = CCScheduler::create(&client, controller.rele
ase()); |
420 client.setScheduler(scheduler.get()); | 425 client.setScheduler(scheduler.get()); |
421 scheduler->setCanBeginFrame(true); | 426 scheduler->setCanBeginFrame(true); |
422 scheduler->setVisible(true); | 427 scheduler->setVisible(true); |
| 428 scheduler->setCanDraw(true); |
423 | 429 |
424 EXPECT_EQ(0, controllerPtr->numFramesPending()); | 430 EXPECT_EQ(0, controllerPtr->numFramesPending()); |
425 | 431 |
426 scheduler->setNeedsRedraw(); | 432 scheduler->setNeedsRedraw(); |
427 EXPECT_TRUE(scheduler->redrawPending()); | 433 EXPECT_TRUE(scheduler->redrawPending()); |
428 EXPECT_TRUE(timeSource->active()); | 434 EXPECT_TRUE(timeSource->active()); |
429 EXPECT_EQ(0, client.numDraws()); | 435 EXPECT_EQ(0, client.numDraws()); |
430 | 436 |
431 // Draw successfully, this starts a new frame. | 437 // Draw successfully, this starts a new frame. |
432 timeSource->tick(); | 438 timeSource->tick(); |
(...skipping 30 matching lines...) Expand all Loading... |
463 // Get the compositor to do a scheduledActionDrawAndSwapForced. | 469 // Get the compositor to do a scheduledActionDrawAndSwapForced. |
464 scheduler->setNeedsRedraw(); | 470 scheduler->setNeedsRedraw(); |
465 scheduler->setNeedsForcedRedraw(); | 471 scheduler->setNeedsForcedRedraw(); |
466 EXPECT_TRUE(client.hasAction("scheduledActionDrawAndSwapForced")); | 472 EXPECT_TRUE(client.hasAction("scheduledActionDrawAndSwapForced")); |
467 | 473 |
468 // We should not have told the frame rate controller that we began a frame. | 474 // We should not have told the frame rate controller that we began a frame. |
469 EXPECT_EQ(0, controllerPtr->numFramesPending()); | 475 EXPECT_EQ(0, controllerPtr->numFramesPending()); |
470 } | 476 } |
471 | 477 |
472 } | 478 } |
OLD | NEW |