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

Side by Side Diff: chrome/test/base/in_process_browser_test.cc

Issue 16022003: Base for Ash browser_tests on Win8. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Do not use SetUp/TearDownTestCase() Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/base/in_process_browser_test.h ('k') | chrome/test/base/test_switches.h » ('j') | 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) 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_util.h" 10 #include "base/file_util.h"
(...skipping 18 matching lines...) Expand all
29 #include "chrome/browser/ui/host_desktop.h" 29 #include "chrome/browser/ui/host_desktop.h"
30 #include "chrome/browser/ui/tabs/tab_strip_model.h" 30 #include "chrome/browser/ui/tabs/tab_strip_model.h"
31 #include "chrome/common/chrome_constants.h" 31 #include "chrome/common/chrome_constants.h"
32 #include "chrome/common/chrome_paths.h" 32 #include "chrome/common/chrome_paths.h"
33 #include "chrome/common/chrome_switches.h" 33 #include "chrome/common/chrome_switches.h"
34 #include "chrome/common/logging_chrome.h" 34 #include "chrome/common/logging_chrome.h"
35 #include "chrome/common/url_constants.h" 35 #include "chrome/common/url_constants.h"
36 #include "chrome/renderer/chrome_content_renderer_client.h" 36 #include "chrome/renderer/chrome_content_renderer_client.h"
37 #include "chrome/test/base/chrome_test_suite.h" 37 #include "chrome/test/base/chrome_test_suite.h"
38 #include "chrome/test/base/test_launcher_utils.h" 38 #include "chrome/test/base/test_launcher_utils.h"
39 #include "chrome/test/base/test_switches.h"
39 #include "chrome/test/base/testing_browser_process.h" 40 #include "chrome/test/base/testing_browser_process.h"
40 #include "chrome/test/base/ui_test_utils.h" 41 #include "chrome/test/base/ui_test_utils.h"
41 #include "content/public/browser/notification_service.h" 42 #include "content/public/browser/notification_service.h"
42 #include "content/public/browser/notification_types.h" 43 #include "content/public/browser/notification_types.h"
43 #include "content/public/test/browser_test_utils.h" 44 #include "content/public/test/browser_test_utils.h"
44 #include "content/public/test/test_browser_thread.h" 45 #include "content/public/test/test_browser_thread.h"
45 #include "content/public/test/test_launcher.h" 46 #include "content/public/test/test_launcher.h"
46 #include "content/public/test/test_navigation_observer.h" 47 #include "content/public/test/test_navigation_observer.h"
47 #include "net/dns/mock_host_resolver.h" 48 #include "net/dns/mock_host_resolver.h"
48 #include "net/test/spawned_test_server/spawned_test_server.h" 49 #include "net/test/spawned_test_server/spawned_test_server.h"
49 #include "ui/compositor/compositor_switches.h" 50 #include "ui/compositor/compositor_switches.h"
50 51
51 #if defined(OS_CHROMEOS) 52 #if defined(OS_CHROMEOS)
52 #include "chrome/browser/chromeos/audio/audio_handler.h" 53 #include "chrome/browser/chromeos/audio/audio_handler.h"
53 #elif defined(OS_MACOSX) 54 #elif defined(OS_MACOSX)
54 #include "base/mac/scoped_nsautorelease_pool.h" 55 #include "base/mac/scoped_nsautorelease_pool.h"
55 #endif 56 #endif
56 57
58 #if defined(OS_WIN) && defined(USE_AURA)
59 #include "base/win/scoped_com_initializer.h"
60 #include "base/win/windows_version.h"
61 #include "ui/base/win/atl_module.h"
62 #include "ui/compositor/compositor_setup.h"
63 #include "win8/test/metro_registration_helper.h"
64 #include "win8/test/test_registrar_constants.h"
65 #endif
66
57 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 67 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
58 #include "chrome/browser/captive_portal/captive_portal_service.h" 68 #include "chrome/browser/captive_portal/captive_portal_service.h"
59 #endif 69 #endif
60 70
61 namespace { 71 namespace {
62 72
63 // Passed as value of kTestType. 73 // Passed as value of kTestType.
64 const char kBrowserTestType[] = "browser"; 74 const char kBrowserTestType[] = "browser";
65 75
66 // Used when running in single-process mode. 76 // Used when running in single-process mode.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 162 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
153 captive_portal::CaptivePortalService::set_state_for_testing( 163 captive_portal::CaptivePortalService::set_state_for_testing(
154 captive_portal::CaptivePortalService::DISABLED_FOR_TESTING); 164 captive_portal::CaptivePortalService::DISABLED_FOR_TESTING);
155 #endif 165 #endif
156 166
157 chrome_browser_net::NetErrorTabHelper::set_state_for_testing( 167 chrome_browser_net::NetErrorTabHelper::set_state_for_testing(
158 chrome_browser_net::NetErrorTabHelper::TESTING_FORCE_DISABLED); 168 chrome_browser_net::NetErrorTabHelper::TESTING_FORCE_DISABLED);
159 169
160 google_util::SetMockLinkDoctorBaseURLForTesting(); 170 google_util::SetMockLinkDoctorBaseURLForTesting();
161 171
172 #if defined(OS_WIN) && defined(USE_AURA)
173 if (base::win::GetVersion() >= base::win::VERSION_WIN8 &&
174 CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) {
175 com_initializer_.reset(new base::win::ScopedCOMInitializer());
176 ui::win::CreateATLModuleIfNeeded();
177 ASSERT_TRUE(win8::MakeTestDefaultBrowserSynchronously());
178
179 // Ash browser tests need the real compositor.
180 ui::DisableTestCompositor();
181 }
182 #endif
183
162 BrowserTestBase::SetUp(); 184 BrowserTestBase::SetUp();
163 } 185 }
164 186
165 void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) { 187 void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) {
166 // Propagate commandline settings from test_launcher_utils. 188 // Propagate commandline settings from test_launcher_utils.
167 test_launcher_utils::PrepareBrowserCommandLineForTests(command_line); 189 test_launcher_utils::PrepareBrowserCommandLineForTests(command_line);
168 190
169 // This is a Browser test. 191 // This is a Browser test.
170 command_line->AppendSwitchASCII(switches::kTestType, kBrowserTestType); 192 command_line->AppendSwitchASCII(switches::kTestType, kBrowserTestType);
171 193
194 #if defined(OS_WIN) && defined(USE_AURA)
195 if (command_line->HasSwitch(switches::kAshBrowserTests)) {
196 command_line->AppendSwitchNative(switches::kViewerLaunchViaAppId,
197 win8::test::kDefaultTestAppUserModelId);
198 }
199 #endif
200
172 #if defined(OS_MACOSX) 201 #if defined(OS_MACOSX)
173 // Explicitly set the path of the binary used for child processes, otherwise 202 // Explicitly set the path of the binary used for child processes, otherwise
174 // they'll try to use browser_tests which doesn't contain ChromeMain. 203 // they'll try to use browser_tests which doesn't contain ChromeMain.
175 base::FilePath subprocess_path; 204 base::FilePath subprocess_path;
176 PathService::Get(base::FILE_EXE, &subprocess_path); 205 PathService::Get(base::FILE_EXE, &subprocess_path);
177 // Recreate the real environment, run the helper within the app bundle. 206 // Recreate the real environment, run the helper within the app bundle.
178 subprocess_path = subprocess_path.DirName().DirName(); 207 subprocess_path = subprocess_path.DirName().DirName();
179 DCHECK_EQ(subprocess_path.BaseName().value(), "Contents"); 208 DCHECK_EQ(subprocess_path.BaseName().value(), "Contents");
180 subprocess_path = 209 subprocess_path =
181 subprocess_path.Append("Versions").Append(chrome::kChromeVersion); 210 subprocess_path.Append("Versions").Append(chrome::kChromeVersion);
(...skipping 23 matching lines...) Expand all
205 LOG(ERROR) << "Could not create temporary user data directory \"" 234 LOG(ERROR) << "Could not create temporary user data directory \""
206 << temp_user_data_dir_.path().value() << "\"."; 235 << temp_user_data_dir_.path().value() << "\".";
207 return false; 236 return false;
208 } 237 }
209 } 238 }
210 return test_launcher_utils::OverrideUserDataDir(user_data_dir); 239 return test_launcher_utils::OverrideUserDataDir(user_data_dir);
211 } 240 }
212 241
213 void InProcessBrowserTest::TearDown() { 242 void InProcessBrowserTest::TearDown() {
214 DCHECK(!g_browser_process); 243 DCHECK(!g_browser_process);
244 #if defined(OS_WIN) && defined(USE_AURA)
245 com_initializer_.reset();
246 #endif
215 BrowserTestBase::TearDown(); 247 BrowserTestBase::TearDown();
216 } 248 }
217 249
218 void InProcessBrowserTest::AddTabAtIndexToBrowser( 250 void InProcessBrowserTest::AddTabAtIndexToBrowser(
219 Browser* browser, 251 Browser* browser,
220 int index, 252 int index,
221 const GURL& url, 253 const GURL& url,
222 content::PageTransition transition) { 254 content::PageTransition transition) {
223 chrome::NavigateParams params(browser, url, transition); 255 chrome::NavigateParams params(browser, url, transition);
224 params.tabstrip_index = index; 256 params.tabstrip_index = index;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 // On the Mac, this eventually reaches 424 // On the Mac, this eventually reaches
393 // -[BrowserWindowController windowWillClose:], which will post a deferred 425 // -[BrowserWindowController windowWillClose:], which will post a deferred
394 // -autorelease on itself to ultimately destroy the Browser object. The line 426 // -autorelease on itself to ultimately destroy the Browser object. The line
395 // below is necessary to pump these pending messages to ensure all Browsers 427 // below is necessary to pump these pending messages to ensure all Browsers
396 // get deleted. 428 // get deleted.
397 content::RunAllPendingInMessageLoop(); 429 content::RunAllPendingInMessageLoop();
398 delete autorelease_pool_; 430 delete autorelease_pool_;
399 autorelease_pool_ = NULL; 431 autorelease_pool_ = NULL;
400 #endif 432 #endif
401 } 433 }
OLDNEW
« no previous file with comments | « chrome/test/base/in_process_browser_test.h ('k') | chrome/test/base/test_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698