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 "content/public/test/browser_test.h" | 12 #include "content/public/test/browser_test.h" |
12 #include "content/public/test/browser_test_base.h" | 13 #include "content/public/test/browser_test_base.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 class WebContents; | 16 class WebContents; |
16 } | 17 } |
17 | 18 |
18 namespace chromecast { | 19 namespace chromecast { |
19 namespace shell { | 20 namespace shell { |
20 | 21 |
21 class CastContentWindow; | |
22 | |
23 // 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 |
24 // 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 |
25 // case, then shuts down the entire shell. | 24 // case, then shuts down the entire shell. |
26 // 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 |
27 // fewer test cases with more assertions are preferable. | 26 // fewer test cases with more assertions are preferable. |
28 class CastBrowserTest : public content::BrowserTestBase { | 27 class CastBrowserTest : public content::BrowserTestBase, |
| 28 CastContentWindow::Delegate { |
29 protected: | 29 protected: |
30 CastBrowserTest(); | 30 CastBrowserTest(); |
31 ~CastBrowserTest() override; | 31 ~CastBrowserTest() override; |
32 | 32 |
33 // content::BrowserTestBase implementation: | 33 // content::BrowserTestBase implementation: |
34 void SetUp() final; | 34 void SetUp() final; |
35 void TearDownOnMainThread() override; | 35 void TearDownOnMainThread() override; |
36 void SetUpCommandLine(base::CommandLine* command_line) override; | 36 void SetUpCommandLine(base::CommandLine* command_line) override; |
37 void RunTestOnMainThreadLoop() final; | 37 void RunTestOnMainThreadLoop() final; |
38 | 38 |
39 content::WebContents* NavigateToURL(const GURL& url); | 39 content::WebContents* NavigateToURL(const GURL& url); |
40 | 40 |
41 private: | 41 private: |
| 42 // CastContentWindow::Delegate implementation: |
| 43 void OnWindowDestroyed() override; |
| 44 void OnKeyEvent(const ui::KeyEvent& key_event) override; |
| 45 |
42 std::unique_ptr<CastContentWindow> window_; | 46 std::unique_ptr<CastContentWindow> window_; |
43 std::unique_ptr<content::WebContents> web_contents_; | 47 std::unique_ptr<content::WebContents> web_contents_; |
44 | 48 |
45 DISALLOW_COPY_AND_ASSIGN(CastBrowserTest); | 49 DISALLOW_COPY_AND_ASSIGN(CastBrowserTest); |
46 }; | 50 }; |
47 | 51 |
48 } // namespace shell | 52 } // namespace shell |
49 } // namespace chromecast | 53 } // namespace chromecast |
50 | 54 |
51 #endif // CHROMECAST_BROWSER_TEST_CAST_BROWSER_TEST_H_ | 55 #endif // CHROMECAST_BROWSER_TEST_CAST_BROWSER_TEST_H_ |
OLD | NEW |