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/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/lazy_instance.h" |
12 #include "base/path_service.h" | 13 #include "base/path_service.h" |
13 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
14 #include "base/test/test_file_util.h" | 15 #include "base/test/test_file_util.h" |
15 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/google/google_util.h" | 17 #include "chrome/browser/google/google_util.h" |
17 #include "chrome/browser/io_thread.h" | 18 #include "chrome/browser/io_thread.h" |
18 #include "chrome/browser/lifetime/application_lifetime.h" | 19 #include "chrome/browser/lifetime/application_lifetime.h" |
19 #include "chrome/browser/net/net_error_tab_helper.h" | 20 #include "chrome/browser/net/net_error_tab_helper.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 54 |
54 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 55 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
55 #include "chrome/browser/captive_portal/captive_portal_service.h" | 56 #include "chrome/browser/captive_portal/captive_portal_service.h" |
56 #endif | 57 #endif |
57 | 58 |
58 namespace { | 59 namespace { |
59 | 60 |
60 // Passed as value of kTestType. | 61 // Passed as value of kTestType. |
61 const char kBrowserTestType[] = "browser"; | 62 const char kBrowserTestType[] = "browser"; |
62 | 63 |
| 64 // Used when running in single-process mode. |
| 65 base::LazyInstance<chrome::ChromeContentRendererClient>::Leaky |
| 66 g_chrome_content_renderer_client = LAZY_INSTANCE_INITIALIZER; |
| 67 |
63 } // namespace | 68 } // namespace |
64 | 69 |
65 InProcessBrowserTest::InProcessBrowserTest() | 70 InProcessBrowserTest::InProcessBrowserTest() |
66 : browser_(NULL) | 71 : browser_(NULL) |
67 #if defined(OS_MACOSX) | 72 #if defined(OS_MACOSX) |
68 , autorelease_pool_(NULL) | 73 , autorelease_pool_(NULL) |
69 #endif // OS_MACOSX | 74 #endif // OS_MACOSX |
70 { | 75 { |
71 #if defined(OS_MACOSX) | 76 #if defined(OS_MACOSX) |
72 // TODO(phajdan.jr): Make browser_tests self-contained on Mac, remove this. | 77 // TODO(phajdan.jr): Make browser_tests self-contained on Mac, remove this. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 << "Could not create user data directory."; | 109 << "Could not create user data directory."; |
105 | 110 |
106 // Allow subclasses the opportunity to make changes to the default user data | 111 // Allow subclasses the opportunity to make changes to the default user data |
107 // dir before running any tests. | 112 // dir before running any tests. |
108 ASSERT_TRUE(SetUpUserDataDirectory()) | 113 ASSERT_TRUE(SetUpUserDataDirectory()) |
109 << "Could not set up user data directory."; | 114 << "Could not set up user data directory."; |
110 | 115 |
111 // Single-process mode is not set in BrowserMain, so process it explicitly, | 116 // Single-process mode is not set in BrowserMain, so process it explicitly, |
112 // and set up renderer. | 117 // and set up renderer. |
113 if (command_line->HasSwitch(switches::kSingleProcess)) { | 118 if (command_line->HasSwitch(switches::kSingleProcess)) { |
114 single_process_renderer_client_.reset( | |
115 new chrome::ChromeContentRendererClient); | |
116 content::GetContentClient()->set_renderer_for_testing( | 119 content::GetContentClient()->set_renderer_for_testing( |
117 single_process_renderer_client_.get()); | 120 &g_chrome_content_renderer_client.Get()); |
118 } | 121 } |
119 | 122 |
120 #if defined(OS_CHROMEOS) | 123 #if defined(OS_CHROMEOS) |
121 // Make sure that the log directory exists. | 124 // Make sure that the log directory exists. |
122 FilePath log_dir = logging::GetSessionLogFile(*command_line).DirName(); | 125 FilePath log_dir = logging::GetSessionLogFile(*command_line).DirName(); |
123 file_util::CreateDirectory(log_dir); | 126 file_util::CreateDirectory(log_dir); |
124 #endif // defined(OS_CHROMEOS) | 127 #endif // defined(OS_CHROMEOS) |
125 | 128 |
126 host_resolver_ = new net::RuleBasedHostResolverProc(NULL); | 129 host_resolver_ = new net::RuleBasedHostResolverProc(NULL); |
127 | 130 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 // On the Mac, this eventually reaches | 381 // On the Mac, this eventually reaches |
379 // -[BrowserWindowController windowWillClose:], which will post a deferred | 382 // -[BrowserWindowController windowWillClose:], which will post a deferred |
380 // -autorelease on itself to ultimately destroy the Browser object. The line | 383 // -autorelease on itself to ultimately destroy the Browser object. The line |
381 // below is necessary to pump these pending messages to ensure all Browsers | 384 // below is necessary to pump these pending messages to ensure all Browsers |
382 // get deleted. | 385 // get deleted. |
383 content::RunAllPendingInMessageLoop(); | 386 content::RunAllPendingInMessageLoop(); |
384 delete autorelease_pool_; | 387 delete autorelease_pool_; |
385 autorelease_pool_ = NULL; | 388 autorelease_pool_ = NULL; |
386 #endif | 389 #endif |
387 } | 390 } |
OLD | NEW |