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

Side by Side Diff: chrome_elf/chrome_elf_util_unittest.cc

Issue 1841573002: [Chrome ELF] New NT registry API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: PRESUBMIT to allow chrome_elf directory files to use wstring. Created 4 years, 5 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_elf/chrome_elf_main.cc ('k') | chrome_elf/hook_util/thunk_getter.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 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 #include <windows.h>
7 #include <versionhelpers.h> // windows.h must be before.
6 8
7 #include "base/test/test_reg_util_win.h" 9 #include "base/test/test_reg_util_win.h"
8 #include "base/win/registry.h" 10 #include "base/win/registry.h"
9 #include "chrome/install_static/install_util.h" 11 #include "chrome/install_static/install_util.h"
12 #include "chrome_elf/chrome_elf_constants.h"
13 #include "chrome_elf/nt_registry/nt_registry.h"
10 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h" 15 #include "testing/platform_test.h"
12 16
13 using namespace install_static; 17 using namespace install_static;
14 18
15 namespace { 19 namespace {
16 20
17 const wchar_t kCanaryExePath[] = 21 const wchar_t kCanaryExePath[] =
18 L"C:\\Users\\user\\AppData\\Local\\Google\\Chrome SxS\\Application" 22 L"C:\\Users\\user\\AppData\\Local\\Google\\Chrome SxS\\Application"
19 L"\\chrome.exe"; 23 L"\\chrome.exe";
(...skipping 14 matching lines...) Expand all
34 EXPECT_TRUE(IsSystemInstall(kChromeSystemExePath)); 38 EXPECT_TRUE(IsSystemInstall(kChromeSystemExePath));
35 EXPECT_FALSE(IsSystemInstall(kChromeUserExePath)); 39 EXPECT_FALSE(IsSystemInstall(kChromeUserExePath));
36 } 40 }
37 41
38 TEST(ChromeElfUtilTest, BrowserProcessTest) { 42 TEST(ChromeElfUtilTest, BrowserProcessTest) {
39 EXPECT_EQ(ProcessType::UNINITIALIZED, g_process_type); 43 EXPECT_EQ(ProcessType::UNINITIALIZED, g_process_type);
40 InitializeProcessType(); 44 InitializeProcessType();
41 EXPECT_FALSE(IsNonBrowserProcess()); 45 EXPECT_FALSE(IsNonBrowserProcess());
42 } 46 }
43 47
48 //------------------------------------------------------------------------------
49 // NT registry API tests (chrome_elf_reg)
50 //------------------------------------------------------------------------------
51
52 TEST(ChromeElfUtilTest, NTRegistry) {
53 HANDLE key_handle;
54 const wchar_t* dword_val_name = L"DwordTestValue";
55 DWORD dword_val = 1234;
56 const wchar_t* sz_val_name = L"SzTestValue";
57 base::string16 sz_val = L"blah de blah de blahhhhh.";
58 const wchar_t* sz_val_name2 = L"SzTestValueEmpty";
59 base::string16 sz_val2 = L"";
60 const wchar_t* multisz_val_name = L"SzmultiTestValue";
61 std::vector<base::string16> multisz_val;
62 base::string16 multi1 = L"one";
63 base::string16 multi2 = L"two";
64 base::string16 multi3 = L"three";
65 const wchar_t* multisz_val_name2 = L"SzmultiTestValueBad";
66 base::string16 multi_empty = L"";
67 const wchar_t* sz_new_key_1 = L"test\\new\\subkey";
68 const wchar_t* sz_new_key_2 = L"test\\new\\subkey\\blah\\";
69 const wchar_t* sz_new_key_3 = L"\\test\\new\\subkey\\\\blah2";
70
71 // Set up registry override for this test.
72 base::string16 temp;
73 registry_util::RegistryOverrideManager override_manager;
74 override_manager.OverrideRegistry(HKEY_CURRENT_USER, &temp);
75 ::wcsncpy(nt::HKCU_override, temp.c_str(), nt::g_kRegMaxPathLen - 1);
76
77 // Create a temp key to play under.
78 ASSERT_TRUE(nt::CreateRegKey(nt::HKCU, elf_sec::kRegSecurityPath,
79 KEY_ALL_ACCESS, &key_handle));
80
81 // Exercise the supported getter & setter functions.
82 EXPECT_TRUE(nt::SetRegValueDWORD(key_handle, dword_val_name, dword_val));
83 EXPECT_TRUE(nt::SetRegValueSZ(key_handle, sz_val_name, sz_val));
84 EXPECT_TRUE(nt::SetRegValueSZ(key_handle, sz_val_name2, sz_val2));
85
86 DWORD get_dword = 0;
87 base::string16 get_sz;
88 EXPECT_TRUE(nt::QueryRegValueDWORD(key_handle, dword_val_name, &get_dword) &&
89 get_dword == dword_val);
90 EXPECT_TRUE(nt::QueryRegValueSZ(key_handle, sz_val_name, &get_sz) &&
91 get_sz.compare(sz_val) == 0);
92 EXPECT_TRUE(nt::QueryRegValueSZ(key_handle, sz_val_name2, &get_sz) &&
93 get_sz.compare(sz_val2) == 0);
94
95 multisz_val.push_back(multi1);
96 multisz_val.push_back(multi2);
97 multisz_val.push_back(multi3);
98 EXPECT_TRUE(
99 nt::SetRegValueMULTISZ(key_handle, multisz_val_name, multisz_val));
100 multisz_val.clear();
101 multisz_val.push_back(multi_empty);
102 EXPECT_TRUE(
103 nt::SetRegValueMULTISZ(key_handle, multisz_val_name2, multisz_val));
104 multisz_val.clear();
105
106 EXPECT_TRUE(
107 nt::QueryRegValueMULTISZ(key_handle, multisz_val_name, &multisz_val));
108 if (multisz_val.size() == 3) {
109 EXPECT_TRUE(multi1.compare(multisz_val.at(0)) == 0);
110 EXPECT_TRUE(multi2.compare(multisz_val.at(1)) == 0);
111 EXPECT_TRUE(multi3.compare(multisz_val.at(2)) == 0);
112 } else {
113 EXPECT_TRUE(false);
114 }
115 multisz_val.clear();
116
117 EXPECT_TRUE(
118 nt::QueryRegValueMULTISZ(key_handle, multisz_val_name2, &multisz_val));
119 if (multisz_val.size() == 1) {
120 EXPECT_TRUE(multi_empty.compare(multisz_val.at(0)) == 0);
121 } else {
122 EXPECT_TRUE(false);
123 }
124 multisz_val.clear();
125
126 // Clean up
127 EXPECT_TRUE(nt::DeleteRegKey(key_handle));
128 nt::CloseRegKey(key_handle);
129
130 // More tests for CreateRegKey recursion.
131 ASSERT_TRUE(
132 nt::CreateRegKey(nt::HKCU, sz_new_key_1, KEY_ALL_ACCESS, nullptr));
133 EXPECT_TRUE(nt::OpenRegKey(nt::HKCU, sz_new_key_1, KEY_ALL_ACCESS,
134 &key_handle, nullptr));
135 EXPECT_TRUE(nt::DeleteRegKey(key_handle));
136 nt::CloseRegKey(key_handle);
137
138 ASSERT_TRUE(
139 nt::CreateRegKey(nt::HKCU, sz_new_key_2, KEY_ALL_ACCESS, nullptr));
140 EXPECT_TRUE(nt::OpenRegKey(nt::HKCU, sz_new_key_2, KEY_ALL_ACCESS,
141 &key_handle, nullptr));
142 EXPECT_TRUE(nt::DeleteRegKey(key_handle));
143 nt::CloseRegKey(key_handle);
144
145 ASSERT_TRUE(
146 nt::CreateRegKey(nt::HKCU, sz_new_key_3, KEY_ALL_ACCESS, nullptr));
147 EXPECT_TRUE(nt::OpenRegKey(nt::HKCU, L"test\\new\\subkey\\blah2",
148 KEY_ALL_ACCESS, &key_handle, nullptr));
149 EXPECT_TRUE(nt::DeleteRegKey(key_handle));
150 nt::CloseRegKey(key_handle);
151
152 ASSERT_TRUE(nt::CreateRegKey(nt::HKCU, nullptr, KEY_ALL_ACCESS, &key_handle));
153 nt::CloseRegKey(key_handle);
154 }
155
44 // Parameterized test with paramters: 156 // Parameterized test with paramters:
45 // 1: product: "canary" or "google" 157 // 1: product: "canary" or "google"
46 // 2: install level: "user" or "system" 158 // 2: install level: "user" or "system"
47 // 3: install mode: "single" or "multi" 159 // 3: install mode: "single" or "multi"
48 class ChromeElfUtilTest : 160 class ChromeElfUtilTest
49 public testing::TestWithParam<std::tuple<const char*, 161 : public testing::TestWithParam<
50 const char*, 162 std::tuple<const char*, const char*, const char*>> {
51 const char*> > {
52 protected: 163 protected:
53 void SetUp() override { 164 void SetUp() override {
54 override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE); 165 base::string16 temp;
55 override_manager_.OverrideRegistry(HKEY_CURRENT_USER); 166 override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE, &temp);
167 ::wcsncpy(nt::HKLM_override, temp.c_str(), nt::g_kRegMaxPathLen - 1);
168 temp.clear();
169 override_manager_.OverrideRegistry(HKEY_CURRENT_USER, &temp);
170 ::wcsncpy(nt::HKCU_override, temp.c_str(), nt::g_kRegMaxPathLen - 1);
171
56 const char* app; 172 const char* app;
57 const char* level; 173 const char* level;
58 const char* mode; 174 const char* mode;
59 std::tie(app, level, mode) = GetParam(); 175 std::tie(app, level, mode) = GetParam();
60 is_canary_ = (std::string(app) == "canary"); 176 is_canary_ = (std::string(app) == "canary");
61 system_level_ = (std::string(level) != "user"); 177 system_level_ = (std::string(level) != "user");
62 multi_install_ = (std::string(mode) != "single"); 178 multi_install_ = (std::string(mode) != "single");
63 if (is_canary_) { 179 if (is_canary_) {
64 ASSERT_FALSE(system_level_); 180 ASSERT_FALSE(system_level_);
65 ASSERT_FALSE(multi_install_); 181 ASSERT_FALSE(multi_install_);
66 app_guid_ = kAppGuidCanary; 182 app_guid_ = kAppGuidCanary;
67 chrome_path_ = kCanaryExePath; 183 chrome_path_ = kCanaryExePath;
68 } else { 184 } else {
69 app_guid_ = kAppGuidGoogleChrome; 185 app_guid_ = kAppGuidGoogleChrome;
70 chrome_path_ = (system_level_ ? kChromeSystemExePath : 186 chrome_path_ =
71 kChromeUserExePath); 187 (system_level_ ? kChromeSystemExePath : kChromeUserExePath);
72 } 188 }
73 if (multi_install_) { 189 if (multi_install_) {
74 SetMultiInstallStateInRegistry(system_level_, true); 190 SetMultiInstallStateInRegistry(system_level_, true);
75 app_guid_ = kAppGuidGoogleBinaries; 191 app_guid_ = kAppGuidGoogleBinaries;
76 } 192 }
77 } 193 }
78 194
79 base::string16 BuildKey(const wchar_t* path, const wchar_t* guid) { 195 base::string16 BuildKey(const wchar_t* path, const wchar_t* guid) {
80 base::string16 full_key_path(path); 196 base::string16 full_key_path(path);
81 full_key_path.append(1, L'\\'); 197 full_key_path.append(1, L'\\');
82 full_key_path.append(guid); 198 full_key_path.append(guid);
83 return full_key_path; 199 return full_key_path;
84 } 200 }
85 201
86 void SetUsageStat(DWORD value, bool state_medium) { 202 void SetUsageStat(DWORD value, bool state_medium) {
87 LONG result = base::win::RegKey( 203 LONG result = base::win::RegKey(
88 system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, 204 system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
89 BuildKey(state_medium ? kRegPathClientStateMedium : kRegPathClientState, 205 BuildKey(state_medium ? kRegPathClientStateMedium
90 app_guid_).c_str(), 206 : kRegPathClientState,
91 KEY_SET_VALUE).WriteValue(kRegValueUsageStats, value); 207 app_guid_)
208 .c_str(),
209 KEY_SET_VALUE)
210 .WriteValue(kRegValueUsageStats, value);
92 ASSERT_EQ(ERROR_SUCCESS, result); 211 ASSERT_EQ(ERROR_SUCCESS, result);
93 } 212 }
94 213
95 void SetMultiInstallStateInRegistry(bool system_install, bool multi) { 214 void SetMultiInstallStateInRegistry(bool system_install, bool multi) {
96 base::win::RegKey key( 215 base::win::RegKey key(
97 system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, 216 system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
98 BuildKey(kRegPathClientState, kAppGuidGoogleChrome).c_str(), 217 BuildKey(kRegPathClientState, kAppGuidGoogleChrome).c_str(),
99 KEY_SET_VALUE); 218 KEY_SET_VALUE);
100 LONG result; 219 LONG result;
101 if (multi) { 220 if (multi) {
102 result = key.WriteValue(kUninstallArgumentsField, 221 result = key.WriteValue(kUninstallArgumentsField,
103 L"yadda yadda --multi-install yadda yadda"); 222 L"yadda yadda --multi-install yadda yadda");
104 } else { 223 } else {
105 result = key.DeleteValue(kUninstallArgumentsField); 224 result = key.DeleteValue(kUninstallArgumentsField);
106 } 225 }
107 ASSERT_EQ(ERROR_SUCCESS, result); 226 ASSERT_EQ(ERROR_SUCCESS, result);
108 } 227 }
109 228
110 void SetChannelName(const base::string16& channel_name) { 229 void SetChannelName(const base::string16& channel_name) {
111 LONG result = base::win::RegKey( 230 LONG result =
112 system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, 231 base::win::RegKey(
113 BuildKey(kRegPathClientState, app_guid_).c_str(), 232 system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
114 KEY_SET_VALUE).WriteValue(kRegApField, channel_name.c_str()); 233 BuildKey(kRegPathClientState, app_guid_).c_str(), KEY_SET_VALUE)
234 .WriteValue(kRegApField, channel_name.c_str());
115 ASSERT_EQ(ERROR_SUCCESS, result); 235 ASSERT_EQ(ERROR_SUCCESS, result);
116 } 236 }
117 237
118 // This function tests the install_static::GetChromeChannelName function and 238 // This function tests the install_static::GetChromeChannelName function and
119 // is based on the ChannelInfoTest.Channels in channel_info_unittest.cc. 239 // is based on the ChannelInfoTest.Channels in channel_info_unittest.cc.
120 // The |add_modifier| parameter controls whether we expect modifiers in the 240 // The |add_modifier| parameter controls whether we expect modifiers in the
121 // returned channel name. 241 // returned channel name.
122 void PerformChannelNameTests(bool add_modifier) { 242 void PerformChannelNameTests(bool add_modifier) {
123 // We can't test the channel name correctly for canary mode because the 243 // We can't test the channel name correctly for canary mode because the
124 // install_static checks whether an exe is a canary executable is based on 244 // install_static checks whether an exe is a canary executable is based on
125 // the path where the exe is running from. 245 // the path where the exe is running from.
126 if (is_canary_) 246 if (is_canary_)
127 return; 247 return;
128 SetChannelName(L""); 248 SetChannelName(L"");
129 base::string16 channel; 249 base::string16 channel;
130 install_static::GetChromeChannelName(!system_level_, add_modifier, 250 install_static::GetChromeChannelName(!system_level_, add_modifier,
131 &channel); 251 &channel);
132 if (multi_install_ && add_modifier) { 252 if (multi_install_ && add_modifier) {
133 EXPECT_EQ(L"-m", channel); 253 EXPECT_STREQ(L"-m", channel.c_str());
134 } else { 254 } else {
135 EXPECT_EQ(install_static::kChromeChannelStable, channel); 255 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str());
136 } 256 }
137 257
138 SetChannelName(L"-full"); 258 SetChannelName(L"-full");
139 install_static::GetChromeChannelName(!system_level_, add_modifier, 259 install_static::GetChromeChannelName(!system_level_, add_modifier,
140 &channel); 260 &channel);
141 if (multi_install_ && add_modifier) { 261 if (multi_install_ && add_modifier) {
142 EXPECT_EQ(L"-m", channel); 262 EXPECT_STREQ(L"-m", channel.c_str());
143 } else { 263 } else {
144 EXPECT_EQ(install_static::kChromeChannelStable, channel); 264 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str());
145 } 265 }
146 266
147 SetChannelName(L"1.1-beta"); 267 SetChannelName(L"1.1-beta");
148 install_static::GetChromeChannelName(!system_level_, add_modifier, 268 install_static::GetChromeChannelName(!system_level_, add_modifier,
149 &channel); 269 &channel);
150 if (multi_install_ && add_modifier) { 270 if (multi_install_ && add_modifier) {
151 EXPECT_EQ(L"beta-m", channel); 271 EXPECT_STREQ(L"beta-m", channel.c_str());
152 } else { 272 } else {
153 EXPECT_EQ(install_static::kChromeChannelBeta, channel); 273 EXPECT_STREQ(install_static::kChromeChannelBeta, channel.c_str());
154 } 274 }
155 275
156 SetChannelName(L"1.1-beta"); 276 SetChannelName(L"1.1-beta");
157 install_static::GetChromeChannelName(!system_level_, add_modifier, 277 install_static::GetChromeChannelName(!system_level_, add_modifier,
158 &channel); 278 &channel);
159 if (multi_install_ && add_modifier) { 279 if (multi_install_ && add_modifier) {
160 EXPECT_EQ(L"beta-m", channel); 280 EXPECT_STREQ(L"beta-m", channel.c_str());
161 } else { 281 } else {
162 EXPECT_EQ(install_static::kChromeChannelBeta, channel); 282 EXPECT_STREQ(install_static::kChromeChannelBeta, channel.c_str());
163 } 283 }
164 284
165 SetChannelName(L"1.1-bar"); 285 SetChannelName(L"1.1-bar");
166 install_static::GetChromeChannelName(!system_level_, add_modifier, 286 install_static::GetChromeChannelName(!system_level_, add_modifier,
167 &channel); 287 &channel);
168 if (multi_install_ && add_modifier) { 288 if (multi_install_ && add_modifier) {
169 EXPECT_EQ(L"beta-m", channel); 289 EXPECT_STREQ(L"beta-m", channel.c_str());
170 } else { 290 } else {
171 EXPECT_EQ(install_static::kChromeChannelBeta, channel); 291 EXPECT_STREQ(install_static::kChromeChannelBeta, channel.c_str());
172 } 292 }
173 293
174 SetChannelName(L"1n1-foobar"); 294 SetChannelName(L"1n1-foobar");
175 install_static::GetChromeChannelName(!system_level_, add_modifier, 295 install_static::GetChromeChannelName(!system_level_, add_modifier,
176 &channel); 296 &channel);
177 if (multi_install_ && add_modifier) { 297 if (multi_install_ && add_modifier) {
178 EXPECT_EQ(L"beta-m", channel); 298 EXPECT_STREQ(L"beta-m", channel.c_str());
179 } else { 299 } else {
180 EXPECT_EQ(install_static::kChromeChannelBeta, channel); 300 EXPECT_STREQ(install_static::kChromeChannelBeta, channel.c_str());
181 } 301 }
182 302
183 SetChannelName(L"foo-1.1-beta"); 303 SetChannelName(L"foo-1.1-beta");
184 install_static::GetChromeChannelName(!system_level_, add_modifier, 304 install_static::GetChromeChannelName(!system_level_, add_modifier,
185 &channel); 305 &channel);
186 if (multi_install_ && add_modifier) { 306 if (multi_install_ && add_modifier) {
187 EXPECT_EQ(L"-m", channel); 307 EXPECT_STREQ(L"-m", channel.c_str());
188 } else { 308 } else {
189 EXPECT_EQ(install_static::kChromeChannelStable, channel); 309 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str());
190 } 310 }
191 SetChannelName(L"2.0-beta"); 311 SetChannelName(L"2.0-beta");
192 install_static::GetChromeChannelName(!system_level_, add_modifier, 312 install_static::GetChromeChannelName(!system_level_, add_modifier,
193 &channel); 313 &channel);
194 if (multi_install_ && add_modifier) { 314 if (multi_install_ && add_modifier) {
195 EXPECT_EQ(L"-m", channel); 315 EXPECT_STREQ(L"-m", channel.c_str());
196 } else { 316 } else {
197 EXPECT_EQ(install_static::kChromeChannelStable, channel); 317 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str());
198 } 318 }
199 319
200 SetChannelName(L"2.0-dev"); 320 SetChannelName(L"2.0-dev");
201 install_static::GetChromeChannelName(!system_level_, add_modifier, 321 install_static::GetChromeChannelName(!system_level_, add_modifier,
202 &channel); 322 &channel);
203 if (multi_install_ && add_modifier) { 323 if (multi_install_ && add_modifier) {
204 EXPECT_EQ(L"dev-m", channel); 324 EXPECT_STREQ(L"dev-m", channel.c_str());
205 } else { 325 } else {
206 EXPECT_EQ(install_static::kChromeChannelDev, channel); 326 EXPECT_STREQ(install_static::kChromeChannelDev, channel.c_str());
207 } 327 }
208 SetChannelName(L"2.0-DEV"); 328 SetChannelName(L"2.0-DEV");
209 install_static::GetChromeChannelName(!system_level_, add_modifier, 329 install_static::GetChromeChannelName(!system_level_, add_modifier,
210 &channel); 330 &channel);
211 if (multi_install_ && add_modifier) { 331 if (multi_install_ && add_modifier) {
212 EXPECT_EQ(L"dev-m", channel); 332 EXPECT_STREQ(L"dev-m", channel.c_str());
213 } else { 333 } else {
214 EXPECT_EQ(install_static::kChromeChannelDev, channel); 334 EXPECT_STREQ(install_static::kChromeChannelDev, channel.c_str());
215 } 335 }
216 SetChannelName(L"2.0-dev-eloper"); 336 SetChannelName(L"2.0-dev-eloper");
217 install_static::GetChromeChannelName(!system_level_, add_modifier, 337 install_static::GetChromeChannelName(!system_level_, add_modifier,
218 &channel); 338 &channel);
219 if (multi_install_ && add_modifier) { 339 if (multi_install_ && add_modifier) {
220 EXPECT_EQ(L"dev-m", channel); 340 EXPECT_STREQ(L"dev-m", channel.c_str());
221 } else { 341 } else {
222 EXPECT_EQ(install_static::kChromeChannelDev, channel); 342 EXPECT_STREQ(install_static::kChromeChannelDev, channel.c_str());
223 } 343 }
224 SetChannelName(L"2.0-doom"); 344 SetChannelName(L"2.0-doom");
225 install_static::GetChromeChannelName(!system_level_, add_modifier, 345 install_static::GetChromeChannelName(!system_level_, add_modifier,
226 &channel); 346 &channel);
227 if (multi_install_ && add_modifier) { 347 if (multi_install_ && add_modifier) {
228 EXPECT_EQ(L"dev-m", channel); 348 EXPECT_STREQ(L"dev-m", channel.c_str());
229 } else { 349 } else {
230 EXPECT_EQ(install_static::kChromeChannelDev, channel); 350 EXPECT_STREQ(install_static::kChromeChannelDev, channel.c_str());
231 } 351 }
232 SetChannelName(L"250-doom"); 352 SetChannelName(L"250-doom");
233 install_static::GetChromeChannelName(!system_level_, add_modifier, 353 install_static::GetChromeChannelName(!system_level_, add_modifier,
234 &channel); 354 &channel);
235 if (multi_install_ && add_modifier) { 355 if (multi_install_ && add_modifier) {
236 EXPECT_EQ(L"dev-m", channel); 356 EXPECT_STREQ(L"dev-m", channel.c_str());
237 } else { 357 } else {
238 EXPECT_EQ(install_static::kChromeChannelDev, channel); 358 EXPECT_STREQ(install_static::kChromeChannelDev, channel.c_str());
239 } 359 }
240 SetChannelName(L"bar-2.0-dev"); 360 SetChannelName(L"bar-2.0-dev");
241 install_static::GetChromeChannelName(!system_level_, add_modifier, 361 install_static::GetChromeChannelName(!system_level_, add_modifier,
242 &channel); 362 &channel);
243 if (multi_install_ && add_modifier) { 363 if (multi_install_ && add_modifier) {
244 EXPECT_EQ(L"-m", channel); 364 EXPECT_STREQ(L"-m", channel.c_str());
245 } else { 365 } else {
246 EXPECT_EQ(install_static::kChromeChannelStable, channel); 366 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str());
247 } 367 }
248 SetChannelName(L"1.0-dev"); 368 SetChannelName(L"1.0-dev");
249 install_static::GetChromeChannelName(!system_level_, add_modifier, 369 install_static::GetChromeChannelName(!system_level_, add_modifier,
250 &channel); 370 &channel);
251 if (multi_install_ && add_modifier) { 371 if (multi_install_ && add_modifier) {
252 EXPECT_EQ(L"-m", channel); 372 EXPECT_STREQ(L"-m", channel.c_str());
253 } else { 373 } else {
254 EXPECT_EQ(install_static::kChromeChannelStable, channel); 374 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str());
255 } 375 }
256 376
257 SetChannelName(L"x64-beta"); 377 SetChannelName(L"x64-beta");
258 install_static::GetChromeChannelName(!system_level_, add_modifier, 378 install_static::GetChromeChannelName(!system_level_, add_modifier,
259 &channel); 379 &channel);
260 if (multi_install_ && add_modifier) { 380 if (multi_install_ && add_modifier) {
261 EXPECT_EQ(L"beta-m", channel); 381 EXPECT_STREQ(L"beta-m", channel.c_str());
262 } else { 382 } else {
263 EXPECT_EQ(install_static::kChromeChannelBeta, channel); 383 EXPECT_STREQ(install_static::kChromeChannelBeta, channel.c_str());
264 } 384 }
265 SetChannelName(L"bar-x64-beta"); 385 SetChannelName(L"bar-x64-beta");
266 install_static::GetChromeChannelName(!system_level_, add_modifier, 386 install_static::GetChromeChannelName(!system_level_, add_modifier,
267 &channel); 387 &channel);
268 if (multi_install_ && add_modifier) { 388 if (multi_install_ && add_modifier) {
269 EXPECT_EQ(L"beta-m", channel); 389 EXPECT_STREQ(L"beta-m", channel.c_str());
270 } else { 390 } else {
271 EXPECT_EQ(install_static::kChromeChannelBeta, channel); 391 EXPECT_STREQ(install_static::kChromeChannelBeta, channel.c_str());
272 } 392 }
273 SetChannelName(L"x64-Beta"); 393 SetChannelName(L"x64-Beta");
274 install_static::GetChromeChannelName(!system_level_, add_modifier, 394 install_static::GetChromeChannelName(!system_level_, add_modifier,
275 &channel); 395 &channel);
276 if (multi_install_ && add_modifier) { 396 if (multi_install_ && add_modifier) {
277 EXPECT_EQ(L"beta-m", channel); 397 EXPECT_STREQ(L"beta-m", channel.c_str());
278 } else { 398 } else {
279 EXPECT_EQ(install_static::kChromeChannelBeta, channel); 399 EXPECT_STREQ(install_static::kChromeChannelBeta, channel.c_str());
280 } 400 }
281 401
282 SetChannelName(L"x64-stable"); 402 SetChannelName(L"x64-stable");
283 install_static::GetChromeChannelName(!system_level_, add_modifier, 403 install_static::GetChromeChannelName(!system_level_, add_modifier,
284 &channel); 404 &channel);
285 if (multi_install_ && add_modifier) { 405 if (multi_install_ && add_modifier) {
286 EXPECT_EQ(L"-m", channel); 406 EXPECT_STREQ(L"-m", channel.c_str());
287 } else { 407 } else {
288 EXPECT_EQ(install_static::kChromeChannelStable, channel); 408 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str());
289 } 409 }
290 SetChannelName(L"baz-x64-stable"); 410 SetChannelName(L"baz-x64-stable");
291 install_static::GetChromeChannelName(!system_level_, add_modifier, 411 install_static::GetChromeChannelName(!system_level_, add_modifier,
292 &channel); 412 &channel);
293 if (multi_install_ && add_modifier) { 413 if (multi_install_ && add_modifier) {
294 EXPECT_EQ(L"-m", channel); 414 EXPECT_STREQ(L"-m", channel.c_str());
295 } else { 415 } else {
296 EXPECT_EQ(install_static::kChromeChannelStable, channel); 416 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str());
297 } 417 }
298 SetChannelName(L"x64-Stable"); 418 SetChannelName(L"x64-Stable");
299 install_static::GetChromeChannelName(!system_level_, add_modifier, 419 install_static::GetChromeChannelName(!system_level_, add_modifier,
300 &channel); 420 &channel);
301 if (multi_install_ && add_modifier) { 421 if (multi_install_ && add_modifier) {
302 EXPECT_EQ(L"-m", channel); 422 EXPECT_STREQ(L"-m", channel.c_str());
303 } else { 423 } else {
304 EXPECT_EQ(install_static::kChromeChannelStable, channel); 424 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str());
305 } 425 }
306 426
307 SetChannelName(L"fuzzy"); 427 SetChannelName(L"fuzzy");
308 install_static::GetChromeChannelName(!system_level_, add_modifier, 428 install_static::GetChromeChannelName(!system_level_, add_modifier,
309 &channel); 429 &channel);
310 if (multi_install_ && add_modifier) { 430 if (multi_install_ && add_modifier) {
311 EXPECT_EQ(L"-m", channel); 431 EXPECT_STREQ(L"-m", channel.c_str());
312 } else { 432 } else {
313 EXPECT_EQ(install_static::kChromeChannelStable, channel); 433 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str());
314 } 434 }
315 SetChannelName(L"foo"); 435 SetChannelName(L"foo");
316 install_static::GetChromeChannelName(!system_level_, add_modifier, 436 install_static::GetChromeChannelName(!system_level_, add_modifier,
317 &channel); 437 &channel);
318 if (multi_install_ && add_modifier) { 438 if (multi_install_ && add_modifier) {
319 EXPECT_EQ(L"-m", channel); 439 EXPECT_STREQ(L"-m", channel.c_str());
320 } else { 440 } else {
321 EXPECT_EQ(install_static::kChromeChannelStable, channel); 441 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str());
322 } 442 }
323 } 443 }
324 444
325 const wchar_t* app_guid_; 445 const wchar_t* app_guid_;
326 const wchar_t* chrome_path_; 446 const wchar_t* chrome_path_;
327 bool system_level_; 447 bool system_level_;
328 bool multi_install_; 448 bool multi_install_;
329 bool is_canary_; 449 bool is_canary_;
330 registry_util::RegistryOverrideManager override_manager_; 450 registry_util::RegistryOverrideManager override_manager_;
331 }; 451 };
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 EXPECT_FALSE(GetCollectStatsConsentForTesting(kCanaryExePath)); 499 EXPECT_FALSE(GetCollectStatsConsentForTesting(kCanaryExePath));
380 EXPECT_FALSE(GetCollectStatsConsentForTesting(kChromeUserExePath)); 500 EXPECT_FALSE(GetCollectStatsConsentForTesting(kChromeUserExePath));
381 } 501 }
382 502
383 // TODO(ananta) 503 // TODO(ananta)
384 // Move this to install_static_unittests. 504 // Move this to install_static_unittests.
385 // http://crbug.com/604923 505 // http://crbug.com/604923
386 // This test tests the install_static::GetChromeChannelName function and is 506 // This test tests the install_static::GetChromeChannelName function and is
387 // based on the ChannelInfoTest.Channels in channel_info_unittest.cc 507 // based on the ChannelInfoTest.Channels in channel_info_unittest.cc
388 TEST_P(ChromeElfUtilTest, InstallStaticGetChannelNameTest) { 508 TEST_P(ChromeElfUtilTest, InstallStaticGetChannelNameTest) {
389 PerformChannelNameTests(true); // add_modifier 509 PerformChannelNameTests(true); // add_modifier
390 PerformChannelNameTests(false); // !add_modifier 510 PerformChannelNameTests(false); // !add_modifier
391 } 511 }
392 512
393 INSTANTIATE_TEST_CASE_P(Canary, ChromeElfUtilTest, 513 INSTANTIATE_TEST_CASE_P(Canary,
514 ChromeElfUtilTest,
394 testing::Combine(testing::Values("canary"), 515 testing::Combine(testing::Values("canary"),
395 testing::Values("user"), 516 testing::Values("user"),
396 testing::Values("single"))); 517 testing::Values("single")));
397 INSTANTIATE_TEST_CASE_P(GoogleChrome, ChromeElfUtilTest, 518 INSTANTIATE_TEST_CASE_P(GoogleChrome,
519 ChromeElfUtilTest,
398 testing::Combine(testing::Values("google"), 520 testing::Combine(testing::Values("google"),
399 testing::Values("user", "system"), 521 testing::Values("user", "system"),
400 testing::Values("single", "multi"))); 522 testing::Values("single", "multi")));
401 523
402 } // namespace 524 } // namespace
OLDNEW
« no previous file with comments | « chrome_elf/chrome_elf_main.cc ('k') | chrome_elf/hook_util/thunk_getter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698