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

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

Issue 7669061: Tommi: I need an owner review for the chrome frame changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Making use of scoped cleanup where it helps Created 9 years, 4 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) 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 "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; 19 using registry_util::ScopedRegistryKeyOverride;
20 20
21 const wchar_t kChannelName[] = L"-dev"; 21 const wchar_t kChannelName[] = L"-dev";
22 const wchar_t kSuffix[] = L"-fix"; 22 const wchar_t kSuffix[] = L"-fix";
23 23
24 // Registry override in the UtilsTest will cause shell APIs to fail 24 // Registry override in the UtilsTest will cause shell APIs to fail
25 // So separate this test from the rest 25 // So separate this test from the rest
26 TEST(SimpleUtilTests, GetTempInternetFiles) { 26 TEST(SimpleUtilTests, GetTempInternetFiles) {
27 FilePath path = GetIETemporaryFilesFolder(); 27 FilePath path = GetIETemporaryFilesFolder();
28 EXPECT_FALSE(path.empty()); 28 EXPECT_FALSE(path.empty());
29 } 29 }
30 30
31 class UtilTests : public testing::Test { 31 class UtilTests : public testing::Test {
32 protected: 32 protected:
33 void SetUp() { 33 void SetUp() {
34 TempRegKeyOverride::DeleteAllTempKeys(); 34 ScopedRegistryKeyOverride::DeleteAllTempKeys();
35 DeleteAllSingletons(); 35 DeleteAllSingletons();
36 36
37 hklm_pol_.reset(new TempRegKeyOverride(HKEY_LOCAL_MACHINE, L"hklm_fake")); 37 hklm_pol_.reset(new ScopedRegistryKeyOverride(HKEY_LOCAL_MACHINE,
38 hkcu_pol_.reset(new TempRegKeyOverride(HKEY_CURRENT_USER, L"hkcu_fake")); 38 L"hklm_fake"));
39 hkcu_pol_.reset(new ScopedRegistryKeyOverride(HKEY_CURRENT_USER,
40 L"hkcu_fake"));
39 } 41 }
40 42
41 void TearDown() { 43 void TearDown() {
42 hkcu_pol_.reset(NULL); 44 hkcu_pol_.reset(NULL);
43 hklm_pol_.reset(NULL); 45 hklm_pol_.reset(NULL);
44 TempRegKeyOverride::DeleteAllTempKeys(); 46 ScopedRegistryKeyOverride::DeleteAllTempKeys();
45 } 47 }
46 48
47 // This is used to manage life cycle of PolicySettings singleton. 49 // This is used to manage life cycle of PolicySettings singleton.
48 // base::ShadowingAtExitManager at_exit_manager_; 50 // base::ShadowingAtExitManager at_exit_manager_;
49 scoped_ptr<TempRegKeyOverride> hklm_pol_; 51 scoped_ptr<ScopedRegistryKeyOverride> hklm_pol_;
50 scoped_ptr<TempRegKeyOverride> hkcu_pol_; 52 scoped_ptr<ScopedRegistryKeyOverride> hkcu_pol_;
51 }; 53 };
52 54
53 TEST_F(UtilTests, GetModuleVersionTest) { 55 TEST_F(UtilTests, GetModuleVersionTest) {
54 HMODULE mod = GetModuleHandle(L"kernel32.dll"); 56 HMODULE mod = GetModuleHandle(L"kernel32.dll");
55 EXPECT_NE(mod, static_cast<HMODULE>(NULL)); 57 EXPECT_NE(mod, static_cast<HMODULE>(NULL));
56 wchar_t path[MAX_PATH] = {0}; 58 wchar_t path[MAX_PATH] = {0};
57 GetModuleFileName(mod, path, arraysize(path)); 59 GetModuleFileName(mod, path, arraysize(path));
58 60
59 // Use the method that goes to disk 61 // Use the method that goes to disk
60 scoped_ptr<FileVersionInfo> base_info( 62 scoped_ptr<FileVersionInfo> base_info(
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 545
544 ASSERT_EQ(expect_match, 546 ASSERT_EQ(expect_match,
545 CheckXUaCompatibleDirective(test.header_value, 547 CheckXUaCompatibleDirective(test.header_value,
546 all_versions[version_index])) 548 all_versions[version_index]))
547 << "Expect '" << test.header_value << "' to " 549 << "Expect '" << test.header_value << "' to "
548 << (expect_match ? "match" : "not match") << " IE major version " 550 << (expect_match ? "match" : "not match") << " IE major version "
549 << all_versions[version_index]; 551 << all_versions[version_index];
550 } 552 }
551 } 553 }
552 } 554 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698