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

Side by Side Diff: third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreatorTest.cpp

Issue 2420203002: Implement convertToBlob() in OffscreenCanvas (Closed)
Patch Set: rebase and fix global-interface-listing-service-worker-expected.txt Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "core/html/canvas/CanvasAsyncBlobCreator.h" 5 #include "core/html/canvas/CanvasAsyncBlobCreator.h"
6 6
7 #include "core/html/ImageData.h" 7 #include "core/html/ImageData.h"
8 #include "core/testing/DummyPageHolder.h" 8 #include "core/testing/DummyPageHolder.h"
9 #include "platform/testing/UnitTestHelpers.h" 9 #include "platform/testing/UnitTestHelpers.h"
10 #include "public/platform/Platform.h" 10 #include "public/platform/Platform.h"
11 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "wtf/Functional.h" 13 #include "wtf/Functional.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 typedef CanvasAsyncBlobCreator::IdleTaskStatus IdleTaskStatus; 17 typedef CanvasAsyncBlobCreator::IdleTaskStatus IdleTaskStatus;
18 18
19 class MockCanvasAsyncBlobCreator : public CanvasAsyncBlobCreator { 19 class MockCanvasAsyncBlobCreator : public CanvasAsyncBlobCreator {
20 public: 20 public:
21 MockCanvasAsyncBlobCreator(DOMUint8ClampedArray* data, 21 MockCanvasAsyncBlobCreator(DOMUint8ClampedArray* data,
22 const IntSize& size, 22 const IntSize& size,
23 MimeType mimeType, 23 MimeType mimeType,
24 Document& document) 24 Document* document)
25 : CanvasAsyncBlobCreator(data, mimeType, size, nullptr, 0, document) {} 25 : CanvasAsyncBlobCreator(data,
26 mimeType,
27 size,
28 nullptr,
29 0,
30 document,
31 nullptr) {}
26 32
27 CanvasAsyncBlobCreator::IdleTaskStatus idleTaskStatus() { 33 CanvasAsyncBlobCreator::IdleTaskStatus idleTaskStatus() {
28 return m_idleTaskStatus; 34 return m_idleTaskStatus;
29 } 35 }
30 36
31 MOCK_METHOD0(signalTaskSwitchInStartTimeoutEventForTesting, void()); 37 MOCK_METHOD0(signalTaskSwitchInStartTimeoutEventForTesting, void());
32 MOCK_METHOD0(signalTaskSwitchInCompleteTimeoutEventForTesting, void()); 38 MOCK_METHOD0(signalTaskSwitchInCompleteTimeoutEventForTesting, void());
33 39
34 protected: 40 protected:
35 void createBlobAndInvokeCallback() override{}; 41 void createBlobAndReturnResult() override{};
36 void createNullAndInvokeCallback() override{}; 42 void createNullAndReturnResult() override{};
37 void signalAlternativeCodePathFinishedForTesting() override; 43 void signalAlternativeCodePathFinishedForTesting() override;
38 void postDelayedTaskToMainThread(const WebTraceLocation&, 44 void postDelayedTaskToMainThread(const WebTraceLocation&,
39 std::unique_ptr<WTF::Closure>, 45 std::unique_ptr<WTF::Closure>,
40 double delayMs) override; 46 double delayMs) override;
41 }; 47 };
42 48
43 void MockCanvasAsyncBlobCreator::signalAlternativeCodePathFinishedForTesting() { 49 void MockCanvasAsyncBlobCreator::signalAlternativeCodePathFinishedForTesting() {
44 testing::exitRunLoop(); 50 testing::exitRunLoop();
45 } 51 }
46 52
47 void MockCanvasAsyncBlobCreator::postDelayedTaskToMainThread( 53 void MockCanvasAsyncBlobCreator::postDelayedTaskToMainThread(
48 const WebTraceLocation& location, 54 const WebTraceLocation& location,
49 std::unique_ptr<WTF::Closure> task, 55 std::unique_ptr<WTF::Closure> task,
50 double delayMs) { 56 double delayMs) {
51 DCHECK(isMainThread()); 57 DCHECK(isMainThread());
52 Platform::current()->mainThread()->getWebTaskRunner()->postTask( 58 Platform::current()->mainThread()->getWebTaskRunner()->postTask(
53 location, std::move(task)); 59 location, std::move(task));
54 } 60 }
55 61
56 //============================================================================== 62 //==============================================================================
57 //=================================PNG========================================== 63 //=================================PNG==========================================
58 //============================================================================== 64 //==============================================================================
59 65
60 class MockCanvasAsyncBlobCreatorWithoutStartPng 66 class MockCanvasAsyncBlobCreatorWithoutStartPng
61 : public MockCanvasAsyncBlobCreator { 67 : public MockCanvasAsyncBlobCreator {
62 public: 68 public:
63 MockCanvasAsyncBlobCreatorWithoutStartPng(DOMUint8ClampedArray* data, 69 MockCanvasAsyncBlobCreatorWithoutStartPng(DOMUint8ClampedArray* data,
64 const IntSize& size, 70 const IntSize& size,
65 Document& document) 71 Document* document)
66 : MockCanvasAsyncBlobCreator(data, size, MimeTypePng, document) {} 72 : MockCanvasAsyncBlobCreator(data, size, MimeTypePng, document) {}
67 73
68 protected: 74 protected:
69 void scheduleInitiatePngEncoding() override { 75 void scheduleInitiatePngEncoding() override {
70 // Deliberately make scheduleInitiatePngEncoding do nothing so that idle 76 // Deliberately make scheduleInitiatePngEncoding do nothing so that idle
71 // task never starts 77 // task never starts
72 } 78 }
73 }; 79 };
74 80
75 //============================================================================== 81 //==============================================================================
76 82
77 class MockCanvasAsyncBlobCreatorWithoutCompletePng 83 class MockCanvasAsyncBlobCreatorWithoutCompletePng
78 : public MockCanvasAsyncBlobCreator { 84 : public MockCanvasAsyncBlobCreator {
79 public: 85 public:
80 MockCanvasAsyncBlobCreatorWithoutCompletePng(DOMUint8ClampedArray* data, 86 MockCanvasAsyncBlobCreatorWithoutCompletePng(DOMUint8ClampedArray* data,
81 const IntSize& size, 87 const IntSize& size,
82 Document& document) 88 Document* document)
83 : MockCanvasAsyncBlobCreator(data, size, MimeTypePng, document) {} 89 : MockCanvasAsyncBlobCreator(data, size, MimeTypePng, document) {}
84 90
85 protected: 91 protected:
86 void scheduleInitiatePngEncoding() override { 92 void scheduleInitiatePngEncoding() override {
87 Platform::current()->mainThread()->getWebTaskRunner()->postTask( 93 Platform::current()->mainThread()->getWebTaskRunner()->postTask(
88 BLINK_FROM_HERE, 94 BLINK_FROM_HERE,
89 WTF::bind( 95 WTF::bind(
90 &MockCanvasAsyncBlobCreatorWithoutCompletePng::initiatePngEncoding, 96 &MockCanvasAsyncBlobCreatorWithoutCompletePng::initiatePngEncoding,
91 wrapPersistent(this), std::numeric_limits<double>::max())); 97 wrapPersistent(this), std::numeric_limits<double>::max()));
92 } 98 }
93 99
94 void idleEncodeRowsPng(double deadlineSeconds) override { 100 void idleEncodeRowsPng(double deadlineSeconds) override {
95 // Deliberately make idleEncodeRowsPng do nothing so that idle task never 101 // Deliberately make idleEncodeRowsPng do nothing so that idle task never
96 // completes 102 // completes
97 } 103 }
98 }; 104 };
99 105
100 //============================================================================== 106 //==============================================================================
101 //=================================JPEG========================================= 107 //=================================JPEG=========================================
102 //============================================================================== 108 //==============================================================================
103 109
104 class MockCanvasAsyncBlobCreatorWithoutStartJpeg 110 class MockCanvasAsyncBlobCreatorWithoutStartJpeg
105 : public MockCanvasAsyncBlobCreator { 111 : public MockCanvasAsyncBlobCreator {
106 public: 112 public:
107 MockCanvasAsyncBlobCreatorWithoutStartJpeg(DOMUint8ClampedArray* data, 113 MockCanvasAsyncBlobCreatorWithoutStartJpeg(DOMUint8ClampedArray* data,
108 const IntSize& size, 114 const IntSize& size,
109 Document& document) 115 Document* document)
110 : MockCanvasAsyncBlobCreator(data, size, MimeTypeJpeg, document) {} 116 : MockCanvasAsyncBlobCreator(data, size, MimeTypeJpeg, document) {}
111 117
112 protected: 118 protected:
113 void scheduleInitiateJpegEncoding(const double&) override { 119 void scheduleInitiateJpegEncoding(const double&) override {
114 // Deliberately make scheduleInitiateJpegEncoding do nothing so that idle 120 // Deliberately make scheduleInitiateJpegEncoding do nothing so that idle
115 // task never starts 121 // task never starts
116 } 122 }
117 }; 123 };
118 124
119 //============================================================================== 125 //==============================================================================
120 126
121 class MockCanvasAsyncBlobCreatorWithoutCompleteJpeg 127 class MockCanvasAsyncBlobCreatorWithoutCompleteJpeg
122 : public MockCanvasAsyncBlobCreator { 128 : public MockCanvasAsyncBlobCreator {
123 public: 129 public:
124 MockCanvasAsyncBlobCreatorWithoutCompleteJpeg(DOMUint8ClampedArray* data, 130 MockCanvasAsyncBlobCreatorWithoutCompleteJpeg(DOMUint8ClampedArray* data,
125 const IntSize& size, 131 const IntSize& size,
126 Document& document) 132 Document* document)
127 : MockCanvasAsyncBlobCreator(data, size, MimeTypeJpeg, document) {} 133 : MockCanvasAsyncBlobCreator(data, size, MimeTypeJpeg, document) {}
128 134
129 protected: 135 protected:
130 void scheduleInitiateJpegEncoding(const double& quality) override { 136 void scheduleInitiateJpegEncoding(const double& quality) override {
131 Platform::current()->mainThread()->getWebTaskRunner()->postTask( 137 Platform::current()->mainThread()->getWebTaskRunner()->postTask(
132 BLINK_FROM_HERE, 138 BLINK_FROM_HERE,
133 WTF::bind(&MockCanvasAsyncBlobCreatorWithoutCompleteJpeg:: 139 WTF::bind(&MockCanvasAsyncBlobCreatorWithoutCompleteJpeg::
134 initiateJpegEncoding, 140 initiateJpegEncoding,
135 wrapPersistent(this), quality, 141 wrapPersistent(this), quality,
136 std::numeric_limits<double>::max())); 142 std::numeric_limits<double>::max()));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 CanvasAsyncBlobCreatorTest::CanvasAsyncBlobCreatorTest() { 179 CanvasAsyncBlobCreatorTest::CanvasAsyncBlobCreatorTest() {
174 m_dummyPageHolder = DummyPageHolder::create(); 180 m_dummyPageHolder = DummyPageHolder::create();
175 } 181 }
176 182
177 void CanvasAsyncBlobCreatorTest:: 183 void CanvasAsyncBlobCreatorTest::
178 prepareMockCanvasAsyncBlobCreatorWithoutStartPng() { 184 prepareMockCanvasAsyncBlobCreatorWithoutStartPng() {
179 IntSize testSize(20, 20); 185 IntSize testSize(20, 20);
180 ImageData* imageData = ImageData::create(testSize); 186 ImageData* imageData = ImageData::create(testSize);
181 187
182 m_asyncBlobCreator = new MockCanvasAsyncBlobCreatorWithoutStartPng( 188 m_asyncBlobCreator = new MockCanvasAsyncBlobCreatorWithoutStartPng(
183 imageData->data(), testSize, document()); 189 imageData->data(), testSize, &document());
184 } 190 }
185 191
186 void CanvasAsyncBlobCreatorTest:: 192 void CanvasAsyncBlobCreatorTest::
187 prepareMockCanvasAsyncBlobCreatorWithoutCompletePng() { 193 prepareMockCanvasAsyncBlobCreatorWithoutCompletePng() {
188 IntSize testSize(20, 20); 194 IntSize testSize(20, 20);
189 ImageData* imageData = ImageData::create(testSize); 195 ImageData* imageData = ImageData::create(testSize);
190 196
191 m_asyncBlobCreator = new MockCanvasAsyncBlobCreatorWithoutCompletePng( 197 m_asyncBlobCreator = new MockCanvasAsyncBlobCreatorWithoutCompletePng(
192 imageData->data(), testSize, document()); 198 imageData->data(), testSize, &document());
193 } 199 }
194 200
195 void CanvasAsyncBlobCreatorTest::prepareMockCanvasAsyncBlobCreatorFailPng() { 201 void CanvasAsyncBlobCreatorTest::prepareMockCanvasAsyncBlobCreatorFailPng() {
196 IntSize testSize(0, 0); 202 IntSize testSize(0, 0);
197 ImageData* imageData = ImageData::create(testSize); 203 ImageData* imageData = ImageData::create(testSize);
198 204
199 // We reuse the class MockCanvasAsyncBlobCreatorWithoutCompletePng because 205 // We reuse the class MockCanvasAsyncBlobCreatorWithoutCompletePng because
200 // this test case is expected to fail at initialization step before 206 // this test case is expected to fail at initialization step before
201 // completion. 207 // completion.
202 m_asyncBlobCreator = new MockCanvasAsyncBlobCreatorWithoutCompletePng( 208 m_asyncBlobCreator = new MockCanvasAsyncBlobCreatorWithoutCompletePng(
203 imageData->data(), testSize, document()); 209 imageData->data(), testSize, &document());
204 } 210 }
205 211
206 void CanvasAsyncBlobCreatorTest:: 212 void CanvasAsyncBlobCreatorTest::
207 prepareMockCanvasAsyncBlobCreatorWithoutStartJpeg() { 213 prepareMockCanvasAsyncBlobCreatorWithoutStartJpeg() {
208 IntSize testSize(20, 20); 214 IntSize testSize(20, 20);
209 ImageData* imageData = ImageData::create(testSize); 215 ImageData* imageData = ImageData::create(testSize);
210 216
211 m_asyncBlobCreator = new MockCanvasAsyncBlobCreatorWithoutStartJpeg( 217 m_asyncBlobCreator = new MockCanvasAsyncBlobCreatorWithoutStartJpeg(
212 imageData->data(), testSize, document()); 218 imageData->data(), testSize, &document());
213 } 219 }
214 220
215 void CanvasAsyncBlobCreatorTest:: 221 void CanvasAsyncBlobCreatorTest::
216 prepareMockCanvasAsyncBlobCreatorWithoutCompleteJpeg() { 222 prepareMockCanvasAsyncBlobCreatorWithoutCompleteJpeg() {
217 IntSize testSize(20, 20); 223 IntSize testSize(20, 20);
218 ImageData* imageData = ImageData::create(testSize); 224 ImageData* imageData = ImageData::create(testSize);
219 225
220 m_asyncBlobCreator = new MockCanvasAsyncBlobCreatorWithoutCompleteJpeg( 226 m_asyncBlobCreator = new MockCanvasAsyncBlobCreatorWithoutCompleteJpeg(
221 imageData->data(), testSize, document()); 227 imageData->data(), testSize, &document());
222 } 228 }
223 229
224 void CanvasAsyncBlobCreatorTest::prepareMockCanvasAsyncBlobCreatorFailJpeg() { 230 void CanvasAsyncBlobCreatorTest::prepareMockCanvasAsyncBlobCreatorFailJpeg() {
225 IntSize testSize(0, 0); 231 IntSize testSize(0, 0);
226 ImageData* imageData = ImageData::create(testSize); 232 ImageData* imageData = ImageData::create(testSize);
227 233
228 // We reuse the class MockCanvasAsyncBlobCreatorWithoutCompleteJpeg because 234 // We reuse the class MockCanvasAsyncBlobCreatorWithoutCompleteJpeg because
229 // this test case is expected to fail at initialization step before 235 // this test case is expected to fail at initialization step before
230 // completion. 236 // completion.
231 m_asyncBlobCreator = new MockCanvasAsyncBlobCreatorWithoutCompleteJpeg( 237 m_asyncBlobCreator = new MockCanvasAsyncBlobCreatorWithoutCompleteJpeg(
232 imageData->data(), testSize, document()); 238 imageData->data(), testSize, &document());
233 } 239 }
234 240
235 void CanvasAsyncBlobCreatorTest::TearDown() { 241 void CanvasAsyncBlobCreatorTest::TearDown() {
236 m_asyncBlobCreator = nullptr; 242 m_asyncBlobCreator = nullptr;
237 } 243 }
238 244
239 //============================================================================== 245 //==============================================================================
240 246
241 TEST_F(CanvasAsyncBlobCreatorTest, 247 TEST_F(CanvasAsyncBlobCreatorTest,
242 PngIdleTaskNotStartedWhenStartTimeoutEventHappens) { 248 PngIdleTaskNotStartedWhenStartTimeoutEventHappens) {
243 // This test mocks the scenario when idle task is not started when the 249 // This test mocks the scenario when idle task is not started when the
244 // StartTimeoutEvent is inspecting the idle task status. 250 // StartTimeoutEvent is inspecting the idle task status.
245 // The whole image encoding process (including initialization) will then 251 // The whole image encoding process (including initialization) will then
246 // become carried out in the alternative code path instead. 252 // become carried out in the alternative code path instead.
247 this->prepareMockCanvasAsyncBlobCreatorWithoutStartPng(); 253 this->prepareMockCanvasAsyncBlobCreatorWithoutStartPng();
248 EXPECT_CALL(*(asyncBlobCreator()), 254 EXPECT_CALL(*(asyncBlobCreator()),
249 signalTaskSwitchInStartTimeoutEventForTesting()); 255 signalTaskSwitchInStartTimeoutEventForTesting());
250 256
251 this->asyncBlobCreator()->scheduleAsyncBlobCreation(true); 257 this->asyncBlobCreator()->scheduleAsyncBlobCreation(true);
252 testing::enterRunLoop(); 258 testing::enterRunLoop();
253 259
254 ::testing::Mock::VerifyAndClearExpectations(asyncBlobCreator()); 260 ::testing::Mock::VerifyAndClearExpectations(asyncBlobCreator());
255 EXPECT_EQ(IdleTaskStatus::IdleTaskSwitchedToMainThreadTask, 261 EXPECT_EQ(IdleTaskStatus::IdleTaskSwitchedToImmediateTask,
256 this->asyncBlobCreator()->idleTaskStatus()); 262 this->asyncBlobCreator()->idleTaskStatus());
257 } 263 }
258 264
259 TEST_F(CanvasAsyncBlobCreatorTest, 265 TEST_F(CanvasAsyncBlobCreatorTest,
260 PngIdleTaskNotCompletedWhenCompleteTimeoutEventHappens) { 266 PngIdleTaskNotCompletedWhenCompleteTimeoutEventHappens) {
261 // This test mocks the scenario when idle task is not completed when the 267 // This test mocks the scenario when idle task is not completed when the
262 // CompleteTimeoutEvent is inspecting the idle task status. 268 // CompleteTimeoutEvent is inspecting the idle task status.
263 // The remaining image encoding process (excluding initialization) will 269 // The remaining image encoding process (excluding initialization) will
264 // then become carried out in the alternative code path instead. 270 // then become carried out in the alternative code path instead.
265 this->prepareMockCanvasAsyncBlobCreatorWithoutCompletePng(); 271 this->prepareMockCanvasAsyncBlobCreatorWithoutCompletePng();
266 EXPECT_CALL(*(asyncBlobCreator()), 272 EXPECT_CALL(*(asyncBlobCreator()),
267 signalTaskSwitchInCompleteTimeoutEventForTesting()); 273 signalTaskSwitchInCompleteTimeoutEventForTesting());
268 274
269 this->asyncBlobCreator()->scheduleAsyncBlobCreation(true); 275 this->asyncBlobCreator()->scheduleAsyncBlobCreation(true);
270 testing::enterRunLoop(); 276 testing::enterRunLoop();
271 277
272 ::testing::Mock::VerifyAndClearExpectations(asyncBlobCreator()); 278 ::testing::Mock::VerifyAndClearExpectations(asyncBlobCreator());
273 EXPECT_EQ(IdleTaskStatus::IdleTaskSwitchedToMainThreadTask, 279 EXPECT_EQ(IdleTaskStatus::IdleTaskSwitchedToImmediateTask,
274 this->asyncBlobCreator()->idleTaskStatus()); 280 this->asyncBlobCreator()->idleTaskStatus());
275 } 281 }
276 282
277 TEST_F(CanvasAsyncBlobCreatorTest, 283 TEST_F(CanvasAsyncBlobCreatorTest,
278 PngIdleTaskFailedWhenStartTimeoutEventHappens) { 284 PngIdleTaskFailedWhenStartTimeoutEventHappens) {
279 // This test mocks the scenario when idle task is not failed during when 285 // This test mocks the scenario when idle task is not failed during when
280 // either the StartTimeoutEvent or the CompleteTimeoutEvent is inspecting 286 // either the StartTimeoutEvent or the CompleteTimeoutEvent is inspecting
281 // the idle task status. 287 // the idle task status.
282 this->prepareMockCanvasAsyncBlobCreatorFailPng(); 288 this->prepareMockCanvasAsyncBlobCreatorFailPng();
283 289
284 this->asyncBlobCreator()->scheduleAsyncBlobCreation(true); 290 this->asyncBlobCreator()->scheduleAsyncBlobCreation(true);
285 testing::enterRunLoop(); 291 testing::enterRunLoop();
286 292
287 EXPECT_EQ(IdleTaskStatus::IdleTaskFailed, 293 EXPECT_EQ(IdleTaskStatus::IdleTaskFailed,
288 this->asyncBlobCreator()->idleTaskStatus()); 294 this->asyncBlobCreator()->idleTaskStatus());
289 } 295 }
290 296
291 // The below 3 unit tests have exactly same workflow as the above 3 unit tests 297 // The below 3 unit tests have exactly same workflow as the above 3 unit tests
292 // except that they are encoding on JPEG image formats instead of PNG. 298 // except that they are encoding on JPEG image formats instead of PNG.
293 TEST_F(CanvasAsyncBlobCreatorTest, 299 TEST_F(CanvasAsyncBlobCreatorTest,
294 JpegIdleTaskNotStartedWhenStartTimeoutEventHappens) { 300 JpegIdleTaskNotStartedWhenStartTimeoutEventHappens) {
295 this->prepareMockCanvasAsyncBlobCreatorWithoutStartJpeg(); 301 this->prepareMockCanvasAsyncBlobCreatorWithoutStartJpeg();
296 EXPECT_CALL(*(asyncBlobCreator()), 302 EXPECT_CALL(*(asyncBlobCreator()),
297 signalTaskSwitchInStartTimeoutEventForTesting()); 303 signalTaskSwitchInStartTimeoutEventForTesting());
298 304
299 this->asyncBlobCreator()->scheduleAsyncBlobCreation(true, 1.0); 305 this->asyncBlobCreator()->scheduleAsyncBlobCreation(1.0);
300 testing::enterRunLoop(); 306 testing::enterRunLoop();
301 307
302 ::testing::Mock::VerifyAndClearExpectations(asyncBlobCreator()); 308 ::testing::Mock::VerifyAndClearExpectations(asyncBlobCreator());
303 EXPECT_EQ(IdleTaskStatus::IdleTaskSwitchedToMainThreadTask, 309 EXPECT_EQ(IdleTaskStatus::IdleTaskSwitchedToImmediateTask,
304 this->asyncBlobCreator()->idleTaskStatus()); 310 this->asyncBlobCreator()->idleTaskStatus());
305 } 311 }
306 312
307 TEST_F(CanvasAsyncBlobCreatorTest, 313 TEST_F(CanvasAsyncBlobCreatorTest,
308 JpegIdleTaskNotCompletedWhenCompleteTimeoutEventHappens) { 314 JpegIdleTaskNotCompletedWhenCompleteTimeoutEventHappens) {
309 this->prepareMockCanvasAsyncBlobCreatorWithoutCompleteJpeg(); 315 this->prepareMockCanvasAsyncBlobCreatorWithoutCompleteJpeg();
310 EXPECT_CALL(*(asyncBlobCreator()), 316 EXPECT_CALL(*(asyncBlobCreator()),
311 signalTaskSwitchInCompleteTimeoutEventForTesting()); 317 signalTaskSwitchInCompleteTimeoutEventForTesting());
312 318
313 this->asyncBlobCreator()->scheduleAsyncBlobCreation(true, 1.0); 319 this->asyncBlobCreator()->scheduleAsyncBlobCreation(1.0);
314 testing::enterRunLoop(); 320 testing::enterRunLoop();
315 321
316 ::testing::Mock::VerifyAndClearExpectations(asyncBlobCreator()); 322 ::testing::Mock::VerifyAndClearExpectations(asyncBlobCreator());
317 EXPECT_EQ(IdleTaskStatus::IdleTaskSwitchedToMainThreadTask, 323 EXPECT_EQ(IdleTaskStatus::IdleTaskSwitchedToImmediateTask,
318 this->asyncBlobCreator()->idleTaskStatus()); 324 this->asyncBlobCreator()->idleTaskStatus());
319 } 325 }
320 326
321 TEST_F(CanvasAsyncBlobCreatorTest, 327 TEST_F(CanvasAsyncBlobCreatorTest,
322 JpegIdleTaskFailedWhenStartTimeoutEventHappens) { 328 JpegIdleTaskFailedWhenStartTimeoutEventHappens) {
323 this->prepareMockCanvasAsyncBlobCreatorFailJpeg(); 329 this->prepareMockCanvasAsyncBlobCreatorFailJpeg();
324 330
325 this->asyncBlobCreator()->scheduleAsyncBlobCreation(true, 1.0); 331 this->asyncBlobCreator()->scheduleAsyncBlobCreation(1.0);
326 testing::enterRunLoop(); 332 testing::enterRunLoop();
327 333
328 EXPECT_EQ(IdleTaskStatus::IdleTaskFailed, 334 EXPECT_EQ(IdleTaskStatus::IdleTaskFailed,
329 this->asyncBlobCreator()->idleTaskStatus()); 335 this->asyncBlobCreator()->idleTaskStatus());
330 } 336 }
331 } 337 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698