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 #include "chromecast/browser/test/cast_browser_test.h" | 5 #include "chromecast/browser/test/cast_browser_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 CastBrowserTest::~CastBrowserTest() {} | 28 CastBrowserTest::~CastBrowserTest() {} |
29 | 29 |
30 void CastBrowserTest::SetUp() { | 30 void CastBrowserTest::SetUp() { |
31 SetUpCommandLine(base::CommandLine::ForCurrentProcess()); | 31 SetUpCommandLine(base::CommandLine::ForCurrentProcess()); |
32 | 32 |
33 BrowserTestBase::SetUp(); | 33 BrowserTestBase::SetUp(); |
34 } | 34 } |
35 | 35 |
36 void CastBrowserTest::TearDownOnMainThread() { | 36 void CastBrowserTest::TearDownOnMainThread() { |
37 web_contents_.reset(); | 37 cast_web_view_.reset(); |
38 window_.reset(); | |
39 | 38 |
40 BrowserTestBase::TearDownOnMainThread(); | 39 BrowserTestBase::TearDownOnMainThread(); |
41 } | 40 } |
42 | 41 |
43 void CastBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { | 42 void CastBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { |
44 BrowserTestBase::SetUpCommandLine(command_line); | 43 BrowserTestBase::SetUpCommandLine(command_line); |
45 | 44 |
46 command_line->AppendSwitch(switches::kNoWifi); | 45 command_line->AppendSwitch(switches::kNoWifi); |
47 command_line->AppendSwitchASCII(switches::kTestType, "browser"); | 46 command_line->AppendSwitchASCII(switches::kTestType, "browser"); |
48 } | 47 } |
49 | 48 |
50 void CastBrowserTest::RunTestOnMainThreadLoop() { | 49 void CastBrowserTest::RunTestOnMainThreadLoop() { |
51 // Pump startup related events. | 50 // Pump startup related events. |
52 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 51 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
53 base::RunLoop().RunUntilIdle(); | 52 base::RunLoop().RunUntilIdle(); |
54 | 53 |
55 metrics::CastMetricsHelper::GetInstance()->SetDummySessionIdForTesting(); | 54 metrics::CastMetricsHelper::GetInstance()->SetDummySessionIdForTesting(); |
56 | 55 |
57 SetUpOnMainThread(); | 56 SetUpOnMainThread(); |
58 RunTestOnMainThread(); | 57 RunTestOnMainThread(); |
59 TearDownOnMainThread(); | 58 TearDownOnMainThread(); |
60 } | 59 } |
61 | 60 |
62 content::WebContents* CastBrowserTest::NavigateToURL(const GURL& url) { | 61 content::WebContents* CastBrowserTest::NavigateToURL(const GURL& url) { |
63 window_ = CastContentWindow::Create(this); | 62 cast_web_view_ = base::WrapUnique(new CastWebView( |
| 63 this, CastBrowserProcess::GetInstance()->browser_context(), nullptr, |
| 64 false /*transparent*/)); |
64 | 65 |
65 web_contents_ = window_->CreateWebContents( | 66 content::WebContents* web_contents = cast_web_view_->web_contents(); |
66 CastBrowserProcess::GetInstance()->browser_context()); | 67 content::WaitForLoadStop(web_contents); |
67 content::WaitForLoadStop(web_contents_.get()); | 68 content::TestNavigationObserver same_tab_observer(web_contents, 1); |
68 | 69 |
69 content::TestNavigationObserver same_tab_observer(web_contents_.get(), 1); | 70 cast_web_view_->LoadUrl(url); |
70 content::NavigationController::LoadURLParams params(url); | 71 |
71 params.transition_type = ui::PageTransitionFromInt( | |
72 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); | |
73 web_contents_->GetController().LoadURLWithParams(params); | |
74 same_tab_observer.Wait(); | 72 same_tab_observer.Wait(); |
75 | 73 |
76 return web_contents_.get(); | 74 return web_contents; |
77 } | 75 } |
78 | 76 |
| 77 void CastBrowserTest::OnPageStopped(int reason) {} |
| 78 |
| 79 void CastBrowserTest::OnLoadingStateChanged(bool loading) {} |
| 80 |
79 void CastBrowserTest::OnWindowDestroyed() {} | 81 void CastBrowserTest::OnWindowDestroyed() {} |
80 | 82 |
81 void CastBrowserTest::OnKeyEvent(const ui::KeyEvent& key_event) {} | 83 void CastBrowserTest::OnKeyEvent(const ui::KeyEvent& key_event) {} |
82 | 84 |
83 } // namespace shell | 85 } // namespace shell |
84 } // namespace chromecast | 86 } // namespace chromecast |
OLD | NEW |