| OLD | NEW |
| 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 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 bool RunJavascriptFunction(const std::string& function_name); | 53 bool RunJavascriptFunction(const std::string& function_name); |
| 54 bool RunJavascriptFunction(const std::string& function_name, | 54 bool RunJavascriptFunction(const std::string& function_name, |
| 55 base::Value* arg); | 55 base::Value* arg); |
| 56 bool RunJavascriptFunction(const std::string& function_name, | 56 bool RunJavascriptFunction(const std::string& function_name, |
| 57 base::Value* arg1, | 57 base::Value* arg1, |
| 58 base::Value* arg2); | 58 base::Value* arg2); |
| 59 bool RunJavascriptFunction(const std::string& function_name, | 59 bool RunJavascriptFunction(const std::string& function_name, |
| 60 const ConstValueVector& function_arguments); | 60 const ConstValueVector& function_arguments); |
| 61 | 61 |
| 62 // Runs a test fixture that may include calls to functions in test_api.js. | 62 // Runs a test fixture that may include calls to functions in test_api.js. |
| 63 bool RunJavascriptTestF(const std::string& test_fixture, | 63 bool RunJavascriptTestF(bool is_async, |
| 64 const std::string& test_fixture, |
| 64 const std::string& test_name); | 65 const std::string& test_name); |
| 65 | 66 |
| 66 // Runs a test that may include calls to functions in test_api.js. | 67 // Runs a test that may include calls to functions in test_api.js. |
| 67 // Takes ownership of Value arguments. | 68 // Takes ownership of Value arguments. |
| 68 bool RunJavascriptTest(const std::string& test_name); | 69 bool RunJavascriptTest(const std::string& test_name); |
| 69 bool RunJavascriptTest(const std::string& test_name, | 70 bool RunJavascriptTest(const std::string& test_name, |
| 70 base::Value* arg); | 71 base::Value* arg); |
| 71 bool RunJavascriptTest(const std::string& test_name, | 72 bool RunJavascriptTest(const std::string& test_name, |
| 72 base::Value* arg1, | 73 base::Value* arg1, |
| 73 base::Value* arg2); | 74 base::Value* arg2); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 107 |
| 107 // Called by javascript-generated test bodies to browse to a page and preload | 108 // Called by javascript-generated test bodies to browse to a page and preload |
| 108 // the javascript for the given |preload_test_fixture| and | 109 // the javascript for the given |preload_test_fixture| and |
| 109 // |preload_test_name|. chrome.send will be overridden to allow javascript | 110 // |preload_test_name|. chrome.send will be overridden to allow javascript |
| 110 // handler mocking. | 111 // handler mocking. |
| 111 void BrowsePrintPreload(const GURL& browse_to, | 112 void BrowsePrintPreload(const GURL& browse_to, |
| 112 const std::string& preload_test_fixture, | 113 const std::string& preload_test_fixture, |
| 113 const std::string& preload_test_name); | 114 const std::string& preload_test_name); |
| 114 | 115 |
| 115 protected: | 116 protected: |
| 117 // URL to dummy WebUI page for testing framework. |
| 118 static const char kDummyURL[]; |
| 119 |
| 116 WebUIBrowserTest(); | 120 WebUIBrowserTest(); |
| 117 | 121 |
| 118 // Setup test path. | 122 // Set up test path & override for |kDummyURL|. |
| 119 virtual void SetUpInProcessBrowserTestFixture(); | 123 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; |
| 124 |
| 125 // Tear down override for |kDummyURL|. |
| 126 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE; |
| 120 | 127 |
| 121 // Returns a mock WebUI object under test (if any). | 128 // Returns a mock WebUI object under test (if any). |
| 122 virtual WebUIMessageHandler* GetMockMessageHandler(); | 129 virtual WebUIMessageHandler* GetMockMessageHandler(); |
| 123 | 130 |
| 124 // Returns a file:// GURL constructed from |path| inside the test data dir for | 131 // Returns a file:// GURL constructed from |path| inside the test data dir for |
| 125 // webui tests. | 132 // webui tests. |
| 126 static GURL WebUITestDataPathToURL(const FilePath::StringType& path); | 133 static GURL WebUITestDataPathToURL(const FilePath::StringType& path); |
| 127 | 134 |
| 128 private: | 135 private: |
| 129 // TestNavigationObserver::JsInjectionReadyObserver implementation. | 136 // TestNavigationObserver::JsInjectionReadyObserver implementation. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // again. | 174 // again. |
| 168 bool libraries_preloaded_; | 175 bool libraries_preloaded_; |
| 169 | 176 |
| 170 // Saves the states of |test_fixture| and |test_name| for calling | 177 // Saves the states of |test_fixture| and |test_name| for calling |
| 171 // PreloadJavascriptLibraries(). | 178 // PreloadJavascriptLibraries(). |
| 172 std::string preload_test_fixture_; | 179 std::string preload_test_fixture_; |
| 173 std::string preload_test_name_; | 180 std::string preload_test_name_; |
| 174 }; | 181 }; |
| 175 | 182 |
| 176 #endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_ | 183 #endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_BROWSERTEST_H_ |
| OLD | NEW |