Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: chromecast/browser/test/cast_browser_test.cc

Issue 2626863006: [Chromecast] Add CastWebContents (Closed)
Patch Set: [Chromecast] Add CastWebContents Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromecast/browser/test/cast_browser_test.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « chromecast/browser/test/cast_browser_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698