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

Side by Side Diff: chrome_frame/test/net/fake_external_tab.cc

Issue 9401013: Don't run chrome_frame_net_tests URLRequestTestHTTP over loopback, due to mysterious failures. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Log the chosen hostname. Created 8 years, 10 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
« no previous file with comments | « chrome_frame/test/net/fake_external_tab.h ('k') | no next file » | 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_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
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
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
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 for (size_t i = 0; i < nic_list.size(); ++i) {
robertshield 2012/02/17 17:40:55 Consider adding a comment that we intentionally pi
634 if (nic_list[i].address.size() != net::kIPv4AddressSize)
635 continue;
636 char* address_string =
637 inet_ntoa(*reinterpret_cast<in_addr*>(&nic_list[i].address[0]));
638 DCHECK(address_string != NULL);
639 if (address_string == NULL)
640 continue;
641 LOG(INFO) << "HTTP tests will run over " << address_string << ".";
642 override_http_host_.reset(new CustomUrlRequestTestHttpHost(address_string));
643 return;
644 }
645
646 LOG(ERROR) << "Failed to find a non-loopback IP_V4 address. Tests will be "
647 << "run over the loopback adapter, which may result in hangs.";
648 }
649
618 void CFUrlRequestUnittestRunner::PreEarlyInitialization() { 650 void CFUrlRequestUnittestRunner::PreEarlyInitialization() {
619 testing::InitGoogleTest(&g_argc, g_argv); 651 testing::InitGoogleTest(&g_argc, g_argv);
620 FilterDisabledTests(); 652 FilterDisabledTests();
621 } 653 }
622 654
623 MessageLoop* CFUrlRequestUnittestRunner::GetMainMessageLoop() { 655 MessageLoop* CFUrlRequestUnittestRunner::GetMainMessageLoop() {
624 return NULL; 656 return NULL;
625 } 657 }
626 658
627 int CFUrlRequestUnittestRunner::PreCreateThreads() { 659 int CFUrlRequestUnittestRunner::PreCreateThreads() {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 // content::InitializeSandboxInfo(&sandbox_info); 787 // content::InitializeSandboxInfo(&sandbox_info);
756 FakeMainDelegate delegate; 788 FakeMainDelegate delegate;
757 content::ContentMain( 789 content::ContentMain(
758 reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL)), 790 reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL)),
759 &sandbox_info, 791 &sandbox_info,
760 &delegate); 792 &delegate);
761 793
762 // Note: In debug builds, we ExitProcess during PostDestroyThreads. 794 // Note: In debug builds, we ExitProcess during PostDestroyThreads.
763 return g_test_suite->test_result(); 795 return g_test_suite->test_result();
764 } 796 }
OLDNEW
« no previous file with comments | « chrome_frame/test/net/fake_external_tab.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698