Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: chrome/install_static/install_modes_unittest.cc

Issue 2764963002: Move ProgID methods from BrowserDistribution into install_static. (Closed)
Patch Set: huangs comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/install_static/install_constants.h ('k') | chrome/install_static/install_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <windows.h>
8
9 #include <ctype.h>
10
7 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
8 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
9 13
10 using ::testing::Eq; 14 using ::testing::Eq;
11 using ::testing::Gt; 15 using ::testing::Gt;
16 using ::testing::Le;
12 using ::testing::Ne; 17 using ::testing::Ne;
18 using ::testing::Not;
19 using ::testing::ResultOf;
13 using ::testing::StrEq; 20 using ::testing::StrEq;
14 using ::testing::StrNe; 21 using ::testing::StrNe;
15 22
16 namespace install_static { 23 namespace install_static {
17 24
25 namespace {
26
27 // A matcher that returns true if |arg| contains a character that is neither
28 // alpha-numeric nor a period.
29 MATCHER(ContainsIllegalProgIdChar, "") {
30 const wchar_t* scan = arg;
31 wint_t c;
32 while ((c = *scan++) != 0) {
33 if (!iswalnum(c) && c != L'.')
34 return true;
35 }
36 return false;
37 }
38
39 } // namespace
40
18 TEST(InstallModes, VerifyModes) { 41 TEST(InstallModes, VerifyModes) {
19 ASSERT_THAT(NUM_INSTALL_MODES, Gt(0)); 42 ASSERT_THAT(NUM_INSTALL_MODES, Gt(0));
20 for (int i = 0; i < NUM_INSTALL_MODES; ++i) { 43 for (int i = 0; i < NUM_INSTALL_MODES; ++i) {
21 const InstallConstants& mode = kInstallModes[i]; 44 const InstallConstants& mode = kInstallModes[i];
22 45
23 // The modes must be listed in order. 46 // The modes must be listed in order.
24 ASSERT_THAT(mode.index, Eq(i)); 47 ASSERT_THAT(mode.index, Eq(i));
25 48
26 // The first mode must have no install switch; the rest must have one. 49 // The first mode must have no install switch; the rest must have one.
27 if (i == 0) 50 if (i == 0)
(...skipping 12 matching lines...) Expand all
40 ASSERT_THAT(mode.logo_suffix, StrEq(L"")); 63 ASSERT_THAT(mode.logo_suffix, StrEq(L""));
41 else 64 else
42 ASSERT_THAT(mode.logo_suffix, StrNe(L"")); 65 ASSERT_THAT(mode.logo_suffix, StrNe(L""));
43 66
44 // The modes must have an appguid if Google Update integration is supported. 67 // The modes must have an appguid if Google Update integration is supported.
45 if (kUseGoogleUpdateIntegration) 68 if (kUseGoogleUpdateIntegration)
46 ASSERT_THAT(mode.app_guid, StrNe(L"")); 69 ASSERT_THAT(mode.app_guid, StrNe(L""));
47 else 70 else
48 ASSERT_THAT(mode.app_guid, StrEq(L"")); 71 ASSERT_THAT(mode.app_guid, StrEq(L""));
49 72
73 // The ProgID prefix must not be empty, must be no greater than 11
74 // characters long, must contain no punctuation, and may not start with a
75 // digit (https://msdn.microsoft.com/library/windows/desktop/dd542719.aspx).
76 ASSERT_THAT(mode.prog_id_prefix, StrNe(L""));
77 ASSERT_THAT(lstrlen(mode.prog_id_prefix), Le(11));
78 ASSERT_THAT(mode.prog_id_prefix, Not(ContainsIllegalProgIdChar()));
79 ASSERT_THAT(*mode.prog_id_prefix, ResultOf(iswdigit, Eq(0)));
80
81 // The ProgID description must not be empty.
82 ASSERT_THAT(mode.prog_id_description, StrNe(L""));
83
50 // UNSUPPORTED and kUseGoogleUpdateIntegration are mutually exclusive. 84 // UNSUPPORTED and kUseGoogleUpdateIntegration are mutually exclusive.
51 if (kUseGoogleUpdateIntegration) 85 if (kUseGoogleUpdateIntegration)
52 ASSERT_THAT(mode.channel_strategy, Ne(ChannelStrategy::UNSUPPORTED)); 86 ASSERT_THAT(mode.channel_strategy, Ne(ChannelStrategy::UNSUPPORTED));
53 else 87 else
54 ASSERT_THAT(mode.channel_strategy, Eq(ChannelStrategy::UNSUPPORTED)); 88 ASSERT_THAT(mode.channel_strategy, Eq(ChannelStrategy::UNSUPPORTED));
55 } 89 }
56 } 90 }
57 91
58 TEST(InstallModes, VerifyBrand) { 92 TEST(InstallModes, VerifyBrand) {
59 if (kUseGoogleUpdateIntegration) { 93 if (kUseGoogleUpdateIntegration) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 GetBinariesClientStateMediumKeyPath(), 165 GetBinariesClientStateMediumKeyPath(),
132 StrEq(std::wstring(L"Software\\Google\\Update\\ClientStateMedium\\") 166 StrEq(std::wstring(L"Software\\Google\\Update\\ClientStateMedium\\")
133 .append(kBinariesAppGuid))); 167 .append(kBinariesAppGuid)));
134 } else { 168 } else {
135 ASSERT_THAT(GetBinariesClientStateMediumKeyPath(), 169 ASSERT_THAT(GetBinariesClientStateMediumKeyPath(),
136 StrEq(std::wstring(L"Software\\").append(kBinariesPathName))); 170 StrEq(std::wstring(L"Software\\").append(kBinariesPathName)));
137 } 171 }
138 } 172 }
139 173
140 } // namespace install_static 174 } // namespace install_static
OLDNEW
« no previous file with comments | « chrome/install_static/install_constants.h ('k') | chrome/install_static/install_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698