| OLD | NEW |
| 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/test/test_reg_util_win.h" | 9 #include "base/test/test_reg_util_win.h" |
| 10 #include "base/win/registry.h" | 10 #include "base/win/registry.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 { | 130 { |
| 131 RegistryOverrideManager override_manager; | 131 RegistryOverrideManager override_manager; |
| 132 override_manager.OverrideRegistry(root, L"root_inst_res"); | 132 override_manager.OverrideRegistry(root, L"root_inst_res"); |
| 133 RegKey(root, state_key_path.c_str(), KEY_SET_VALUE) | 133 RegKey(root, state_key_path.c_str(), KEY_SET_VALUE) |
| 134 .DeleteValue(installer::kInstallerExtraCode1); | 134 .DeleteValue(installer::kInstallerExtraCode1); |
| 135 InstallUtil::UpdateInstallerStage(system_level, state_key_path, | 135 InstallUtil::UpdateInstallerStage(system_level, state_key_path, |
| 136 installer::BUILDING); | 136 installer::BUILDING); |
| 137 DWORD value; | 137 DWORD value; |
| 138 EXPECT_EQ(ERROR_SUCCESS, | 138 EXPECT_EQ(ERROR_SUCCESS, |
| 139 RegKey(root, state_key_path.c_str(), KEY_QUERY_VALUE) | 139 RegKey(root, state_key_path.c_str(), KEY_QUERY_VALUE) |
| 140 .ReadValueDW(installer::kInstallerExtraCode1, &value)); | 140 .ReadValue(installer::kInstallerExtraCode1, &value)); |
| 141 EXPECT_EQ(static_cast<DWORD>(installer::BUILDING), value); | 141 EXPECT_EQ(static_cast<DWORD>(installer::BUILDING), value); |
| 142 } | 142 } |
| 143 | 143 |
| 144 // Update the stage when there is an "InstallerExtraCode1" value. | 144 // Update the stage when there is an "InstallerExtraCode1" value. |
| 145 { | 145 { |
| 146 RegistryOverrideManager override_manager; | 146 RegistryOverrideManager override_manager; |
| 147 override_manager.OverrideRegistry(root, L"root_inst_res"); | 147 override_manager.OverrideRegistry(root, L"root_inst_res"); |
| 148 RegKey(root, state_key_path.c_str(), KEY_SET_VALUE) | 148 RegKey(root, state_key_path.c_str(), KEY_SET_VALUE) |
| 149 .WriteValue(installer::kInstallerExtraCode1, | 149 .WriteValue(installer::kInstallerExtraCode1, |
| 150 static_cast<DWORD>(installer::UNPACKING)); | 150 static_cast<DWORD>(installer::UNPACKING)); |
| 151 InstallUtil::UpdateInstallerStage(system_level, state_key_path, | 151 InstallUtil::UpdateInstallerStage(system_level, state_key_path, |
| 152 installer::BUILDING); | 152 installer::BUILDING); |
| 153 DWORD value; | 153 DWORD value; |
| 154 EXPECT_EQ(ERROR_SUCCESS, | 154 EXPECT_EQ(ERROR_SUCCESS, |
| 155 RegKey(root, state_key_path.c_str(), KEY_QUERY_VALUE) | 155 RegKey(root, state_key_path.c_str(), KEY_QUERY_VALUE) |
| 156 .ReadValueDW(installer::kInstallerExtraCode1, &value)); | 156 .ReadValue(installer::kInstallerExtraCode1, &value)); |
| 157 EXPECT_EQ(static_cast<DWORD>(installer::BUILDING), value); | 157 EXPECT_EQ(static_cast<DWORD>(installer::BUILDING), value); |
| 158 } | 158 } |
| 159 | 159 |
| 160 // Clear the stage. | 160 // Clear the stage. |
| 161 { | 161 { |
| 162 RegistryOverrideManager override_manager; | 162 RegistryOverrideManager override_manager; |
| 163 override_manager.OverrideRegistry(root, L"root_inst_res"); | 163 override_manager.OverrideRegistry(root, L"root_inst_res"); |
| 164 RegKey(root, state_key_path.c_str(), KEY_SET_VALUE) | 164 RegKey(root, state_key_path.c_str(), KEY_SET_VALUE) |
| 165 .WriteValue(installer::kInstallerExtraCode1, static_cast<DWORD>(5)); | 165 .WriteValue(installer::kInstallerExtraCode1, static_cast<DWORD>(5)); |
| 166 InstallUtil::UpdateInstallerStage(system_level, state_key_path, | 166 InstallUtil::UpdateInstallerStage(system_level, state_key_path, |
| 167 installer::NO_STAGE); | 167 installer::NO_STAGE); |
| 168 DWORD value; | 168 DWORD value; |
| 169 EXPECT_EQ(ERROR_FILE_NOT_FOUND, | 169 EXPECT_EQ(ERROR_FILE_NOT_FOUND, |
| 170 RegKey(root, state_key_path.c_str(), KEY_QUERY_VALUE) | 170 RegKey(root, state_key_path.c_str(), KEY_QUERY_VALUE) |
| 171 .ReadValueDW(installer::kInstallerExtraCode1, &value)); | 171 .ReadValue(installer::kInstallerExtraCode1, &value)); |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 TEST_F(InstallUtilTest, DeleteRegistryKeyIf) { | 175 TEST_F(InstallUtilTest, DeleteRegistryKeyIf) { |
| 176 const HKEY root = HKEY_CURRENT_USER; | 176 const HKEY root = HKEY_CURRENT_USER; |
| 177 std::wstring parent_key_path(L"SomeKey\\ToDelete"); | 177 std::wstring parent_key_path(L"SomeKey\\ToDelete"); |
| 178 std::wstring child_key_path(parent_key_path); | 178 std::wstring child_key_path(parent_key_path); |
| 179 child_key_path.append(L"\\ChildKey\\WithAValue"); | 179 child_key_path.append(L"\\ChildKey\\WithAValue"); |
| 180 const wchar_t value_name[] = L"some_value_name"; | 180 const wchar_t value_name[] = L"some_value_name"; |
| 181 const wchar_t value[] = L"hi mom"; | 181 const wchar_t value[] = L"hi mom"; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 334 |
| 335 TEST_F(InstallUtilTest, ValueEquals) { | 335 TEST_F(InstallUtilTest, ValueEquals) { |
| 336 InstallUtil::ValueEquals pred(L"howdy"); | 336 InstallUtil::ValueEquals pred(L"howdy"); |
| 337 | 337 |
| 338 EXPECT_FALSE(pred.Evaluate(L"")); | 338 EXPECT_FALSE(pred.Evaluate(L"")); |
| 339 EXPECT_FALSE(pred.Evaluate(L"Howdy")); | 339 EXPECT_FALSE(pred.Evaluate(L"Howdy")); |
| 340 EXPECT_FALSE(pred.Evaluate(L"howdy!")); | 340 EXPECT_FALSE(pred.Evaluate(L"howdy!")); |
| 341 EXPECT_FALSE(pred.Evaluate(L"!howdy")); | 341 EXPECT_FALSE(pred.Evaluate(L"!howdy")); |
| 342 EXPECT_TRUE(pred.Evaluate(L"howdy")); | 342 EXPECT_TRUE(pred.Evaluate(L"howdy")); |
| 343 } | 343 } |
| OLD | NEW |