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

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

Issue 1211213003: mac: Swizzle out +[NSBundle mainBundle] for in process browser tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor formatting, nits. 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
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/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "content/public/browser/notification_service.h" 47 #include "content/public/browser/notification_service.h"
48 #include "content/public/browser/notification_types.h" 48 #include "content/public/browser/notification_types.h"
49 #include "content/public/test/browser_test_utils.h" 49 #include "content/public/test/browser_test_utils.h"
50 #include "content/public/test/test_launcher.h" 50 #include "content/public/test/test_launcher.h"
51 #include "content/public/test/test_navigation_observer.h" 51 #include "content/public/test/test_navigation_observer.h"
52 #include "net/test/embedded_test_server/embedded_test_server.h" 52 #include "net/test/embedded_test_server/embedded_test_server.h"
53 #include "net/test/spawned_test_server/spawned_test_server.h" 53 #include "net/test/spawned_test_server/spawned_test_server.h"
54 54
55 #if defined(OS_MACOSX) 55 #if defined(OS_MACOSX)
56 #include "base/mac/scoped_nsautorelease_pool.h" 56 #include "base/mac/scoped_nsautorelease_pool.h"
57 #include "chrome/test/base/scoped_bundle_swizzler_mac.h"
57 #endif 58 #endif
58 59
59 #if defined(OS_WIN) 60 #if defined(OS_WIN)
60 #include "base/win/scoped_com_initializer.h" 61 #include "base/win/scoped_com_initializer.h"
61 #include "base/win/windows_version.h" 62 #include "base/win/windows_version.h"
62 #include "ui/base/win/atl_module.h" 63 #include "ui/base/win/atl_module.h"
63 #include "win8/test/metro_registration_helper.h" 64 #include "win8/test/metro_registration_helper.h"
64 #include "win8/test/test_registrar_constants.h" 65 #include "win8/test/test_registrar_constants.h"
65 #endif 66 #endif
66 67
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 base::CreateDirectory(log_dir); 224 base::CreateDirectory(log_dir);
224 // Disable IME extension loading to avoid many browser tests failures. 225 // Disable IME extension loading to avoid many browser tests failures.
225 chromeos::input_method::DisableExtensionLoading(); 226 chromeos::input_method::DisableExtensionLoading();
226 #endif // defined(OS_CHROMEOS) 227 #endif // defined(OS_CHROMEOS)
227 228
228 #if defined(OS_MACOSX) 229 #if defined(OS_MACOSX)
229 // Always use the MockKeychain if OS encription is used (which is when 230 // Always use the MockKeychain if OS encription is used (which is when
230 // anything sensitive gets stored, including Cookies). Without this, 231 // anything sensitive gets stored, including Cookies). Without this,
231 // many tests will hang waiting for a user to approve KeyChain access. 232 // many tests will hang waiting for a user to approve KeyChain access.
232 OSCrypt::UseMockKeychain(true); 233 OSCrypt::UseMockKeychain(true);
234
235 bundle_swizzler_.reset(new ScopedBundleSwizzlerMac);
233 #endif 236 #endif
234 237
235 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 238 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
236 CaptivePortalService::set_state_for_testing( 239 CaptivePortalService::set_state_for_testing(
237 CaptivePortalService::DISABLED_FOR_TESTING); 240 CaptivePortalService::DISABLED_FOR_TESTING);
238 #endif 241 #endif
239 242
240 chrome_browser_net::NetErrorTabHelper::set_state_for_testing( 243 chrome_browser_net::NetErrorTabHelper::set_state_for_testing(
241 chrome_browser_net::NetErrorTabHelper::TESTING_FORCE_DISABLED); 244 chrome_browser_net::NetErrorTabHelper::TESTING_FORCE_DISABLED);
242 245
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 370 }
368 } 371 }
369 return test_launcher_utils::OverrideUserDataDir(user_data_dir); 372 return test_launcher_utils::OverrideUserDataDir(user_data_dir);
370 } 373 }
371 374
372 void InProcessBrowserTest::TearDown() { 375 void InProcessBrowserTest::TearDown() {
373 DCHECK(!g_browser_process); 376 DCHECK(!g_browser_process);
374 #if defined(OS_WIN) 377 #if defined(OS_WIN)
375 com_initializer_.reset(); 378 com_initializer_.reset();
376 #endif 379 #endif
380
381 #if defined(OS_MACOSX)
382 bundle_swizzler_.reset();
Robert Sesek 2015/06/26 22:36:54 Does this need to be done between each test, or ca
erikchen 2015/06/26 23:14:52 I'm generally prefer to keep all light-weight conf
383 #endif
384
377 BrowserTestBase::TearDown(); 385 BrowserTestBase::TearDown();
378 } 386 }
379 387
380 // TODO(alexmos): This function should expose success of the underlying 388 // TODO(alexmos): This function should expose success of the underlying
381 // navigation to tests, which should make sure navigations succeed when 389 // navigation to tests, which should make sure navigations succeed when
382 // appropriate. See https://crbug.com/425335 390 // appropriate. See https://crbug.com/425335
383 void InProcessBrowserTest::AddTabAtIndexToBrowser( 391 void InProcessBrowserTest::AddTabAtIndexToBrowser(
384 Browser* browser, 392 Browser* browser,
385 int index, 393 int index,
386 const GURL& url, 394 const GURL& url,
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 // On the Mac, this eventually reaches 599 // On the Mac, this eventually reaches
592 // -[BrowserWindowController windowWillClose:], which will post a deferred 600 // -[BrowserWindowController windowWillClose:], which will post a deferred
593 // -autorelease on itself to ultimately destroy the Browser object. The line 601 // -autorelease on itself to ultimately destroy the Browser object. The line
594 // below is necessary to pump these pending messages to ensure all Browsers 602 // below is necessary to pump these pending messages to ensure all Browsers
595 // get deleted. 603 // get deleted.
596 content::RunAllPendingInMessageLoop(); 604 content::RunAllPendingInMessageLoop();
597 delete autorelease_pool_; 605 delete autorelease_pool_;
598 autorelease_pool_ = NULL; 606 autorelease_pool_ = NULL;
599 #endif 607 #endif
600 } 608 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698