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

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: cleanup 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
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "net/dns/mock_host_resolver.h" 47 #include "net/dns/mock_host_resolver.h"
48 #include "net/test/spawned_test_server/spawned_test_server.h" 48 #include "net/test/spawned_test_server/spawned_test_server.h"
49 #include "ui/compositor/compositor_switches.h" 49 #include "ui/compositor/compositor_switches.h"
50 50
51 #if defined(OS_CHROMEOS) 51 #if defined(OS_CHROMEOS)
52 #include "chrome/browser/chromeos/audio/audio_handler.h" 52 #include "chrome/browser/chromeos/audio/audio_handler.h"
53 #elif defined(OS_MACOSX) 53 #elif defined(OS_MACOSX)
54 #include "base/mac/scoped_nsautorelease_pool.h" 54 #include "base/mac/scoped_nsautorelease_pool.h"
55 #endif 55 #endif
56 56
57 #if defined(OS_WIN) && defined(USE_AURA)
58 #include "base/win/scoped_com_initializer.h"
59 #include "base/win/windows_version.h"
60 #include "ui/base/win/atl_module.h"
61 #include "win8/test/metro_registration_helper.h"
62 #endif
63
57 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 64 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
58 #include "chrome/browser/captive_portal/captive_portal_service.h" 65 #include "chrome/browser/captive_portal/captive_portal_service.h"
59 #endif 66 #endif
60 67
61 namespace { 68 namespace {
62 69
63 // Passed as value of kTestType. 70 // Passed as value of kTestType.
64 const char kBrowserTestType[] = "browser"; 71 const char kBrowserTestType[] = "browser";
65 72
66 // Used when running in single-process mode. 73 // Used when running in single-process mode.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 116
110 // Create a temporary user data directory if required. 117 // Create a temporary user data directory if required.
111 ASSERT_TRUE(CreateUserDataDirectory()) 118 ASSERT_TRUE(CreateUserDataDirectory())
112 << "Could not create user data directory."; 119 << "Could not create user data directory.";
113 120
114 // Allow subclasses the opportunity to make changes to the default user data 121 // Allow subclasses the opportunity to make changes to the default user data
115 // dir before running any tests. 122 // dir before running any tests.
116 ASSERT_TRUE(SetUpUserDataDirectory()) 123 ASSERT_TRUE(SetUpUserDataDirectory())
117 << "Could not set up user data directory."; 124 << "Could not set up user data directory.";
118 125
126 #if defined(OS_WIN) && defined(USE_AURA)
127 if (base::win::GetVersion() >= base::win::VERSION_WIN8 &&
grt (UTC plus 2) 2013/05/29 02:22:51 this only needs to happen once per process rather
gab 2013/05/29 14:52:20 Right, these are static methods though so they can
grt (UTC plus 2) 2013/05/29 15:51:03 This is their raison d'être; see https://code.goog
gab 2013/05/29 23:09:42 I see.
128 command_line->HasSwitch(switches::kAshBrowserTests)) {
129 com_initializer_.reset(new base::win::ScopedCOMInitializer());
130 ui::win::CreateATLModuleIfNeeded();
131 ASSERT_TRUE(win8::MakeTestDefaultBrowserSynchronously());
132 }
133 #endif
134
119 // Single-process mode is not set in BrowserMain, so process it explicitly, 135 // Single-process mode is not set in BrowserMain, so process it explicitly,
120 // and set up renderer. 136 // and set up renderer.
121 if (command_line->HasSwitch(switches::kSingleProcess)) { 137 if (command_line->HasSwitch(switches::kSingleProcess)) {
122 content::SetRendererClientForTesting( 138 content::SetRendererClientForTesting(
123 &g_chrome_content_renderer_client.Get()); 139 &g_chrome_content_renderer_client.Get());
124 } 140 }
125 141
126 #if defined(OS_CHROMEOS) 142 #if defined(OS_CHROMEOS)
127 // Make sure that the log directory exists. 143 // Make sure that the log directory exists.
128 base::FilePath log_dir = logging::GetSessionLogFile(*command_line).DirName(); 144 base::FilePath log_dir = logging::GetSessionLogFile(*command_line).DirName();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 LOG(ERROR) << "Could not create temporary user data directory \"" 221 LOG(ERROR) << "Could not create temporary user data directory \""
206 << temp_user_data_dir_.path().value() << "\"."; 222 << temp_user_data_dir_.path().value() << "\".";
207 return false; 223 return false;
208 } 224 }
209 } 225 }
210 return test_launcher_utils::OverrideUserDataDir(user_data_dir); 226 return test_launcher_utils::OverrideUserDataDir(user_data_dir);
211 } 227 }
212 228
213 void InProcessBrowserTest::TearDown() { 229 void InProcessBrowserTest::TearDown() {
214 DCHECK(!g_browser_process); 230 DCHECK(!g_browser_process);
231 #if defined(OS_WIN) && defined(USE_AURA)
grt (UTC plus 2) 2013/05/29 02:22:51 likewise, TearDownTestCase
gab 2013/05/29 14:52:20 Done.
232 com_initializer_.reset();
233 #endif
215 BrowserTestBase::TearDown(); 234 BrowserTestBase::TearDown();
216 } 235 }
217 236
218 void InProcessBrowserTest::AddTabAtIndexToBrowser( 237 void InProcessBrowserTest::AddTabAtIndexToBrowser(
219 Browser* browser, 238 Browser* browser,
220 int index, 239 int index,
221 const GURL& url, 240 const GURL& url,
222 content::PageTransition transition) { 241 content::PageTransition transition) {
223 content::TestNavigationObserver observer( 242 content::TestNavigationObserver observer(
224 content::NotificationService::AllSources(), 1); 243 content::NotificationService::AllSources(), 1);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 // On the Mac, this eventually reaches 414 // On the Mac, this eventually reaches
396 // -[BrowserWindowController windowWillClose:], which will post a deferred 415 // -[BrowserWindowController windowWillClose:], which will post a deferred
397 // -autorelease on itself to ultimately destroy the Browser object. The line 416 // -autorelease on itself to ultimately destroy the Browser object. The line
398 // below is necessary to pump these pending messages to ensure all Browsers 417 // below is necessary to pump these pending messages to ensure all Browsers
399 // get deleted. 418 // get deleted.
400 content::RunAllPendingInMessageLoop(); 419 content::RunAllPendingInMessageLoop();
401 delete autorelease_pool_; 420 delete autorelease_pool_;
402 autorelease_pool_ = NULL; 421 autorelease_pool_ = NULL;
403 #endif 422 #endif
404 } 423 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698