| 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_frame/test/net/fake_external_tab.h" | 5 #include "chrome_frame/test/net/fake_external_tab.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlcom.h> | 8 #include <atlcom.h> |
| 9 #include <exdisp.h> | 9 #include <exdisp.h> |
| 10 #include <Winsock2.h> |
| 10 | 11 |
| 11 #include "base/bind.h" | 12 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 13 #include "base/debug/debugger.h" | 14 #include "base/debug/debugger.h" |
| 14 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 15 #include "base/file_version_info.h" | 16 #include "base/file_version_info.h" |
| 16 #include "base/i18n/icu_util.h" | 17 #include "base/i18n/icu_util.h" |
| 17 #include "base/lazy_instance.h" | 18 #include "base/lazy_instance.h" |
| 18 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 49 #include "chrome_frame/test/simulate_input.h" | 50 #include "chrome_frame/test/simulate_input.h" |
| 50 #include "chrome_frame/test/win_event_receiver.h" | 51 #include "chrome_frame/test/win_event_receiver.h" |
| 51 #include "chrome_frame/utils.h" | 52 #include "chrome_frame/utils.h" |
| 52 #include "content/public/app/content_main.h" | 53 #include "content/public/app/content_main.h" |
| 53 #include "content/public/app/startup_helper_win.h" | 54 #include "content/public/app/startup_helper_win.h" |
| 54 #include "content/public/browser/browser_thread.h" | 55 #include "content/public/browser/browser_thread.h" |
| 55 #include "content/public/browser/notification_service.h" | 56 #include "content/public/browser/notification_service.h" |
| 56 #include "content/public/browser/render_process_host.h" | 57 #include "content/public/browser/render_process_host.h" |
| 57 #include "content/public/common/content_client.h" | 58 #include "content/public/common/content_client.h" |
| 58 #include "content/public/common/content_paths.h" | 59 #include "content/public/common/content_paths.h" |
| 60 #include "net/base/net_util.h" |
| 59 #include "sandbox/src/sandbox_types.h" | 61 #include "sandbox/src/sandbox_types.h" |
| 60 #include "testing/gtest/include/gtest/gtest.h" | 62 #include "testing/gtest/include/gtest/gtest.h" |
| 61 #include "ui/base/resource/resource_bundle.h" | 63 #include "ui/base/resource/resource_bundle.h" |
| 62 #include "ui/base/ui_base_paths.h" | 64 #include "ui/base/ui_base_paths.h" |
| 63 | 65 |
| 64 using content::BrowserThread; | 66 using content::BrowserThread; |
| 65 | 67 |
| 66 namespace { | 68 namespace { |
| 67 | 69 |
| 68 // We must store this globally so that our main delegate can set it. | 70 // We must store this globally so that our main delegate can set it. |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 // Value: 0 | 518 // Value: 0 |
| 517 } | 519 } |
| 518 | 520 |
| 519 void CFUrlRequestUnittestRunner::ShutDownHostBrowser() { | 521 void CFUrlRequestUnittestRunner::ShutDownHostBrowser() { |
| 520 if (ShouldLaunchBrowser()) { | 522 if (ShouldLaunchBrowser()) { |
| 521 base::win::ScopedCOMInitializer com; | 523 base::win::ScopedCOMInitializer com; |
| 522 chrome_frame_test::CloseAllIEWindows(); | 524 chrome_frame_test::CloseAllIEWindows(); |
| 523 } | 525 } |
| 524 } | 526 } |
| 525 | 527 |
| 526 // Override virtual void Initialize to not call icu initialize | 528 // Override virtual void Initialize to not call icu initialize. |
| 527 void CFUrlRequestUnittestRunner::Initialize() { | 529 void CFUrlRequestUnittestRunner::Initialize() { |
| 528 DCHECK(::GetCurrentThreadId() == test_thread_id_); | 530 DCHECK(::GetCurrentThreadId() == test_thread_id_); |
| 529 | 531 |
| 530 // Start by replicating some of the steps that would otherwise be | 532 // Start by replicating some of the steps that would otherwise be |
| 531 // done by TestSuite::Initialize. We can't call the base class | 533 // done by TestSuite::Initialize. We can't call the base class |
| 532 // directly because it will attempt to initialize some things such as | 534 // directly because it will attempt to initialize some things such as |
| 533 // ICU that have already been initialized for this process. | 535 // ICU that have already been initialized for this process. |
| 534 CFUrlRequestUnittestRunner::InitializeLogging(); | 536 CFUrlRequestUnittestRunner::InitializeLogging(); |
| 535 | 537 |
| 536 if (!CommandLine::ForCurrentProcess()->HasSwitch(kNoCrashService)) { | 538 if (!CommandLine::ForCurrentProcess()->HasSwitch(kNoCrashService)) { |
| 537 SuppressErrorDialogs(); | 539 SuppressErrorDialogs(); |
| 538 base::debug::SetSuppressDebugUI(true); | 540 base::debug::SetSuppressDebugUI(true); |
| 539 } | 541 } |
| 540 logging::SetLogAssertHandler(UnitTestAssertHandler); | 542 logging::SetLogAssertHandler(UnitTestAssertHandler); |
| 541 | 543 |
| 542 // Next, do some initialization for NetTestSuite. | 544 // Next, do some initialization for NetTestSuite. |
| 543 NetTestSuite::InitializeTestThreadNoNetworkChangeNotifier(); | 545 NetTestSuite::InitializeTestThreadNoNetworkChangeNotifier(); |
| 546 |
| 547 // Finally, override the host used by the HTTP tests. See |
| 548 // http://crbug.com/114369 . |
| 549 OverrideHttpHost(); |
| 544 } | 550 } |
| 545 | 551 |
| 546 void CFUrlRequestUnittestRunner::Shutdown() { | 552 void CFUrlRequestUnittestRunner::Shutdown() { |
| 547 DCHECK(::GetCurrentThreadId() == test_thread_id_); | 553 DCHECK(::GetCurrentThreadId() == test_thread_id_); |
| 548 NetTestSuite::Shutdown(); | 554 NetTestSuite::Shutdown(); |
| 549 OleUninitialize(); | 555 OleUninitialize(); |
| 550 } | 556 } |
| 551 | 557 |
| 552 void CFUrlRequestUnittestRunner::OnConnectAutomationProviderToChannel( | 558 void CFUrlRequestUnittestRunner::OnConnectAutomationProviderToChannel( |
| 553 const std::string& channel_id) { | 559 const std::string& channel_id) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 log_filename.value().c_str(), | 614 log_filename.value().c_str(), |
| 609 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, | 615 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, |
| 610 logging::LOCK_LOG_FILE, | 616 logging::LOCK_LOG_FILE, |
| 611 logging::DELETE_OLD_LOG_FILE, | 617 logging::DELETE_OLD_LOG_FILE, |
| 612 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); | 618 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); |
| 613 // We want process and thread IDs because we may have multiple processes. | 619 // We want process and thread IDs because we may have multiple processes. |
| 614 // Note: temporarily enabled timestamps in an effort to catch bug 6361. | 620 // Note: temporarily enabled timestamps in an effort to catch bug 6361. |
| 615 logging::SetLogItems(true, true, true, true); | 621 logging::SetLogItems(true, true, true, true); |
| 616 } | 622 } |
| 617 | 623 |
| 624 void CFUrlRequestUnittestRunner::OverrideHttpHost() { |
| 625 net::NetworkInterfaceList nic_list; |
| 626 if (!net::GetNetworkList(&nic_list)) { |
| 627 LOG(ERROR) << "GetNetworkList failed to look up non-loopback adapters. " |
| 628 << "Tests will be run over the loopback adapter, which may " |
| 629 << "result in hangs."; |
| 630 return; |
| 631 } |
| 632 |
| 633 // GetNetworkList only returns 'Up' non-loopback adapters. Select the first |
| 634 // IPV4 address found - we should be able to bind/connect over it. |
| 635 for (size_t i = 0; i < nic_list.size(); ++i) { |
| 636 if (nic_list[i].address.size() != net::kIPv4AddressSize) |
| 637 continue; |
| 638 char* address_string = |
| 639 inet_ntoa(*reinterpret_cast<in_addr*>(&nic_list[i].address[0])); |
| 640 DCHECK(address_string != NULL); |
| 641 if (address_string == NULL) |
| 642 continue; |
| 643 LOG(INFO) << "HTTP tests will run over " << address_string << "."; |
| 644 override_http_host_.reset( |
| 645 new ScopedCustomUrlRequestTestHttpHost(address_string)); |
| 646 return; |
| 647 } |
| 648 |
| 649 LOG(ERROR) << "Failed to find a non-loopback IP_V4 address. Tests will be " |
| 650 << "run over the loopback adapter, which may result in hangs."; |
| 651 } |
| 652 |
| 618 void CFUrlRequestUnittestRunner::PreEarlyInitialization() { | 653 void CFUrlRequestUnittestRunner::PreEarlyInitialization() { |
| 619 testing::InitGoogleTest(&g_argc, g_argv); | 654 testing::InitGoogleTest(&g_argc, g_argv); |
| 620 FilterDisabledTests(); | 655 FilterDisabledTests(); |
| 621 } | 656 } |
| 622 | 657 |
| 623 MessageLoop* CFUrlRequestUnittestRunner::GetMainMessageLoop() { | 658 MessageLoop* CFUrlRequestUnittestRunner::GetMainMessageLoop() { |
| 624 return NULL; | 659 return NULL; |
| 625 } | 660 } |
| 626 | 661 |
| 627 int CFUrlRequestUnittestRunner::PreCreateThreads() { | 662 int CFUrlRequestUnittestRunner::PreCreateThreads() { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 // content::InitializeSandboxInfo(&sandbox_info); | 790 // content::InitializeSandboxInfo(&sandbox_info); |
| 756 FakeMainDelegate delegate; | 791 FakeMainDelegate delegate; |
| 757 content::ContentMain( | 792 content::ContentMain( |
| 758 reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL)), | 793 reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL)), |
| 759 &sandbox_info, | 794 &sandbox_info, |
| 760 &delegate); | 795 &delegate); |
| 761 | 796 |
| 762 // Note: In debug builds, we ExitProcess during PostDestroyThreads. | 797 // Note: In debug builds, we ExitProcess during PostDestroyThreads. |
| 763 return g_test_suite->test_result(); | 798 return g_test_suite->test_result(); |
| 764 } | 799 } |
| OLD | NEW |