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

Side by Side Diff: chrome_frame/test/chrome_frame_test_utils.cc

Issue 10007043: Attempt to fix ChromeFrameTestWithWebServer tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added retry logic for WidgetModeIE_Version. Created 8 years, 8 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 | Annotate | Revision Log
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/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 |
41 FILE_WRITE_ATTRIBUTES; 43 FILE_WRITE_ATTRIBUTES;
42 44
43 const DWORD kCrashServicePipeFlagsAndAttributes = SECURITY_IDENTIFICATION | 45 const DWORD kCrashServicePipeFlagsAndAttributes = SECURITY_IDENTIFICATION |
44 SECURITY_SQOS_PRESENT; 46 SECURITY_SQOS_PRESENT;
45 const int kCrashServiceStartupTimeoutMs = 500; 47 const int kCrashServiceStartupTimeoutMs = 500;
46 48
47 const wchar_t kIEImageName[] = L"iexplore.exe"; 49 const wchar_t kIEImageName[] = L"iexplore.exe";
48 const wchar_t kIEBrokerImageName[] = L"ieuser.exe"; 50 const wchar_t kIEBrokerImageName[] = L"ieuser.exe";
49 const char kChromeImageName[] = "chrome.exe"; 51 const char kChromeImageName[] = "chrome.exe";
50 const wchar_t kIEProfileName[] = L"iexplore"; 52 const wchar_t kIEProfileName[] = L"iexplore";
51 const wchar_t kChromeLauncher[] = L"chrome_launcher.exe"; 53 const wchar_t kChromeLauncher[] = L"chrome_launcher.exe";
52 54
53 #ifndef NDEBUG 55 #ifndef NDEBUG
54 const int kChromeFrameLongNavigationTimeoutInSeconds = 30; 56 const base::TimeDelta kChromeFrameLongNavigationTimeout =
55 const int kChromeFrameVeryLongNavigationTimeoutInSeconds = 90; 57 base::TimeDelta::FromSeconds(30);
58 const base::TimeDelta kChromeFrameVeryLongNavigationTimeout =
59 base::TimeDelta::FromSeconds(90);
56 #else 60 #else
57 const int kChromeFrameLongNavigationTimeoutInSeconds = 15; 61 const base::TimeDelta kChromeFrameLongNavigationTimeout =
58 const int kChromeFrameVeryLongNavigationTimeoutInSeconds = 45; 62 base::TimeDelta::FromSeconds(15);
63 const base::TimeDelta kChromeFrameVeryLongNavigationTimeout =
64 base::TimeDelta::FromSeconds(45);
59 #endif 65 #endif
60 66
61 // Callback function for EnumThreadWindows. 67 // Callback function for EnumThreadWindows.
62 BOOL CALLBACK CloseWindowsThreadCallback(HWND hwnd, LPARAM param) { 68 BOOL CALLBACK CloseWindowsThreadCallback(HWND hwnd, LPARAM param) {
63 int& count = *reinterpret_cast<int*>(param); 69 int& count = *reinterpret_cast<int*>(param);
64 if (IsWindowVisible(hwnd)) { 70 if (IsWindowVisible(hwnd)) {
65 if (IsWindowEnabled(hwnd)) { 71 if (IsWindowEnabled(hwnd)) {
66 DWORD results = 0; 72 DWORD results = 0;
67 if (!::SendMessageTimeout(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0, SMTO_BLOCK, 73 if (!::SendMessageTimeout(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0, SMTO_BLOCK,
68 10000, &results)) { 74 10000, &results)) {
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 FilePath session_history_path; 672 FilePath session_history_path;
667 if (!PathService::Get(base::DIR_LOCAL_APP_DATA, &session_history_path)) 673 if (!PathService::Get(base::DIR_LOCAL_APP_DATA, &session_history_path))
668 return; 674 return;
669 675
670 session_history_path = session_history_path.AppendASCII("Microsoft"); 676 session_history_path = session_history_path.AppendASCII("Microsoft");
671 session_history_path = session_history_path.AppendASCII("Internet Explorer"); 677 session_history_path = session_history_path.AppendASCII("Internet Explorer");
672 session_history_path = session_history_path.AppendASCII("Recovery"); 678 session_history_path = session_history_path.AppendASCII("Recovery");
673 file_util::Delete(session_history_path, true); 679 file_util::Delete(session_history_path, true);
674 } 680 }
675 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
676 } // namespace chrome_frame_test 716 } // namespace chrome_frame_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698