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

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

Issue 518773003: Chromecast: end-to-end browser test based on content::BrowserTest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cast-browser-process
Patch Set: Created 6 years, 3 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
(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/shell/browser/test/chromecast_browser_test.h"
6
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h"
10 #include "chromecast/shell/browser/cast_browser_context.h"
11 #include "chromecast/shell/browser/cast_browser_process.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/web_contents.h"
15 #include "content/public/test/browser_test_utils.h"
16 #include "content/public/test/test_navigation_observer.h"
17
18 namespace chromecast {
19 namespace shell {
20
21 ChromecastBrowserTest::ChromecastBrowserTest()
22 : setup_called_(false) {
23 }
24
25 ChromecastBrowserTest::~ChromecastBrowserTest() {
26 CHECK(setup_called_) << "Overridden SetUp() did not call parent "
27 << "implementation, so test not run.";
28 }
29
30 void ChromecastBrowserTest::SetUp() {
31 SetUpCommandLine(CommandLine::ForCurrentProcess());
32 setup_called_ = true;
33 BrowserTestBase::SetUp();
34 }
35
36 void ChromecastBrowserTest::TearDown() {
byungchul 2014/08/30 00:18:59 necessary while it calls just super class function
gunsch 2014/08/30 15:28:43 Done.
37 BrowserTestBase::TearDown();
38 }
39
40 void ChromecastBrowserTest::RunTestOnMainThreadLoop() {
41 // Pump startup related events.
42 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
43 base::RunLoop().RunUntilIdle();
44
45 SetUpOnMainThread();
46
47 RunTestOnMainThread();
48
49 TearDownOnMainThread();
50
51 for (content::RenderProcessHost::iterator i(
52 content::RenderProcessHost::AllHostsIterator());
53 !i.IsAtEnd(); i.Advance()) {
54 i.GetCurrentValue()->FastShutdownIfPossible();
55 }
56
57 web_contents_.reset();
58 }
59
60 void ChromecastBrowserTest::NavigateToURL(content::WebContents* window,
61 const GURL& url) {
62 content::WaitForLoadStop(window);
63 content::TestNavigationObserver same_tab_observer(window, 1);
64 content::NavigationController::LoadURLParams params(url);
65 params.transition_type = content::PageTransitionFromInt(
66 content::PAGE_TRANSITION_TYPED |
67 content::PAGE_TRANSITION_FROM_ADDRESS_BAR);
68 window->GetController().LoadURLWithParams(params);
69 same_tab_observer.Wait();
70 }
71
72 content::WebContents* ChromecastBrowserTest::CreateBrowser() {
73 content::WebContents::CreateParams create_params(
74 CastBrowserProcess::GetInstance()->browser_context(),
75 NULL);
76 create_params.routing_id = MSG_ROUTING_NONE;
77 create_params.initial_size = gfx::Size(1280, 720);
78 web_contents_.reset(content::WebContents::Create(create_params));
79 return web_contents_.get();
80 }
81
82 } // namespace shell
83 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698