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

Side by Side Diff: Source/web/tests/FrameTestHelpers.h

Issue 271793007: Fix webkit_unit_tests to use the threaded parser and enable everywhere. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add loadHistoryItem wrapper Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/tests/CompositedLayerMappingTest.cpp ('k') | Source/web/tests/FrameTestHelpers.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef FrameTestHelpers_h 31 #ifndef FrameTestHelpers_h
32 #define FrameTestHelpers_h 32 #define FrameTestHelpers_h
33 33
34 #include "public/platform/WebURLRequest.h"
34 #include "public/web/WebFrameClient.h" 35 #include "public/web/WebFrameClient.h"
36 #include "public/web/WebHistoryItem.h"
35 #include "public/web/WebViewClient.h" 37 #include "public/web/WebViewClient.h"
36 #include "web/WebViewImpl.h" 38 #include "web/WebViewImpl.h"
37 #include "wtf/PassOwnPtr.h" 39 #include "wtf/PassOwnPtr.h"
38 #include <string> 40 #include <string>
39 41
40 namespace blink { 42 namespace blink {
41 43
42 class WebLocalFrameImpl; 44 class WebLocalFrameImpl;
43 class WebSettings; 45 class WebSettings;
44 46
45 namespace FrameTestHelpers { 47 namespace FrameTestHelpers {
46 48
49 class TestWebFrameClient;
50
51 // Loads a url into the specified WebFrame for testing purposes. Pumps any
52 // pending resource requests, as well as waiting for the threaded parser to
53 // finish, before returning.
47 void loadFrame(WebFrame*, const std::string& url); 54 void loadFrame(WebFrame*, const std::string& url);
55 // Same as above, but for WebFrame::loadHTMLString().
56 void loadHTMLString(WebFrame*, const std::string& html, const WebURL& baseURL);
57 // Same as above, but for WebFrame::loadHistoryItem().
58 void loadHistoryItem(WebFrame*, const WebHistoryItem&, WebHistoryLoadType, WebUR LRequest::CachePolicy);
59 // Same as above, but for WebFrame::reload().
60 void reloadFrame(WebFrame*);
61 void reloadFrameIgnoringCache(WebFrame*);
62
63 // Pumps pending resource requests while waiting for a frame to load. Don't use
64 // this. Use one of the above helpers.
Nico 2015/08/29 22:07:49 I found this comment pretty confusing today. The m
65 void pumpPendingRequestsDoNotUse(WebFrame*);
66
48 void runPendingTasks(); 67 void runPendingTasks();
49 68
50 // Convenience class for handling the lifetime of a WebView and its associated m ainframe in tests. 69 // Convenience class for handling the lifetime of a WebView and its associated m ainframe in tests.
51 class WebViewHelper { 70 class WebViewHelper {
52 WTF_MAKE_NONCOPYABLE(WebViewHelper); 71 WTF_MAKE_NONCOPYABLE(WebViewHelper);
53 public: 72 public:
54 WebViewHelper(); 73 WebViewHelper();
55 ~WebViewHelper(); 74 ~WebViewHelper();
56 75
57 // Creates and initializes the WebView. Implicitly calls reset() first. IF a 76 // Creates and initializes the WebView. Implicitly calls reset() first. IF a
58 // WebFrameClient or a WebViewClient are passed in, they must outlive the 77 // WebFrameClient or a WebViewClient are passed in, they must outlive the
59 // WebViewHelper. 78 // WebViewHelper.
60 WebViewImpl* initialize(bool enableJavascript = false, WebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc)(WebSettings*) = 0); 79 WebViewImpl* initialize(bool enableJavascript = false, TestWebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc)(WebSettings*) = 0);
61 80
62 // Same as initialize() but also performs the initial load of the url. 81 // Same as initialize() but also performs the initial load of the url. Only
63 WebViewImpl* initializeAndLoad(const std::string& url, bool enableJavascript = false, WebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc)(We bSettings*) = 0); 82 // returns once the load is complete.
83 WebViewImpl* initializeAndLoad(const std::string& url, bool enableJavascript = false, TestWebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc )(WebSettings*) = 0);
64 84
65 void reset(); 85 void reset();
66 86
67 WebView* webView() const { return m_webView; } 87 WebView* webView() const { return m_webView; }
68 WebViewImpl* webViewImpl() const { return m_webView; } 88 WebViewImpl* webViewImpl() const { return m_webView; }
69 89
70 private: 90 private:
71 WebViewImpl* m_webView; 91 WebViewImpl* m_webView;
72 }; 92 };
73 93
74 // Minimal implementation of WebFrameClient needed for unit tests that load fram es. Tests that load 94 // Minimal implementation of WebFrameClient needed for unit tests that load fram es. Tests that load
75 // frames and need further specialization of WebFrameClient behavior should subc lass this. 95 // frames and need further specialization of WebFrameClient behavior should subc lass this.
76 class TestWebFrameClient : public WebFrameClient { 96 class TestWebFrameClient : public WebFrameClient {
77 public: 97 public:
98 TestWebFrameClient();
99
78 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f rameName) OVERRIDE; 100 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f rameName) OVERRIDE;
79 virtual void frameDetached(WebFrame*) OVERRIDE; 101 virtual void frameDetached(WebFrame*) OVERRIDE;
102 virtual void didStartLoading(bool) OVERRIDE;
103 virtual void didStopLoading() OVERRIDE;
104
105 bool isLoading() { return m_loadsInProgress > 0; }
106
107 private:
108 int m_loadsInProgress;
80 }; 109 };
81 110
82 class TestWebViewClient : public WebViewClient { 111 class TestWebViewClient : public WebViewClient {
83 public: 112 public:
84 virtual ~TestWebViewClient() { } 113 virtual ~TestWebViewClient() { }
85 virtual void initializeLayerTreeView() OVERRIDE; 114 virtual void initializeLayerTreeView() OVERRIDE;
86 virtual WebLayerTreeView* layerTreeView() OVERRIDE { return m_layerTreeView. get(); } 115 virtual WebLayerTreeView* layerTreeView() OVERRIDE { return m_layerTreeView. get(); }
87 116
88 private: 117 private:
89 OwnPtr<WebLayerTreeView> m_layerTreeView; 118 OwnPtr<WebLayerTreeView> m_layerTreeView;
90 }; 119 };
91 120
92 } // namespace FrameTestHelpers 121 } // namespace FrameTestHelpers
93 } // namespace blink 122 } // namespace blink
94 123
95 #endif // FrameTestHelpers_h 124 #endif // FrameTestHelpers_h
OLDNEW
« no previous file with comments | « Source/web/tests/CompositedLayerMappingTest.cpp ('k') | Source/web/tests/FrameTestHelpers.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698