Chromium Code Reviews| Index: chrome/installer/util/google_update_settings_unittest.cc |
| diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc |
| index 2f229ae84b723eeefae64b12ee557ddf4497a81a..7b1b5d68d7c605da677d1377a51c3396f49d2444 100644 |
| --- a/chrome/installer/util/google_update_settings_unittest.cc |
| +++ b/chrome/installer/util/google_update_settings_unittest.cc |
| @@ -990,6 +990,46 @@ TEST_F(GoogleUpdateSettingsTest, ExperimentsLabelHelperUser) { |
| #endif // defined(GOOGLE_CHROME_BUILD) |
| +TEST_F(GoogleUpdateSettingsTest, GetDownloadPreference) { |
| + RegKey policy_key; |
| + |
| + if (policy_key.Open(HKEY_LOCAL_MACHINE, GoogleUpdateSettings::kPoliciesKey, |
| + KEY_SET_VALUE) == ERROR_SUCCESS) { |
| + policy_key.DeleteValue(GoogleUpdateSettings::kDownloadPreference); |
| + } |
| + policy_key.Close(); |
| + |
| + // When no policy is present expect to return an empty string. |
| + EXPECT_TRUE(GoogleUpdateSettings::GetDownloadPreference().empty()); |
| + |
| + // Expect "cacheable" when the correct policy is present. |
| + EXPECT_EQ(ERROR_SUCCESS, policy_key.Create(HKEY_LOCAL_MACHINE, |
| + GoogleUpdateSettings::kPoliciesKey, |
| + KEY_SET_VALUE)); |
| + EXPECT_EQ(ERROR_SUCCESS, |
| + policy_key.WriteValue( |
| + GoogleUpdateSettings::kDownloadPreference, |
| + GoogleUpdateSettings::kDownloadPreferenceCacheable)); |
| + EXPECT_STREQ(L"cacheable", |
| + GoogleUpdateSettings::GetDownloadPreference().c_str()); |
| + |
| + // Expect an empty string when an unsupported policy is set. |
| + EXPECT_EQ( |
| + ERROR_SUCCESS, |
| + policy_key.WriteValue(GoogleUpdateSettings::kDownloadPreference, L"a b")); |
| + EXPECT_TRUE(GoogleUpdateSettings::GetDownloadPreference().empty()); |
| + |
| + EXPECT_EQ( |
| + ERROR_SUCCESS, |
| + policy_key.WriteValue(GoogleUpdateSettings::kDownloadPreference, L"<a>")); |
| + EXPECT_TRUE(GoogleUpdateSettings::GetDownloadPreference().empty()); |
| + |
| + EXPECT_EQ(ERROR_SUCCESS, |
| + policy_key.WriteValue(GoogleUpdateSettings::kDownloadPreference, |
| + L"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); |
|
gab
2016/01/21 21:08:49
base::string16(33, L'a')
to make it clearer that
Sorin Jianu
2016/01/25 20:04:58
Done.
|
| + EXPECT_TRUE(GoogleUpdateSettings::GetDownloadPreference().empty()); |
| +} |
| + |
| // Test GoogleUpdateSettings::GetUninstallCommandLine at system- or user-level, |
| // according to the param. |
| class GetUninstallCommandLine : public GoogleUpdateSettingsTest, |