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/install_util.h" | 5 #include "chrome/install_static/install_util.h" |
6 | 6 |
7 #include <tuple> | 7 #include <tuple> |
8 | 8 |
| 9 #include "base/macros.h" |
9 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
10 #include "base/test/test_reg_util_win.h" | 11 #include "base/test/test_reg_util_win.h" |
11 #include "chrome/install_static/install_details.h" | 12 #include "chrome/install_static/install_details.h" |
12 #include "chrome/install_static/install_modes.h" | 13 #include "chrome/install_static/install_modes.h" |
13 #include "chrome/install_static/test/scoped_install_details.h" | 14 #include "chrome/install_static/test/scoped_install_details.h" |
14 #include "chrome_elf/nt_registry/nt_registry.h" | 15 #include "chrome_elf/nt_registry/nt_registry.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 using ::testing::ElementsAre; | 19 using ::testing::ElementsAre; |
| 20 using ::testing::StrCaseEq; |
19 | 21 |
20 namespace install_static { | 22 namespace install_static { |
21 | 23 |
22 // Tests the MatchPattern function in the install_static library. | 24 // Tests the MatchPattern function in the install_static library. |
23 TEST(InstallStaticTest, MatchPattern) { | 25 TEST(InstallStaticTest, MatchPattern) { |
24 EXPECT_TRUE(MatchPattern(L"", L"")); | 26 EXPECT_TRUE(MatchPattern(L"", L"")); |
25 EXPECT_TRUE(MatchPattern(L"", L"*")); | 27 EXPECT_TRUE(MatchPattern(L"", L"*")); |
26 EXPECT_FALSE(MatchPattern(L"", L"*a")); | 28 EXPECT_FALSE(MatchPattern(L"", L"*a")); |
27 EXPECT_FALSE(MatchPattern(L"", L"abc")); | 29 EXPECT_FALSE(MatchPattern(L"", L"abc")); |
28 EXPECT_TRUE(MatchPattern(L"Hello1234", L"He??o*1*")); | 30 EXPECT_TRUE(MatchPattern(L"Hello1234", L"He??o*1*")); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 const bool system_level_; | 336 const bool system_level_; |
335 const ScopedInstallDetails scoped_install_details_; | 337 const ScopedInstallDetails scoped_install_details_; |
336 const InstallConstants* mode_; | 338 const InstallConstants* mode_; |
337 const HKEY root_key_; | 339 const HKEY root_key_; |
338 const nt::ROOT_KEY nt_root_key_; | 340 const nt::ROOT_KEY nt_root_key_; |
339 registry_util::RegistryOverrideManager override_manager_; | 341 registry_util::RegistryOverrideManager override_manager_; |
340 | 342 |
341 DISALLOW_COPY_AND_ASSIGN(InstallStaticUtilTest); | 343 DISALLOW_COPY_AND_ASSIGN(InstallStaticUtilTest); |
342 }; | 344 }; |
343 | 345 |
| 346 TEST_P(InstallStaticUtilTest, GetAppGuid) { |
| 347 // For brands that do not integrate with Omaha/Google Update, the app guid is |
| 348 // an empty string. |
| 349 if (!kUseGoogleUpdateIntegration) { |
| 350 EXPECT_STREQ(L"", GetAppGuid()); |
| 351 return; |
| 352 } |
| 353 |
| 354 #if defined(GOOGLE_CHROME_BUILD) |
| 355 // The app guids for the brand's install modes; parallel to kInstalLModes. |
| 356 static constexpr const wchar_t* kAppGuids[] = { |
| 357 L"{8A69D345-D564-463c-AFF1-A69D9E530F96}", // Google Chrome. |
| 358 L"{4EA16AC7-FD5A-47C3-875B-DBF4A2008C20}", // Google Chrome SxS (Canary). |
| 359 }; |
| 360 static_assert(arraysize(kAppGuids) == NUM_INSTALL_MODES, |
| 361 "kAppGuids out of date."); |
| 362 EXPECT_THAT(GetAppGuid(), StrCaseEq(kAppGuids[std::get<0>(GetParam())])); |
| 363 #else |
| 364 FAIL() << "Not implemented."; |
| 365 #endif |
| 366 } |
| 367 |
344 TEST_P(InstallStaticUtilTest, UsageStatsAbsent) { | 368 TEST_P(InstallStaticUtilTest, UsageStatsAbsent) { |
345 EXPECT_FALSE(GetCollectStatsConsent()); | 369 EXPECT_FALSE(GetCollectStatsConsent()); |
346 } | 370 } |
347 | 371 |
348 TEST_P(InstallStaticUtilTest, UsageStatsZero) { | 372 TEST_P(InstallStaticUtilTest, UsageStatsZero) { |
349 SetUsageStat(0, false); | 373 SetUsageStat(0, false); |
350 EXPECT_FALSE(GetCollectStatsConsent()); | 374 EXPECT_FALSE(GetCollectStatsConsent()); |
351 } | 375 } |
352 | 376 |
353 TEST_P(InstallStaticUtilTest, UsageStatsZeroMedium) { | 377 TEST_P(InstallStaticUtilTest, UsageStatsZeroMedium) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 testing::Values("user"))); | 441 testing::Values("user"))); |
418 #else // GOOGLE_CHROME_BUILD | 442 #else // GOOGLE_CHROME_BUILD |
419 // Chromium supports user and system levels. | 443 // Chromium supports user and system levels. |
420 INSTANTIATE_TEST_CASE_P(Chromium, | 444 INSTANTIATE_TEST_CASE_P(Chromium, |
421 InstallStaticUtilTest, | 445 InstallStaticUtilTest, |
422 testing::Combine(testing::Values(CHROMIUM_INDEX), | 446 testing::Combine(testing::Values(CHROMIUM_INDEX), |
423 testing::Values("user", "system"))); | 447 testing::Values("user", "system"))); |
424 #endif // !GOOGLE_CHROME_BUILD | 448 #endif // !GOOGLE_CHROME_BUILD |
425 | 449 |
426 } // namespace install_static | 450 } // namespace install_static |
OLD | NEW |