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

Side by Side Diff: chrome_elf/chrome_elf_util_unittest.cc

Issue 1913943003: Remove dependencies on chrome\installer from the ChromeCrashReporterClient class on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile failure on win_clang and fix the chrome_elf_unittests on 64 bit. We need to add version… Created 4 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <tuple> 5 #include <tuple>
6 6
7 #include "base/test/test_reg_util_win.h" 7 #include "base/test/test_reg_util_win.h"
8 #include "base/win/registry.h" 8 #include "base/win/registry.h"
9 #include "chrome/install_static/install_util.h" 9 #include "chrome/install_static/install_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h" 11 #include "testing/platform_test.h"
12 12
13 using namespace install_static;
14
13 namespace { 15 namespace {
14 16
15 const wchar_t kRegPathClientState[] = L"Software\\Google\\Update\\ClientState"; 17 const wchar_t kRegPathClientState[] = L"Software\\Google\\Update\\ClientState";
16 const wchar_t kRegPathClientStateMedium[] = 18 const wchar_t kRegPathClientStateMedium[] =
17 L"Software\\Google\\Update\\ClientStateMedium"; 19 L"Software\\Google\\Update\\ClientStateMedium";
18 const wchar_t kRegValueUsageStats[] = L"usagestats"; 20 const wchar_t kRegValueUsageStats[] = L"usagestats";
19 const wchar_t kUninstallArgumentsField[] = L"UninstallArguments"; 21 const wchar_t kUninstallArgumentsField[] = L"UninstallArguments";
20 22
21 const wchar_t kAppGuidCanary[] = 23 const wchar_t kAppGuidCanary[] =
22 L"{4ea16ac7-fd5a-47c3-875b-dbf4a2008c20}"; 24 L"{4ea16ac7-fd5a-47c3-875b-dbf4a2008c20}";
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 if (is_canary_) 133 if (is_canary_)
132 return; 134 return;
133 SetMultiInstallStateInRegistry(system_level_, true); 135 SetMultiInstallStateInRegistry(system_level_, true);
134 EXPECT_TRUE(IsMultiInstall(system_level_)); 136 EXPECT_TRUE(IsMultiInstall(system_level_));
135 137
136 SetMultiInstallStateInRegistry(system_level_, false); 138 SetMultiInstallStateInRegistry(system_level_, false);
137 EXPECT_FALSE(IsMultiInstall(system_level_)); 139 EXPECT_FALSE(IsMultiInstall(system_level_));
138 } 140 }
139 141
140 TEST_P(ChromeElfUtilTest, UsageStatsAbsent) { 142 TEST_P(ChromeElfUtilTest, UsageStatsAbsent) {
141 EXPECT_FALSE(AreUsageStatsEnabled(chrome_path_)); 143 EXPECT_FALSE(GetCollectStatsConsentForTesting(chrome_path_));
142 } 144 }
143 145
144 TEST_P(ChromeElfUtilTest, UsageStatsZero) { 146 TEST_P(ChromeElfUtilTest, UsageStatsZero) {
145 SetUsageStat(0, false); 147 SetUsageStat(0, false);
146 EXPECT_FALSE(AreUsageStatsEnabled(chrome_path_)); 148 EXPECT_FALSE(GetCollectStatsConsentForTesting(chrome_path_));
147 } 149 }
148 150
149 TEST_P(ChromeElfUtilTest, UsageStatsOne) { 151 TEST_P(ChromeElfUtilTest, UsageStatsOne) {
150 SetUsageStat(1, false); 152 SetUsageStat(1, false);
151 EXPECT_TRUE(AreUsageStatsEnabled(chrome_path_)); 153 EXPECT_TRUE(GetCollectStatsConsentForTesting(chrome_path_));
152 if (is_canary_) { 154 if (is_canary_) {
153 EXPECT_FALSE(AreUsageStatsEnabled(kChromeUserExePath)); 155 EXPECT_FALSE(GetCollectStatsConsentForTesting(kChromeUserExePath));
154 EXPECT_FALSE(AreUsageStatsEnabled(kChromeSystemExePath)); 156 EXPECT_FALSE(GetCollectStatsConsentForTesting(kChromeSystemExePath));
155 } else if (system_level_) { 157 } else if (system_level_) {
156 EXPECT_FALSE(AreUsageStatsEnabled(kCanaryExePath)); 158 EXPECT_FALSE(GetCollectStatsConsentForTesting(kCanaryExePath));
157 EXPECT_FALSE(AreUsageStatsEnabled(kChromeUserExePath)); 159 EXPECT_FALSE(GetCollectStatsConsentForTesting(kChromeUserExePath));
158 } else { 160 } else {
159 EXPECT_FALSE(AreUsageStatsEnabled(kCanaryExePath)); 161 EXPECT_FALSE(GetCollectStatsConsentForTesting(kCanaryExePath));
160 EXPECT_FALSE(AreUsageStatsEnabled(kChromeSystemExePath)); 162 EXPECT_FALSE(GetCollectStatsConsentForTesting(kChromeSystemExePath));
161 } 163 }
162 } 164 }
163 165
164 TEST_P(ChromeElfUtilTest, UsageStatsZeroInStateMedium) { 166 TEST_P(ChromeElfUtilTest, UsageStatsZeroInStateMedium) {
165 if (!system_level_) 167 if (!system_level_)
166 return; 168 return;
167 SetUsageStat(0, true); 169 SetUsageStat(0, true);
168 EXPECT_FALSE(AreUsageStatsEnabled(chrome_path_)); 170 EXPECT_FALSE(GetCollectStatsConsentForTesting(chrome_path_));
169 } 171 }
170 172
171 TEST_P(ChromeElfUtilTest, UsageStatsOneInStateMedium) { 173 TEST_P(ChromeElfUtilTest, UsageStatsOneInStateMedium) {
172 if (!system_level_) 174 if (!system_level_)
173 return; 175 return;
174 SetUsageStat(1, true); 176 SetUsageStat(1, true);
175 EXPECT_TRUE(AreUsageStatsEnabled(chrome_path_)); 177 EXPECT_TRUE(GetCollectStatsConsentForTesting(chrome_path_));
176 EXPECT_FALSE(AreUsageStatsEnabled(kCanaryExePath)); 178 EXPECT_FALSE(GetCollectStatsConsentForTesting(kCanaryExePath));
177 EXPECT_FALSE(AreUsageStatsEnabled(kChromeUserExePath)); 179 EXPECT_FALSE(GetCollectStatsConsentForTesting(kChromeUserExePath));
178 } 180 }
179 181
180 INSTANTIATE_TEST_CASE_P(Canary, ChromeElfUtilTest, 182 INSTANTIATE_TEST_CASE_P(Canary, ChromeElfUtilTest,
181 testing::Combine(testing::Values("canary"), 183 testing::Combine(testing::Values("canary"),
182 testing::Values("user"), 184 testing::Values("user"),
183 testing::Values("single"))); 185 testing::Values("single")));
184 INSTANTIATE_TEST_CASE_P(GoogleChrome, ChromeElfUtilTest, 186 INSTANTIATE_TEST_CASE_P(GoogleChrome, ChromeElfUtilTest,
185 testing::Combine(testing::Values("google"), 187 testing::Combine(testing::Values("google"),
186 testing::Values("user", "system"), 188 testing::Values("user", "system"),
187 testing::Values("single", "multi"))); 189 testing::Values("single", "multi")));
188 190
191 // Tests the MatchPattern function in the install_static library.
192 // TODO(ananta)
193 // Move this to install_static_unittests.
194 // http://crbug.com/604923
195 TEST(MiscUtilTest, InstallStaticMatchPattern) {
196 EXPECT_TRUE(install_static::MatchPattern(L"Hello1234", L"He??o*1*"));
scottmg 2016/04/28 23:16:42 Add a few tests for source and/or pattern being em
ananta 2016/04/29 02:28:05 Done.
197 EXPECT_TRUE(install_static::MatchPattern(L"Foo", L"F*?"));
198 EXPECT_TRUE(install_static::MatchPattern(L"Foo", L"F*"));
199 EXPECT_FALSE(install_static::MatchPattern(L"Foo", L"F*b"));
200 EXPECT_TRUE(install_static::MatchPattern(L"abcd", L"*c*d"));
201 EXPECT_TRUE(install_static::MatchPattern(L"abcd", L"*?c*d"));
202 EXPECT_FALSE(install_static::MatchPattern(L"abcd", L"abcd*efgh"));
203 }
204
189 } // namespace 205 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698