Index: Source/web/tests/FrameTestHelpers.h |
diff --git a/Source/web/tests/FrameTestHelpers.h b/Source/web/tests/FrameTestHelpers.h |
index 944921993da43bfd02125eda492ec71cb9069f45..ff7ff6b77fceb17917c2453532d5874e9ad8ed96 100644 |
--- a/Source/web/tests/FrameTestHelpers.h |
+++ b/Source/web/tests/FrameTestHelpers.h |
@@ -31,7 +31,9 @@ |
#ifndef FrameTestHelpers_h |
#define FrameTestHelpers_h |
+#include "public/platform/WebURLRequest.h" |
#include "public/web/WebFrameClient.h" |
+#include "public/web/WebHistoryItem.h" |
#include "public/web/WebViewClient.h" |
#include "web/WebViewImpl.h" |
#include "wtf/PassOwnPtr.h" |
@@ -44,7 +46,24 @@ class WebSettings; |
namespace FrameTestHelpers { |
+class TestWebFrameClient; |
+ |
+// Loads a url into the specified WebFrame for testing purposes. Pumps any |
+// pending resource requests, as well as waiting for the threaded parser to |
+// finish, before returning. |
void loadFrame(WebFrame*, const std::string& url); |
+// Same as above, but for WebFrame::loadHTMLString(). |
+void loadHTMLString(WebFrame*, const std::string& html, const WebURL& baseURL); |
+// Same as above, but for WebFrame::loadHistoryItem(). |
+void loadHistoryItem(WebFrame*, const WebHistoryItem&, WebHistoryLoadType, WebURLRequest::CachePolicy); |
+// Same as above, but for WebFrame::reload(). |
+void reloadFrame(WebFrame*); |
+void reloadFrameIgnoringCache(WebFrame*); |
+ |
+// Pumps pending resource requests while waiting for a frame to load. Don't use |
+// this. Use one of the above helpers. |
Nico
2015/08/29 22:07:49
I found this comment pretty confusing today. The m
|
+void pumpPendingRequestsDoNotUse(WebFrame*); |
+ |
void runPendingTasks(); |
// Convenience class for handling the lifetime of a WebView and its associated mainframe in tests. |
@@ -57,10 +76,11 @@ public: |
// Creates and initializes the WebView. Implicitly calls reset() first. IF a |
// WebFrameClient or a WebViewClient are passed in, they must outlive the |
// WebViewHelper. |
- WebViewImpl* initialize(bool enableJavascript = false, WebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc)(WebSettings*) = 0); |
+ WebViewImpl* initialize(bool enableJavascript = false, TestWebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc)(WebSettings*) = 0); |
- // Same as initialize() but also performs the initial load of the url. |
- WebViewImpl* initializeAndLoad(const std::string& url, bool enableJavascript = false, WebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc)(WebSettings*) = 0); |
+ // Same as initialize() but also performs the initial load of the url. Only |
+ // returns once the load is complete. |
+ WebViewImpl* initializeAndLoad(const std::string& url, bool enableJavascript = false, TestWebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc)(WebSettings*) = 0); |
void reset(); |
@@ -75,8 +95,17 @@ private: |
// frames and need further specialization of WebFrameClient behavior should subclass this. |
class TestWebFrameClient : public WebFrameClient { |
public: |
+ TestWebFrameClient(); |
+ |
virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& frameName) OVERRIDE; |
virtual void frameDetached(WebFrame*) OVERRIDE; |
+ virtual void didStartLoading(bool) OVERRIDE; |
+ virtual void didStopLoading() OVERRIDE; |
+ |
+ bool isLoading() { return m_loadsInProgress > 0; } |
+ |
+private: |
+ int m_loadsInProgress; |
}; |
class TestWebViewClient : public WebViewClient { |