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> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/string_piece.h" | 23 #include "base/string_piece.h" |
24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
25 #include "base/stringprintf.h" | 25 #include "base/stringprintf.h" |
26 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
27 #include "base/win/registry.h" | 27 #include "base/win/registry.h" |
28 #include "base/win/scoped_handle.h" | 28 #include "base/win/scoped_handle.h" |
29 #include "base/win/windows_version.h" | 29 #include "base/win/windows_version.h" |
30 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
31 #include "chrome/common/chrome_paths_internal.h" | 31 #include "chrome/common/chrome_paths_internal.h" |
32 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/test/base/ui_test_utils.h" |
33 #include "chrome_frame/utils.h" | 34 #include "chrome_frame/utils.h" |
34 #include "net/base/net_util.h" | 35 #include "net/base/net_util.h" |
35 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
36 #include "ui/base/clipboard/clipboard.h" | 37 #include "ui/base/clipboard/clipboard.h" |
37 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 38 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
38 | 39 |
39 namespace chrome_frame_test { | 40 namespace chrome_frame_test { |
40 | 41 |
41 const wchar_t kCrashServicePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; | 42 const wchar_t kCrashServicePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; |
42 | 43 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 if (GetInstalledIEVersion() >= IE_8) { | 233 if (GetInstalledIEVersion() >= IE_8) { |
233 chrome_frame_test::ClearIESessionHistory(); | 234 chrome_frame_test::ClearIESessionHistory(); |
234 } | 235 } |
235 | 236 |
236 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | 237 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
237 return LaunchIEOnVista(url); | 238 return LaunchIEOnVista(url); |
238 } | 239 } |
239 return LaunchExecutable(kIEImageName, url); | 240 return LaunchExecutable(kIEImageName, url); |
240 } | 241 } |
241 | 242 |
| 243 bool TakeSnapshotAndLog() { |
| 244 testing::UnitTest* unit_test = testing::UnitTest::GetInstance(); |
| 245 const testing::TestInfo* test_info = unit_test->current_test_info(); |
| 246 std::string name; |
| 247 if (test_info != NULL) { |
| 248 name.append(test_info->test_case_name()) |
| 249 .append(1, '.') |
| 250 .append(test_info->name()); |
| 251 } else { |
| 252 name = "unknown test"; |
| 253 } |
| 254 |
| 255 base::FilePath snapshot; |
| 256 if (!ui_test_utils::SaveScreenSnapshotToDesktop(&snapshot)) { |
| 257 LOG(ERROR) << "Failed saving screen snapshot for " << name; |
| 258 return false; |
| 259 } |
| 260 |
| 261 LOG(ERROR) << "Saved screen snapshot for " << name << " to " |
| 262 << snapshot.value(); |
| 263 return true; |
| 264 } |
| 265 |
242 int CloseAllIEWindows() { | 266 int CloseAllIEWindows() { |
243 int ret = 0; | 267 int ret = 0; |
244 | 268 |
245 base::win::ScopedComPtr<IShellWindows> windows; | 269 base::win::ScopedComPtr<IShellWindows> windows; |
246 HRESULT hr = ::CoCreateInstance(__uuidof(ShellWindows), NULL, CLSCTX_ALL, | 270 HRESULT hr = ::CoCreateInstance(__uuidof(ShellWindows), NULL, CLSCTX_ALL, |
247 IID_IShellWindows, reinterpret_cast<void**>(windows.Receive())); | 271 IID_IShellWindows, reinterpret_cast<void**>(windows.Receive())); |
248 DCHECK(SUCCEEDED(hr)); | 272 DCHECK(SUCCEEDED(hr)); |
249 | 273 |
250 if (SUCCEEDED(hr)) { | 274 if (SUCCEEDED(hr)) { |
251 long count = 0; // NOLINT | 275 long count = 0; // NOLINT |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 if (address.empty()) { | 733 if (address.empty()) { |
710 LOG(ERROR) << "Failed to find a non-loopback IP_V4 address. Tests will be " | 734 LOG(ERROR) << "Failed to find a non-loopback IP_V4 address. Tests will be " |
711 << "run over the loopback adapter, which may result in hangs."; | 735 << "run over the loopback adapter, which may result in hangs."; |
712 address.assign("127.0.0.1"); | 736 address.assign("127.0.0.1"); |
713 } | 737 } |
714 | 738 |
715 return address; | 739 return address; |
716 } | 740 } |
717 | 741 |
718 } // namespace chrome_frame_test | 742 } // namespace chrome_frame_test |
OLD | NEW |