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