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

Side by Side Diff: chrome/test/base/web_ui_browsertest.h

Issue 292313004: Port aria_util_test.js to run as a WebUI test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 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/renderer/chrome_render_view_observer.cc ('k') | chrome/test/base/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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_TEST_BASE_WEB_UI_BROWSERTEST_H_ 5 #ifndef CHROME_TEST_BASE_WEB_UI_BROWSERTEST_H_
6 #define CHROME_TEST_BASE_WEB_UI_BROWSERTEST_H_ 6 #define CHROME_TEST_BASE_WEB_UI_BROWSERTEST_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void SetWebUIInstance(content::WebUI* web_ui); 130 void SetWebUIInstance(content::WebUI* web_ui);
131 131
132 // Returns a mock WebUI object under test (if any). 132 // Returns a mock WebUI object under test (if any).
133 virtual content::WebUIMessageHandler* GetMockMessageHandler(); 133 virtual content::WebUIMessageHandler* GetMockMessageHandler();
134 134
135 // Returns a file:// GURL constructed from |path| inside the test data dir for 135 // Returns a file:// GURL constructed from |path| inside the test data dir for
136 // webui tests. 136 // webui tests.
137 static GURL WebUITestDataPathToURL(const base::FilePath::StringType& path); 137 static GURL WebUITestDataPathToURL(const base::FilePath::StringType& path);
138 138
139 private: 139 private:
140 // Builds a string containing all added javascript libraries. 140 // Builds a vector of strings of all added javascript libraries.
141 void BuildJavascriptLibraries(base::string16* content); 141 void BuildJavascriptLibraries(std::vector<base::string16>* libraries);
142 142
143 // Builds a string with a call to the runTest JS function, passing the 143 // Builds a string with a call to the runTest JS function, passing the
144 // given |is_async|, |test_name| and its |args|. 144 // given |is_async|, |test_name| and its |args|.
145 base::string16 BuildRunTestJSCall( 145 base::string16 BuildRunTestJSCall(
146 bool is_async, 146 bool is_async,
147 const std::string& test_name, 147 const std::string& test_name,
148 const WebUIBrowserTest::ConstValueVector& args); 148 const WebUIBrowserTest::ConstValueVector& args);
149 149
150 // Loads all libraries added with AddLibrary(), and calls |function_name| with 150 // Loads all libraries added with AddLibrary(), and calls |function_name| with
151 // |function_arguments|. When |is_test| is true, the framework wraps 151 // |function_arguments|. When |is_test| is true, the framework wraps
152 // |function_name| with a test helper function, which waits for completion, 152 // |function_name| with a test helper function, which waits for completion,
153 // logging an error message on failure, otherwise |function_name| is called 153 // logging an error message on failure, otherwise |function_name| is called
154 // asynchronously. When |preload_host| is non-NULL, sends the javascript to 154 // asynchronously. When |preload_host| is non-NULL, sends the javascript to
155 // the RenderView for evaluation at the appropriate time before the onload 155 // the RenderView for evaluation at the appropriate time before the onload
156 // call is made. Passes |is_async| along to runTest wrapper. 156 // call is made. Passes |is_async| along to runTest wrapper.
157 bool RunJavascriptUsingHandler(const std::string& function_name, 157 bool RunJavascriptUsingHandler(const std::string& function_name,
158 const ConstValueVector& function_arguments, 158 const ConstValueVector& function_arguments,
159 bool is_test, 159 bool is_test,
160 bool is_async, 160 bool is_async,
161 content::RenderViewHost* preload_host); 161 content::RenderViewHost* preload_host);
162 162
163 // Attaches mock and test handlers. 163 // Attaches mock and test handlers.
164 void SetupHandlers(); 164 void SetupHandlers();
165 165
166 // Handles test framework messages. 166 // Handles test framework messages.
167 scoped_ptr<WebUITestHandler> test_handler_; 167 scoped_ptr<WebUITestHandler> test_handler_;
168 168
169 // Location of test data (currently test/data/webui).
170 base::FilePath test_data_directory_;
171
172 // Location of generated test data (<(PROGRAM_DIR)/test_data).
173 base::FilePath gen_test_data_directory_;
174
175 // User added libraries
176 std::vector<base::FilePath> user_libraries_;
177
178 // Indicates that the libraries have been pre-loaded and to not load them 169 // Indicates that the libraries have been pre-loaded and to not load them
179 // again. 170 // again.
180 bool libraries_preloaded_; 171 bool libraries_preloaded_;
181 172
182 // Saves the states of |test_fixture| and |test_name| for calling 173 // Saves the states of |test_fixture| and |test_name| for calling
183 // PreloadJavascriptLibraries(). 174 // PreloadJavascriptLibraries().
184 std::string preload_test_fixture_; 175 std::string preload_test_fixture_;
185 std::string preload_test_name_; 176 std::string preload_test_name_;
186 177
178 // User added libraries.
179 std::vector<base::FilePath> user_libraries_;
180
181 // User library search paths.
182 std::vector<base::FilePath> library_search_paths_;
183
187 // When this is non-NULL, this is The WebUI instance used for testing. 184 // When this is non-NULL, this is The WebUI instance used for testing.
188 // Otherwise the selected tab's web_ui is used. 185 // Otherwise the selected tab's web_ui is used.
189 content::WebUI* override_selected_web_ui_; 186 content::WebUI* override_selected_web_ui_;
190 187
191 scoped_ptr<TestChromeWebUIControllerFactory> test_factory_; 188 scoped_ptr<TestChromeWebUIControllerFactory> test_factory_;
192 }; 189 };
193 190
194 #endif // CHROME_TEST_BASE_WEB_UI_BROWSERTEST_H_ 191 #endif // CHROME_TEST_BASE_WEB_UI_BROWSERTEST_H_
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_view_observer.cc ('k') | chrome/test/base/web_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698