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

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

Issue 1870443003: [Chromecast] Enable browser media tests to work on internal builds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 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
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/message_loop/message_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/cast_content_window.h" 13 #include "chromecast/browser/test/chromecast_browser_test_helper.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"
19 18
20 namespace chromecast { 19 namespace chromecast {
21 namespace shell { 20 namespace shell {
22 21
23 ChromecastBrowserTest::ChromecastBrowserTest() 22 ChromecastBrowserTest::ChromecastBrowserTest()
24 : setup_called_(false) { 23 : setup_called_(false) {
25 } 24 }
26 25
27 ChromecastBrowserTest::~ChromecastBrowserTest() { 26 ChromecastBrowserTest::~ChromecastBrowserTest() {
28 CHECK(setup_called_) << "Overridden SetUp() did not call parent " 27 CHECK(setup_called_) << "Overridden SetUp() did not call parent "
29 << "implementation, so test not run."; 28 << "implementation, so test not run.";
30 } 29 }
31 30
32 void ChromecastBrowserTest::SetUp() { 31 void ChromecastBrowserTest::SetUp() {
33 SetUpCommandLine(base::CommandLine::ForCurrentProcess()); 32 SetUpCommandLine(base::CommandLine::ForCurrentProcess());
34 setup_called_ = true; 33 setup_called_ = true;
35 BrowserTestBase::SetUp(); 34 BrowserTestBase::SetUp();
36 } 35 }
37 36
38 void ChromecastBrowserTest::RunTestOnMainThreadLoop() { 37 void ChromecastBrowserTest::RunTestOnMainThreadLoop() {
39 // Pump startup related events. 38 // Pump startup related events.
40 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 39 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
41 base::RunLoop().RunUntilIdle(); 40 base::RunLoop().RunUntilIdle();
42 41
42 helper_ = ChromecastBrowserTestHelper::Create();
43 metrics::CastMetricsHelper::GetInstance()->SetDummySessionIdForTesting();
43 SetUpOnMainThread(); 44 SetUpOnMainThread();
44 45
45 RunTestOnMainThread(); 46 RunTestOnMainThread();
46 47
47 TearDownOnMainThread(); 48 TearDownOnMainThread();
48 49
49 web_contents_.reset(); 50 helper_.reset();
50 window_.reset();
51 }
52
53 void ChromecastBrowserTest::NavigateToURL(content::WebContents* window,
54 const GURL& url) {
55 content::WaitForLoadStop(window);
56 content::TestNavigationObserver same_tab_observer(window, 1);
57 content::NavigationController::LoadURLParams params(url);
58 params.transition_type = ui::PageTransitionFromInt(
59 ui::PAGE_TRANSITION_TYPED |
60 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
61 window->GetController().LoadURLWithParams(params);
62 same_tab_observer.Wait();
63 }
64
65 content::WebContents* ChromecastBrowserTest::CreateBrowser() {
66 window_.reset(new CastContentWindow);
67 gfx::Size initial_size(1280, 720);
68
69 web_contents_ = window_->CreateWebContents(
70 initial_size,
71 CastBrowserProcess::GetInstance()->browser_context());
72 window_->CreateWindowTree(initial_size, web_contents_.get());
73
74 metrics::CastMetricsHelper::GetInstance()->SetDummySessionIdForTesting();
75
76 return web_contents_.get();
77 } 51 }
78 52
79 } // namespace shell 53 } // namespace shell
80 } // namespace chromecast 54 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/test/chromecast_browser_test.h ('k') | chromecast/browser/test/chromecast_browser_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698