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

Side by Side Diff: content/public/test/content_browser_test.cc

Issue 1232973002: Crash tests when BrowserTestBase::SetUp is not called (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 | « content/public/test/content_browser_test.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/public/test/content_browser_test.h" 5 #include "content/public/test/content_browser_test.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 17 matching lines...) Expand all
28 #if defined(OS_MACOSX) 28 #if defined(OS_MACOSX)
29 #include "base/mac/scoped_nsautorelease_pool.h" 29 #include "base/mac/scoped_nsautorelease_pool.h"
30 #endif 30 #endif
31 31
32 #if !defined(OS_CHROMEOS) && defined(OS_LINUX) 32 #if !defined(OS_CHROMEOS) && defined(OS_LINUX)
33 #include "ui/base/ime/input_method_initializer.h" 33 #include "ui/base/ime/input_method_initializer.h"
34 #endif 34 #endif
35 35
36 namespace content { 36 namespace content {
37 37
38 ContentBrowserTest::ContentBrowserTest() 38 ContentBrowserTest::ContentBrowserTest() {
39 : setup_called_(false) {
40 #if defined(OS_MACOSX) 39 #if defined(OS_MACOSX)
41 // See comment in InProcessBrowserTest::InProcessBrowserTest(). 40 // See comment in InProcessBrowserTest::InProcessBrowserTest().
42 base::FilePath content_shell_path; 41 base::FilePath content_shell_path;
43 CHECK(PathService::Get(base::FILE_EXE, &content_shell_path)); 42 CHECK(PathService::Get(base::FILE_EXE, &content_shell_path));
44 content_shell_path = content_shell_path.DirName(); 43 content_shell_path = content_shell_path.DirName();
45 content_shell_path = content_shell_path.Append( 44 content_shell_path = content_shell_path.Append(
46 FILE_PATH_LITERAL("Content Shell.app/Contents/MacOS/Content Shell")); 45 FILE_PATH_LITERAL("Content Shell.app/Contents/MacOS/Content Shell"));
47 CHECK(PathService::Override(base::FILE_EXE, content_shell_path)); 46 CHECK(PathService::Override(base::FILE_EXE, content_shell_path));
48 #endif 47 #endif
49 base::FilePath content_test_data(FILE_PATH_LITERAL("content/test/data")); 48 base::FilePath content_test_data(FILE_PATH_LITERAL("content/test/data"));
50 CreateTestServer(content_test_data); 49 CreateTestServer(content_test_data);
51 base::FilePath content_test_data_absolute; 50 base::FilePath content_test_data_absolute;
52 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &content_test_data_absolute)); 51 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &content_test_data_absolute));
53 content_test_data_absolute = 52 content_test_data_absolute =
54 content_test_data_absolute.Append(content_test_data); 53 content_test_data_absolute.Append(content_test_data);
55 embedded_test_server()->ServeFilesFromDirectory(content_test_data_absolute); 54 embedded_test_server()->ServeFilesFromDirectory(content_test_data_absolute);
56 } 55 }
57 56
58 ContentBrowserTest::~ContentBrowserTest() { 57 ContentBrowserTest::~ContentBrowserTest() {
59 CHECK(setup_called_) << "Overridden SetUp() did not call parent "
60 "implementation, so test not run.";
61 } 58 }
62 59
63 void ContentBrowserTest::SetUp() { 60 void ContentBrowserTest::SetUp() {
64 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 61 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
65 command_line->AppendSwitch(switches::kContentBrowserTest); 62 command_line->AppendSwitch(switches::kContentBrowserTest);
66 63
67 SetUpCommandLine(command_line); 64 SetUpCommandLine(command_line);
68 65
69 #if defined(OS_ANDROID) 66 #if defined(OS_ANDROID)
70 shell_main_delegate_.reset(new ShellMainDelegate); 67 shell_main_delegate_.reset(new ShellMainDelegate);
(...skipping 19 matching lines...) Expand all
90 "Frameworks/Content Shell Helper.app/Contents/MacOS/Content Shell Helper") ; 87 "Frameworks/Content Shell Helper.app/Contents/MacOS/Content Shell Helper") ;
91 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, 88 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath,
92 subprocess_path); 89 subprocess_path);
93 #endif 90 #endif
94 91
95 // LinuxInputMethodContextFactory has to be initialized. 92 // LinuxInputMethodContextFactory has to be initialized.
96 #if !defined(OS_CHROMEOS) && defined(OS_LINUX) 93 #if !defined(OS_CHROMEOS) && defined(OS_LINUX)
97 ui::InitializeInputMethodForTesting(); 94 ui::InitializeInputMethodForTesting();
98 #endif 95 #endif
99 96
100 setup_called_ = true;
101
102 BrowserTestBase::SetUp(); 97 BrowserTestBase::SetUp();
103 } 98 }
104 99
105 void ContentBrowserTest::TearDown() { 100 void ContentBrowserTest::TearDown() {
106 BrowserTestBase::TearDown(); 101 BrowserTestBase::TearDown();
107 102
108 // LinuxInputMethodContextFactory has to be shutdown. 103 // LinuxInputMethodContextFactory has to be shutdown.
109 #if !defined(OS_CHROMEOS) && defined(OS_LINUX) 104 #if !defined(OS_CHROMEOS) && defined(OS_LINUX)
110 ui::ShutdownInputMethodForTesting(); 105 ui::ShutdownInputMethodForTesting();
111 #endif 106 #endif
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 162
168 Shell* ContentBrowserTest::CreateOffTheRecordBrowser() { 163 Shell* ContentBrowserTest::CreateOffTheRecordBrowser() {
169 return Shell::CreateNewWindow( 164 return Shell::CreateNewWindow(
170 ShellContentBrowserClient::Get()->off_the_record_browser_context(), 165 ShellContentBrowserClient::Get()->off_the_record_browser_context(),
171 GURL(url::kAboutBlankURL), 166 GURL(url::kAboutBlankURL),
172 NULL, 167 NULL,
173 gfx::Size()); 168 gfx::Size());
174 } 169 }
175 170
176 } // namespace content 171 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/content_browser_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698