OLD | NEW |
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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 188 |
189 const TestData& test_data() const { return test_data_; } | 189 const TestData& test_data() const { return test_data_; } |
190 | 190 |
191 void SetAp(const wchar_t* value) { | 191 void SetAp(const wchar_t* value) { |
192 ASSERT_THAT(base::win::RegKey(root_key_, GetClientStateKeyPath().c_str(), | 192 ASSERT_THAT(base::win::RegKey(root_key_, GetClientStateKeyPath().c_str(), |
193 KEY_WOW64_32KEY | KEY_SET_VALUE) | 193 KEY_WOW64_32KEY | KEY_SET_VALUE) |
194 .WriteValue(L"ap", value), | 194 .WriteValue(L"ap", value), |
195 Eq(ERROR_SUCCESS)); | 195 Eq(ERROR_SUCCESS)); |
196 } | 196 } |
197 | 197 |
| 198 void SetCohortName(const wchar_t* value) { |
| 199 ASSERT_THAT( |
| 200 base::win::RegKey(root_key_, |
| 201 GetClientStateKeyPath().append(L"\\cohort").c_str(), |
| 202 KEY_WOW64_32KEY | KEY_SET_VALUE) |
| 203 .WriteValue(L"name", value), |
| 204 Eq(ERROR_SUCCESS)); |
| 205 } |
| 206 |
198 private: | 207 private: |
199 // Returns the registry path for the product's ClientState key. | 208 // Returns the registry path for the product's ClientState key. |
200 std::wstring GetClientStateKeyPath() { | 209 std::wstring GetClientStateKeyPath() { |
201 std::wstring result(L"Software\\"); | 210 std::wstring result(L"Software\\"); |
202 if (kUseGoogleUpdateIntegration) { | 211 if (kUseGoogleUpdateIntegration) { |
203 result.append(L"Google\\Update\\ClientState\\"); | 212 result.append(L"Google\\Update\\ClientState\\"); |
204 result.append(kInstallModes[test_data().index].app_guid); | 213 result.append(kInstallModes[test_data().index].app_guid); |
205 } else { | 214 } else { |
206 result.append(kProductPathName); | 215 result.append(kProductPathName); |
207 } | 216 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 if (kInstallModes[test_data().index].channel_strategy == | 292 if (kInstallModes[test_data().index].channel_strategy == |
284 ChannelStrategy::ADDITIONAL_PARAMETERS) { | 293 ChannelStrategy::ADDITIONAL_PARAMETERS) { |
285 EXPECT_THAT(details->channel(), StrEq(ap_and_channel.second)); | 294 EXPECT_THAT(details->channel(), StrEq(ap_and_channel.second)); |
286 } else { | 295 } else { |
287 // "ap" is ignored for this mode. | 296 // "ap" is ignored for this mode. |
288 EXPECT_THAT(details->channel(), StrEq(test_data().channel)); | 297 EXPECT_THAT(details->channel(), StrEq(test_data().channel)); |
289 } | 298 } |
290 } | 299 } |
291 } | 300 } |
292 | 301 |
| 302 // Test that the "ap" value is cached during initialization. |
| 303 TEST_P(MakeProductDetailsTest, UpdateAp) { |
| 304 // This test is only valid for brands that integrate with Google Update. |
| 305 if (!kUseGoogleUpdateIntegration) |
| 306 return; |
| 307 |
| 308 // With no value in the registry, the ap value should be empty. |
| 309 { |
| 310 std::unique_ptr<PrimaryInstallDetails> details( |
| 311 MakeProductDetails(test_data().path)); |
| 312 EXPECT_THAT(details->update_ap(), StrEq(L"")); |
| 313 } |
| 314 |
| 315 // And with a value, it should have ... the value. |
| 316 static constexpr wchar_t kCrookedMoon[] = L"CrookedMoon"; |
| 317 SetAp(kCrookedMoon); |
| 318 { |
| 319 std::unique_ptr<PrimaryInstallDetails> details( |
| 320 MakeProductDetails(test_data().path)); |
| 321 EXPECT_THAT(details->update_ap(), StrEq(kCrookedMoon)); |
| 322 } |
| 323 } |
| 324 |
| 325 // Test that the cohort name is cached during initialization. |
| 326 TEST_P(MakeProductDetailsTest, UpdateCohortName) { |
| 327 // This test is only valid for brands that integrate with Google Update. |
| 328 if (!kUseGoogleUpdateIntegration) |
| 329 return; |
| 330 |
| 331 // With no value in the registry, the cohort name should be empty. |
| 332 { |
| 333 std::unique_ptr<PrimaryInstallDetails> details( |
| 334 MakeProductDetails(test_data().path)); |
| 335 EXPECT_THAT(details->update_cohort_name(), StrEq(L"")); |
| 336 } |
| 337 |
| 338 // And with a value, it should have ... the value. |
| 339 static constexpr wchar_t kPhony[] = L"Phony"; |
| 340 SetCohortName(kPhony); |
| 341 { |
| 342 std::unique_ptr<PrimaryInstallDetails> details( |
| 343 MakeProductDetails(test_data().path)); |
| 344 EXPECT_THAT(details->update_cohort_name(), StrEq(kPhony)); |
| 345 } |
| 346 } |
| 347 |
293 INSTANTIATE_TEST_CASE_P(All, | 348 INSTANTIATE_TEST_CASE_P(All, |
294 MakeProductDetailsTest, | 349 MakeProductDetailsTest, |
295 testing::ValuesIn(kTestData)); | 350 testing::ValuesIn(kTestData)); |
296 | 351 |
297 } // namespace install_static | 352 } // namespace install_static |
OLD | NEW |