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

Unified Diff: third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp

Issue 1264453002: Split the constructor of ThreadableLoader into two methods (ctor and start()) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Uplaod MockThreadableLoader Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp b/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp
index 65f8eeddd0ba624f2ccbf43540b9b9c4d7037915..1e80822c7ba7c9bef17e587f036a280e8405e106 100644
--- a/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp
@@ -6,7 +6,7 @@
#include "core/dom/ExecutionContext.h"
#include "core/fetch/ResourceLoaderOptions.h"
-#include "core/loader/ThreadableLoader.h"
+#include "core/loader/MockThreadableLoader.h"
#include "core/loader/ThreadableLoaderClient.h"
#include "core/testing/DummyPageHolder.h"
#include "modules/fetch/DataConsumerHandleTestUtil.h"
@@ -51,18 +51,7 @@ using Checkpoint = StrictMock<::testing::MockFunction<void(int)>>;
class MockLoaderFactory : public FetchBlobDataConsumerHandle::LoaderFactory {
public:
- MOCK_METHOD5(create, PassRefPtr<ThreadableLoader>(ExecutionContext&, ThreadableLoaderClient*, const ResourceRequest&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&));
-};
-
-class MockThreadableLoader : public ThreadableLoader {
-public:
- static PassRefPtr<MockThreadableLoader> create() { return adoptRef(new StrictMock<MockThreadableLoader>); }
-
- MOCK_METHOD1(overrideTimeout, void(unsigned long));
- MOCK_METHOD0(cancel, void());
-
-protected:
- MockThreadableLoader() = default;
+ MOCK_METHOD4(create, PassRefPtr<ThreadableLoader>(ExecutionContext&, ThreadableLoaderClient*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&));
};
PassRefPtr<BlobDataHandle> createBlobDataHandle(const char* s)
@@ -108,11 +97,11 @@ TEST_F(FetchBlobDataConsumerHandleTest, CreateLoader)
InSequence s;
EXPECT_CALL(checkpoint, Call(1));
- EXPECT_CALL(*factory, create(Ref(document()), _, _, _, _)).WillOnce(DoAll(
- SaveArg<2>(&request),
- SaveArg<3>(&options),
- SaveArg<4>(&resourceLoaderOptions),
+ EXPECT_CALL(*factory, create(Ref(document()), _, _, _)).WillOnce(DoAll(
+ SaveArg<2>(&options),
+ SaveArg<3>(&resourceLoaderOptions),
Return(loader.get())));
+ EXPECT_CALL(*loader, start(_)).WillOnce(SaveArg<0>(&request));
EXPECT_CALL(checkpoint, Call(2));
EXPECT_CALL(*loader, cancel());
@@ -152,7 +141,8 @@ TEST_F(FetchBlobDataConsumerHandleTest, CancelLoaderWhenStopped)
InSequence s;
EXPECT_CALL(checkpoint, Call(1));
- EXPECT_CALL(*factory, create(Ref(document()), _, _, _, _)).WillOnce(Return(loader.get()));
+ EXPECT_CALL(*factory, create(Ref(document()), _, _, _)).WillOnce(Return(loader.get()));
+ EXPECT_CALL(*loader, start(_));
EXPECT_CALL(checkpoint, Call(2));
EXPECT_CALL(*loader, cancel());
EXPECT_CALL(checkpoint, Call(3));
@@ -180,7 +170,8 @@ TEST_F(FetchBlobDataConsumerHandleTest, CancelLoaderWhenDestinationDetached)
InSequence s;
EXPECT_CALL(checkpoint, Call(1));
- EXPECT_CALL(*factory, create(Ref(document()), _, _, _, _)).WillOnce(Return(loader.get()));
+ EXPECT_CALL(*factory, create(Ref(document()), _, _, _)).WillOnce(Return(loader.get()));
+ EXPECT_CALL(*loader, start(_));
EXPECT_CALL(checkpoint, Call(2));
EXPECT_CALL(checkpoint, Call(3));
EXPECT_CALL(*loader, cancel());
@@ -214,7 +205,8 @@ TEST_F(FetchBlobDataConsumerHandleTest, ReadTest)
InSequence s;
EXPECT_CALL(checkpoint, Call(1));
- EXPECT_CALL(*factory, create(Ref(document()), _, _, _, _)).WillOnce(DoAll(SaveArg<1>(&client), Return(loader.get())));
+ EXPECT_CALL(*factory, create(Ref(document()), _, _, _)).WillOnce(DoAll(SaveArg<1>(&client), Return(loader.get())));
+ EXPECT_CALL(*loader, start(_));
EXPECT_CALL(checkpoint, Call(2));
EXPECT_CALL(*loader, cancel());
@@ -251,7 +243,8 @@ TEST_F(FetchBlobDataConsumerHandleTest, TwoPhaseReadTest)
InSequence s;
EXPECT_CALL(checkpoint, Call(1));
- EXPECT_CALL(*factory, create(Ref(document()), _, _, _, _)).WillOnce(DoAll(SaveArg<1>(&client), Return(loader.get())));
+ EXPECT_CALL(*factory, create(Ref(document()), _, _, _)).WillOnce(DoAll(SaveArg<1>(&client), Return(loader.get())));
+ EXPECT_CALL(*loader, start(_));
EXPECT_CALL(checkpoint, Call(2));
EXPECT_CALL(*loader, cancel());
@@ -288,7 +281,8 @@ TEST_F(FetchBlobDataConsumerHandleTest, LoadErrorTest)
InSequence s;
EXPECT_CALL(checkpoint, Call(1));
- EXPECT_CALL(*factory, create(Ref(document()), _, _, _, _)).WillOnce(DoAll(SaveArg<1>(&client), Return(loader.get())));
+ EXPECT_CALL(*factory, create(Ref(document()), _, _, _)).WillOnce(DoAll(SaveArg<1>(&client), Return(loader.get())));
+ EXPECT_CALL(*loader, start(_));
EXPECT_CALL(checkpoint, Call(2));
RefPtr<BlobDataHandle> blobDataHandle = createBlobDataHandle("Once upon a time");
@@ -316,7 +310,8 @@ TEST_F(FetchBlobDataConsumerHandleTest, BodyLoadErrorTest)
InSequence s;
EXPECT_CALL(checkpoint, Call(1));
- EXPECT_CALL(*factory, create(Ref(document()), _, _, _, _)).WillOnce(DoAll(SaveArg<1>(&client), Return(loader.get())));
+ EXPECT_CALL(*factory, create(Ref(document()), _, _, _)).WillOnce(DoAll(SaveArg<1>(&client), Return(loader.get())));
+ EXPECT_CALL(*loader, start(_));
EXPECT_CALL(checkpoint, Call(2));
EXPECT_CALL(*loader, cancel());

Powered by Google App Engine
This is Rietveld 408576698