| 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_UI_TEST_UTILS_H_ | 5 #ifndef CHROME_TEST_BASE_UI_TEST_UTILS_H_ |
| 6 #define CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 6 #define CHROME_TEST_BASE_UI_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 const GURL& url, | 138 const GURL& url, |
| 139 WindowOpenDisposition disposition, | 139 WindowOpenDisposition disposition, |
| 140 int browser_test_flags); | 140 int browser_test_flags); |
| 141 | 141 |
| 142 // Navigates the selected tab of |browser| to |url|, blocking until the | 142 // Navigates the selected tab of |browser| to |url|, blocking until the |
| 143 // number of navigations specified complete. | 143 // number of navigations specified complete. |
| 144 void NavigateToURLBlockUntilNavigationsComplete(Browser* browser, | 144 void NavigateToURLBlockUntilNavigationsComplete(Browser* browser, |
| 145 const GURL& url, | 145 const GURL& url, |
| 146 int number_of_navigations); | 146 int number_of_navigations); |
| 147 | 147 |
| 148 // Executes the passed |script| in the frame pointed to by |frame_xpath| (use | |
| 149 // empty string for main frame). The |script| should not invoke | |
| 150 // domAutomationController.send(); otherwise, your test will hang or be flaky. | |
| 151 // If you want to extract a result, use one of the below functions. | |
| 152 // Returns true on success. | |
| 153 bool ExecuteJavaScript(content::RenderViewHost* render_view_host, | |
| 154 const std::wstring& frame_xpath, | |
| 155 const std::wstring& script) WARN_UNUSED_RESULT; | |
| 156 | |
| 157 // The following methods executes the passed |script| in the frame pointed to by | |
| 158 // |frame_xpath| (use empty string for main frame) and sets |result| to the | |
| 159 // value returned by the script evaluation. | |
| 160 // They return true on success, false if the script evaluation failed or did not | |
| 161 // evaluate to the expected type. | |
| 162 bool ExecuteJavaScriptAndExtractInt(content::RenderViewHost* render_view_host, | |
| 163 const std::wstring& frame_xpath, | |
| 164 const std::wstring& script, | |
| 165 int* result) WARN_UNUSED_RESULT; | |
| 166 bool ExecuteJavaScriptAndExtractBool(content::RenderViewHost* render_view_host, | |
| 167 const std::wstring& frame_xpath, | |
| 168 const std::wstring& script, | |
| 169 bool* result) WARN_UNUSED_RESULT; | |
| 170 bool ExecuteJavaScriptAndExtractString( | |
| 171 content::RenderViewHost* render_view_host, | |
| 172 const std::wstring& frame_xpath, | |
| 173 const std::wstring& script, | |
| 174 std::string* result) WARN_UNUSED_RESULT; | |
| 175 | |
| 176 // Generate the file path for testing a particular test. | 148 // Generate the file path for testing a particular test. |
| 177 // The file for the tests is all located in | 149 // The file for the tests is all located in |
| 178 // test_root_directory/dir/<file> | 150 // test_root_directory/dir/<file> |
| 179 // The returned path is FilePath format. | 151 // The returned path is FilePath format. |
| 180 FilePath GetTestFilePath(const FilePath& dir, const FilePath& file); | 152 FilePath GetTestFilePath(const FilePath& dir, const FilePath& file); |
| 181 | 153 |
| 182 // Generate the URL for testing a particular test. | 154 // Generate the URL for testing a particular test. |
| 183 // HTML for the tests is all located in | 155 // HTML for the tests is all located in |
| 184 // test_root_directory/dir/<file> | 156 // test_root_directory/dir/<file> |
| 185 // The returned path is GURL format. | 157 // The returned path is GURL format. |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 // ui_controls_linux.cc and ui_controls_mac.cc | 526 // ui_controls_linux.cc and ui_controls_mac.cc |
| 555 void ClickTask(ui_controls::MouseButton button, | 527 void ClickTask(ui_controls::MouseButton button, |
| 556 int state, | 528 int state, |
| 557 const base::Closure& followup); | 529 const base::Closure& followup); |
| 558 | 530 |
| 559 } // namespace internal | 531 } // namespace internal |
| 560 | 532 |
| 561 } // namespace ui_test_utils | 533 } // namespace ui_test_utils |
| 562 | 534 |
| 563 #endif // CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 535 #endif // CHROME_TEST_BASE_UI_TEST_UTILS_H_ |
| OLD | NEW |