Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: chrome/installer/util/google_update_settings_unittest.cc

Issue 1606943007: Implement Windows GPO support for "dlpref" in component updater. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: whitespace comments only Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(
999 GoogleUpdateSettings::kDownloadPreferencePolicyValue);
1000 }
1001 policy_key.Close();
1002
1003 // When no policy is present expect to return an empty string.
1004 EXPECT_TRUE(GoogleUpdateSettings::GetDownloadPreference().empty());
1005
1006 // Expect "cacheable" when the correct policy is present.
1007 EXPECT_EQ(ERROR_SUCCESS, policy_key.Create(HKEY_LOCAL_MACHINE,
1008 GoogleUpdateSettings::kPoliciesKey,
1009 KEY_SET_VALUE));
1010 EXPECT_EQ(
1011 ERROR_SUCCESS,
1012 policy_key.WriteValue(
1013 GoogleUpdateSettings::kDownloadPreferencePolicyValue, L"cacheable"));
1014 EXPECT_STREQ(L"cacheable",
1015 GoogleUpdateSettings::GetDownloadPreference().c_str());
1016
1017 EXPECT_EQ(ERROR_SUCCESS,
1018 policy_key.WriteValue(
1019 GoogleUpdateSettings::kDownloadPreferencePolicyValue,
1020 base::string16(32, L'a').c_str()));
1021 EXPECT_STREQ(base::string16(32, L'a').c_str(),
1022 GoogleUpdateSettings::GetDownloadPreference().c_str());
1023
1024 // Expect an empty string when an unsupported policy is set.
1025 // It contains spaces.
1026 EXPECT_EQ(ERROR_SUCCESS,
1027 policy_key.WriteValue(
1028 GoogleUpdateSettings::kDownloadPreferencePolicyValue, L"a b"));
1029 EXPECT_TRUE(GoogleUpdateSettings::GetDownloadPreference().empty());
1030
1031 // It contains non alpha-numeric characters.
1032 EXPECT_EQ(ERROR_SUCCESS,
1033 policy_key.WriteValue(
1034 GoogleUpdateSettings::kDownloadPreferencePolicyValue, L"<a>"));
1035 EXPECT_TRUE(GoogleUpdateSettings::GetDownloadPreference().empty());
1036
1037 // It is too long.
1038 EXPECT_EQ(ERROR_SUCCESS,
1039 policy_key.WriteValue(
1040 GoogleUpdateSettings::kDownloadPreferencePolicyValue,
1041 base::string16(33, L'a').c_str()));
1042 EXPECT_TRUE(GoogleUpdateSettings::GetDownloadPreference().empty());
1043 }
1044
993 // Test GoogleUpdateSettings::GetUninstallCommandLine at system- or user-level, 1045 // Test GoogleUpdateSettings::GetUninstallCommandLine at system- or user-level,
994 // according to the param. 1046 // according to the param.
995 class GetUninstallCommandLine : public GoogleUpdateSettingsTest, 1047 class GetUninstallCommandLine : public GoogleUpdateSettingsTest,
996 public testing::WithParamInterface<bool> { 1048 public testing::WithParamInterface<bool> {
997 protected: 1049 protected:
998 static const wchar_t kDummyCommand[]; 1050 static const wchar_t kDummyCommand[];
999 1051
1000 void SetUp() override { 1052 void SetUp() override {
1001 GoogleUpdateSettingsTest::SetUp(); 1053 GoogleUpdateSettingsTest::SetUp();
1002 system_install_ = GetParam(); 1054 system_install_ = GetParam();
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, 1418 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL,
1367 StatsState::FALSE_SETTING, StatsState::FALSE_SETTING), 1419 StatsState::FALSE_SETTING, StatsState::FALSE_SETTING),
1368 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, 1420 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL,
1369 StatsState::FALSE_SETTING, StatsState::TRUE_SETTING), 1421 StatsState::FALSE_SETTING, StatsState::TRUE_SETTING),
1370 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, 1422 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL,
1371 StatsState::TRUE_SETTING, StatsState::NO_SETTING), 1423 StatsState::TRUE_SETTING, StatsState::NO_SETTING),
1372 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, 1424 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL,
1373 StatsState::TRUE_SETTING, StatsState::FALSE_SETTING), 1425 StatsState::TRUE_SETTING, StatsState::FALSE_SETTING),
1374 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, 1426 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL,
1375 StatsState::TRUE_SETTING, StatsState::TRUE_SETTING))); 1427 StatsState::TRUE_SETTING, StatsState::TRUE_SETTING)));
OLDNEW
« no previous file with comments | « chrome/installer/util/google_update_settings.cc ('k') | components/component_updater/configurator_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698