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

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: Reupload? 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
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 26 matching lines...) Expand all
37 #include "wtf/PassOwnPtr.h" 37 #include "wtf/PassOwnPtr.h"
38 #include <string> 38 #include <string>
39 39
40 namespace blink { 40 namespace blink {
41 41
42 class WebLocalFrameImpl; 42 class WebLocalFrameImpl;
43 class WebSettings; 43 class WebSettings;
44 44
45 namespace FrameTestHelpers { 45 namespace FrameTestHelpers {
46 46
47 class TestWebFrameClient;
48
49 // Loads a url into the specified WebFrame for testing purposes. Pumps any
50 // pending resource requests, as well as waiting for the threaded parser to
51 // finish, before returning.
47 void loadFrame(WebFrame*, const std::string& url); 52 void loadFrame(WebFrame*, const std::string& url);
53 // Same as above, but for WebFrame::loadHTMLString().
54 void loadHTMLString(WebFrame*, const std::string& html, const WebURL& baseURL);
55 // Same as above, but for WebFrame::reload().
56 void reloadFrame(WebFrame*);
57 void reloadFrameIgnoringCache(WebFrame*);
58
59 // Pumps pending resource requests while waiting for a frame to load. Don't use
60 // this. Use one of the above helpers.
61 void pumpPendingRequestsDoNotUse(WebFrame*);
62
48 void runPendingTasks(); 63 void runPendingTasks();
49 64
50 // Convenience class for handling the lifetime of a WebView and its associated m ainframe in tests. 65 // Convenience class for handling the lifetime of a WebView and its associated m ainframe in tests.
51 class WebViewHelper { 66 class WebViewHelper {
52 WTF_MAKE_NONCOPYABLE(WebViewHelper); 67 WTF_MAKE_NONCOPYABLE(WebViewHelper);
53 public: 68 public:
54 WebViewHelper(); 69 WebViewHelper();
55 ~WebViewHelper(); 70 ~WebViewHelper();
56 71
57 // Creates and initializes the WebView. Implicitly calls reset() first. IF a 72 // Creates and initializes the WebView. Implicitly calls reset() first. IF a
58 // WebFrameClient or a WebViewClient are passed in, they must outlive the 73 // WebFrameClient or a WebViewClient are passed in, they must outlive the
59 // WebViewHelper. 74 // WebViewHelper.
60 WebViewImpl* initialize(bool enableJavascript = false, WebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc)(WebSettings*) = 0); 75 WebViewImpl* initialize(bool enableJavascript = false, TestWebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc)(WebSettings*) = 0);
61 76
62 // Same as initialize() but also performs the initial load of the url. 77 // Same as initialize() but also performs the initial load of the url.
63 WebViewImpl* initializeAndLoad(const std::string& url, bool enableJavascript = false, WebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc)(We bSettings*) = 0); 78 WebViewImpl* initializeAndLoad(const std::string& url, bool enableJavascript = false, TestWebFrameClient* = 0, WebViewClient* = 0, void (*updateSettingsFunc )(WebSettings*) = 0);
64 79
65 void reset(); 80 void reset();
66 81
67 WebView* webView() const { return m_webView; } 82 WebView* webView() const { return m_webView; }
68 WebViewImpl* webViewImpl() const { return m_webView; } 83 WebViewImpl* webViewImpl() const { return m_webView; }
69 84
70 private: 85 private:
71 WebViewImpl* m_webView; 86 WebViewImpl* m_webView;
72 }; 87 };
73 88
74 // Minimal implementation of WebFrameClient needed for unit tests that load fram es. Tests that load 89 // 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. 90 // frames and need further specialization of WebFrameClient behavior should subc lass this.
76 class TestWebFrameClient : public WebFrameClient { 91 class TestWebFrameClient : public WebFrameClient {
77 public: 92 public:
93 TestWebFrameClient();
94
78 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f rameName) OVERRIDE; 95 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f rameName) OVERRIDE;
79 virtual void frameDetached(WebFrame*) OVERRIDE; 96 virtual void frameDetached(WebFrame*) OVERRIDE;
97 virtual void didStartLoading(bool) OVERRIDE;
98 virtual void didStopLoading() OVERRIDE;
99
100 bool isLoading() { return m_loadsInProgress > 0; }
101
102 private:
103 int m_loadsInProgress;
80 }; 104 };
81 105
82 class TestWebViewClient : public WebViewClient { 106 class TestWebViewClient : public WebViewClient {
83 public: 107 public:
84 virtual ~TestWebViewClient() { } 108 virtual ~TestWebViewClient() { }
85 virtual void initializeLayerTreeView() OVERRIDE; 109 virtual void initializeLayerTreeView() OVERRIDE;
86 virtual WebLayerTreeView* layerTreeView() OVERRIDE { return m_layerTreeView. get(); } 110 virtual WebLayerTreeView* layerTreeView() OVERRIDE { return m_layerTreeView. get(); }
87 111
88 private: 112 private:
89 OwnPtr<WebLayerTreeView> m_layerTreeView; 113 OwnPtr<WebLayerTreeView> m_layerTreeView;
90 }; 114 };
91 115
92 } // namespace FrameTestHelpers 116 } // namespace FrameTestHelpers
93 } // namespace blink 117 } // namespace blink
94 118
95 #endif // FrameTestHelpers_h 119 #endif // FrameTestHelpers_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698