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

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

Issue 2485843002: [chromecast] Merge ChromecastBrowserTestHelper into ChromecastBrowserTest (Closed)
Patch Set: cleanup Created 4 years, 1 month 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
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/chromecast_browser_test.h" 5 #include "chromecast/browser/test/chromecast_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/run_loop.h" 9 #include "base/run_loop.h"
10 #include "chromecast/base/metrics/cast_metrics_helper.h" 10 #include "chromecast/base/metrics/cast_metrics_helper.h"
11 #include "chromecast/browser/cast_browser_context.h" 11 #include "chromecast/browser/cast_browser_context.h"
12 #include "chromecast/browser/cast_browser_process.h" 12 #include "chromecast/browser/cast_browser_process.h"
13 #include "chromecast/browser/test/chromecast_browser_test_helper.h" 13 #include "chromecast/browser/cast_content_window.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/render_process_host.h" 15 #include "content/public/browser/render_process_host.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/test/browser_test_utils.h" 17 #include "content/public/test/browser_test_utils.h"
18 #include "content/public/test/test_navigation_observer.h"
18 19
19 namespace chromecast { 20 namespace chromecast {
20 namespace shell { 21 namespace shell {
21 22
22 ChromecastBrowserTest::ChromecastBrowserTest() 23 ChromecastBrowserTest::ChromecastBrowserTest() {}
23 : setup_called_(false) {
24 }
25 24
26 ChromecastBrowserTest::~ChromecastBrowserTest() { 25 ChromecastBrowserTest::~ChromecastBrowserTest() {}
27 CHECK(setup_called_) << "Overridden SetUp() did not call parent "
alokp 2016/11/08 19:02:44 There is no need to check this here. It is already
28 << "implementation, so test not run.";
29 }
30 26
31 void ChromecastBrowserTest::SetUp() { 27 void ChromecastBrowserTest::SetUp() {
32 SetUpCommandLine(base::CommandLine::ForCurrentProcess()); 28 SetUpCommandLine(base::CommandLine::ForCurrentProcess());
33 setup_called_ = true; 29
34 BrowserTestBase::SetUp(); 30 BrowserTestBase::SetUp();
35 } 31 }
36 32
33 void ChromecastBrowserTest::TearDownOnMainThread() {
34 web_contents_.reset();
35 window_.reset();
36
37 BrowserTestBase::TearDownOnMainThread();
38 }
39
37 void ChromecastBrowserTest::RunTestOnMainThreadLoop() { 40 void ChromecastBrowserTest::RunTestOnMainThreadLoop() {
38 // Pump startup related events. 41 // Pump startup related events.
39 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 42 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
40 base::RunLoop().RunUntilIdle(); 43 base::RunLoop().RunUntilIdle();
41 44
42 helper_ = ChromecastBrowserTestHelper::Create();
43 metrics::CastMetricsHelper::GetInstance()->SetDummySessionIdForTesting(); 45 metrics::CastMetricsHelper::GetInstance()->SetDummySessionIdForTesting();
46
44 SetUpOnMainThread(); 47 SetUpOnMainThread();
48 RunTestOnMainThread();
49 TearDownOnMainThread();
50 }
45 51
46 RunTestOnMainThread(); 52 content::WebContents* ChromecastBrowserTest::NavigateToURL(const GURL& url) {
53 window_ = base::MakeUnique<CastContentWindow>();
47 54
48 TearDownOnMainThread(); 55 web_contents_ = window_->CreateWebContents(
56 CastBrowserProcess::GetInstance()->browser_context());
57 window_->CreateWindowTree(web_contents_.get());
58 content::WaitForLoadStop(web_contents_.get());
49 59
50 helper_.reset(); 60 content::TestNavigationObserver same_tab_observer(web_contents_.get(), 1);
61 content::NavigationController::LoadURLParams params(url);
62 params.transition_type = ui::PageTransitionFromInt(
63 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
64 web_contents_->GetController().LoadURLWithParams(params);
65 same_tab_observer.Wait();
66
67 return web_contents_.get();
51 } 68 }
52 69
53 } // namespace shell 70 } // namespace shell
54 } // namespace chromecast 71 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698