OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/test/base/in_process_browser_test.h" | 5 #include "chrome/test/base/in_process_browser_test.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/stack_trace.h" | 10 #include "base/debug/stack_trace.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 test_server_.reset(new net::TestServer( | 80 test_server_.reset(new net::TestServer( |
81 net::TestServer::TYPE_HTTP, | 81 net::TestServer::TYPE_HTTP, |
82 net::TestServer::kLocalhost, | 82 net::TestServer::kLocalhost, |
83 FilePath(FILE_PATH_LITERAL("chrome/test/data")))); | 83 FilePath(FILE_PATH_LITERAL("chrome/test/data")))); |
84 } | 84 } |
85 | 85 |
86 InProcessBrowserTest::~InProcessBrowserTest() { | 86 InProcessBrowserTest::~InProcessBrowserTest() { |
87 } | 87 } |
88 | 88 |
89 void InProcessBrowserTest::SetUp() { | 89 void InProcessBrowserTest::SetUp() { |
90 // Create a temporary user data directory if required. | |
91 ASSERT_TRUE(CreateUserDataDirectory()) | |
92 << "Could not create user data directory."; | |
93 | |
94 // Undo TestingBrowserProcess creation in ChromeTestSuite. | 90 // Undo TestingBrowserProcess creation in ChromeTestSuite. |
95 // TODO(phajdan.jr): Extract a smaller test suite so we don't need this. | 91 // TODO(phajdan.jr): Extract a smaller test suite so we don't need this. |
96 DCHECK(g_browser_process); | 92 DCHECK(g_browser_process); |
97 delete g_browser_process; | 93 delete g_browser_process; |
98 g_browser_process = NULL; | 94 g_browser_process = NULL; |
99 | 95 |
100 // Allow subclasses the opportunity to make changes to the default user data | |
101 // dir before running any tests. | |
102 ASSERT_TRUE(SetUpUserDataDirectory()) | |
103 << "Could not set up user data directory."; | |
104 | |
105 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 96 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
106 // Allow subclasses to change the command line before running any tests. | 97 // Allow subclasses to change the command line before running any tests. |
107 SetUpCommandLine(command_line); | 98 SetUpCommandLine(command_line); |
108 // Add command line arguments that are used by all InProcessBrowserTests. | 99 // Add command line arguments that are used by all InProcessBrowserTests. |
109 PrepareTestCommandLine(command_line); | 100 PrepareTestCommandLine(command_line); |
110 | 101 |
| 102 // Create a temporary user data directory if required. |
| 103 ASSERT_TRUE(CreateUserDataDirectory()) |
| 104 << "Could not create user data directory."; |
| 105 |
| 106 // Allow subclasses the opportunity to make changes to the default user data |
| 107 // dir before running any tests. |
| 108 ASSERT_TRUE(SetUpUserDataDirectory()) |
| 109 << "Could not set up user data directory."; |
| 110 |
111 // Single-process mode is not set in BrowserMain, so process it explicitly, | 111 // Single-process mode is not set in BrowserMain, so process it explicitly, |
112 // and set up renderer. | 112 // and set up renderer. |
113 if (command_line->HasSwitch(switches::kSingleProcess)) { | 113 if (command_line->HasSwitch(switches::kSingleProcess)) { |
114 content::RenderProcessHost::set_run_renderer_in_process(true); | 114 content::RenderProcessHost::set_run_renderer_in_process(true); |
115 single_process_renderer_client_.reset( | 115 single_process_renderer_client_.reset( |
116 new content::MockContentRendererClient); | 116 new content::MockContentRendererClient); |
117 content::GetContentClient()->set_renderer( | 117 content::GetContentClient()->set_renderer( |
118 single_process_renderer_client_.get()); | 118 single_process_renderer_client_.get()); |
119 } | 119 } |
120 | 120 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 if (BrowserList::size() == 0) | 352 if (BrowserList::size() == 0) |
353 return; | 353 return; |
354 | 354 |
355 // Invoke CloseAllBrowsersAndMayExit on a running message loop. | 355 // Invoke CloseAllBrowsersAndMayExit on a running message loop. |
356 // CloseAllBrowsersAndMayExit exits the message loop after everything has been | 356 // CloseAllBrowsersAndMayExit exits the message loop after everything has been |
357 // shut down properly. | 357 // shut down properly. |
358 MessageLoopForUI::current()->PostTask(FROM_HERE, | 358 MessageLoopForUI::current()->PostTask(FROM_HERE, |
359 base::Bind(&BrowserList::AttemptExit)); | 359 base::Bind(&BrowserList::AttemptExit)); |
360 ui_test_utils::RunMessageLoop(); | 360 ui_test_utils::RunMessageLoop(); |
361 } | 361 } |
OLD | NEW |