| OLD | NEW |
| 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" |
| 11 #include "core/testing/DummyPageHolder.h" | 11 #include "core/testing/DummyPageHolder.h" |
| 12 #include "modules/fetch/DataConsumerHandleTestUtil.h" | 12 #include "modules/fetch/DataConsumerHandleTestUtil.h" |
| 13 #include "platform/network/ResourceResponse.h" | 13 #include "platform/network/ResourceResponse.h" |
| 14 #include "platform/testing/UnitTestHelpers.h" | 14 #include "platform/testing/UnitTestHelpers.h" |
| 15 #include "platform/weborigin/KURL.h" | 15 #include "platform/weborigin/KURL.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "wtf/OwnPtr.h" |
| 18 #include "wtf/PassOwnPtr.h" | 19 #include "wtf/PassOwnPtr.h" |
| 19 #include "wtf/PassRefPtr.h" | 20 #include "wtf/PassRefPtr.h" |
| 20 #include "wtf/RefPtr.h" | 21 #include "wtf/RefPtr.h" |
| 21 #include "wtf/Vector.h" | 22 #include "wtf/Vector.h" |
| 22 #include "wtf/text/TextEncoding.h" | 23 #include "wtf/text/TextEncoding.h" |
| 23 #include "wtf/text/WTFString.h" | 24 #include "wtf/text/WTFString.h" |
| 24 #include <string.h> | 25 #include <string.h> |
| 25 | 26 |
| 26 namespace blink { | 27 namespace blink { |
| 27 namespace { | 28 namespace { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 45 String toString(const Vector<char>& data) | 46 String toString(const Vector<char>& data) |
| 46 { | 47 { |
| 47 return String(data.data(), data.size()); | 48 return String(data.data(), data.size()); |
| 48 } | 49 } |
| 49 | 50 |
| 50 class LoaderFactory : public FetchBlobDataConsumerHandle::LoaderFactory { | 51 class LoaderFactory : public FetchBlobDataConsumerHandle::LoaderFactory { |
| 51 public: | 52 public: |
| 52 explicit LoaderFactory(PassOwnPtr<WebDataConsumerHandle> handle) | 53 explicit LoaderFactory(PassOwnPtr<WebDataConsumerHandle> handle) |
| 53 : m_client(nullptr) | 54 : m_client(nullptr) |
| 54 , m_handle(handle) {} | 55 , m_handle(handle) {} |
| 55 PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoaderClien
t* client, const ThreadableLoaderOptions&, const ResourceLoaderOptions&) overrid
e | 56 PassOwnPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoaderClien
t* client, const ThreadableLoaderOptions&, const ResourceLoaderOptions&) overrid
e |
| 56 { | 57 { |
| 57 m_client = client; | 58 m_client = client; |
| 58 | 59 |
| 59 RefPtr<MockThreadableLoader> loader = MockThreadableLoader::create(); | 60 OwnPtr<MockThreadableLoader> loader = MockThreadableLoader::create(); |
| 60 EXPECT_CALL(*loader, start(_)).WillOnce(InvokeWithoutArgs(this, &LoaderF
actory::handleDidReceiveResponse)); | 61 EXPECT_CALL(*loader, start(_)).WillOnce(InvokeWithoutArgs(this, &LoaderF
actory::handleDidReceiveResponse)); |
| 61 EXPECT_CALL(*loader, cancel()).Times(1); | 62 EXPECT_CALL(*loader, cancel()).Times(1); |
| 62 return loader.release(); | 63 return loader.release(); |
| 63 } | 64 } |
| 64 | 65 |
| 65 private: | 66 private: |
| 66 void handleDidReceiveResponse() | 67 void handleDidReceiveResponse() |
| 67 { | 68 { |
| 68 m_client->didReceiveResponse(0, ResourceResponse(), m_handle.release()); | 69 m_client->didReceiveResponse(0, ResourceResponse(), m_handle.release()); |
| 69 } | 70 } |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available)); | 438 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available)); |
| 438 testing::runPendingTasks(); | 439 testing::runPendingTasks(); |
| 439 EXPECT_EQ(kOk, reader->beginRead(&buffer, kNone, &available)); | 440 EXPECT_EQ(kOk, reader->beginRead(&buffer, kNone, &available)); |
| 440 EXPECT_FALSE(reader->drainAsFormData()); | 441 EXPECT_FALSE(reader->drainAsFormData()); |
| 441 reader->endRead(0); | 442 reader->endRead(0); |
| 442 EXPECT_FALSE(reader->drainAsFormData()); | 443 EXPECT_FALSE(reader->drainAsFormData()); |
| 443 } | 444 } |
| 444 | 445 |
| 445 } // namespace | 446 } // namespace |
| 446 } // namespace blink | 447 } // namespace blink |
| OLD | NEW |