| 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <shlwapi.h> // For SHDeleteKey. | 6 #include <shlwapi.h> // For SHDeleteKey. |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/win/registry.h" | 9 #include "base/win/registry.h" |
| 10 #include "chrome/common/chrome_constants.h" | 10 #include "chrome/common/chrome_constants.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 for (size_t i = 0; i < arraysize(prefixes); ++i) { | 124 for (size_t i = 0; i < arraysize(prefixes); ++i) { |
| 125 for (size_t j = 0; j < arraysize(expectations); ++j) { | 125 for (size_t j = 0; j < arraysize(expectations); ++j) { |
| 126 for (size_t k = 0; k < arraysize(suffixes); ++k) { | 126 for (size_t k = 0; k < arraysize(suffixes); ++k) { |
| 127 std::wstring ap = prefixes[i]; | 127 std::wstring ap = prefixes[i]; |
| 128 ap += expectations[j].ap_value; | 128 ap += expectations[j].ap_value; |
| 129 ap += suffixes[k]; | 129 ap += suffixes[k]; |
| 130 const wchar_t* channel = expectations[j].channel; | 130 const wchar_t* channel = expectations[j].channel; |
| 131 | 131 |
| 132 SetApField(install, ap.c_str()); | 132 SetApField(install, ap.c_str()); |
| 133 std::wstring ret_channel; | 133 string16 ret_channel; |
| 134 | 134 |
| 135 EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers( | 135 EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers( |
| 136 is_system, &ret_channel)); | 136 is_system, &ret_channel)); |
| 137 EXPECT_STREQ(channel, ret_channel.c_str()) | 137 EXPECT_STREQ(channel, ret_channel.c_str()) |
| 138 << "Expecting channel \"" << channel | 138 << "Expecting channel \"" << channel |
| 139 << "\" for ap=\"" << ap << "\""; | 139 << "\" for ap=\"" << ap << "\""; |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 } | 143 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 RegKey hkcu_; | 182 RegKey hkcu_; |
| 183 RegKey hklm_; | 183 RegKey hklm_; |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 } // namespace | 186 } // namespace |
| 187 | 187 |
| 188 // Verify that we return success on no registration (which means stable), | 188 // Verify that we return success on no registration (which means stable), |
| 189 // whether per-system or per-user install. | 189 // whether per-system or per-user install. |
| 190 TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelAbsent) { | 190 TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelAbsent) { |
| 191 // Per-system first. | 191 // Per-system first. |
| 192 std::wstring channel; | 192 string16 channel; |
| 193 EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(true, | 193 EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(true, |
| 194 &channel)); | 194 &channel)); |
| 195 EXPECT_STREQ(L"", channel.c_str()); | 195 EXPECT_STREQ(L"", channel.c_str()); |
| 196 | 196 |
| 197 // Then per-user. | 197 // Then per-user. |
| 198 EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false, | 198 EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false, |
| 199 &channel)); | 199 &channel)); |
| 200 EXPECT_STREQ(L"", channel.c_str()); | 200 EXPECT_STREQ(L"", channel.c_str()); |
| 201 } | 201 } |
| 202 | 202 |
| 203 // Test an empty Ap key for system and user. | 203 // Test an empty Ap key for system and user. |
| 204 TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelEmptySystem) { | 204 TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelEmptySystem) { |
| 205 SetApField(SYSTEM_INSTALL, L""); | 205 SetApField(SYSTEM_INSTALL, L""); |
| 206 std::wstring channel; | 206 string16 channel; |
| 207 EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(true, | 207 EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(true, |
| 208 &channel)); | 208 &channel)); |
| 209 EXPECT_STREQ(L"", channel.c_str()); | 209 EXPECT_STREQ(L"", channel.c_str()); |
| 210 | 210 |
| 211 // Per-user lookups still succeed and return empty string. | 211 // Per-user lookups still succeed and return empty string. |
| 212 EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false, | 212 EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false, |
| 213 &channel)); | 213 &channel)); |
| 214 EXPECT_STREQ(L"", channel.c_str()); | 214 EXPECT_STREQ(L"", channel.c_str()); |
| 215 } | 215 } |
| 216 | 216 |
| 217 TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelEmptyUser) { | 217 TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelEmptyUser) { |
| 218 SetApField(USER_INSTALL, L""); | 218 SetApField(USER_INSTALL, L""); |
| 219 // Per-system lookups still succeed and return empty string. | 219 // Per-system lookups still succeed and return empty string. |
| 220 std::wstring channel; | 220 string16 channel; |
| 221 EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(true, | 221 EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(true, |
| 222 &channel)); | 222 &channel)); |
| 223 EXPECT_STREQ(L"", channel.c_str()); | 223 EXPECT_STREQ(L"", channel.c_str()); |
| 224 | 224 |
| 225 // Per-user lookup should succeed. | 225 // Per-user lookup should succeed. |
| 226 EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false, | 226 EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false, |
| 227 &channel)); | 227 &channel)); |
| 228 EXPECT_STREQ(L"", channel.c_str()); | 228 EXPECT_STREQ(L"", channel.c_str()); |
| 229 } | 229 } |
| 230 | 230 |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 KEY_SET_VALUE).WriteValue(app_policy_value.c_str(), | 580 KEY_SET_VALUE).WriteValue(app_policy_value.c_str(), |
| 581 static_cast<DWORD>(3))); | 581 static_cast<DWORD>(3))); |
| 582 is_overridden = true; | 582 is_overridden = true; |
| 583 EXPECT_EQ(GoogleUpdateSettings::UPDATES_DISABLED, | 583 EXPECT_EQ(GoogleUpdateSettings::UPDATES_DISABLED, |
| 584 GoogleUpdateSettings::GetAppUpdatePolicy(kTestProductGuid, | 584 GoogleUpdateSettings::GetAppUpdatePolicy(kTestProductGuid, |
| 585 &is_overridden)); | 585 &is_overridden)); |
| 586 EXPECT_FALSE(is_overridden); | 586 EXPECT_FALSE(is_overridden); |
| 587 } | 587 } |
| 588 | 588 |
| 589 #endif // defined(GOOGLE_CHROME_BUILD) | 589 #endif // defined(GOOGLE_CHROME_BUILD) |
| OLD | NEW |