| 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/chrome_frame_test_utils.h" | 5 #include "chrome_frame/test/chrome_frame_test_utils.h" |
| 6 | 6 |
| 7 #include <atlapp.h> | 7 #include <atlapp.h> |
| 8 #include <atlmisc.h> | 8 #include <atlmisc.h> |
| 9 #include <iepmapi.h> | 9 #include <iepmapi.h> |
| 10 #include <sddl.h> | 10 #include <sddl.h> |
| 11 #include <shlobj.h> | 11 #include <shlobj.h> |
| 12 #include <winsock2.h> |
| 12 | 13 |
| 13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 14 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 15 #include "base/file_util.h" | 16 #include "base/file_util.h" |
| 16 #include "base/file_version_info.h" | 17 #include "base/file_version_info.h" |
| 17 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 19 #include "base/process.h" | 20 #include "base/process.h" |
| 20 #include "base/process_util.h" | 21 #include "base/process_util.h" |
| 21 #include "base/string_util.h" | 22 #include "base/string_util.h" |
| 22 #include "base/stringprintf.h" | 23 #include "base/stringprintf.h" |
| 23 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
| 24 #include "base/win/registry.h" | 25 #include "base/win/registry.h" |
| 25 #include "base/win/scoped_handle.h" | 26 #include "base/win/scoped_handle.h" |
| 26 #include "base/win/windows_version.h" | 27 #include "base/win/windows_version.h" |
| 27 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 28 #include "chrome/common/chrome_paths_internal.h" | 29 #include "chrome/common/chrome_paths_internal.h" |
| 29 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome_frame/utils.h" | 31 #include "chrome_frame/utils.h" |
| 32 #include "net/base/net_util.h" |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 32 #include "ui/base/clipboard/clipboard.h" | 34 #include "ui/base/clipboard/clipboard.h" |
| 33 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 35 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 34 | 36 |
| 35 namespace chrome_frame_test { | 37 namespace chrome_frame_test { |
| 36 | 38 |
| 37 const wchar_t kCrashServicePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; | 39 const wchar_t kCrashServicePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; |
| 38 | 40 |
| 39 const DWORD kCrashServicePipeDesiredAccess = FILE_READ_DATA | | 41 const DWORD kCrashServicePipeDesiredAccess = FILE_READ_DATA | |
| 40 FILE_WRITE_DATA | | 42 FILE_WRITE_DATA | |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 FilePath session_history_path; | 672 FilePath session_history_path; |
| 671 if (!PathService::Get(base::DIR_LOCAL_APP_DATA, &session_history_path)) | 673 if (!PathService::Get(base::DIR_LOCAL_APP_DATA, &session_history_path)) |
| 672 return; | 674 return; |
| 673 | 675 |
| 674 session_history_path = session_history_path.AppendASCII("Microsoft"); | 676 session_history_path = session_history_path.AppendASCII("Microsoft"); |
| 675 session_history_path = session_history_path.AppendASCII("Internet Explorer"); | 677 session_history_path = session_history_path.AppendASCII("Internet Explorer"); |
| 676 session_history_path = session_history_path.AppendASCII("Recovery"); | 678 session_history_path = session_history_path.AppendASCII("Recovery"); |
| 677 file_util::Delete(session_history_path, true); | 679 file_util::Delete(session_history_path, true); |
| 678 } | 680 } |
| 679 | 681 |
| 682 std::string GetLocalIPv4Address() { |
| 683 std::string address; |
| 684 net::NetworkInterfaceList nic_list; |
| 685 |
| 686 if (!net::GetNetworkList(&nic_list)) { |
| 687 LOG(ERROR) << "GetNetworkList failed to look up non-loopback adapters. " |
| 688 << "Tests will be run over the loopback adapter, which may " |
| 689 << "result in hangs."; |
| 690 } else { |
| 691 // GetNetworkList only returns 'Up' non-loopback adapters. Select the first |
| 692 // IPv4 address found - we should be able to bind/connect over it. |
| 693 for (size_t i = 0; i < nic_list.size(); ++i) { |
| 694 if (nic_list[i].address.size() != net::kIPv4AddressSize) |
| 695 continue; |
| 696 char* address_string = |
| 697 inet_ntoa(*reinterpret_cast<in_addr*>(&nic_list[i].address[0])); |
| 698 DCHECK(address_string != NULL); |
| 699 if (address_string != NULL) { |
| 700 LOG(INFO) << "HTTP tests will run over " << address_string << "."; |
| 701 address.assign(address_string); |
| 702 break; |
| 703 } |
| 704 } |
| 705 } |
| 706 |
| 707 if (address.empty()) { |
| 708 LOG(ERROR) << "Failed to find a non-loopback IP_V4 address. Tests will be " |
| 709 << "run over the loopback adapter, which may result in hangs."; |
| 710 address.assign("127.0.0.1"); |
| 711 } |
| 712 |
| 713 return address; |
| 714 } |
| 715 |
| 680 } // namespace chrome_frame_test | 716 } // namespace chrome_frame_test |
| OLD | NEW |