Commit ada969c8 authored by esprehn@chromium.org's avatar esprehn@chromium.org

Expand the interface to WebURLLoaderTestDelegate.

To implement FOUC tests we need to be able to control both the
didReceiveData and the didFinishLoading callbacks to have precise
control over when resources finish loading.

This patch expands the interface of WebURLLoaderTestDelegate to delegate
all the steps called in WebURLLoaderMock::ServeAsynchronousRequest. It
also provides a default implementation of each one so tests don't need to
add each proxy method. It also allows this patch to avoid being multiple
steps to handle the Chromium changes.

The next patch in Chromium will update ServeAsynchronousRequest
to use the new methods.

BUG=521692
R=pdr@chromium.org

Review URL: https://codereview.chromium.org/1303953003

git-svn-id: svn://svn.chromium.org/blink/trunk@201003 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8348c238
...@@ -342,6 +342,7 @@ ...@@ -342,6 +342,7 @@
'exported/WebURL.cpp', 'exported/WebURL.cpp',
'exported/WebURLError.cpp', 'exported/WebURLError.cpp',
'exported/WebURLLoaderClient.cpp', 'exported/WebURLLoaderClient.cpp',
'exported/WebURLLoaderTestDelegate.cpp',
'exported/WebURLLoadTiming.cpp', 'exported/WebURLLoadTiming.cpp',
'exported/WebURLRequest.cpp', 'exported/WebURLRequest.cpp',
'exported/WebURLRequestPrivate.h', 'exported/WebURLRequestPrivate.h',
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "public/platform/WebURLLoaderTestDelegate.h"
#include "public/platform/WebURLError.h"
#include "public/platform/WebURLLoader.h"
#include "public/platform/WebURLLoaderClient.h"
#include "public/platform/WebURLRequest.h"
namespace blink {
WebURLLoaderTestDelegate::WebURLLoaderTestDelegate()
{
}
WebURLLoaderTestDelegate::~WebURLLoaderTestDelegate()
{
}
void WebURLLoaderTestDelegate::didReceiveResponse(WebURLLoaderClient* originalClient, WebURLLoader* loader, const WebURLResponse& response)
{
originalClient->didReceiveResponse(loader, response);
}
void WebURLLoaderTestDelegate::didReceiveData(WebURLLoaderClient* originalClient, WebURLLoader* loader, const char* data, int dataLength, int encodedDataLength)
{
originalClient->didReceiveData(loader, data, dataLength, encodedDataLength);
}
void WebURLLoaderTestDelegate::didFail(WebURLLoaderClient* originalClient, WebURLLoader* loader, const WebURLError& error)
{
originalClient->didFail(loader, error);
}
void WebURLLoaderTestDelegate::didFinishLoading(WebURLLoaderClient* originalClient, WebURLLoader* loader, double finishTime, int64_t totalEncodedDataLength)
{
originalClient->didFinishLoading(loader, finishTime, totalEncodedDataLength);
}
} // namespace blink
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WebURLLoaderTestDelegate_h
#define WebURLLoaderTestDelegate_h
#include "public/platform/WebCommon.h"
namespace blink {
class WebURLLoader;
class WebURLResponse;
class WebURLLoaderClient;
struct WebURLError;
// Use with WebUnitTestSupport::setLoaderDelegate to intercept calls to a
// WebURLLoaderClient for controlling network responses in a test. Default
// implementations of all methods just call the original method on the
// WebURLLoaderClient.
class BLINK_PLATFORM_EXPORT WebURLLoaderTestDelegate {
public:
WebURLLoaderTestDelegate();
virtual ~WebURLLoaderTestDelegate();
virtual void didReceiveResponse(WebURLLoaderClient* originalClient, WebURLLoader*, const WebURLResponse&);
virtual void didReceiveData(WebURLLoaderClient* originalClient, WebURLLoader*, const char* data, int dataLength, int encodedDataLength);
virtual void didFail(WebURLLoaderClient* originalClient, WebURLLoader*, const WebURLError&);
virtual void didFinishLoading(WebURLLoaderClient* originalClient, WebURLLoader*, double finishTime, int64_t totalEncodedDataLength);
};
} // namespace blink
#endif
...@@ -30,24 +30,16 @@ ...@@ -30,24 +30,16 @@
#include "WebCommon.h" #include "WebCommon.h"
#include "WebData.h" #include "WebData.h"
#include "WebString.h" #include "WebString.h"
#include "WebURLLoaderTestDelegate.h"
#include "WebVector.h" #include "WebVector.h"
namespace blink { namespace blink {
class WebLayerTreeView; class WebLayerTreeView;
class WebURL; class WebURL;
class WebURLLoader;
class WebURLResponse; class WebURLResponse;
class WebURLLoaderClient;
struct WebURLError; struct WebURLError;
class WebURLLoaderTestDelegate {
public:
~WebURLLoaderTestDelegate() { }
virtual void didReceiveData(WebURLLoaderClient* originalClient, WebURLLoader*, const char* data, int dataLength, int encodedDataLength) { }
};
class WebUnitTestSupport { class WebUnitTestSupport {
public: public:
virtual void registerMockedURL(const WebURL&, const WebURLResponse&, const WebString& filePath) { } virtual void registerMockedURL(const WebURL&, const WebURLResponse&, const WebString& filePath) { }
...@@ -64,7 +56,7 @@ public: ...@@ -64,7 +56,7 @@ public:
virtual void serveAsynchronousMockedRequests() { } virtual void serveAsynchronousMockedRequests() { }
// Set a delegate that allows callbacks for all WebURLLoaderClients to be intercepted. // Set a delegate that allows callbacks for all WebURLLoaderClients to be intercepted.
virtual void setLoaderDelegate(WebURLLoaderTestDelegate*) {} virtual void setLoaderDelegate(WebURLLoaderTestDelegate*) { }
// Returns the root directory of the WebKit code. // Returns the root directory of the WebKit code.
virtual WebString webKitRootDir() { return WebString(); } virtual WebString webKitRootDir() { return WebString(); }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment