OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/file_version_info.h" | 6 #include "base/file_version_info.h" |
7 #include "base/file_version_info_win.h" | 7 #include "base/file_version_info_win.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "base/win/registry.h" | 10 #include "base/win/registry.h" |
11 #include "chrome_frame/navigation_constraints.h" | 11 #include "chrome_frame/navigation_constraints.h" |
12 #include "chrome_frame/test/chrome_frame_test_utils.h" | 12 #include "chrome_frame/test/chrome_frame_test_utils.h" |
13 #include "chrome_frame/utils.h" | 13 #include "chrome_frame/utils.h" |
14 | 14 |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 | 17 |
18 using base::win::RegKey; | 18 using base::win::RegKey; |
19 using chrome_frame_test::TempRegKeyOverride; | |
20 | 19 |
21 const wchar_t kChannelName[] = L"-dev"; | 20 const wchar_t kChannelName[] = L"-dev"; |
22 const wchar_t kSuffix[] = L"-fix"; | 21 const wchar_t kSuffix[] = L"-fix"; |
23 | 22 |
24 // Registry override in the UtilsTest will cause shell APIs to fail | 23 // Registry override in the UtilsTest will cause shell APIs to fail |
25 // So separate this test from the rest | 24 // So separate this test from the rest |
26 TEST(SimpleUtilTests, GetTempInternetFiles) { | 25 TEST(SimpleUtilTests, GetTempInternetFiles) { |
27 FilePath path = GetIETemporaryFilesFolder(); | 26 FilePath path = GetIETemporaryFilesFolder(); |
28 EXPECT_FALSE(path.empty()); | 27 EXPECT_FALSE(path.empty()); |
29 } | 28 } |
30 | 29 |
31 class UtilTests : public testing::Test { | 30 class UtilTests : public testing::Test { |
32 protected: | 31 protected: |
33 void SetUp() { | 32 void SetUp() { |
34 TempRegKeyOverride::DeleteAllTempKeys(); | |
35 DeleteAllSingletons(); | 33 DeleteAllSingletons(); |
36 | |
37 hklm_pol_.reset(new TempRegKeyOverride(HKEY_LOCAL_MACHINE, L"hklm_fake")); | |
38 hkcu_pol_.reset(new TempRegKeyOverride(HKEY_CURRENT_USER, L"hkcu_fake")); | |
39 } | 34 } |
40 | 35 |
41 void TearDown() { | 36 void TearDown() { |
42 hkcu_pol_.reset(NULL); | 37 registry_virtualization_.RemoveAllOverrides(); |
43 hklm_pol_.reset(NULL); | |
44 TempRegKeyOverride::DeleteAllTempKeys(); | |
45 } | 38 } |
46 | 39 |
47 // This is used to manage life cycle of PolicySettings singleton. | 40 // This is used to manage life cycle of PolicySettings singleton. |
48 // base::ShadowingAtExitManager at_exit_manager_; | 41 // base::ShadowingAtExitManager at_exit_manager_; |
49 scoped_ptr<TempRegKeyOverride> hklm_pol_; | 42 chrome_frame_test::ScopedVirtualizeHklmAndHkcu registry_virtualization_; |
50 scoped_ptr<TempRegKeyOverride> hkcu_pol_; | |
51 }; | 43 }; |
52 | 44 |
53 TEST_F(UtilTests, GetModuleVersionTest) { | 45 TEST_F(UtilTests, GetModuleVersionTest) { |
54 HMODULE mod = GetModuleHandle(L"kernel32.dll"); | 46 HMODULE mod = GetModuleHandle(L"kernel32.dll"); |
55 EXPECT_NE(mod, static_cast<HMODULE>(NULL)); | 47 EXPECT_NE(mod, static_cast<HMODULE>(NULL)); |
56 wchar_t path[MAX_PATH] = {0}; | 48 wchar_t path[MAX_PATH] = {0}; |
57 GetModuleFileName(mod, path, arraysize(path)); | 49 GetModuleFileName(mod, path, arraysize(path)); |
58 | 50 |
59 // Use the method that goes to disk | 51 // Use the method that goes to disk |
60 scoped_ptr<FileVersionInfo> base_info( | 52 scoped_ptr<FileVersionInfo> base_info( |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 | 535 |
544 ASSERT_EQ(expect_match, | 536 ASSERT_EQ(expect_match, |
545 CheckXUaCompatibleDirective(test.header_value, | 537 CheckXUaCompatibleDirective(test.header_value, |
546 all_versions[version_index])) | 538 all_versions[version_index])) |
547 << "Expect '" << test.header_value << "' to " | 539 << "Expect '" << test.header_value << "' to " |
548 << (expect_match ? "match" : "not match") << " IE major version " | 540 << (expect_match ? "match" : "not match") << " IE major version " |
549 << all_versions[version_index]; | 541 << all_versions[version_index]; |
550 } | 542 } |
551 } | 543 } |
552 } | 544 } |
OLD | NEW |