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

Side by Side Diff: chromecast/browser/renderer_prelauncher_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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/renderer_prelauncher.h" 5 #include "chromecast/browser/renderer_prelauncher.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 12 matching lines...) Expand all
23 namespace chromecast { 23 namespace chromecast {
24 24
25 class RendererPrelauncherTest : public content::BrowserTestBase { 25 class RendererPrelauncherTest : public content::BrowserTestBase {
26 public: 26 public:
27 RendererPrelauncherTest() {} 27 RendererPrelauncherTest() {}
28 ~RendererPrelauncherTest() override {} 28 ~RendererPrelauncherTest() override {}
29 29
30 protected: 30 protected:
31 // content::BrowserTestBase implementation: 31 // content::BrowserTestBase implementation:
32 void SetUp() override; 32 void SetUp() override;
33 void RunTestOnMainThreadLoop() override; 33 void PreRunTestOnMainThread() override;
34 void PostRunTestOnMainThread() override {}
34 35
35 private: 36 private:
36 DISALLOW_COPY_AND_ASSIGN(RendererPrelauncherTest); 37 DISALLOW_COPY_AND_ASSIGN(RendererPrelauncherTest);
37 }; 38 };
38 39
39 void RendererPrelauncherTest::SetUp() { 40 void RendererPrelauncherTest::SetUp() {
40 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 41 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
41 command_line->AppendSwitch(switches::kNoWifi); 42 command_line->AppendSwitch(switches::kNoWifi);
42 command_line->AppendSwitchASCII(switches::kTestType, "browser"); 43 command_line->AppendSwitchASCII(switches::kTestType, "browser");
43 44
44 BrowserTestBase::SetUp(); 45 BrowserTestBase::SetUp();
45 } 46 }
46 47
47 void RendererPrelauncherTest::RunTestOnMainThreadLoop() { 48 void RendererPrelauncherTest::PreRunTestOnMainThread() {
48 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 49 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
49 base::RunLoop().RunUntilIdle(); 50 base::RunLoop().RunUntilIdle();
50 51
51 metrics::CastMetricsHelper::GetInstance()->SetDummySessionIdForTesting(); 52 metrics::CastMetricsHelper::GetInstance()->SetDummySessionIdForTesting();
52
53 SetUpOnMainThread();
54 RunTestOnMainThread();
55 TearDownOnMainThread();
56 } 53 }
57 54
58 IN_PROC_BROWSER_TEST_F(RendererPrelauncherTest, ReusedRenderer) { 55 IN_PROC_BROWSER_TEST_F(RendererPrelauncherTest, ReusedRenderer) {
59 GURL gurl("https://www.google.com/"); 56 GURL gurl("https://www.google.com/");
60 content::BrowserContext* browser_context = 57 content::BrowserContext* browser_context =
61 shell::CastBrowserProcess::GetInstance()->browser_context(); 58 shell::CastBrowserProcess::GetInstance()->browser_context();
62 EXPECT_TRUE(browser_context); 59 EXPECT_TRUE(browser_context);
63 60
64 // Prelaunch a renderer process for the url. 61 // Prelaunch a renderer process for the url.
65 std::unique_ptr<RendererPrelauncher> prelauncher( 62 std::unique_ptr<RendererPrelauncher> prelauncher(
(...skipping 20 matching lines...) Expand all
86 // Ensure that the renderer process terminates. 83 // Ensure that the renderer process terminates.
87 prelauncher.reset(); 84 prelauncher.reset();
88 web_contents.reset(); 85 web_contents.reset();
89 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 86 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
90 switches::kSingleProcess)) { 87 switches::kSingleProcess)) {
91 EXPECT_FALSE(site_instance->HasProcess()); 88 EXPECT_FALSE(site_instance->HasProcess());
92 } 89 }
93 } 90 }
94 91
95 } // namespace chromecast 92 } // namespace chromecast
OLDNEW
« no previous file with comments | « chrome/test/base/in_process_browser_test.cc ('k') | chromecast/browser/test/cast_browser_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698