Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 | |
| 143 // User added libraries. | |
|
Paweł Hajdan Jr.
2014/05/23 10:50:11
nit: Member variables need to go after _all_ the m
| |
| 144 std::vector<base::FilePath> user_libraries_; | |
| 145 | |
| 146 // User library search paths. | |
| 147 std::vector<base::FilePath> library_search_paths_; | |
| 142 | 148 |
| 143 // Builds a string with a call to the runTest JS function, passing the | 149 // Builds a string with a call to the runTest JS function, passing the |
| 144 // given |is_async|, |test_name| and its |args|. | 150 // given |is_async|, |test_name| and its |args|. |
| 145 base::string16 BuildRunTestJSCall( | 151 base::string16 BuildRunTestJSCall( |
| 146 bool is_async, | 152 bool is_async, |
| 147 const std::string& test_name, | 153 const std::string& test_name, |
| 148 const WebUIBrowserTest::ConstValueVector& args); | 154 const WebUIBrowserTest::ConstValueVector& args); |
| 149 | 155 |
| 150 // Loads all libraries added with AddLibrary(), and calls |function_name| with | 156 // Loads all libraries added with AddLibrary(), and calls |function_name| with |
| 151 // |function_arguments|. When |is_test| is true, the framework wraps | 157 // |function_arguments|. When |is_test| is true, the framework wraps |
| 152 // |function_name| with a test helper function, which waits for completion, | 158 // |function_name| with a test helper function, which waits for completion, |
| 153 // logging an error message on failure, otherwise |function_name| is called | 159 // logging an error message on failure, otherwise |function_name| is called |
| 154 // asynchronously. When |preload_host| is non-NULL, sends the javascript to | 160 // asynchronously. When |preload_host| is non-NULL, sends the javascript to |
| 155 // the RenderView for evaluation at the appropriate time before the onload | 161 // the RenderView for evaluation at the appropriate time before the onload |
| 156 // call is made. Passes |is_async| along to runTest wrapper. | 162 // call is made. Passes |is_async| along to runTest wrapper. |
| 157 bool RunJavascriptUsingHandler(const std::string& function_name, | 163 bool RunJavascriptUsingHandler(const std::string& function_name, |
| 158 const ConstValueVector& function_arguments, | 164 const ConstValueVector& function_arguments, |
| 159 bool is_test, | 165 bool is_test, |
| 160 bool is_async, | 166 bool is_async, |
| 161 content::RenderViewHost* preload_host); | 167 content::RenderViewHost* preload_host); |
| 162 | 168 |
| 163 // Attaches mock and test handlers. | 169 // Attaches mock and test handlers. |
| 164 void SetupHandlers(); | 170 void SetupHandlers(); |
| 165 | 171 |
| 166 // Handles test framework messages. | 172 // Handles test framework messages. |
| 167 scoped_ptr<WebUITestHandler> test_handler_; | 173 scoped_ptr<WebUITestHandler> test_handler_; |
| 168 | 174 |
| 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 | 175 // Indicates that the libraries have been pre-loaded and to not load them |
| 179 // again. | 176 // again. |
| 180 bool libraries_preloaded_; | 177 bool libraries_preloaded_; |
| 181 | 178 |
| 182 // Saves the states of |test_fixture| and |test_name| for calling | 179 // Saves the states of |test_fixture| and |test_name| for calling |
| 183 // PreloadJavascriptLibraries(). | 180 // PreloadJavascriptLibraries(). |
| 184 std::string preload_test_fixture_; | 181 std::string preload_test_fixture_; |
| 185 std::string preload_test_name_; | 182 std::string preload_test_name_; |
| 186 | 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_ |
| OLD | NEW |