Index: chrome/install_static/install_modes_unittest.cc |
diff --git a/chrome/install_static/install_modes_unittest.cc b/chrome/install_static/install_modes_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ec297f1a7436ddcee2f0cc10d95d276768fbc819 |
--- /dev/null |
+++ b/chrome/install_static/install_modes_unittest.cc |
@@ -0,0 +1,105 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/install_static/install_modes.h" |
+ |
+#include "testing/gmock/include/gmock/gmock.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+using ::testing::Eq; |
+using ::testing::Gt; |
+using ::testing::Ne; |
+using ::testing::StrEq; |
+using ::testing::StrNe; |
+ |
+namespace install_static { |
+ |
+TEST(InstallModes, VerifyModes) { |
+ ASSERT_THAT(NUM_INSTALL_MODES, Gt(0)); |
+ for (int i = 0; i < NUM_INSTALL_MODES; ++i) { |
+ const InstallConstants& mode = kInstallModes[i]; |
+ |
+ // The modes must be listed in order. |
+ ASSERT_THAT(mode.index, Eq(i)); |
+ |
+ // The first mode must have no suffix; the rest must have one. |
+ if (i == 0) |
+ ASSERT_THAT(mode.install_suffix, StrEq(L"")); |
+ else |
+ ASSERT_THAT(mode.install_suffix, StrNe(L"")); |
+ |
+ // The modes must have an appguid if Google Update integration is supported. |
+ if (kUseGoogleUpdateIntegration) |
+ ASSERT_THAT(mode.app_guid, StrNe(L"")); |
+ else |
+ ASSERT_THAT(mode.app_guid, StrEq(L"")); |
+ |
+ // UNSUPPORTED and kUseGoogleUpdateIntegration are mutually exclusive. |
+ if (kUseGoogleUpdateIntegration) |
+ ASSERT_THAT(mode.channel_strategy, Ne(ChannelStrategy::UNSUPPORTED)); |
+ else |
+ ASSERT_THAT(mode.channel_strategy, Eq(ChannelStrategy::UNSUPPORTED)); |
+ } |
+} |
+ |
+TEST(InstallModes, VerifyBrand) { |
+ if (kUseGoogleUpdateIntegration) { |
+ // Binaries are registered under an app guid with Google Update integration. |
+ ASSERT_THAT(kBinariesAppGuid, StrNe(L"")); |
+ ASSERT_THAT(kBinariesPathName, StrEq(L"")); |
+ } else { |
+ // Binaries are registered under a different path name without. |
+ ASSERT_THAT(kBinariesAppGuid, StrEq(L"")); |
+ ASSERT_THAT(kBinariesPathName, StrNe(L"")); |
+ } |
+} |
+ |
+TEST(InstallModes, GetClientStateKeyPath) { |
+ constexpr wchar_t kAppGuid[] = L"test"; |
+ |
+ if (kUseGoogleUpdateIntegration) { |
+ ASSERT_THAT(GetClientStateKeyPath(kAppGuid), |
+ StrEq(L"Software\\Google\\Update\\ClientState\\test")); |
+ } else { |
+ ASSERT_THAT(GetClientStateKeyPath(kAppGuid), |
+ StrEq(std::wstring(L"Software\\").append(kProductPathName))); |
+ } |
+} |
+ |
+TEST(InstallModes, GetBinariesClientStateKeyPath) { |
+ if (kUseGoogleUpdateIntegration) { |
+ ASSERT_THAT(GetBinariesClientStateKeyPath(), |
+ StrEq(std::wstring(L"Software\\Google\\Update\\ClientState\\") |
+ .append(kBinariesAppGuid))); |
+ } else { |
+ ASSERT_THAT(GetBinariesClientStateKeyPath(), |
+ StrEq(std::wstring(L"Software\\").append(kBinariesPathName))); |
+ } |
+} |
+ |
+TEST(InstallModes, GetClientStateMediumKeyPath) { |
+ constexpr wchar_t kAppGuid[] = L"test"; |
+ |
+ if (kUseGoogleUpdateIntegration) { |
+ ASSERT_THAT(GetClientStateMediumKeyPath(kAppGuid), |
+ StrEq(L"Software\\Google\\Update\\ClientStateMedium\\test")); |
+ } else { |
+ ASSERT_THAT(GetClientStateMediumKeyPath(kAppGuid), |
+ StrEq(std::wstring(L"Software\\").append(kProductPathName))); |
+ } |
+} |
+ |
+TEST(InstallModes, GetBinariesClientStateMediumKeyPath) { |
+ if (kUseGoogleUpdateIntegration) { |
+ ASSERT_THAT( |
+ GetBinariesClientStateMediumKeyPath(), |
+ StrEq(std::wstring(L"Software\\Google\\Update\\ClientStateMedium\\") |
+ .append(kBinariesAppGuid))); |
+ } else { |
+ ASSERT_THAT(GetBinariesClientStateMediumKeyPath(), |
+ StrEq(std::wstring(L"Software\\").append(kBinariesPathName))); |
+ } |
+} |
+ |
+} // namespace install_static |