OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROMECAST_BROWSER_TEST_CAST_BROWSER_TEST_H_ | 5 #ifndef CHROMECAST_BROWSER_TEST_CAST_BROWSER_TEST_H_ |
6 #define CHROMECAST_BROWSER_TEST_CAST_BROWSER_TEST_H_ | 6 #define CHROMECAST_BROWSER_TEST_CAST_BROWSER_TEST_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "chromecast/browser/cast_content_window.h" | 11 #include "chromecast/browser/cast_web_view.h" |
12 #include "content/public/test/browser_test.h" | 12 #include "content/public/test/browser_test.h" |
13 #include "content/public/test/browser_test_base.h" | 13 #include "content/public/test/browser_test_base.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 class WebContents; | 16 class WebContents; |
17 } | 17 } |
18 | 18 |
19 namespace chromecast { | 19 namespace chromecast { |
20 namespace shell { | 20 namespace shell { |
21 | 21 |
22 // This test allows for running an entire browser-process lifecycle per unit | 22 // This test allows for running an entire browser-process lifecycle per unit |
23 // test, using Chromecast's cast_shell. This starts up the shell, runs a test | 23 // test, using Chromecast's cast_shell. This starts up the shell, runs a test |
24 // case, then shuts down the entire shell. | 24 // case, then shuts down the entire shell. |
25 // Note that this process takes 7-10 seconds per test case on Chromecast, so | 25 // Note that this process takes 7-10 seconds per test case on Chromecast, so |
26 // fewer test cases with more assertions are preferable. | 26 // fewer test cases with more assertions are preferable. |
27 class CastBrowserTest : public content::BrowserTestBase, | 27 class CastBrowserTest : public content::BrowserTestBase, CastWebView::Delegate { |
28 CastContentWindow::Delegate { | |
29 protected: | 28 protected: |
30 CastBrowserTest(); | 29 CastBrowserTest(); |
31 ~CastBrowserTest() override; | 30 ~CastBrowserTest() override; |
32 | 31 |
33 // content::BrowserTestBase implementation: | 32 // content::BrowserTestBase implementation: |
34 void SetUp() final; | 33 void SetUp() final; |
35 void TearDownOnMainThread() override; | 34 void TearDownOnMainThread() override; |
36 void SetUpCommandLine(base::CommandLine* command_line) override; | 35 void SetUpCommandLine(base::CommandLine* command_line) override; |
37 void RunTestOnMainThreadLoop() final; | 36 void RunTestOnMainThreadLoop() final; |
38 | 37 |
39 content::WebContents* NavigateToURL(const GURL& url); | 38 content::WebContents* NavigateToURL(const GURL& url); |
40 | 39 |
41 private: | 40 private: |
42 // CastContentWindow::Delegate implementation: | 41 // CastWebView::Delegate implementation: |
| 42 void OnPageStopped(int error_code) override; |
| 43 void OnLoadingStateChanged(bool loading) override; |
43 void OnWindowDestroyed() override; | 44 void OnWindowDestroyed() override; |
44 void OnKeyEvent(const ui::KeyEvent& key_event) override; | 45 void OnKeyEvent(const ui::KeyEvent& key_event) override; |
45 | 46 |
46 std::unique_ptr<CastContentWindow> window_; | 47 std::unique_ptr<CastWebView> cast_web_view_; |
47 std::unique_ptr<content::WebContents> web_contents_; | |
48 | 48 |
49 DISALLOW_COPY_AND_ASSIGN(CastBrowserTest); | 49 DISALLOW_COPY_AND_ASSIGN(CastBrowserTest); |
50 }; | 50 }; |
51 | 51 |
52 } // namespace shell | 52 } // namespace shell |
53 } // namespace chromecast | 53 } // namespace chromecast |
54 | 54 |
55 #endif // CHROMECAST_BROWSER_TEST_CAST_BROWSER_TEST_H_ | 55 #endif // CHROMECAST_BROWSER_TEST_CAST_BROWSER_TEST_H_ |
OLD | NEW |