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

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

Issue 2303753003: [Fetch API] Start reading blob only when the reader wants to read contents. (Closed)
Patch Set: fix tests Created 4 years, 3 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/modules/fetch/FetchBlobDataConsumerHandleTest.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 "modules/fetch/FetchFormDataConsumerHandle.h" 5 #include "modules/fetch/FetchFormDataConsumerHandle.h"
6 6
7 #include "core/dom/DOMTypedArray.h" 7 #include "core/dom/DOMTypedArray.h"
8 #include "core/html/FormData.h" 8 #include "core/html/FormData.h"
9 #include "core/loader/MockThreadableLoader.h" 9 #include "core/loader/MockThreadableLoader.h"
10 #include "core/loader/ThreadableLoaderClient.h" 10 #include "core/loader/ThreadableLoaderClient.h"
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 TEST_F(FetchFormDataConsumerHandleTest, ZeroByteReadDoesNotAffectDrainingForComp lexFormData) 394 TEST_F(FetchFormDataConsumerHandleTest, ZeroByteReadDoesNotAffectDrainingForComp lexFormData)
395 { 395 {
396 std::unique_ptr<ReplayingHandle> src = ReplayingHandle::create(); 396 std::unique_ptr<ReplayingHandle> src = ReplayingHandle::create();
397 src->add(Command(Command::Data, "bar")); 397 src->add(Command(Command::Data, "bar"));
398 src->add(Command(Command::Done)); 398 src->add(Command(Command::Done));
399 std::unique_ptr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandl e::createForTest(getDocument(), complexFormData(), new LoaderFactory(std::move(s rc))); 399 std::unique_ptr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandl e::createForTest(getDocument(), complexFormData(), new LoaderFactory(std::move(s rc)));
400 std::unique_ptr<FetchDataConsumerHandle::Reader> reader = handle->obtainFetc hDataReader(nullptr); 400 std::unique_ptr<FetchDataConsumerHandle::Reader> reader = handle->obtainFetc hDataReader(nullptr);
401 size_t readSize; 401 size_t readSize;
402 EXPECT_EQ(kShouldWait, reader->read(nullptr, 0, kNone, &readSize)); 402 EXPECT_EQ(kShouldWait, reader->read(nullptr, 0, kNone, &readSize));
403 testing::runPendingTasks(); 403 testing::runPendingTasks();
404 EXPECT_EQ(kOk, reader->read(nullptr, 0, kNone, &readSize));
hiroshige 2016/09/07 09:38:03 Why this line is removed?
yhirano 2016/09/07 11:03:24 My change makes this read return kShouldWait, and
405 RefPtr<EncodedFormData> formData = reader->drainAsFormData(); 404 RefPtr<EncodedFormData> formData = reader->drainAsFormData();
406 ASSERT_TRUE(formData); 405 ASSERT_TRUE(formData);
407 EXPECT_TRUE(formData->isSafeToSendToAnotherThread()); 406 EXPECT_TRUE(formData->isSafeToSendToAnotherThread());
408 verifyComplexFormData(formData.get()); 407 verifyComplexFormData(formData.get());
409 } 408 }
410 409
411 TEST_F(FetchFormDataConsumerHandleTest, OneByteReadAffectsDrainingForComplexForm Data) 410 TEST_F(FetchFormDataConsumerHandleTest, OneByteReadAffectsDrainingForComplexForm Data)
412 { 411 {
413 std::unique_ptr<ReplayingHandle> src = ReplayingHandle::create(); 412 std::unique_ptr<ReplayingHandle> src = ReplayingHandle::create();
414 src->add(Command(Command::Data, "bar")); 413 src->add(Command(Command::Data, "bar"));
(...skipping 22 matching lines...) Expand all
437 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available)); 436 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available));
438 testing::runPendingTasks(); 437 testing::runPendingTasks();
439 EXPECT_EQ(kOk, reader->beginRead(&buffer, kNone, &available)); 438 EXPECT_EQ(kOk, reader->beginRead(&buffer, kNone, &available));
440 EXPECT_FALSE(reader->drainAsFormData()); 439 EXPECT_FALSE(reader->drainAsFormData());
441 reader->endRead(0); 440 reader->endRead(0);
442 EXPECT_FALSE(reader->drainAsFormData()); 441 EXPECT_FALSE(reader->drainAsFormData());
443 } 442 }
444 443
445 } // namespace 444 } // namespace
446 } // namespace blink 445 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698