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

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: fixes 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 BrowserTestBase::SetUp();
45 } 44 }
46 45
47 void RendererPrelauncherTest::RunTestOnMainThreadLoop() { 46 void RendererPrelauncherTest::PreRunTestOnMainThread() {
48 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 47 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
49 base::RunLoop().RunUntilIdle(); 48 base::RunLoop().RunUntilIdle();
50 49
51 metrics::CastMetricsHelper::GetInstance()->SetDummySessionIdForTesting(); 50 metrics::CastMetricsHelper::GetInstance()->SetDummySessionIdForTesting();
52
53 SetUpOnMainThread();
54 RunTestOnMainThread();
55 TearDownOnMainThread();
56 } 51 }
57 52
58 IN_PROC_BROWSER_TEST_F(RendererPrelauncherTest, ReusedRenderer) { 53 IN_PROC_BROWSER_TEST_F(RendererPrelauncherTest, ReusedRenderer) {
59 GURL gurl("https://www.google.com/"); 54 GURL gurl("https://www.google.com/");
60 content::BrowserContext* browser_context = 55 content::BrowserContext* browser_context =
61 shell::CastBrowserProcess::GetInstance()->browser_context(); 56 shell::CastBrowserProcess::GetInstance()->browser_context();
62 EXPECT_TRUE(browser_context); 57 EXPECT_TRUE(browser_context);
63 58
64 // Prelaunch a renderer process for the url. 59 // Prelaunch a renderer process for the url.
65 std::unique_ptr<RendererPrelauncher> prelauncher( 60 std::unique_ptr<RendererPrelauncher> prelauncher(
(...skipping 20 matching lines...) Expand all
86 // Ensure that the renderer process terminates. 81 // Ensure that the renderer process terminates.
87 prelauncher.reset(); 82 prelauncher.reset();
88 web_contents.reset(); 83 web_contents.reset();
89 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 84 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
90 switches::kSingleProcess)) { 85 switches::kSingleProcess)) {
91 EXPECT_FALSE(site_instance->HasProcess()); 86 EXPECT_FALSE(site_instance->HasProcess());
92 } 87 }
93 } 88 }
94 89
95 } // namespace chromecast 90 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698