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

Unified Diff: third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandleTest.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/FetchFormDataConsumerHandleTest.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandleTest.cpp b/third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandleTest.cpp
index b79f4ea2e6f87910c434df582563b098a14f3e1b..34af58149e8db3ffa624290a972332d2ff88727d 100644
--- a/third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandleTest.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandleTest.cpp
@@ -6,14 +6,16 @@
#include "core/dom/DOMTypedArray.h"
#include "core/html/FormData.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"
#include "platform/network/ResourceResponse.h"
#include "platform/testing/UnitTestHelpers.h"
#include "platform/weborigin/KURL.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "wtf/PassOwnPtr.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefPtr.h"
#include "wtf/Vector.h"
@@ -37,29 +39,36 @@ using HandleReaderRunner = DataConsumerHandleTestUtil::HandleReaderRunner<T>;
using ReplayingHandle = DataConsumerHandleTestUtil::ReplayingHandle;
using Command = DataConsumerHandleTestUtil::Command;
+using ::testing::_;
+using ::testing::InvokeWithoutArgs;
+
String toString(const Vector<char>& data)
{
return String(data.data(), data.size());
}
-class NoopLoader final : public ThreadableLoader {
-public:
- static PassRefPtr<ThreadableLoader> create() { return adoptRef(new NoopLoader); }
- void overrideTimeout(unsigned long) override {}
- void cancel() override {}
-};
-
class LoaderFactory : public FetchBlobDataConsumerHandle::LoaderFactory {
public:
- explicit LoaderFactory(PassOwnPtr<WebDataConsumerHandle> handle) : m_handle(handle) {}
- PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoaderClient* client, const ResourceRequest&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&) override
+ explicit LoaderFactory(PassOwnPtr<WebDataConsumerHandle> handle)
+ : m_client(nullptr)
+ , m_handle(handle) {}
+ PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoaderClient* client, const ThreadableLoaderOptions&, const ResourceLoaderOptions&) override
{
- RefPtr<ThreadableLoader> loader = NoopLoader::create();
- client->didReceiveResponse(0, ResourceResponse(), m_handle.release());
+ m_client = client;
+
+ RefPtr<MockThreadableLoader> loader = MockThreadableLoader::create();
+ EXPECT_CALL(*loader, start(_)).Times(1).WillOnce(InvokeWithoutArgs(this, &LoaderFactory::handleDidReceiveResponse));
hiroshige 2016/02/05 08:11:53 nit: |Times(1).WillOnce(...)| looks redundant. Is
tyoshino (SeeGerritForStatus) 2016/02/09 14:42:02 Yeah. We're using the StrictMock, so WillOnce() is
+ EXPECT_CALL(*loader, cancel()).Times(1);
return loader.release();
}
private:
+ void handleDidReceiveResponse()
+ {
+ m_client->didReceiveResponse(0, ResourceResponse(), m_handle.release());
+ }
+
+ ThreadableLoaderClient* m_client;
OwnPtr<WebDataConsumerHandle> m_handle;
};

Powered by Google App Engine
This is Rietveld 408576698