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

Side by Side Diff: chrome/installer/util/channel_info_unittest.cc

Issue 2476573004: Use InstallDetails in installer_util. (Closed)
Patch Set: sync to position 451835 Created 3 years, 10 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/installer/util/channel_info.cc ('k') | chrome/installer/util/google_update_settings.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/installer/util/channel_info.h" 5 #include "chrome/installer/util/channel_info.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "chrome/installer/util/util_constants.h" 9 #include "chrome/installer/util/util_constants.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 using installer::ChannelInfo; 12 using installer::ChannelInfo;
13 13
14 namespace {
15
16 const base::string16 kChannelStable(installer::kChromeChannelStable);
17 const base::string16 kChannelBeta(installer::kChromeChannelBeta);
18 const base::string16 kChannelDev(installer::kChromeChannelDev);
19
20 } // namespace
21
22 TEST(ChannelInfoTest, Channels) {
23 ChannelInfo ci;
24 base::string16 channel;
25
26 ci.set_value(L"");
27 EXPECT_TRUE(ci.GetChannelName(&channel));
28 EXPECT_EQ(kChannelStable, channel);
29 ci.set_value(L"-full");
30 EXPECT_TRUE(ci.GetChannelName(&channel));
31 EXPECT_EQ(kChannelStable, channel);
32
33 ci.set_value(L"1.1-beta");
34 EXPECT_TRUE(ci.GetChannelName(&channel));
35 EXPECT_EQ(kChannelBeta, channel);
36 ci.set_value(L"1.1-beta-foo");
37 EXPECT_TRUE(ci.GetChannelName(&channel));
38 EXPECT_EQ(kChannelBeta, channel);
39 ci.set_value(L"1.1-bar");
40 EXPECT_TRUE(ci.GetChannelName(&channel));
41 EXPECT_EQ(kChannelBeta, channel);
42 ci.set_value(L"1n1-foobar");
43 EXPECT_TRUE(ci.GetChannelName(&channel));
44 EXPECT_EQ(kChannelBeta, channel);
45 ci.set_value(L"foo-1.1-beta");
46 EXPECT_FALSE(ci.GetChannelName(&channel));
47 ci.set_value(L"2.0-beta");
48 EXPECT_FALSE(ci.GetChannelName(&channel));
49
50 ci.set_value(L"2.0-dev");
51 EXPECT_TRUE(ci.GetChannelName(&channel));
52 EXPECT_EQ(kChannelDev, channel);
53 ci.set_value(L"2.0-DEV");
54 EXPECT_TRUE(ci.GetChannelName(&channel));
55 EXPECT_EQ(kChannelDev, channel);
56 ci.set_value(L"2.0-dev-eloper");
57 EXPECT_TRUE(ci.GetChannelName(&channel));
58 EXPECT_EQ(kChannelDev, channel);
59 ci.set_value(L"2.0-doom");
60 EXPECT_TRUE(ci.GetChannelName(&channel));
61 EXPECT_EQ(kChannelDev, channel);
62 ci.set_value(L"250-doom");
63 EXPECT_TRUE(ci.GetChannelName(&channel));
64 EXPECT_EQ(kChannelDev, channel);
65 ci.set_value(L"bar-2.0-dev");
66 EXPECT_FALSE(ci.GetChannelName(&channel));
67 ci.set_value(L"1.0-dev");
68 EXPECT_FALSE(ci.GetChannelName(&channel));
69
70 ci.set_value(L"x64-dev");
71 EXPECT_TRUE(ci.GetChannelName(&channel));
72 EXPECT_EQ(kChannelDev, channel);
73 ci.set_value(L"foo-x64-dev");
74 EXPECT_TRUE(ci.GetChannelName(&channel));
75 EXPECT_EQ(kChannelDev, channel);
76 ci.set_value(L"x64-Dev");
77 EXPECT_FALSE(ci.GetChannelName(&channel));
78
79 ci.set_value(L"x64-beta");
80 EXPECT_TRUE(ci.GetChannelName(&channel));
81 EXPECT_EQ(kChannelBeta, channel);
82 ci.set_value(L"bar-x64-beta");
83 EXPECT_TRUE(ci.GetChannelName(&channel));
84 EXPECT_EQ(kChannelBeta, channel);
85 ci.set_value(L"x64-Beta");
86 EXPECT_FALSE(ci.GetChannelName(&channel));
87
88 ci.set_value(L"x64-stable");
89 EXPECT_TRUE(ci.GetChannelName(&channel));
90 EXPECT_EQ(kChannelStable, channel);
91 ci.set_value(L"baz-x64-stable");
92 EXPECT_TRUE(ci.GetChannelName(&channel));
93 EXPECT_EQ(kChannelStable, channel);
94 ci.set_value(L"x64-Stable");
95 EXPECT_FALSE(ci.GetChannelName(&channel));
96
97 ci.set_value(L"fuzzy");
98 EXPECT_FALSE(ci.GetChannelName(&channel));
99 ci.set_value(L"foo");
100 EXPECT_FALSE(ci.GetChannelName(&channel));
101 }
102
103 TEST(ChannelInfoTest, FullInstall) { 14 TEST(ChannelInfoTest, FullInstall) {
104 ChannelInfo ci; 15 ChannelInfo ci;
105 16
106 ci.set_value(L""); 17 ci.set_value(L"");
107 EXPECT_TRUE(ci.SetFullSuffix(true)); 18 EXPECT_TRUE(ci.SetFullSuffix(true));
108 EXPECT_TRUE(ci.HasFullSuffix()); 19 EXPECT_TRUE(ci.HasFullSuffix());
109 EXPECT_EQ(L"-full", ci.value()); 20 EXPECT_EQ(L"-full", ci.value());
110 EXPECT_FALSE(ci.SetFullSuffix(true)); 21 EXPECT_FALSE(ci.SetFullSuffix(true));
111 EXPECT_TRUE(ci.HasFullSuffix()); 22 EXPECT_TRUE(ci.HasFullSuffix());
112 EXPECT_EQ(L"-full", ci.value()); 23 EXPECT_EQ(L"-full", ci.value());
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 ci.set_value(L"2.0-beta-stage:spammy-multi"); 139 ci.set_value(L"2.0-beta-stage:spammy-multi");
229 EXPECT_TRUE(ci.ClearStage()); 140 EXPECT_TRUE(ci.ClearStage());
230 EXPECT_EQ(L"2.0-beta-multi", ci.value()); 141 EXPECT_EQ(L"2.0-beta-multi", ci.value());
231 142
232 ci.set_value(L"2.0-beta-stage:-multi"); 143 ci.set_value(L"2.0-beta-stage:-multi");
233 EXPECT_TRUE(ci.ClearStage()); 144 EXPECT_TRUE(ci.ClearStage());
234 EXPECT_EQ(L"2.0-beta-multi", ci.value()); 145 EXPECT_EQ(L"2.0-beta-multi", ci.value());
235 } 146 }
236 147
237 TEST(ChannelInfoTest, GetStatsDefault) { 148 TEST(ChannelInfoTest, GetStatsDefault) {
238 struct { 149 const base::string16 base_values[] = {
239 const base::string16 base_value; 150 L"", L"x64-stable", L"1.1-beta", L"x64-beta", L"2.0-dev", L"x64-dev",
240 const base::string16& expected_channel;
241 } test_cases[] = {
242 {L"", kChannelStable},
243 {L"x64-stable", kChannelStable},
244 {L"1.1-beta", kChannelBeta},
245 {L"x64-beta", kChannelBeta},
246 {L"2.0-dev", kChannelDev},
247 {L"x64-dev", kChannelDev},
248 }; 151 };
249 const base::string16 suffixes[] = {L"", L"-multi", L"-multi-chrome"}; 152 const base::string16 suffixes[] = {L"", L"-multi", L"-multi-chrome"};
250 153
251 for (const auto& test_case : test_cases) { 154 for (const auto& base_value : base_values) {
252 const base::string16& base_value = test_case.base_value;
253 const base::string16& expected_channel = test_case.expected_channel;
254
255 for (const auto& suffix : suffixes) { 155 for (const auto& suffix : suffixes) {
256 ChannelInfo ci; 156 ChannelInfo ci;
257 base::string16 channel; 157 base::string16 channel;
258 158
259 ci.set_value(base_value + suffix); 159 ci.set_value(base_value + suffix);
260 EXPECT_EQ(L"", ci.GetStatsDefault()); 160 EXPECT_EQ(L"", ci.GetStatsDefault());
261 ci.set_value(base_value + L"-statsdef" + suffix); 161 ci.set_value(base_value + L"-statsdef" + suffix);
262 EXPECT_EQ(L"", ci.GetStatsDefault()); 162 EXPECT_EQ(L"", ci.GetStatsDefault());
263 ci.set_value(base_value + L"-statsdef_" + suffix); 163 ci.set_value(base_value + L"-statsdef_" + suffix);
264 EXPECT_EQ(L"", ci.GetStatsDefault()); 164 EXPECT_EQ(L"", ci.GetStatsDefault());
265 ci.set_value(base_value + L"-statsdef_0" + suffix); 165 ci.set_value(base_value + L"-statsdef_0" + suffix);
266 EXPECT_EQ(L"0", ci.GetStatsDefault()); 166 EXPECT_EQ(L"0", ci.GetStatsDefault());
267 EXPECT_TRUE(ci.GetChannelName(&channel));
268 EXPECT_EQ(expected_channel, channel);
269 ci.set_value(base_value + L"-statsdef_1" + suffix); 167 ci.set_value(base_value + L"-statsdef_1" + suffix);
270 EXPECT_EQ(L"1", ci.GetStatsDefault()); 168 EXPECT_EQ(L"1", ci.GetStatsDefault());
271 EXPECT_TRUE(ci.GetChannelName(&channel));
272 EXPECT_EQ(expected_channel, channel);
273 } 169 }
274 } 170 }
275 } 171 }
276 172
277 TEST(ChannelInfoTest, RemoveAllModifiersAndSuffixes) { 173 TEST(ChannelInfoTest, RemoveAllModifiersAndSuffixes) {
278 ChannelInfo ci; 174 ChannelInfo ci;
279 175
280 ci.set_value(L""); 176 ci.set_value(L"");
281 EXPECT_FALSE(ci.RemoveAllModifiersAndSuffixes()); 177 EXPECT_FALSE(ci.RemoveAllModifiersAndSuffixes());
282 EXPECT_EQ(L"", ci.value()); 178 EXPECT_EQ(L"", ci.value());
283 179
284 ci.set_value(L"2.0-dev-multi-chrome-chromeframe-migrating"); 180 ci.set_value(L"2.0-dev-multi-chrome-chromeframe-migrating");
285 EXPECT_TRUE(ci.RemoveAllModifiersAndSuffixes()); 181 EXPECT_TRUE(ci.RemoveAllModifiersAndSuffixes());
286 EXPECT_EQ(L"2.0-dev", ci.value()); 182 EXPECT_EQ(L"2.0-dev", ci.value());
287 } 183 }
OLDNEW
« no previous file with comments | « chrome/installer/util/channel_info.cc ('k') | chrome/installer/util/google_update_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698