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 <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/test/test_reg_util_win.h" | 9 #include "base/test/test_reg_util_win.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 // Test the writing and deleting functionality of the experiments label | 116 // Test the writing and deleting functionality of the experiments label |
117 // helper. | 117 // helper. |
118 void TestExperimentsLabelHelper(SystemUserInstall install) { | 118 void TestExperimentsLabelHelper(SystemUserInstall install) { |
119 BrowserDistribution* chrome = | 119 BrowserDistribution* chrome = |
120 BrowserDistribution::GetSpecificDistribution( | 120 BrowserDistribution::GetSpecificDistribution( |
121 BrowserDistribution::CHROME_BROWSER); | 121 BrowserDistribution::CHROME_BROWSER); |
| 122 std::wstring value; |
122 #if defined(GOOGLE_CHROME_BUILD) | 123 #if defined(GOOGLE_CHROME_BUILD) |
123 EXPECT_TRUE(chrome->ShouldSetExperimentLabels()); | 124 EXPECT_TRUE(chrome->ShouldSetExperimentLabels()); |
124 | 125 |
125 EXPECT_TRUE(GoogleUpdateSettings::SetExperimentLabels( | 126 EXPECT_TRUE(GoogleUpdateSettings::SetExperimentLabels( |
126 install == SYSTEM_INSTALL, kTestExperimentLabel)); | 127 install == SYSTEM_INSTALL, kTestExperimentLabel)); |
127 | 128 |
128 // Validate that something is written. Only worry about the label itself. | 129 // Validate that something is written. Only worry about the label itself. |
129 RegKey key; | 130 RegKey key; |
130 std::wstring value; | |
131 HKEY root = install == SYSTEM_INSTALL ? | 131 HKEY root = install == SYSTEM_INSTALL ? |
132 HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 132 HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
133 string16 state_key = install == SYSTEM_INSTALL ? | 133 string16 state_key = install == SYSTEM_INSTALL ? |
134 chrome->GetStateMediumKey() : chrome->GetStateKey(); | 134 chrome->GetStateMediumKey() : chrome->GetStateKey(); |
135 | 135 |
136 EXPECT_EQ(ERROR_SUCCESS, | 136 EXPECT_EQ(ERROR_SUCCESS, |
137 key.Open(root, state_key.c_str(), KEY_QUERY_VALUE)); | 137 key.Open(root, state_key.c_str(), KEY_QUERY_VALUE)); |
138 EXPECT_EQ(ERROR_SUCCESS, | 138 EXPECT_EQ(ERROR_SUCCESS, |
139 key.ReadValue(google_update::kExperimentLabels, &value)); | 139 key.ReadValue(google_update::kExperimentLabels, &value)); |
140 EXPECT_EQ(kTestExperimentLabel, value); | 140 EXPECT_EQ(kTestExperimentLabel, value); |
| 141 EXPECT_TRUE(GoogleUpdateSettings::ReadExperimentLabels( |
| 142 install == SYSTEM_INSTALL, &value)); |
| 143 EXPECT_EQ(kTestExperimentLabel, value); |
141 key.Close(); | 144 key.Close(); |
142 | 145 |
143 // Now that the label is set, test the delete functionality. An empty label | 146 // Now that the label is set, test the delete functionality. An empty label |
144 // should result in deleting the value. | 147 // should result in deleting the value. |
145 EXPECT_TRUE(GoogleUpdateSettings::SetExperimentLabels( | 148 EXPECT_TRUE(GoogleUpdateSettings::SetExperimentLabels( |
146 install == SYSTEM_INSTALL, string16())); | 149 install == SYSTEM_INSTALL, string16())); |
147 EXPECT_EQ(ERROR_SUCCESS, | 150 EXPECT_EQ(ERROR_SUCCESS, |
148 key.Open(root, state_key.c_str(), KEY_QUERY_VALUE)); | 151 key.Open(root, state_key.c_str(), KEY_QUERY_VALUE)); |
149 EXPECT_EQ(ERROR_FILE_NOT_FOUND, | 152 EXPECT_EQ(ERROR_FILE_NOT_FOUND, |
150 key.ReadValue(google_update::kExperimentLabels, &value)); | 153 key.ReadValue(google_update::kExperimentLabels, &value)); |
| 154 EXPECT_FALSE(GoogleUpdateSettings::ReadExperimentLabels( |
| 155 install == SYSTEM_INSTALL, &value)); |
151 key.Close(); | 156 key.Close(); |
152 #else | 157 #else |
153 EXPECT_FALSE(chrome->ShouldSetExperimentLabels()); | 158 EXPECT_FALSE(chrome->ShouldSetExperimentLabels()); |
| 159 EXPECT_FALSE(GoogleUpdateSettings::ReadExperimentLabels( |
| 160 install == SYSTEM_INSTALL, &value)); |
154 #endif // GOOGLE_CHROME_BUILD | 161 #endif // GOOGLE_CHROME_BUILD |
155 } | 162 } |
156 | 163 |
157 // Creates "ap" key with the value given as parameter. Also adds work | 164 // Creates "ap" key with the value given as parameter. Also adds work |
158 // items to work_item_list given so that they can be rolled back later. | 165 // items to work_item_list given so that they can be rolled back later. |
159 bool CreateApKey(WorkItemList* work_item_list, const std::wstring& value) { | 166 bool CreateApKey(WorkItemList* work_item_list, const std::wstring& value) { |
160 HKEY reg_root = HKEY_CURRENT_USER; | 167 HKEY reg_root = HKEY_CURRENT_USER; |
161 std::wstring reg_key = GetApKeyPath(); | 168 std::wstring reg_key = GetApKeyPath(); |
162 work_item_list->AddCreateRegKeyWorkItem(reg_root, reg_key); | 169 work_item_list->AddCreateRegKeyWorkItem(reg_root, reg_key); |
163 work_item_list->AddSetRegValueWorkItem(reg_root, reg_key, | 170 work_item_list->AddSetRegValueWorkItem(reg_root, reg_key, |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 988 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
982 StatsState::FALSE_SETTING, StatsState::FALSE_SETTING), | 989 StatsState::FALSE_SETTING, StatsState::FALSE_SETTING), |
983 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 990 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
984 StatsState::FALSE_SETTING, StatsState::TRUE_SETTING), | 991 StatsState::FALSE_SETTING, StatsState::TRUE_SETTING), |
985 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 992 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
986 StatsState::TRUE_SETTING, StatsState::NO_SETTING), | 993 StatsState::TRUE_SETTING, StatsState::NO_SETTING), |
987 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 994 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
988 StatsState::TRUE_SETTING, StatsState::FALSE_SETTING), | 995 StatsState::TRUE_SETTING, StatsState::FALSE_SETTING), |
989 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, | 996 StatsState(StatsState::kSystemLevel, StatsState::MULTI_INSTALL, |
990 StatsState::TRUE_SETTING, StatsState::TRUE_SETTING))); | 997 StatsState::TRUE_SETTING, StatsState::TRUE_SETTING))); |
OLD | NEW |