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

Side by Side Diff: third_party/WebKit/Source/core/streams/ReadableStreamOperationsTest.cpp

Issue 1898873003: Add ReadableStream operations to use it from Fetch API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@body-stream-buffer-test-refactoring
Patch Set: Created 4 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
« no previous file with comments | « third_party/WebKit/Source/core/streams/ReadableStreamOperations.cpp ('k') | 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 "core/streams/ReadableStreamOperations.h" 5 #include "core/streams/ReadableStreamOperations.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptFunction.h" 8 #include "bindings/core/v8/ScriptFunction.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "bindings/core/v8/ScriptValue.h" 10 #include "bindings/core/v8/ScriptValue.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 EXPECT_FALSE(it3->isSet()); 327 EXPECT_FALSE(it3->isSet());
328 328
329 underlyingSource->close(); 329 underlyingSource->close();
330 v8::MicrotasksScope::PerformCheckpoint(isolate()); 330 v8::MicrotasksScope::PerformCheckpoint(isolate());
331 331
332 EXPECT_TRUE(it3->isSet()); 332 EXPECT_TRUE(it3->isSet());
333 EXPECT_TRUE(it3->isValid()); 333 EXPECT_TRUE(it3->isValid());
334 EXPECT_TRUE(it3->isDone()); 334 EXPECT_TRUE(it3->isDone());
335 } 335 }
336 336
337 TEST_F(ReadableStreamOperationsTest, SetDisturbed)
338 {
339 ScriptValue stream = evalWithPrintingError("new ReadableStream()");
340 ASSERT_FALSE(stream.isEmpty());
341
342 EXPECT_FALSE(ReadableStreamOperations::isDisturbed(getScriptState(), stream) );
343 ReadableStreamOperations::setDisturbed(getScriptState(), stream);
344 EXPECT_TRUE(ReadableStreamOperations::isDisturbed(getScriptState(), stream)) ;
345 }
346
347 TEST_F(ReadableStreamOperationsTest, IsReadable)
348 {
349 ScriptValue readable = evalWithPrintingError("new ReadableStream()");
350 ScriptValue closed = evalWithPrintingError("new ReadableStream({start: c => c.close()})");
351 ScriptValue errored = evalWithPrintingError("new ReadableStream({start: c => c.error()})");
352 ASSERT_FALSE(readable.isEmpty());
353 ASSERT_FALSE(closed.isEmpty());
354 ASSERT_FALSE(errored.isEmpty());
355
356 EXPECT_TRUE(ReadableStreamOperations::isReadable(getScriptState(), readable) );
357 EXPECT_FALSE(ReadableStreamOperations::isReadable(getScriptState(), closed)) ;
358 EXPECT_FALSE(ReadableStreamOperations::isReadable(getScriptState(), errored) );
359 }
360
361 TEST_F(ReadableStreamOperationsTest, IsClosed)
362 {
363 ScriptValue readable = evalWithPrintingError("new ReadableStream()");
364 ScriptValue closed = evalWithPrintingError("new ReadableStream({start: c => c.close()})");
365 ScriptValue errored = evalWithPrintingError("new ReadableStream({start: c => c.error()})");
366 ASSERT_FALSE(readable.isEmpty());
367 ASSERT_FALSE(closed.isEmpty());
368 ASSERT_FALSE(errored.isEmpty());
369
370 EXPECT_FALSE(ReadableStreamOperations::isClosed(getScriptState(), readable)) ;
371 EXPECT_TRUE(ReadableStreamOperations::isClosed(getScriptState(), closed));
372 EXPECT_FALSE(ReadableStreamOperations::isClosed(getScriptState(), errored));
373 }
374
375 TEST_F(ReadableStreamOperationsTest, IsErrored)
376 {
377 ScriptValue readable = evalWithPrintingError("new ReadableStream()");
378 ScriptValue closed = evalWithPrintingError("new ReadableStream({start: c => c.close()})");
379 ScriptValue errored = evalWithPrintingError("new ReadableStream({start: c => c.error()})");
380 ASSERT_FALSE(readable.isEmpty());
381 ASSERT_FALSE(closed.isEmpty());
382 ASSERT_FALSE(errored.isEmpty());
383
384 EXPECT_FALSE(ReadableStreamOperations::isErrored(getScriptState(), readable) );
385 EXPECT_FALSE(ReadableStreamOperations::isErrored(getScriptState(), closed));
386 EXPECT_TRUE(ReadableStreamOperations::isErrored(getScriptState(), errored));
387 }
388
337 } // namespace 389 } // namespace
338 390
339 } // namespace blink 391 } // namespace blink
340 392
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/streams/ReadableStreamOperations.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698