OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/install_static/install_modes.h" |
| 6 |
| 7 #include "testing/gmock/include/gmock/gmock.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 using ::testing::Eq; |
| 11 using ::testing::Gt; |
| 12 using ::testing::Ne; |
| 13 using ::testing::StrEq; |
| 14 using ::testing::StrNe; |
| 15 |
| 16 namespace install_static { |
| 17 |
| 18 TEST(InstallModes, VerifyModes) { |
| 19 ASSERT_THAT(NUM_INSTALL_MODES, Gt(0)); |
| 20 for (int i = 0; i < NUM_INSTALL_MODES; ++i) { |
| 21 const InstallConstants& mode = kInstallModes[i]; |
| 22 |
| 23 // The modes must be listed in order. |
| 24 ASSERT_THAT(mode.index, Eq(i)); |
| 25 |
| 26 // The first mode must have no suffix; the rest must have one. |
| 27 if (i == 0) |
| 28 ASSERT_THAT(mode.install_suffix, StrEq(L"")); |
| 29 else |
| 30 ASSERT_THAT(mode.install_suffix, StrNe(L"")); |
| 31 |
| 32 // The modes must have an appguid if Google Update integration is supported. |
| 33 if (kUseGoogleUpdateIntegration) |
| 34 ASSERT_THAT(mode.app_guid, StrNe(L"")); |
| 35 else |
| 36 ASSERT_THAT(mode.app_guid, StrEq(L"")); |
| 37 |
| 38 // UNSUPPORTED and kUseGoogleUpdateIntegration are mutually exclusive. |
| 39 if (kUseGoogleUpdateIntegration) |
| 40 ASSERT_THAT(mode.channel_strategy, Ne(ChannelStrategy::UNSUPPORTED)); |
| 41 else |
| 42 ASSERT_THAT(mode.channel_strategy, Eq(ChannelStrategy::UNSUPPORTED)); |
| 43 } |
| 44 } |
| 45 |
| 46 TEST(InstallModes, VerifyBrand) { |
| 47 if (kUseGoogleUpdateIntegration) { |
| 48 // Binaries are registered under an app guid with Google Update integration. |
| 49 ASSERT_THAT(kBinariesAppGuid, StrNe(L"")); |
| 50 ASSERT_THAT(kBinariesPathName, StrEq(L"")); |
| 51 } else { |
| 52 // Binaries are registered under a different path name without. |
| 53 ASSERT_THAT(kBinariesAppGuid, StrEq(L"")); |
| 54 ASSERT_THAT(kBinariesPathName, StrNe(L"")); |
| 55 } |
| 56 } |
| 57 |
| 58 TEST(InstallModes, GetClientStateKeyPath) { |
| 59 constexpr wchar_t kAppGuid[] = L"test"; |
| 60 |
| 61 if (kUseGoogleUpdateIntegration) { |
| 62 ASSERT_THAT(GetClientStateKeyPath(kAppGuid), |
| 63 StrEq(L"Software\\Google\\Update\\ClientState\\test")); |
| 64 } else { |
| 65 ASSERT_THAT(GetClientStateKeyPath(kAppGuid), |
| 66 StrEq(std::wstring(L"Software\\").append(kProductPathName))); |
| 67 } |
| 68 } |
| 69 |
| 70 TEST(InstallModes, GetBinariesClientStateKeyPath) { |
| 71 if (kUseGoogleUpdateIntegration) { |
| 72 ASSERT_THAT(GetBinariesClientStateKeyPath(), |
| 73 StrEq(std::wstring(L"Software\\Google\\Update\\ClientState\\") |
| 74 .append(kBinariesAppGuid))); |
| 75 } else { |
| 76 ASSERT_THAT(GetBinariesClientStateKeyPath(), |
| 77 StrEq(std::wstring(L"Software\\").append(kBinariesPathName))); |
| 78 } |
| 79 } |
| 80 |
| 81 TEST(InstallModes, GetClientStateMediumKeyPath) { |
| 82 constexpr wchar_t kAppGuid[] = L"test"; |
| 83 |
| 84 if (kUseGoogleUpdateIntegration) { |
| 85 ASSERT_THAT(GetClientStateMediumKeyPath(kAppGuid), |
| 86 StrEq(L"Software\\Google\\Update\\ClientStateMedium\\test")); |
| 87 } else { |
| 88 ASSERT_THAT(GetClientStateMediumKeyPath(kAppGuid), |
| 89 StrEq(std::wstring(L"Software\\").append(kProductPathName))); |
| 90 } |
| 91 } |
| 92 |
| 93 TEST(InstallModes, GetBinariesClientStateMediumKeyPath) { |
| 94 if (kUseGoogleUpdateIntegration) { |
| 95 ASSERT_THAT( |
| 96 GetBinariesClientStateMediumKeyPath(), |
| 97 StrEq(std::wstring(L"Software\\Google\\Update\\ClientStateMedium\\") |
| 98 .append(kBinariesAppGuid))); |
| 99 } else { |
| 100 ASSERT_THAT(GetBinariesClientStateMediumKeyPath(), |
| 101 StrEq(std::wstring(L"Software\\").append(kBinariesPathName))); |
| 102 } |
| 103 } |
| 104 |
| 105 } // namespace install_static |
OLD | NEW |