OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/google_update_settings.h" | 5 #include "chrome/installer/util/google_update_settings.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shlwapi.h> // For SHDeleteKey. | 8 #include <shlwapi.h> // For SHDeleteKey. |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 TEST_F(GoogleUpdateSettingsTest, ExperimentsLabelHelperSystem) { | 983 TEST_F(GoogleUpdateSettingsTest, ExperimentsLabelHelperSystem) { |
984 TestExperimentsLabelHelper(SYSTEM_INSTALL); | 984 TestExperimentsLabelHelper(SYSTEM_INSTALL); |
985 } | 985 } |
986 | 986 |
987 TEST_F(GoogleUpdateSettingsTest, ExperimentsLabelHelperUser) { | 987 TEST_F(GoogleUpdateSettingsTest, ExperimentsLabelHelperUser) { |
988 TestExperimentsLabelHelper(USER_INSTALL); | 988 TestExperimentsLabelHelper(USER_INSTALL); |
989 } | 989 } |
990 | 990 |
991 #endif // defined(GOOGLE_CHROME_BUILD) | 991 #endif // defined(GOOGLE_CHROME_BUILD) |
992 | 992 |
| 993 TEST_F(GoogleUpdateSettingsTest, GetDownloadPreference) { |
| 994 RegKey policy_key; |
| 995 |
| 996 if (policy_key.Open(HKEY_LOCAL_MACHINE, GoogleUpdateSettings::kPoliciesKey, |
| 997 KEY_SET_VALUE) == ERROR_SUCCESS) { |
| 998 policy_key.DeleteValue(GoogleUpdateSettings::kDownloadPreference); |
| 999 } |
| 1000 policy_key.Close(); |
| 1001 |
| 1002 // When no policy is present expect to return an empty string. |
| 1003 EXPECT_TRUE(GoogleUpdateSettings::GetDownloadPreference().empty()); |
| 1004 |
| 1005 // Expect "cacheable" when the correct policy is present. |
| 1006 EXPECT_EQ(ERROR_SUCCESS, policy_key.Create(HKEY_LOCAL_MACHINE, |
| 1007 GoogleUpdateSettings::kPoliciesKey, |
| 1008 KEY_SET_VALUE)); |
| 1009 EXPECT_EQ(ERROR_SUCCESS, |
| 1010 policy_key.WriteValue( |
| 1011 GoogleUpdateSettings::kDownloadPreference, |
| 1012 GoogleUpdateSettings::kDownloadPreferenceCacheable)); |
| 1013 EXPECT_STREQ(L"cacheable", |
| 1014 GoogleUpdateSettings::GetDownloadPreference().c_str()); |
| 1015 |
| 1016 // Expect an empty string when an unsupported policy is set. |
| 1017 EXPECT_EQ( |
| 1018 ERROR_SUCCESS, |
| 1019 policy_key.WriteValue(GoogleUpdateSettings::kDownloadPreference, L"foo")); |
| 1020 EXPECT_TRUE(GoogleUpdateSettings::GetDownloadPreference().empty()); |
| 1021 } |
| 1022 |
993 // Test GoogleUpdateSettings::GetUninstallCommandLine at system- or user-level, | 1023 // Test GoogleUpdateSettings::GetUninstallCommandLine at system- or user-level, |
994 // according to the param. | 1024 // according to the param. |
995 class GetUninstallCommandLine : public GoogleUpdateSettingsTest, | 1025 class GetUninstallCommandLine : public GoogleUpdateSettingsTest, |
996 public testing::WithParamInterface<bool> { | 1026 public testing::WithParamInterface<bool> { |
997 protected: | 1027 protected: |
998 static const wchar_t kDummyCommand[]; | 1028 static const wchar_t kDummyCommand[]; |
999 | 1029 |
1000 void SetUp() override { | 1030 void SetUp() override { |
1001 GoogleUpdateSettingsTest::SetUp(); | 1031 GoogleUpdateSettingsTest::SetUp(); |
1002 system_install_ = GetParam(); | 1032 system_install_ = GetParam(); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 1396 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
1367 StatsState::FALSE_SETTING, StatsState::FALSE_SETTING), | 1397 StatsState::FALSE_SETTING, StatsState::FALSE_SETTING), |
1368 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 1398 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
1369 StatsState::FALSE_SETTING, StatsState::TRUE_SETTING), | 1399 StatsState::FALSE_SETTING, StatsState::TRUE_SETTING), |
1370 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 1400 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
1371 StatsState::TRUE_SETTING, StatsState::NO_SETTING), | 1401 StatsState::TRUE_SETTING, StatsState::NO_SETTING), |
1372 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 1402 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
1373 StatsState::TRUE_SETTING, StatsState::FALSE_SETTING), | 1403 StatsState::TRUE_SETTING, StatsState::FALSE_SETTING), |
1374 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 1404 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
1375 StatsState::TRUE_SETTING, StatsState::TRUE_SETTING))); | 1405 StatsState::TRUE_SETTING, StatsState::TRUE_SETTING))); |
OLD | NEW |