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

Side by Side Diff: chrome/install_static/product_install_details_unittest.cc

Issue 2601443002: Remove multi-install from install_static. (Closed)
Patch Set: Created 3 years, 12 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/install_static/product_install_details.h" 5 #include "chrome/install_static/product_install_details.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 nt::SetTestingOverride(nt_root_key_, path); 178 nt::SetTestingOverride(nt_root_key_, path);
179 } 179 }
180 180
181 ~MakeProductDetailsTest() { 181 ~MakeProductDetailsTest() {
182 nt::SetTestingOverride(nt_root_key_, base::string16()); 182 nt::SetTestingOverride(nt_root_key_, base::string16());
183 } 183 }
184 184
185 const TestData& test_data() const { return test_data_; } 185 const TestData& test_data() const { return test_data_; }
186 186
187 void SetUninstallArguments(const wchar_t* value) { 187 void SetUninstallArguments(const wchar_t* value) {
188 ASSERT_THAT( 188 ASSERT_THAT(base::win::RegKey(root_key_, GetClientStateKeyPath().c_str(),
189 base::win::RegKey(root_key_, GetClientStateKeyPath(false).c_str(), 189 KEY_WOW64_32KEY | KEY_SET_VALUE)
190 KEY_WOW64_32KEY | KEY_SET_VALUE) 190 .WriteValue(L"UninstallArguments", value),
191 .WriteValue(L"UninstallArguments", value), 191 Eq(ERROR_SUCCESS));
192 Eq(ERROR_SUCCESS));
193 } 192 }
194 193
195 void SetAp(const wchar_t* value, bool binaries) { 194 void SetAp(const wchar_t* value) {
196 ASSERT_TRUE(!binaries || 195 ASSERT_THAT(base::win::RegKey(root_key_, GetClientStateKeyPath().c_str(),
197 kInstallModes[test_data().index].supports_multi_install); 196 KEY_WOW64_32KEY | KEY_SET_VALUE)
198 ASSERT_THAT( 197 .WriteValue(L"ap", value),
199 base::win::RegKey(root_key_, GetClientStateKeyPath(binaries).c_str(), 198 Eq(ERROR_SUCCESS));
200 KEY_WOW64_32KEY | KEY_SET_VALUE)
201 .WriteValue(L"ap", value),
202 Eq(ERROR_SUCCESS));
203 } 199 }
204 200
205 private: 201 private:
206 // Returns the registry path for the product's ClientState key. 202 // Returns the registry path for the product's ClientState key.
207 std::wstring GetClientStateKeyPath(bool binaries) { 203 std::wstring GetClientStateKeyPath() {
208 EXPECT_TRUE(!binaries ||
209 kInstallModes[test_data().index].supports_multi_install);
210 std::wstring result(L"Software\\"); 204 std::wstring result(L"Software\\");
211 if (kUseGoogleUpdateIntegration) { 205 if (kUseGoogleUpdateIntegration) {
212 result.append(L"Google\\Update\\ClientState\\"); 206 result.append(L"Google\\Update\\ClientState\\");
213 if (binaries) 207 result.append(kInstallModes[test_data().index].app_guid);
214 result.append(kBinariesAppGuid);
215 else
216 result.append(kInstallModes[test_data().index].app_guid);
217 } else if (binaries) {
218 result.append(kBinariesPathName);
219 } else { 208 } else {
220 result.append(kProductPathName); 209 result.append(kProductPathName);
221 } 210 }
222 return result; 211 return result;
223 } 212 }
224 213
225 registry_util::RegistryOverrideManager override_manager_; 214 registry_util::RegistryOverrideManager override_manager_;
226 const TestData& test_data_; 215 const TestData& test_data_;
227 HKEY root_key_; 216 HKEY root_key_;
228 nt::ROOT_KEY nt_root_key_; 217 nt::ROOT_KEY nt_root_key_;
(...skipping 15 matching lines...) Expand all
244 EXPECT_THAT(details->system_level(), Eq(test_data().system_level)); 233 EXPECT_THAT(details->system_level(), Eq(test_data().system_level));
245 } 234 }
246 235
247 // Test that the default channel is sniffed properly based on the path. 236 // Test that the default channel is sniffed properly based on the path.
248 TEST_P(MakeProductDetailsTest, DefaultChannel) { 237 TEST_P(MakeProductDetailsTest, DefaultChannel) {
249 std::unique_ptr<PrimaryInstallDetails> details( 238 std::unique_ptr<PrimaryInstallDetails> details(
250 MakeProductDetails(test_data().path)); 239 MakeProductDetails(test_data().path));
251 EXPECT_THAT(details->channel(), StrEq(test_data().channel)); 240 EXPECT_THAT(details->channel(), StrEq(test_data().channel));
252 } 241 }
253 242
254 // Test that multi-install is properly parsed out of the registry.
255 TEST_P(MakeProductDetailsTest, MultiInstall) {
256 {
257 std::unique_ptr<PrimaryInstallDetails> details(
258 MakeProductDetails(test_data().path));
259 EXPECT_FALSE(details->multi_install());
260 }
261
262 {
263 SetUninstallArguments(L"--uninstall");
264 std::unique_ptr<PrimaryInstallDetails> details(
265 MakeProductDetails(test_data().path));
266 EXPECT_FALSE(details->multi_install());
267 }
268
269 if (!kInstallModes[test_data().index].supports_multi_install)
270 return;
271
272 {
273 SetUninstallArguments(L"--uninstall --multi-install --chrome");
274 std::unique_ptr<PrimaryInstallDetails> details(
275 MakeProductDetails(test_data().path));
276 EXPECT_TRUE(details->multi_install());
277 }
278 }
279
280 // Test that the channel name is properly parsed out of additional parameters. 243 // Test that the channel name is properly parsed out of additional parameters.
281 TEST_P(MakeProductDetailsTest, AdditionalParametersChannels) { 244 TEST_P(MakeProductDetailsTest, AdditionalParametersChannels) {
282 const std::pair<const wchar_t*, const wchar_t*> kApChannels[] = { 245 const std::pair<const wchar_t*, const wchar_t*> kApChannels[] = {
283 // stable 246 // stable
284 {L"", L""}, 247 {L"", L""},
285 {L"-full", L""}, 248 {L"-full", L""},
286 {L"x64-stable", L""}, 249 {L"x64-stable", L""},
287 {L"x64-stable-full", L""}, 250 {L"x64-stable-full", L""},
288 {L"baz-x64-stable", L""}, 251 {L"baz-x64-stable", L""},
289 {L"foo-1.1-beta", L""}, 252 {L"foo-1.1-beta", L""},
290 {L"2.0-beta", L""}, 253 {L"2.0-beta", L""},
291 {L"bar-2.0-dev", L""}, 254 {L"bar-2.0-dev", L""},
292 {L"1.0-dev", L""}, 255 {L"1.0-dev", L""},
293 {L"fuzzy", L""}, 256 {L"fuzzy", L""},
294 {L"foo", L""}, 257 {L"foo", L""},
295 {L"-multi-chrome", L""}, 258 {L"-multi-chrome", L""},
huangs 2016/12/27 20:04:23 Address these? So maybe remove. Alternatively, a
grt (UTC plus 2) 2017/01/02 12:58:45 There will still be clients with "-multi" in their
296 {L"x64-stable-multi-chrome", L""}, 259 {L"x64-stable-multi-chrome", L""},
297 {L"-stage:ensemble_patching-multi-chrome-full", L""}, 260 {L"-stage:ensemble_patching-multi-chrome-full", L""},
298 {L"-multi-chrome-full", L""}, 261 {L"-multi-chrome-full", L""},
299 // beta 262 // beta
300 {L"1.1-beta", L"beta"}, 263 {L"1.1-beta", L"beta"},
301 {L"1.1-beta-full", L"beta"}, 264 {L"1.1-beta-full", L"beta"},
302 {L"x64-beta", L"beta"}, 265 {L"x64-beta", L"beta"},
303 {L"x64-beta-full", L"beta"}, 266 {L"x64-beta-full", L"beta"},
304 {L"1.1-bar", L"beta"}, 267 {L"1.1-bar", L"beta"},
305 {L"1n1-foobar", L"beta"}, 268 {L"1n1-foobar", L"beta"},
306 {L"x64-Beta", L"beta"}, 269 {L"x64-Beta", L"beta"},
307 {L"bar-x64-beta", L"beta"}, 270 {L"bar-x64-beta", L"beta"},
308 // dev 271 // dev
309 {L"2.0-dev", L"dev"}, 272 {L"2.0-dev", L"dev"},
310 {L"2.0-dev-full", L"dev"}, 273 {L"2.0-dev-full", L"dev"},
311 {L"x64-dev", L"dev"}, 274 {L"x64-dev", L"dev"},
312 {L"x64-dev-full", L"dev"}, 275 {L"x64-dev-full", L"dev"},
313 {L"2.0-DEV", L"dev"}, 276 {L"2.0-DEV", L"dev"},
314 {L"2.0-dev-eloper", L"dev"}, 277 {L"2.0-dev-eloper", L"dev"},
315 {L"2.0-doom", L"dev"}, 278 {L"2.0-doom", L"dev"},
316 {L"250-doom", L"dev"}, 279 {L"250-doom", L"dev"},
317 }; 280 };
318 281
319 for (const auto& ap_and_channel : kApChannels) { 282 for (const auto& ap_and_channel : kApChannels) {
320 SetAp(ap_and_channel.first, false); 283 SetAp(ap_and_channel.first);
321 std::unique_ptr<PrimaryInstallDetails> details( 284 std::unique_ptr<PrimaryInstallDetails> details(
322 MakeProductDetails(test_data().path)); 285 MakeProductDetails(test_data().path));
323 if (kInstallModes[test_data().index].channel_strategy == 286 if (kInstallModes[test_data().index].channel_strategy ==
324 ChannelStrategy::ADDITIONAL_PARAMETERS) {
325 EXPECT_THAT(details->channel(), StrEq(ap_and_channel.second));
326 } else {
327 // "ap" is ignored for this mode.
328 EXPECT_THAT(details->channel(), StrEq(test_data().channel));
329 }
330 }
331
332 if (!kInstallModes[test_data().index].supports_multi_install)
333 return;
334
335 // For multi-install modes, "ap" is pulled from the binaries' key.
336 for (const auto& ap_and_channel : kApChannels) {
337 SetAp(ap_and_channel.first, true);
338 SetUninstallArguments(L"--uninstall --multi-install --chrome");
339 std::unique_ptr<PrimaryInstallDetails> details(
340 MakeProductDetails(test_data().path));
341 if (kInstallModes[test_data().index].channel_strategy ==
342 ChannelStrategy::ADDITIONAL_PARAMETERS) { 287 ChannelStrategy::ADDITIONAL_PARAMETERS) {
343 EXPECT_THAT(details->channel(), StrEq(ap_and_channel.second)); 288 EXPECT_THAT(details->channel(), StrEq(ap_and_channel.second));
344 } else { 289 } else {
345 // "ap" is ignored for this mode. 290 // "ap" is ignored for this mode.
346 EXPECT_THAT(details->channel(), StrEq(test_data().channel)); 291 EXPECT_THAT(details->channel(), StrEq(test_data().channel));
347 } 292 }
348 } 293 }
349 } 294 }
350 295
351 INSTANTIATE_TEST_CASE_P(All, 296 INSTANTIATE_TEST_CASE_P(All,
352 MakeProductDetailsTest, 297 MakeProductDetailsTest,
353 testing::ValuesIn(kTestData)); 298 testing::ValuesIn(kTestData));
354 299
355 } // namespace install_static 300 } // namespace install_static
OLDNEW
« chrome/install_static/install_util.cc ('K') | « chrome/install_static/product_install_details.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698