| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chromecast/browser/test/chromecast_browser_test.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" |
| 9 #include "base/run_loop.h" |
| 10 #include "chromecast/base/metrics/cast_metrics_helper.h" |
| 11 #include "chromecast/browser/cast_browser_context.h" |
| 12 #include "chromecast/browser/cast_browser_process.h" |
| 13 #include "chromecast/browser/cast_content_window.h" |
| 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/render_process_host.h" |
| 16 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/test/browser_test_utils.h" |
| 18 #include "content/public/test/test_navigation_observer.h" |
| 19 |
| 20 namespace chromecast { |
| 21 namespace shell { |
| 22 |
| 23 ChromecastBrowserTest::ChromecastBrowserTest() {} |
| 24 |
| 25 ChromecastBrowserTest::~ChromecastBrowserTest() {} |
| 26 |
| 27 void ChromecastBrowserTest::SetUp() { |
| 28 SetUpCommandLine(base::CommandLine::ForCurrentProcess()); |
| 29 |
| 30 BrowserTestBase::SetUp(); |
| 31 } |
| 32 |
| 33 void ChromecastBrowserTest::TearDownOnMainThread() { |
| 34 web_contents_.reset(); |
| 35 window_.reset(); |
| 36 |
| 37 BrowserTestBase::TearDownOnMainThread(); |
| 38 } |
| 39 |
| 40 void ChromecastBrowserTest::RunTestOnMainThreadLoop() { |
| 41 // Pump startup related events. |
| 42 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 43 base::RunLoop().RunUntilIdle(); |
| 44 |
| 45 metrics::CastMetricsHelper::GetInstance()->SetDummySessionIdForTesting(); |
| 46 |
| 47 SetUpOnMainThread(); |
| 48 RunTestOnMainThread(); |
| 49 TearDownOnMainThread(); |
| 50 } |
| 51 |
| 52 content::WebContents* ChromecastBrowserTest::NavigateToURL(const GURL& url) { |
| 53 window_ = base::MakeUnique<CastContentWindow>(); |
| 54 |
| 55 web_contents_ = window_->CreateWebContents( |
| 56 CastBrowserProcess::GetInstance()->browser_context()); |
| 57 window_->CreateWindowTree(web_contents_.get()); |
| 58 content::WaitForLoadStop(web_contents_.get()); |
| 59 |
| 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(); |
| 68 } |
| 69 |
| 70 } // namespace shell |
| 71 } // namespace chromecast |
| OLD | NEW |