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

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

Issue 1656673003: Factor out MockThreadableLoader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added an include guard Created 4 years, 10 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
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/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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698