OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/installer/util/scoped_user_protocol_entry.h" | 5 #include "chrome/installer/util/scoped_user_protocol_entry.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
8 #include "base/test/test_reg_util_win.h" | 9 #include "base/test/test_reg_util_win.h" |
9 #include "base/win/registry.h" | 10 #include "base/win/registry.h" |
10 #include "chrome/installer/util/registry_entry.h" | 11 #include "chrome/installer/util/registry_entry.h" |
11 #include "chrome/installer/util/shell_util.h" | 12 #include "chrome/installer/util/shell_util.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 class ScopedUserProtocolEntryTest : public testing::Test { | 15 class ScopedUserProtocolEntryTest : public testing::Test { |
15 protected: | 16 protected: |
16 static const wchar_t kProtocolEntryKeyPath[]; | 17 static const wchar_t kProtocolEntryKeyPath[]; |
(...skipping 12 matching lines...) Expand all Loading... |
29 void CreateNewRegistryValue(const base::string16& key_path, | 30 void CreateNewRegistryValue(const base::string16& key_path, |
30 const base::string16& name, | 31 const base::string16& name, |
31 const base::string16& value) { | 32 const base::string16& value) { |
32 ScopedVector<RegistryEntry> entries; | 33 ScopedVector<RegistryEntry> entries; |
33 entries.push_back(new RegistryEntry(key_path, name, value)); | 34 entries.push_back(new RegistryEntry(key_path, name, value)); |
34 ASSERT_TRUE(ShellUtil::AddRegistryEntries(HKEY_CURRENT_USER, entries)); | 35 ASSERT_TRUE(ShellUtil::AddRegistryEntries(HKEY_CURRENT_USER, entries)); |
35 } | 36 } |
36 | 37 |
37 void CreateScopedUserProtocolEntryAndVerifyRegistryValue( | 38 void CreateScopedUserProtocolEntryAndVerifyRegistryValue( |
38 const base::string16& expected_entry_value) { | 39 const base::string16& expected_entry_value) { |
39 entry_ = make_scoped_ptr(new ScopedUserProtocolEntry()); | 40 entry_ = base::WrapUnique(new ScopedUserProtocolEntry()); |
40 ASSERT_TRUE(RegistryEntry(kProtocolEntryKeyPath, kProtocolEntryName, | 41 ASSERT_TRUE(RegistryEntry(kProtocolEntryKeyPath, kProtocolEntryName, |
41 expected_entry_value) | 42 expected_entry_value) |
42 .ExistsInRegistry(RegistryEntry::LOOK_IN_HKCU)); | 43 .ExistsInRegistry(RegistryEntry::LOOK_IN_HKCU)); |
43 } | 44 } |
44 | 45 |
45 registry_util::RegistryOverrideManager registry_overrides_manager_; | 46 registry_util::RegistryOverrideManager registry_overrides_manager_; |
46 scoped_ptr<ScopedUserProtocolEntry> entry_; | 47 std::unique_ptr<ScopedUserProtocolEntry> entry_; |
47 }; | 48 }; |
48 | 49 |
49 const wchar_t ScopedUserProtocolEntryTest::kProtocolEntryKeyPath[] = | 50 const wchar_t ScopedUserProtocolEntryTest::kProtocolEntryKeyPath[] = |
50 L"Software\\Classes\\http"; | 51 L"Software\\Classes\\http"; |
51 const wchar_t ScopedUserProtocolEntryTest::kProtocolEntrySubKeyPath[] = | 52 const wchar_t ScopedUserProtocolEntryTest::kProtocolEntrySubKeyPath[] = |
52 L"Software\\Classes\\http\\sub"; | 53 L"Software\\Classes\\http\\sub"; |
53 const wchar_t ScopedUserProtocolEntryTest::kProtocolEntryName[] = | 54 const wchar_t ScopedUserProtocolEntryTest::kProtocolEntryName[] = |
54 L"URL Protocol"; | 55 L"URL Protocol"; |
55 const wchar_t ScopedUserProtocolEntryTest::kProtocolEntryFakeName[] = | 56 const wchar_t ScopedUserProtocolEntryTest::kProtocolEntryFakeName[] = |
56 L"Fake URL Protocol"; | 57 L"Fake URL Protocol"; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 117 |
117 TEST_F(ScopedUserProtocolEntryTest, KeyHasBeenDeletedByOthersTest) { | 118 TEST_F(ScopedUserProtocolEntryTest, KeyHasBeenDeletedByOthersTest) { |
118 CreateScopedUserProtocolEntryAndVerifyRegistryValue(base::string16()); | 119 CreateScopedUserProtocolEntryAndVerifyRegistryValue(base::string16()); |
119 base::win::RegKey key(HKEY_CURRENT_USER, L"", KEY_WRITE); | 120 base::win::RegKey key(HKEY_CURRENT_USER, L"", KEY_WRITE); |
120 EXPECT_EQ(ERROR_SUCCESS, key.DeleteKey(kProtocolEntryKeyPath)); | 121 EXPECT_EQ(ERROR_SUCCESS, key.DeleteKey(kProtocolEntryKeyPath)); |
121 entry_.reset(); | 122 entry_.reset(); |
122 ASSERT_FALSE( | 123 ASSERT_FALSE( |
123 RegistryEntry(kProtocolEntryKeyPath, kProtocolEntryName, base::string16()) | 124 RegistryEntry(kProtocolEntryKeyPath, kProtocolEntryName, base::string16()) |
124 .KeyExistsInRegistry(RegistryEntry::LOOK_IN_HKCU)); | 125 .KeyExistsInRegistry(RegistryEntry::LOOK_IN_HKCU)); |
125 } | 126 } |
OLD | NEW |