| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 HEADLESS_TEST_HEADLESS_BROWSER_TEST_H_ | 5 #ifndef HEADLESS_TEST_HEADLESS_BROWSER_TEST_H_ |
| 6 #define HEADLESS_TEST_HEADLESS_BROWSER_TEST_H_ | 6 #define HEADLESS_TEST_HEADLESS_BROWSER_TEST_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 protected: | 58 protected: |
| 59 HeadlessBrowserTest(); | 59 HeadlessBrowserTest(); |
| 60 ~HeadlessBrowserTest() override; | 60 ~HeadlessBrowserTest() override; |
| 61 | 61 |
| 62 // BrowserTestBase: | 62 // BrowserTestBase: |
| 63 void RunTestOnMainThreadLoop() override; | 63 void RunTestOnMainThreadLoop() override; |
| 64 void SetUpOnMainThread() override; | 64 void SetUpOnMainThread() override; |
| 65 void TearDownOnMainThread() override; | 65 void TearDownOnMainThread() override; |
| 66 | 66 |
| 67 // Customize the options used in this test. Note that options which take | |
| 68 // effect before the message loop has been started (e.g., custom message | |
| 69 // pumps) cannot be set via this method. | |
| 70 void SetBrowserOptions(HeadlessBrowser::Options options); | |
| 71 | |
| 72 // Run an asynchronous test in a nested run loop. The caller should call | 67 // Run an asynchronous test in a nested run loop. The caller should call |
| 73 // FinishAsynchronousTest() to notify that the test should finish. | 68 // FinishAsynchronousTest() to notify that the test should finish. |
| 74 void RunAsynchronousTest(); | 69 void RunAsynchronousTest(); |
| 75 | 70 |
| 76 // Synchronously waits for a tab to finish loading. | 71 // Synchronously waits for a tab to finish loading. |
| 77 bool WaitForLoad(HeadlessWebContents* web_contents); | 72 bool WaitForLoad(HeadlessWebContents* web_contents); |
| 78 | 73 |
| 79 // Synchronously evaluates a script and returns the result. | 74 // Synchronously evaluates a script and returns the result. |
| 80 std::unique_ptr<runtime::EvaluateResult> EvaluateScript( | 75 std::unique_ptr<runtime::EvaluateResult> EvaluateScript( |
| 81 HeadlessWebContents* web_contents, | 76 HeadlessWebContents* web_contents, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 108 void DevToolsTargetReady() override; | 103 void DevToolsTargetReady() override; |
| 109 | 104 |
| 110 // Implemented by tests and used to send request(s) to DevTools. Subclasses | 105 // Implemented by tests and used to send request(s) to DevTools. Subclasses |
| 111 // need to ensure that FinishAsynchronousTest() is called after response(s) | 106 // need to ensure that FinishAsynchronousTest() is called after response(s) |
| 112 // are processed (e.g. in a callback). | 107 // are processed (e.g. in a callback). |
| 113 virtual void RunDevTooledTest() = 0; | 108 virtual void RunDevTooledTest() = 0; |
| 114 | 109 |
| 115 protected: | 110 protected: |
| 116 void RunTest(); | 111 void RunTest(); |
| 117 | 112 |
| 113 std::unique_ptr<HeadlessBrowserContext> browser_context_; |
| 118 HeadlessWebContents* web_contents_; | 114 HeadlessWebContents* web_contents_; |
| 119 std::unique_ptr<HeadlessDevToolsClient> devtools_client_; | 115 std::unique_ptr<HeadlessDevToolsClient> devtools_client_; |
| 120 }; | 116 }; |
| 121 | 117 |
| 122 } // namespace headless | 118 } // namespace headless |
| 123 | 119 |
| 124 #endif // HEADLESS_TEST_HEADLESS_BROWSER_TEST_H_ | 120 #endif // HEADLESS_TEST_HEADLESS_BROWSER_TEST_H_ |
| OLD | NEW |