| 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 de3f2e352d5c03797b6da0a4f1d6c07e9091e6fe..4e1fba28e01da40d4eee01de780b0ea92938fc30 100644
|
| --- a/chrome/installer/util/google_update_settings_unittest.cc
|
| +++ b/chrome/installer/util/google_update_settings_unittest.cc
|
| @@ -36,11 +36,12 @@ const GoogleUpdateSettings::UpdatePolicy kDefaultUpdatePolicy =
|
| #endif
|
|
|
| const wchar_t kTestProductGuid[] = L"{89F1B351-B15D-48D4-8F10-1298721CF13D}";
|
| +const wchar_t kTestExperimentLabel[] = L"test_label_value";
|
|
|
| // This test fixture redirects the HKLM and HKCU registry hives for
|
| // the duration of the test to make it independent of the machine
|
| // and user settings.
|
| -class GoogleUpdateSettingsTest: public testing::Test {
|
| +class GoogleUpdateSettingsTest : public testing::Test {
|
| protected:
|
| virtual void SetUp() OVERRIDE {
|
| registry_overrides_.OverrideRegistry(HKEY_LOCAL_MACHINE, L"HKLM_pit");
|
| @@ -112,6 +113,47 @@ class GoogleUpdateSettingsTest: public testing::Test {
|
| }
|
| }
|
|
|
| + // Test the writing and deleting functionality of the experiments label
|
| + // helper.
|
| + void TestExperimentsLabelHelper(SystemUserInstall install) {
|
| + BrowserDistribution* chrome =
|
| + BrowserDistribution::GetSpecificDistribution(
|
| + BrowserDistribution::CHROME_BROWSER);
|
| +#if defined(GOOGLE_CHROME_BUILD)
|
| + EXPECT_TRUE(chrome->ShouldSetExperimentLabels());
|
| +
|
| + EXPECT_TRUE(GoogleUpdateSettings::SetExperimentLabels(
|
| + install == SYSTEM_INSTALL, kTestExperimentLabel));
|
| +
|
| + // Validate that something is written. Only worry about the label itself.
|
| + RegKey key;
|
| + std::wstring value;
|
| + HKEY root = install == SYSTEM_INSTALL ?
|
| + HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
|
| + string16 state_key = install == SYSTEM_INSTALL ?
|
| + chrome->GetStateMediumKey() : chrome->GetStateKey();
|
| +
|
| + EXPECT_EQ(ERROR_SUCCESS,
|
| + key.Open(root, state_key.c_str(), KEY_QUERY_VALUE));
|
| + EXPECT_EQ(ERROR_SUCCESS,
|
| + key.ReadValue(google_update::kExperimentLabels, &value));
|
| + EXPECT_EQ(kTestExperimentLabel, value);
|
| + key.Close();
|
| +
|
| + // Now that the label is set, test the delete functionality. An empty label
|
| + // should result in deleting the value.
|
| + EXPECT_TRUE(GoogleUpdateSettings::SetExperimentLabels(
|
| + install == SYSTEM_INSTALL, string16()));
|
| + EXPECT_EQ(ERROR_SUCCESS,
|
| + key.Open(root, state_key.c_str(), KEY_QUERY_VALUE));
|
| + EXPECT_EQ(ERROR_FILE_NOT_FOUND,
|
| + key.ReadValue(google_update::kExperimentLabels, &value));
|
| + key.Close();
|
| +#else
|
| + EXPECT_FALSE(chrome->ShouldSetExperimentLabels());
|
| +#endif // GOOGLE_CHROME_BUILD
|
| + }
|
| +
|
| // Creates "ap" key with the value given as parameter. Also adds work
|
| // items to work_item_list given so that they can be rolled back later.
|
| bool CreateApKey(WorkItemList* work_item_list, const std::wstring& value) {
|
| @@ -555,6 +597,14 @@ TEST_F(GoogleUpdateSettingsTest, GetAppUpdatePolicyAppOverride) {
|
| EXPECT_FALSE(is_overridden);
|
| }
|
|
|
| +TEST_F(GoogleUpdateSettingsTest, ExperimentsLabelHelperSystem) {
|
| + TestExperimentsLabelHelper(SYSTEM_INSTALL);
|
| +}
|
| +
|
| +TEST_F(GoogleUpdateSettingsTest, ExperimentsLabelHelperUser) {
|
| + TestExperimentsLabelHelper(USER_INSTALL);
|
| +}
|
| +
|
| #endif // defined(GOOGLE_CHROME_BUILD)
|
|
|
| // Test GoogleUpdateSettings::GetUninstallCommandLine at system- or user-level,
|
|
|