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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp

Issue 1940763002: Use Persistent to retain pointers on unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "modules/fetch/ReadableStreamDataConsumerHandle.h" 5 #include "modules/fetch/ReadableStreamDataConsumerHandle.h"
6 6
7 #include "bindings/core/v8/ScriptState.h" 7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/V8BindingMacros.h" 8 #include "bindings/core/v8/V8BindingMacros.h"
9 #include "bindings/core/v8/V8GCController.h" 9 #include "bindings/core/v8/V8GCController.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 OwnPtr<DummyPageHolder> m_page; 96 OwnPtr<DummyPageHolder> m_page;
97 }; 97 };
98 98
99 TEST_F(ReadableStreamDataConsumerHandleTest, Create) 99 TEST_F(ReadableStreamDataConsumerHandleTest, Create)
100 { 100 {
101 ScriptState::Scope scope(getScriptState()); 101 ScriptState::Scope scope(getScriptState());
102 ScriptValue stream(getScriptState(), evalWithPrintingError("new ReadableStre am")); 102 ScriptValue stream(getScriptState(), evalWithPrintingError("new ReadableStre am"));
103 ASSERT_FALSE(stream.isEmpty()); 103 ASSERT_FALSE(stream.isEmpty());
104 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream); 104 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream);
105 ASSERT_TRUE(handle); 105 ASSERT_TRUE(handle);
106 MockClient* client = MockClient::create(); 106 Persistent<MockClient> client = MockClient::create();
107 Checkpoint checkpoint; 107 Checkpoint checkpoint;
108 108
109 InSequence s; 109 InSequence s;
110 EXPECT_CALL(checkpoint, Call(1)); 110 EXPECT_CALL(checkpoint, Call(1));
111 EXPECT_CALL(*client, didGetReadable()); 111 EXPECT_CALL(*client, didGetReadable());
112 EXPECT_CALL(checkpoint, Call(2)); 112 EXPECT_CALL(checkpoint, Call(2));
113 113
114 OwnPtr<FetchDataConsumerHandle::Reader> reader = handle->obtainReader(client ); 114 OwnPtr<FetchDataConsumerHandle::Reader> reader = handle->obtainReader(client );
115 ASSERT_TRUE(reader); 115 ASSERT_TRUE(reader);
116 checkpoint.Call(1); 116 checkpoint.Call(1);
117 testing::runPendingTasks(); 117 testing::runPendingTasks();
118 checkpoint.Call(2); 118 checkpoint.Call(2);
119 } 119 }
120 120
121 TEST_F(ReadableStreamDataConsumerHandleTest, EmptyStream) 121 TEST_F(ReadableStreamDataConsumerHandleTest, EmptyStream)
122 { 122 {
123 ScriptState::Scope scope(getScriptState()); 123 ScriptState::Scope scope(getScriptState());
124 ScriptValue stream(getScriptState(), evalWithPrintingError( 124 ScriptValue stream(getScriptState(), evalWithPrintingError(
125 "new ReadableStream({start: c => c.close()})")); 125 "new ReadableStream({start: c => c.close()})"));
126 ASSERT_FALSE(stream.isEmpty()); 126 ASSERT_FALSE(stream.isEmpty());
127 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream); 127 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream);
128 ASSERT_TRUE(handle); 128 ASSERT_TRUE(handle);
129 MockClient* client = MockClient::create(); 129 Persistent<MockClient> client = MockClient::create();
130 Checkpoint checkpoint; 130 Checkpoint checkpoint;
131 131
132 InSequence s; 132 InSequence s;
133 EXPECT_CALL(checkpoint, Call(1)); 133 EXPECT_CALL(checkpoint, Call(1));
134 EXPECT_CALL(*client, didGetReadable()); 134 EXPECT_CALL(*client, didGetReadable());
135 EXPECT_CALL(checkpoint, Call(2)); 135 EXPECT_CALL(checkpoint, Call(2));
136 EXPECT_CALL(*client, didGetReadable()); 136 EXPECT_CALL(*client, didGetReadable());
137 EXPECT_CALL(checkpoint, Call(3)); 137 EXPECT_CALL(checkpoint, Call(3));
138 138
139 char c; 139 char c;
(...skipping 10 matching lines...) Expand all
150 } 150 }
151 151
152 TEST_F(ReadableStreamDataConsumerHandleTest, ErroredStream) 152 TEST_F(ReadableStreamDataConsumerHandleTest, ErroredStream)
153 { 153 {
154 ScriptState::Scope scope(getScriptState()); 154 ScriptState::Scope scope(getScriptState());
155 ScriptValue stream(getScriptState(), evalWithPrintingError( 155 ScriptValue stream(getScriptState(), evalWithPrintingError(
156 "new ReadableStream({start: c => c.error()})")); 156 "new ReadableStream({start: c => c.error()})"));
157 ASSERT_FALSE(stream.isEmpty()); 157 ASSERT_FALSE(stream.isEmpty());
158 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream); 158 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream);
159 ASSERT_TRUE(handle); 159 ASSERT_TRUE(handle);
160 MockClient* client = MockClient::create(); 160 Persistent<MockClient> client = MockClient::create();
161 Checkpoint checkpoint; 161 Checkpoint checkpoint;
162 162
163 InSequence s; 163 InSequence s;
164 EXPECT_CALL(checkpoint, Call(1)); 164 EXPECT_CALL(checkpoint, Call(1));
165 EXPECT_CALL(*client, didGetReadable()); 165 EXPECT_CALL(*client, didGetReadable());
166 EXPECT_CALL(checkpoint, Call(2)); 166 EXPECT_CALL(checkpoint, Call(2));
167 EXPECT_CALL(*client, didGetReadable()); 167 EXPECT_CALL(*client, didGetReadable());
168 EXPECT_CALL(checkpoint, Call(3)); 168 EXPECT_CALL(checkpoint, Call(3));
169 169
170 char c; 170 char c;
(...skipping 16 matching lines...) Expand all
187 "var controller;" 187 "var controller;"
188 "var stream = new ReadableStream({start: c => controller = c});" 188 "var stream = new ReadableStream({start: c => controller = c});"
189 "controller.enqueue(new Uint8Array());" 189 "controller.enqueue(new Uint8Array());"
190 "controller.enqueue(new Uint8Array([0x43, 0x44, 0x45, 0x46]));" 190 "controller.enqueue(new Uint8Array([0x43, 0x44, 0x45, 0x46]));"
191 "controller.enqueue(new Uint8Array([0x47, 0x48, 0x49, 0x4a]));" 191 "controller.enqueue(new Uint8Array([0x47, 0x48, 0x49, 0x4a]));"
192 "controller.close();" 192 "controller.close();"
193 "stream")); 193 "stream"));
194 ASSERT_FALSE(stream.isEmpty()); 194 ASSERT_FALSE(stream.isEmpty());
195 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream); 195 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream);
196 ASSERT_TRUE(handle); 196 ASSERT_TRUE(handle);
197 MockClient* client = MockClient::create(); 197 Persistent<MockClient> client = MockClient::create();
198 Checkpoint checkpoint; 198 Checkpoint checkpoint;
199 199
200 InSequence s; 200 InSequence s;
201 EXPECT_CALL(checkpoint, Call(1)); 201 EXPECT_CALL(checkpoint, Call(1));
202 EXPECT_CALL(*client, didGetReadable()); 202 EXPECT_CALL(*client, didGetReadable());
203 EXPECT_CALL(checkpoint, Call(2)); 203 EXPECT_CALL(checkpoint, Call(2));
204 EXPECT_CALL(*client, didGetReadable()); 204 EXPECT_CALL(*client, didGetReadable());
205 EXPECT_CALL(checkpoint, Call(3)); 205 EXPECT_CALL(checkpoint, Call(3));
206 EXPECT_CALL(*client, didGetReadable()); 206 EXPECT_CALL(*client, didGetReadable());
207 EXPECT_CALL(checkpoint, Call(4)); 207 EXPECT_CALL(checkpoint, Call(4));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 "var controller;" 255 "var controller;"
256 "var stream = new ReadableStream({start: c => controller = c});" 256 "var stream = new ReadableStream({start: c => controller = c});"
257 "controller.enqueue(new Uint8Array());" 257 "controller.enqueue(new Uint8Array());"
258 "controller.enqueue(new Uint8Array([0x43, 0x44, 0x45, 0x46]));" 258 "controller.enqueue(new Uint8Array([0x43, 0x44, 0x45, 0x46]));"
259 "controller.enqueue(new Uint8Array([0x47, 0x48, 0x49, 0x4a]));" 259 "controller.enqueue(new Uint8Array([0x47, 0x48, 0x49, 0x4a]));"
260 "controller.close();" 260 "controller.close();"
261 "stream")); 261 "stream"));
262 ASSERT_FALSE(stream.isEmpty()); 262 ASSERT_FALSE(stream.isEmpty());
263 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream); 263 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream);
264 ASSERT_TRUE(handle); 264 ASSERT_TRUE(handle);
265 MockClient* client = MockClient::create(); 265 Persistent<MockClient> client = MockClient::create();
266 Checkpoint checkpoint; 266 Checkpoint checkpoint;
267 267
268 InSequence s; 268 InSequence s;
269 EXPECT_CALL(checkpoint, Call(1)); 269 EXPECT_CALL(checkpoint, Call(1));
270 EXPECT_CALL(*client, didGetReadable()); 270 EXPECT_CALL(*client, didGetReadable());
271 EXPECT_CALL(checkpoint, Call(2)); 271 EXPECT_CALL(checkpoint, Call(2));
272 EXPECT_CALL(*client, didGetReadable()); 272 EXPECT_CALL(*client, didGetReadable());
273 EXPECT_CALL(checkpoint, Call(3)); 273 EXPECT_CALL(checkpoint, Call(3));
274 EXPECT_CALL(*client, didGetReadable()); 274 EXPECT_CALL(*client, didGetReadable());
275 EXPECT_CALL(checkpoint, Call(4)); 275 EXPECT_CALL(checkpoint, Call(4));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 ScriptState::Scope scope(getScriptState()); 332 ScriptState::Scope scope(getScriptState());
333 ScriptValue stream(getScriptState(), evalWithPrintingError( 333 ScriptValue stream(getScriptState(), evalWithPrintingError(
334 "var controller;" 334 "var controller;"
335 "var stream = new ReadableStream({start: c => controller = c});" 335 "var stream = new ReadableStream({start: c => controller = c});"
336 "controller.enqueue(undefined);" 336 "controller.enqueue(undefined);"
337 "controller.close();" 337 "controller.close();"
338 "stream")); 338 "stream"));
339 ASSERT_FALSE(stream.isEmpty()); 339 ASSERT_FALSE(stream.isEmpty());
340 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream); 340 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream);
341 ASSERT_TRUE(handle); 341 ASSERT_TRUE(handle);
342 MockClient* client = MockClient::create(); 342 Persistent<MockClient> client = MockClient::create();
343 Checkpoint checkpoint; 343 Checkpoint checkpoint;
344 344
345 InSequence s; 345 InSequence s;
346 EXPECT_CALL(checkpoint, Call(1)); 346 EXPECT_CALL(checkpoint, Call(1));
347 EXPECT_CALL(*client, didGetReadable()); 347 EXPECT_CALL(*client, didGetReadable());
348 EXPECT_CALL(checkpoint, Call(2)); 348 EXPECT_CALL(checkpoint, Call(2));
349 EXPECT_CALL(*client, didGetReadable()); 349 EXPECT_CALL(*client, didGetReadable());
350 EXPECT_CALL(checkpoint, Call(3)); 350 EXPECT_CALL(checkpoint, Call(3));
351 351
352 const void* buffer; 352 const void* buffer;
(...skipping 14 matching lines...) Expand all
367 ScriptState::Scope scope(getScriptState()); 367 ScriptState::Scope scope(getScriptState());
368 ScriptValue stream(getScriptState(), evalWithPrintingError( 368 ScriptValue stream(getScriptState(), evalWithPrintingError(
369 "var controller;" 369 "var controller;"
370 "var stream = new ReadableStream({start: c => controller = c});" 370 "var stream = new ReadableStream({start: c => controller = c});"
371 "controller.enqueue(null);" 371 "controller.enqueue(null);"
372 "controller.close();" 372 "controller.close();"
373 "stream")); 373 "stream"));
374 ASSERT_FALSE(stream.isEmpty()); 374 ASSERT_FALSE(stream.isEmpty());
375 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream); 375 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream);
376 ASSERT_TRUE(handle); 376 ASSERT_TRUE(handle);
377 MockClient* client = MockClient::create(); 377 Persistent<MockClient> client = MockClient::create();
378 Checkpoint checkpoint; 378 Checkpoint checkpoint;
379 379
380 InSequence s; 380 InSequence s;
381 EXPECT_CALL(checkpoint, Call(1)); 381 EXPECT_CALL(checkpoint, Call(1));
382 EXPECT_CALL(*client, didGetReadable()); 382 EXPECT_CALL(*client, didGetReadable());
383 EXPECT_CALL(checkpoint, Call(2)); 383 EXPECT_CALL(checkpoint, Call(2));
384 EXPECT_CALL(*client, didGetReadable()); 384 EXPECT_CALL(*client, didGetReadable());
385 EXPECT_CALL(checkpoint, Call(3)); 385 EXPECT_CALL(checkpoint, Call(3));
386 386
387 const void* buffer; 387 const void* buffer;
(...skipping 14 matching lines...) Expand all
402 ScriptState::Scope scope(getScriptState()); 402 ScriptState::Scope scope(getScriptState());
403 ScriptValue stream(getScriptState(), evalWithPrintingError( 403 ScriptValue stream(getScriptState(), evalWithPrintingError(
404 "var controller;" 404 "var controller;"
405 "var stream = new ReadableStream({start: c => controller = c});" 405 "var stream = new ReadableStream({start: c => controller = c});"
406 "controller.enqueue('hello');" 406 "controller.enqueue('hello');"
407 "controller.close();" 407 "controller.close();"
408 "stream")); 408 "stream"));
409 ASSERT_FALSE(stream.isEmpty()); 409 ASSERT_FALSE(stream.isEmpty());
410 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream); 410 OwnPtr<ReadableStreamDataConsumerHandle> handle = createHandle(stream);
411 ASSERT_TRUE(handle); 411 ASSERT_TRUE(handle);
412 MockClient* client = MockClient::create(); 412 Persistent<MockClient> client = MockClient::create();
413 Checkpoint checkpoint; 413 Checkpoint checkpoint;
414 414
415 InSequence s; 415 InSequence s;
416 EXPECT_CALL(checkpoint, Call(1)); 416 EXPECT_CALL(checkpoint, Call(1));
417 EXPECT_CALL(*client, didGetReadable()); 417 EXPECT_CALL(*client, didGetReadable());
418 EXPECT_CALL(checkpoint, Call(2)); 418 EXPECT_CALL(checkpoint, Call(2));
419 EXPECT_CALL(*client, didGetReadable()); 419 EXPECT_CALL(*client, didGetReadable());
420 EXPECT_CALL(checkpoint, Call(3)); 420 EXPECT_CALL(checkpoint, Call(3));
421 421
422 const void* buffer; 422 const void* buffer;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 testing::runPendingTasks(); 516 testing::runPendingTasks();
517 517
518 checkpoint.Call(5); 518 checkpoint.Call(5);
519 EXPECT_EQ(kUnexpectedError, reader->beginRead(&buffer, kNone, &available)); 519 EXPECT_EQ(kUnexpectedError, reader->beginRead(&buffer, kNone, &available));
520 } 520 }
521 521
522 } // namespace 522 } // namespace
523 523
524 } // namespace blink 524 } // namespace blink
525 525
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698