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

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

Issue 5564009: Temporary workaround to get tests that reference singletons either directly o... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <atlbase.h> 7 #include <atlbase.h>
8 #include <atlwin.h> 8 #include <atlwin.h>
9 #include <iepmapi.h> 9 #include <iepmapi.h>
10 #include <sddl.h> 10 #include <sddl.h>
(...skipping 11 matching lines...) Expand all
22 #include "base/stringprintf.h" 22 #include "base/stringprintf.h"
23 #include "base/utf_string_conversions.h" 23 #include "base/utf_string_conversions.h"
24 #include "base/win_util.h" 24 #include "base/win_util.h"
25 #include "base/win/registry.h" 25 #include "base/win/registry.h"
26 #include "base/win/windows_version.h" 26 #include "base/win/windows_version.h"
27 #include "ceee/ie/common/ceee_util.h" 27 #include "ceee/ie/common/ceee_util.h"
28 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/chrome_paths.h" 29 #include "chrome/common/chrome_paths.h"
30 #include "chrome/common/chrome_paths_internal.h" 30 #include "chrome/common/chrome_paths_internal.h"
31 #include "chrome_frame/utils.h" 31 #include "chrome_frame/utils.h"
32 #include "testing/gtest/include/gtest/gtest.h"
32 33
33 namespace chrome_frame_test { 34 namespace chrome_frame_test {
34 35
35 const wchar_t kCrashServicePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; 36 const wchar_t kCrashServicePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices";
36 37
37 const DWORD kCrashServicePipeDesiredAccess = FILE_READ_DATA | 38 const DWORD kCrashServicePipeDesiredAccess = FILE_READ_DATA |
38 FILE_WRITE_DATA | 39 FILE_WRITE_DATA |
39 FILE_WRITE_ATTRIBUTES; 40 FILE_WRITE_ATTRIBUTES;
40 41
41 const DWORD kCrashServicePipeFlagsAndAttributes = SECURITY_IDENTIFICATION | 42 const DWORD kCrashServicePipeFlagsAndAttributes = SECURITY_IDENTIFICATION |
42 SECURITY_SQOS_PRESENT; 43 SECURITY_SQOS_PRESENT;
43 const int kCrashServiceStartupTimeoutMs = 500; 44 const int kCrashServiceStartupTimeoutMs = 500;
44 45
45 const wchar_t kIEImageName[] = L"iexplore.exe"; 46 const wchar_t kIEImageName[] = L"iexplore.exe";
46 const wchar_t kIEBrokerImageName[] = L"ieuser.exe"; 47 const wchar_t kIEBrokerImageName[] = L"ieuser.exe";
47 const wchar_t kFirefoxImageName[] = L"firefox.exe"; 48 const wchar_t kFirefoxImageName[] = L"firefox.exe";
48 const wchar_t kOperaImageName[] = L"opera.exe"; 49 const wchar_t kOperaImageName[] = L"opera.exe";
49 const wchar_t kSafariImageName[] = L"safari.exe"; 50 const wchar_t kSafariImageName[] = L"safari.exe";
50 const char kChromeImageName[] = "chrome.exe"; 51 const char kChromeImageName[] = "chrome.exe";
51 const wchar_t kIEProfileName[] = L"iexplore"; 52 const wchar_t kIEProfileName[] = L"iexplore";
52 const wchar_t kChromeLauncher[] = L"chrome_launcher.exe"; 53 const wchar_t kChromeLauncher[] = L"chrome_launcher.exe";
53 const int kChromeFrameLongNavigationTimeoutInSeconds = 10; 54 const int kChromeFrameLongNavigationTimeoutInSeconds = 10;
54 55
56 const wchar_t TempRegKeyOverride::kTempTestKeyPath[] =
57 L"Software\\Chromium\\TempTestKeys";
58
55 // Callback function for EnumThreadWindows. 59 // Callback function for EnumThreadWindows.
56 BOOL CALLBACK CloseWindowsThreadCallback(HWND hwnd, LPARAM param) { 60 BOOL CALLBACK CloseWindowsThreadCallback(HWND hwnd, LPARAM param) {
57 int& count = *reinterpret_cast<int*>(param); 61 int& count = *reinterpret_cast<int*>(param);
58 if (IsWindowVisible(hwnd)) { 62 if (IsWindowVisible(hwnd)) {
59 if (IsWindowEnabled(hwnd)) { 63 if (IsWindowEnabled(hwnd)) {
60 DWORD results = 0; 64 DWORD results = 0;
61 if (!::SendMessageTimeout(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0, SMTO_BLOCK, 65 if (!::SendMessageTimeout(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0, SMTO_BLOCK,
62 10000, &results)) { 66 10000, &results)) {
63 LOG(WARNING) << "Window hung: " << base::StringPrintf(L"%08X", hwnd); 67 LOG(WARNING) << "Window hung: " << base::StringPrintf(L"%08X", hwnd);
64 } 68 }
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 621
618 // First check to see if it's even still running just to minimize the 622 // First check to see if it's even still running just to minimize the
619 // likelihood of spurious error messages from KillProcess. 623 // likelihood of spurious error messages from KillProcess.
620 if (WAIT_OBJECT_0 != ::WaitForSingleObject(crash_service, 0)) { 624 if (WAIT_OBJECT_0 != ::WaitForSingleObject(crash_service, 0)) {
621 base::KillProcess(crash_service, 0, false); 625 base::KillProcess(crash_service, 0, false);
622 } 626 }
623 return NULL; 627 return NULL;
624 } 628 }
625 } 629 }
626 630
631 TempRegKeyOverride::TempRegKeyOverride(HKEY override, const wchar_t* temp_name)
632 : override_(override), temp_name_(temp_name) {
633 DCHECK(temp_name && lstrlenW(temp_name));
634 std::wstring key_path(kTempTestKeyPath);
635 key_path += L"\\" + temp_name_;
636 EXPECT_TRUE(temp_key_.Create(HKEY_CURRENT_USER, key_path.c_str(),
637 KEY_ALL_ACCESS));
638 EXPECT_EQ(ERROR_SUCCESS,
639 ::RegOverridePredefKey(override_, temp_key_.Handle()));
640 }
641
642 TempRegKeyOverride::~TempRegKeyOverride() {
643 ::RegOverridePredefKey(override_, NULL);
644 // The temp key will be deleted via a call to DeleteAllTempKeys().
645 }
646
647 // static
648 void TempRegKeyOverride::DeleteAllTempKeys() {
649 base::win::RegKey key;
650 if (key.Open(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS)) {
651 key.DeleteKey(kTempTestKeyPath);
652 }
653 }
654
655 ScopedVirtualizeHklmAndHkcu::ScopedVirtualizeHklmAndHkcu() {
656 TempRegKeyOverride::DeleteAllTempKeys();
657 hklm_.reset(new TempRegKeyOverride(HKEY_LOCAL_MACHINE, L"hklm_fake"));
658 hkcu_.reset(new TempRegKeyOverride(HKEY_CURRENT_USER, L"hkcu_fake"));
659 }
660
661 ScopedVirtualizeHklmAndHkcu::~ScopedVirtualizeHklmAndHkcu() {
662 hkcu_.reset(NULL);
663 hklm_.reset(NULL);
664 TempRegKeyOverride::DeleteAllTempKeys();
665 }
666
627 } // namespace chrome_frame_test 667 } // namespace chrome_frame_test
OLDNEW
« no previous file with comments | « chrome_frame/test/chrome_frame_test_utils.h ('k') | chrome_frame/test/policy_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698