| 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/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" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/test/test_file_util.h" | 16 #include "base/test/test_file_util.h" |
| 17 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/google/google_util.h" | 19 #include "chrome/browser/google/google_util.h" |
| 20 #include "chrome/browser/io_thread.h" | 20 #include "chrome/browser/io_thread.h" |
| 21 #include "chrome/browser/lifetime/application_lifetime.h" | 21 #include "chrome/browser/lifetime/application_lifetime.h" |
| 22 #include "chrome/browser/net/net_error_tab_helper.h" | 22 #include "chrome/browser/net/net_error_tab_helper.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
| 25 #include "chrome/browser/search/instant_service.h" |
| 26 #include "chrome/browser/search/instant_service_factory.h" |
| 25 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
| 27 #include "chrome/browser/ui/browser_list.h" | 29 #include "chrome/browser/ui/browser_list.h" |
| 28 #include "chrome/browser/ui/browser_list_observer.h" | 30 #include "chrome/browser/ui/browser_list_observer.h" |
| 29 #include "chrome/browser/ui/browser_navigator.h" | 31 #include "chrome/browser/ui/browser_navigator.h" |
| 30 #include "chrome/browser/ui/browser_tabstrip.h" | 32 #include "chrome/browser/ui/browser_tabstrip.h" |
| 31 #include "chrome/browser/ui/browser_window.h" | 33 #include "chrome/browser/ui/browser_window.h" |
| 32 #include "chrome/browser/ui/host_desktop.h" | 34 #include "chrome/browser/ui/host_desktop.h" |
| 33 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 34 #include "chrome/common/chrome_constants.h" | 36 #include "chrome/common/chrome_constants.h" |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 409 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 408 // Do not use the real StorageMonitor for tests, which introduces another | 410 // Do not use the real StorageMonitor for tests, which introduces another |
| 409 // source of variability and potential slowness. | 411 // source of variability and potential slowness. |
| 410 ASSERT_TRUE(TestStorageMonitor::CreateForBrowserTests()); | 412 ASSERT_TRUE(TestStorageMonitor::CreateForBrowserTests()); |
| 411 #endif | 413 #endif |
| 412 | 414 |
| 413 // Pump any pending events that were created as a result of creating a | 415 // Pump any pending events that were created as a result of creating a |
| 414 // browser. | 416 // browser. |
| 415 content::RunAllPendingInMessageLoop(); | 417 content::RunAllPendingInMessageLoop(); |
| 416 | 418 |
| 419 if (browser_) { |
| 420 // InstantService prerenders an Instant NTP on the first browser creation. |
| 421 // Since many tests listen for load notifications, the NTP load can confuse |
| 422 // them unless we first wait for the NTP contents to finish loading before |
| 423 // running the test. |
| 424 InstantService* instant_service = InstantServiceFactory::GetForProfile( |
| 425 browser_->profile()); |
| 426 if (instant_service && instant_service->GetNTPContents() && |
| 427 instant_service->GetNTPContents()->IsLoading()) { |
| 428 content::WindowedNotificationObserver observer( |
| 429 content::NOTIFICATION_LOAD_STOP, |
| 430 content::NotificationService::AllSources()); |
| 431 observer.Wait(); |
| 432 } |
| 433 } |
| 434 |
| 417 SetUpOnMainThread(); | 435 SetUpOnMainThread(); |
| 418 #if defined(OS_MACOSX) | 436 #if defined(OS_MACOSX) |
| 419 autorelease_pool_->Recycle(); | 437 autorelease_pool_->Recycle(); |
| 420 #endif | 438 #endif |
| 421 | 439 |
| 422 if (!HasFatalFailure()) | 440 if (!HasFatalFailure()) |
| 423 RunTestOnMainThread(); | 441 RunTestOnMainThread(); |
| 424 #if defined(OS_MACOSX) | 442 #if defined(OS_MACOSX) |
| 425 autorelease_pool_->Recycle(); | 443 autorelease_pool_->Recycle(); |
| 426 #endif | 444 #endif |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 // On the Mac, this eventually reaches | 486 // On the Mac, this eventually reaches |
| 469 // -[BrowserWindowController windowWillClose:], which will post a deferred | 487 // -[BrowserWindowController windowWillClose:], which will post a deferred |
| 470 // -autorelease on itself to ultimately destroy the Browser object. The line | 488 // -autorelease on itself to ultimately destroy the Browser object. The line |
| 471 // below is necessary to pump these pending messages to ensure all Browsers | 489 // below is necessary to pump these pending messages to ensure all Browsers |
| 472 // get deleted. | 490 // get deleted. |
| 473 content::RunAllPendingInMessageLoop(); | 491 content::RunAllPendingInMessageLoop(); |
| 474 delete autorelease_pool_; | 492 delete autorelease_pool_; |
| 475 autorelease_pool_ = NULL; | 493 autorelease_pool_ = NULL; |
| 476 #endif | 494 #endif |
| 477 } | 495 } |
| OLD | NEW |