| 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/FetchBlobDataConsumerHandle.h" | 5 #include "modules/fetch/FetchBlobDataConsumerHandle.h" |
| 6 | 6 |
| 7 #include "core/dom/ExecutionContext.h" | 7 #include "core/dom/ExecutionContext.h" |
| 8 #include "core/fetch/ResourceLoaderOptions.h" | 8 #include "core/fetch/ResourceLoaderOptions.h" |
| 9 #include "core/loader/ThreadableLoader.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/blob/BlobData.h" | 13 #include "platform/blob/BlobData.h" |
| 14 #include "platform/blob/BlobURL.h" | 14 #include "platform/blob/BlobURL.h" |
| 15 #include "platform/network/ResourceError.h" | 15 #include "platform/network/ResourceError.h" |
| 16 #include "platform/network/ResourceRequest.h" | 16 #include "platform/network/ResourceRequest.h" |
| 17 #include "platform/network/ResourceResponse.h" | 17 #include "platform/network/ResourceResponse.h" |
| 18 #include "platform/testing/UnitTestHelpers.h" | 18 #include "platform/testing/UnitTestHelpers.h" |
| 19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 47 using ::testing::Return; | 47 using ::testing::Return; |
| 48 using ::testing::SaveArg; | 48 using ::testing::SaveArg; |
| 49 using ::testing::StrictMock; | 49 using ::testing::StrictMock; |
| 50 using Checkpoint = StrictMock<::testing::MockFunction<void(int)>>; | 50 using Checkpoint = StrictMock<::testing::MockFunction<void(int)>>; |
| 51 | 51 |
| 52 class MockLoaderFactory : public FetchBlobDataConsumerHandle::LoaderFactory { | 52 class MockLoaderFactory : public FetchBlobDataConsumerHandle::LoaderFactory { |
| 53 public: | 53 public: |
| 54 MOCK_METHOD5(create, PassRefPtr<ThreadableLoader>(ExecutionContext&, Threada
bleLoaderClient*, const ResourceRequest&, const ThreadableLoaderOptions&, const
ResourceLoaderOptions&)); | 54 MOCK_METHOD5(create, PassRefPtr<ThreadableLoader>(ExecutionContext&, Threada
bleLoaderClient*, const ResourceRequest&, const ThreadableLoaderOptions&, const
ResourceLoaderOptions&)); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 class MockThreadableLoader : public ThreadableLoader { | |
| 58 public: | |
| 59 static PassRefPtr<MockThreadableLoader> create() { return adoptRef(new Stric
tMock<MockThreadableLoader>); } | |
| 60 | |
| 61 MOCK_METHOD1(overrideTimeout, void(unsigned long)); | |
| 62 MOCK_METHOD0(cancel, void()); | |
| 63 | |
| 64 protected: | |
| 65 MockThreadableLoader() = default; | |
| 66 }; | |
| 67 | |
| 68 PassRefPtr<BlobDataHandle> createBlobDataHandle(const char* s) | 57 PassRefPtr<BlobDataHandle> createBlobDataHandle(const char* s) |
| 69 { | 58 { |
| 70 OwnPtr<BlobData> data = BlobData::create(); | 59 OwnPtr<BlobData> data = BlobData::create(); |
| 71 data->appendText(s, false); | 60 data->appendText(s, false); |
| 72 auto size = data->length(); | 61 auto size = data->length(); |
| 73 return BlobDataHandle::create(data.release(), size); | 62 return BlobDataHandle::create(data.release(), size); |
| 74 } | 63 } |
| 75 | 64 |
| 76 String toString(const Vector<char>& data) | 65 String toString(const Vector<char>& data) |
| 77 { | 66 { |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 OwnPtr<FetchDataConsumerHandle::Reader> reader = handle->obtainReader(nullpt
r); | 404 OwnPtr<FetchDataConsumerHandle::Reader> reader = handle->obtainReader(nullpt
r); |
| 416 | 405 |
| 417 const void* buffer; | 406 const void* buffer; |
| 418 size_t available; | 407 size_t available; |
| 419 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available)); | 408 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available)); |
| 420 EXPECT_FALSE(reader->drainAsBlobDataHandle()); | 409 EXPECT_FALSE(reader->drainAsBlobDataHandle()); |
| 421 } | 410 } |
| 422 | 411 |
| 423 } // namespace | 412 } // namespace |
| 424 } // namespace blink | 413 } // namespace blink |
| OLD | NEW |