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

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

Issue 2832153003: Move calling of shared browser test methods like SetUpOnMainThread/TearDownOnMainThread/RunTestOn... (Closed)
Patch Set: sync Created 3 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
« no previous file with comments | « chromecast/browser/test/cast_browser_test.h ('k') | content/public/test/browser_test_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/cast_browser_test.h" 5 #include "chromecast/browser/test/cast_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/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 15 matching lines...) Expand all
26 CastBrowserTest::CastBrowserTest() {} 26 CastBrowserTest::CastBrowserTest() {}
27 27
28 CastBrowserTest::~CastBrowserTest() {} 28 CastBrowserTest::~CastBrowserTest() {}
29 29
30 void CastBrowserTest::SetUp() { 30 void CastBrowserTest::SetUp() {
31 SetUpCommandLine(base::CommandLine::ForCurrentProcess()); 31 SetUpCommandLine(base::CommandLine::ForCurrentProcess());
32 32
33 BrowserTestBase::SetUp(); 33 BrowserTestBase::SetUp();
34 } 34 }
35 35
36 void CastBrowserTest::TearDownOnMainThread() {
37 cast_web_view_.reset();
38
39 BrowserTestBase::TearDownOnMainThread();
40 }
41
42 void CastBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { 36 void CastBrowserTest::SetUpCommandLine(base::CommandLine* command_line) {
43 BrowserTestBase::SetUpCommandLine(command_line);
44
45 command_line->AppendSwitch(switches::kNoWifi); 37 command_line->AppendSwitch(switches::kNoWifi);
46 command_line->AppendSwitchASCII(switches::kTestType, "browser"); 38 command_line->AppendSwitchASCII(switches::kTestType, "browser");
47 } 39 }
48 40
49 void CastBrowserTest::RunTestOnMainThreadLoop() { 41 void CastBrowserTest::PreRunTestOnMainThread() {
50 // Pump startup related events. 42 // Pump startup related events.
51 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 43 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
52 base::RunLoop().RunUntilIdle(); 44 base::RunLoop().RunUntilIdle();
53 45
54 metrics::CastMetricsHelper::GetInstance()->SetDummySessionIdForTesting(); 46 metrics::CastMetricsHelper::GetInstance()->SetDummySessionIdForTesting();
47 }
55 48
56 SetUpOnMainThread(); 49 void CastBrowserTest::PostRunTestOnMainThread() {
57 RunTestOnMainThread(); 50 cast_web_view_.reset();
58 TearDownOnMainThread();
59 } 51 }
60 52
61 content::WebContents* CastBrowserTest::NavigateToURL(const GURL& url) { 53 content::WebContents* CastBrowserTest::NavigateToURL(const GURL& url) {
62 cast_web_view_ = base::WrapUnique(new CastWebView( 54 cast_web_view_ = base::WrapUnique(new CastWebView(
63 this, CastBrowserProcess::GetInstance()->browser_context(), nullptr, 55 this, CastBrowserProcess::GetInstance()->browser_context(), nullptr,
64 false /*transparent*/)); 56 false /*transparent*/));
65 57
66 content::WebContents* web_contents = cast_web_view_->web_contents(); 58 content::WebContents* web_contents = cast_web_view_->web_contents();
67 content::WaitForLoadStop(web_contents); 59 content::WaitForLoadStop(web_contents);
68 content::TestNavigationObserver same_tab_observer(web_contents, 1); 60 content::TestNavigationObserver same_tab_observer(web_contents, 1);
69 61
70 cast_web_view_->LoadUrl(url); 62 cast_web_view_->LoadUrl(url);
71 63
72 same_tab_observer.Wait(); 64 same_tab_observer.Wait();
73 65
74 return web_contents; 66 return web_contents;
75 } 67 }
76 68
77 void CastBrowserTest::OnPageStopped(int reason) {} 69 void CastBrowserTest::OnPageStopped(int reason) {}
78 70
79 void CastBrowserTest::OnLoadingStateChanged(bool loading) {} 71 void CastBrowserTest::OnLoadingStateChanged(bool loading) {}
80 72
81 void CastBrowserTest::OnWindowDestroyed() {} 73 void CastBrowserTest::OnWindowDestroyed() {}
82 74
83 void CastBrowserTest::OnKeyEvent(const ui::KeyEvent& key_event) {} 75 void CastBrowserTest::OnKeyEvent(const ui::KeyEvent& key_event) {}
84 76
85 } // namespace shell 77 } // namespace shell
86 } // namespace chromecast 78 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/test/cast_browser_test.h ('k') | content/public/test/browser_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698