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

Side by Side Diff: chrome/browser/ui/webui/web_ui_browsertest.h

Issue 9600036: Move Render(View|Widget)Host and associated classes to content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments. Created 8 years, 9 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 | « chrome/browser/ui/webui/uber/uber_ui.cc ('k') | chrome/browser/ui/webui/web_ui_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_
6 #define CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_ 6 #define CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "chrome/browser/ui/webui/web_ui_test_handler.h" 13 #include "chrome/browser/ui/webui/web_ui_test_handler.h"
14 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
15 #include "content/test/js_injection_ready_observer.h" 15 #include "content/test/js_injection_ready_observer.h"
16 #include "content/test/test_navigation_observer.h" 16 #include "content/test/test_navigation_observer.h"
17 17
18 class RenderViewHost;
19
20 namespace base { 18 namespace base {
21 class Value; 19 class Value;
22 } 20 }
23 21
24 namespace content { 22 namespace content {
23 class RenderViewHost;
25 class WebUI; 24 class WebUI;
26 class WebUIMessageHandler; 25 class WebUIMessageHandler;
27 } 26 }
28 27
29 // This macro simplifies the declaration of simple javascript unit tests. 28 // This macro simplifies the declaration of simple javascript unit tests.
30 // Use: 29 // Use:
31 // WEB_UI_UNITTEST_F(MyWebUIPageTest, myJavascriptUnittest); 30 // WEB_UI_UNITTEST_F(MyWebUIPageTest, myJavascriptUnittest);
32 #define WEB_UI_UNITTEST_F(x, y) \ 31 #define WEB_UI_UNITTEST_F(x, y) \
33 IN_PROC_BROWSER_TEST_F(x, y) { \ 32 IN_PROC_BROWSER_TEST_F(x, y) { \
34 ASSERT_TRUE(RunJavascriptTest(#y)); \ 33 ASSERT_TRUE(RunJavascriptTest(#y)); \
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 base::Value* arg2, 92 base::Value* arg2,
94 base::Value* arg3); 93 base::Value* arg3);
95 bool RunJavascriptAsyncTest(const std::string& test_name, 94 bool RunJavascriptAsyncTest(const std::string& test_name,
96 const ConstValueVector& test_arguments); 95 const ConstValueVector& test_arguments);
97 96
98 // Sends message through |preload_host| to preload javascript libraries and 97 // Sends message through |preload_host| to preload javascript libraries and
99 // sets the |libraries_preloaded| flag to prevent re-loading at next 98 // sets the |libraries_preloaded| flag to prevent re-loading at next
100 // javascript invocation. 99 // javascript invocation.
101 void PreLoadJavascriptLibraries(const std::string& preload_test_fixture, 100 void PreLoadJavascriptLibraries(const std::string& preload_test_fixture,
102 const std::string& preload_test_name, 101 const std::string& preload_test_name,
103 RenderViewHost* preload_host); 102 content::RenderViewHost* preload_host);
104 103
105 // Called by javascript-generated test bodies to browse to a page and preload 104 // Called by javascript-generated test bodies to browse to a page and preload
106 // the javascript for the given |preload_test_fixture| and 105 // the javascript for the given |preload_test_fixture| and
107 // |preload_test_name|. chrome.send will be overridden to allow javascript 106 // |preload_test_name|. chrome.send will be overridden to allow javascript
108 // handler mocking. 107 // handler mocking.
109 void BrowsePreload(const GURL& browse_to); 108 void BrowsePreload(const GURL& browse_to);
110 109
111 // Called by javascript-generated test bodies to browse to a page and preload 110 // Called by javascript-generated test bodies to browse to a page and preload
112 // the javascript for the given |preload_test_fixture| and 111 // the javascript for the given |preload_test_fixture| and
113 // |preload_test_name|. chrome.send will be overridden to allow javascript 112 // |preload_test_name|. chrome.send will be overridden to allow javascript
(...skipping 25 matching lines...) Expand all
139 138
140 // Returns a mock WebUI object under test (if any). 139 // Returns a mock WebUI object under test (if any).
141 virtual content::WebUIMessageHandler* GetMockMessageHandler(); 140 virtual content::WebUIMessageHandler* GetMockMessageHandler();
142 141
143 // Returns a file:// GURL constructed from |path| inside the test data dir for 142 // Returns a file:// GURL constructed from |path| inside the test data dir for
144 // webui tests. 143 // webui tests.
145 static GURL WebUITestDataPathToURL(const FilePath::StringType& path); 144 static GURL WebUITestDataPathToURL(const FilePath::StringType& path);
146 145
147 private: 146 private:
148 // JsInjectionReadyObserver implementation. 147 // JsInjectionReadyObserver implementation.
149 virtual void OnJsInjectionReady(RenderViewHost* render_view_host) OVERRIDE; 148 virtual void OnJsInjectionReady(
149 content::RenderViewHost* render_view_host) OVERRIDE;
150 150
151 // Builds a string containing all added javascript libraries. 151 // Builds a string containing all added javascript libraries.
152 void BuildJavascriptLibraries(string16* content); 152 void BuildJavascriptLibraries(string16* content);
153 153
154 // Builds a string with a call to the runTest JS function, passing the 154 // Builds a string with a call to the runTest JS function, passing the
155 // given |is_async|, |test_name| and its |args|. 155 // given |is_async|, |test_name| and its |args|.
156 string16 BuildRunTestJSCall(bool is_async, 156 string16 BuildRunTestJSCall(bool is_async,
157 const std::string& test_name, 157 const std::string& test_name,
158 const WebUIBrowserTest::ConstValueVector& args); 158 const WebUIBrowserTest::ConstValueVector& args);
159 159
160 // Loads all libraries added with AddLibrary(), and calls |function_name| with 160 // Loads all libraries added with AddLibrary(), and calls |function_name| with
161 // |function_arguments|. When |is_test| is true, the framework wraps 161 // |function_arguments|. When |is_test| is true, the framework wraps
162 // |function_name| with a test helper function, which waits for completion, 162 // |function_name| with a test helper function, which waits for completion,
163 // logging an error message on failure, otherwise |function_name| is called 163 // logging an error message on failure, otherwise |function_name| is called
164 // asynchronously. When |preload_host| is non-NULL, sends the javascript to 164 // asynchronously. When |preload_host| is non-NULL, sends the javascript to
165 // the RenderView for evaluation at the appropriate time before the onload 165 // the RenderView for evaluation at the appropriate time before the onload
166 // call is made. Passes |is_async| along to runTest wrapper. 166 // call is made. Passes |is_async| along to runTest wrapper.
167 bool RunJavascriptUsingHandler(const std::string& function_name, 167 bool RunJavascriptUsingHandler(const std::string& function_name,
168 const ConstValueVector& function_arguments, 168 const ConstValueVector& function_arguments,
169 bool is_test, 169 bool is_test,
170 bool is_async, 170 bool is_async,
171 RenderViewHost* preload_host); 171 content::RenderViewHost* preload_host);
172 172
173 // Attaches mock and test handlers. 173 // Attaches mock and test handlers.
174 void SetupHandlers(); 174 void SetupHandlers();
175 175
176 // Handles test framework messages. 176 // Handles test framework messages.
177 scoped_ptr<WebUITestHandler> test_handler_; 177 scoped_ptr<WebUITestHandler> test_handler_;
178 178
179 // Location of test data (currently test/data/webui). 179 // Location of test data (currently test/data/webui).
180 FilePath test_data_directory_; 180 FilePath test_data_directory_;
181 181
(...skipping 11 matching lines...) Expand all
193 // PreloadJavascriptLibraries(). 193 // PreloadJavascriptLibraries().
194 std::string preload_test_fixture_; 194 std::string preload_test_fixture_;
195 std::string preload_test_name_; 195 std::string preload_test_name_;
196 196
197 // When this is non-NULL, this is The WebUI instance used for testing. 197 // When this is non-NULL, this is The WebUI instance used for testing.
198 // Otherwise the selected tab's web_ui is used. 198 // Otherwise the selected tab's web_ui is used.
199 content::WebUI* override_selected_web_ui_; 199 content::WebUI* override_selected_web_ui_;
200 }; 200 };
201 201
202 #endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_ 202 #endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/uber/uber_ui.cc ('k') | chrome/browser/ui/webui/web_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698