Make Ctrl + T from apps focus the new tab's omnibox on Linux and ChromeOS.
[chromium-blink-merge.git] / chromecast / browser / test / chromecast_browser_test.cc
blob3a502a144e344d8e94e130d7e5caaa5a07e8f3e3
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.
5 #include "chromecast/browser/test/chromecast_browser_test.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h"
10 #include "chromecast/browser/cast_browser_context.h"
11 #include "chromecast/browser/cast_browser_process.h"
12 #include "chromecast/browser/cast_content_window.h"
13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/web_contents.h"
16 #include "content/public/test/browser_test_utils.h"
17 #include "content/public/test/test_navigation_observer.h"
19 namespace chromecast {
20 namespace shell {
22 ChromecastBrowserTest::ChromecastBrowserTest()
23 : setup_called_(false) {
26 ChromecastBrowserTest::~ChromecastBrowserTest() {
27 CHECK(setup_called_) << "Overridden SetUp() did not call parent "
28 << "implementation, so test not run.";
31 void ChromecastBrowserTest::SetUp() {
32 SetUpCommandLine(base::CommandLine::ForCurrentProcess());
33 setup_called_ = true;
34 BrowserTestBase::SetUp();
37 void ChromecastBrowserTest::RunTestOnMainThreadLoop() {
38 // Pump startup related events.
39 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
40 base::RunLoop().RunUntilIdle();
42 SetUpOnMainThread();
44 RunTestOnMainThread();
46 TearDownOnMainThread();
48 web_contents_.reset();
49 window_.reset();
52 void ChromecastBrowserTest::NavigateToURL(content::WebContents* window,
53 const GURL& url) {
54 content::WaitForLoadStop(window);
55 content::TestNavigationObserver same_tab_observer(window, 1);
56 content::NavigationController::LoadURLParams params(url);
57 params.transition_type = ui::PageTransitionFromInt(
58 ui::PAGE_TRANSITION_TYPED |
59 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
60 window->GetController().LoadURLWithParams(params);
61 same_tab_observer.Wait();
64 content::WebContents* ChromecastBrowserTest::CreateBrowser() {
65 window_.reset(new CastContentWindow);
66 gfx::Size initial_size(1280, 720);
68 web_contents_ = window_->CreateWebContents(
69 initial_size,
70 CastBrowserProcess::GetInstance()->browser_context());
71 window_->CreateWindowTree(initial_size, web_contents_.get());
72 return web_contents_.get();
75 } // namespace shell
76 } // namespace chromecast