| OLD | NEW |
| 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 Loading... |
| 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 |
| 68 // Create a temp key to play under. |
| 69 ASSERT_TRUE(nt::CreateRegKey(nt::AUTO, elf_sec::kRegSecurityPath, |
| 70 KEY_ALL_ACCESS, &key_handle)); |
| 71 |
| 72 // Exercise the supported getter & setter functions. |
| 73 EXPECT_TRUE(nt::SetRegValueDWORD(key_handle, dword_val_name, dword_val)); |
| 74 EXPECT_TRUE(nt::SetRegValueSZ(key_handle, sz_val_name, sz_val)); |
| 75 EXPECT_TRUE(nt::SetRegValueSZ(key_handle, sz_val_name2, sz_val2)); |
| 76 |
| 77 DWORD get_dword = 0; |
| 78 base::string16 get_sz; |
| 79 EXPECT_TRUE(nt::QueryRegValueDWORD(key_handle, dword_val_name, &get_dword) && |
| 80 get_dword == dword_val); |
| 81 EXPECT_TRUE(nt::QueryRegValueSZ(key_handle, sz_val_name, &get_sz) && |
| 82 get_sz.compare(sz_val) == 0); |
| 83 EXPECT_TRUE(nt::QueryRegValueSZ(key_handle, sz_val_name2, &get_sz) && |
| 84 get_sz.compare(sz_val2) == 0); |
| 85 |
| 86 multisz_val.push_back(multi1); |
| 87 multisz_val.push_back(multi2); |
| 88 multisz_val.push_back(multi3); |
| 89 EXPECT_TRUE( |
| 90 nt::SetRegValueMULTISZ(key_handle, multisz_val_name, multisz_val)); |
| 91 multisz_val.clear(); |
| 92 multisz_val.push_back(multi_empty); |
| 93 EXPECT_TRUE( |
| 94 nt::SetRegValueMULTISZ(key_handle, multisz_val_name2, multisz_val)); |
| 95 multisz_val.clear(); |
| 96 |
| 97 EXPECT_TRUE( |
| 98 nt::QueryRegValueMULTISZ(key_handle, multisz_val_name, &multisz_val)); |
| 99 if (multisz_val.size() == 3) { |
| 100 EXPECT_TRUE(multi1.compare(multisz_val.at(0)) == 0); |
| 101 EXPECT_TRUE(multi2.compare(multisz_val.at(1)) == 0); |
| 102 EXPECT_TRUE(multi3.compare(multisz_val.at(2)) == 0); |
| 103 } else { |
| 104 EXPECT_TRUE(false); |
| 105 } |
| 106 multisz_val.clear(); |
| 107 |
| 108 EXPECT_TRUE( |
| 109 nt::QueryRegValueMULTISZ(key_handle, multisz_val_name2, &multisz_val)); |
| 110 if (multisz_val.size() == 1) { |
| 111 EXPECT_TRUE(multi_empty.compare(multisz_val.at(0)) == 0); |
| 112 } else { |
| 113 EXPECT_TRUE(false); |
| 114 } |
| 115 multisz_val.clear(); |
| 116 |
| 117 // Clean up |
| 118 EXPECT_TRUE(nt::DeleteRegKey(key_handle)); |
| 119 nt::CloseRegKey(key_handle); |
| 120 } |
| 121 |
| 44 // Parameterized test with paramters: | 122 // Parameterized test with paramters: |
| 45 // 1: product: "canary" or "google" | 123 // 1: product: "canary" or "google" |
| 46 // 2: install level: "user" or "system" | 124 // 2: install level: "user" or "system" |
| 47 // 3: install mode: "single" or "multi" | 125 // 3: install mode: "single" or "multi" |
| 48 class ChromeElfUtilTest : | 126 class ChromeElfUtilTest |
| 49 public testing::TestWithParam<std::tuple<const char*, | 127 : public testing::TestWithParam< |
| 50 const char*, | 128 std::tuple<const char*, const char*, const char*>> { |
| 51 const char*> > { | |
| 52 protected: | 129 protected: |
| 53 void SetUp() override { | 130 void SetUp() override { |
| 54 override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE); | 131 override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE, &nt::HKLM_override); |
| 55 override_manager_.OverrideRegistry(HKEY_CURRENT_USER); | 132 override_manager_.OverrideRegistry(HKEY_CURRENT_USER, &nt::HKCU_override); |
| 133 |
| 56 const char* app; | 134 const char* app; |
| 57 const char* level; | 135 const char* level; |
| 58 const char* mode; | 136 const char* mode; |
| 59 std::tie(app, level, mode) = GetParam(); | 137 std::tie(app, level, mode) = GetParam(); |
| 60 is_canary_ = (std::string(app) == "canary"); | 138 is_canary_ = (std::string(app) == "canary"); |
| 61 system_level_ = (std::string(level) != "user"); | 139 system_level_ = (std::string(level) != "user"); |
| 62 multi_install_ = (std::string(mode) != "single"); | 140 multi_install_ = (std::string(mode) != "single"); |
| 63 if (is_canary_) { | 141 if (is_canary_) { |
| 64 ASSERT_FALSE(system_level_); | 142 ASSERT_FALSE(system_level_); |
| 65 ASSERT_FALSE(multi_install_); | 143 ASSERT_FALSE(multi_install_); |
| 66 app_guid_ = kAppGuidCanary; | 144 app_guid_ = kAppGuidCanary; |
| 67 chrome_path_ = kCanaryExePath; | 145 chrome_path_ = kCanaryExePath; |
| 68 } else { | 146 } else { |
| 69 app_guid_ = kAppGuidGoogleChrome; | 147 app_guid_ = kAppGuidGoogleChrome; |
| 70 chrome_path_ = (system_level_ ? kChromeSystemExePath : | 148 chrome_path_ = |
| 71 kChromeUserExePath); | 149 (system_level_ ? kChromeSystemExePath : kChromeUserExePath); |
| 72 } | 150 } |
| 73 if (multi_install_) { | 151 if (multi_install_) { |
| 74 SetMultiInstallStateInRegistry(system_level_, true); | 152 SetMultiInstallStateInRegistry(system_level_, true); |
| 75 app_guid_ = kAppGuidGoogleBinaries; | 153 app_guid_ = kAppGuidGoogleBinaries; |
| 76 } | 154 } |
| 77 } | 155 } |
| 78 | 156 |
| 79 base::string16 BuildKey(const wchar_t* path, const wchar_t* guid) { | 157 base::string16 BuildKey(const wchar_t* path, const wchar_t* guid) { |
| 80 base::string16 full_key_path(path); | 158 base::string16 full_key_path(path); |
| 81 full_key_path.append(1, L'\\'); | 159 full_key_path.append(1, L'\\'); |
| 82 full_key_path.append(guid); | 160 full_key_path.append(guid); |
| 83 return full_key_path; | 161 return full_key_path; |
| 84 } | 162 } |
| 85 | 163 |
| 86 void SetUsageStat(DWORD value, bool state_medium) { | 164 void SetUsageStat(DWORD value, bool state_medium) { |
| 87 LONG result = base::win::RegKey( | 165 LONG result = base::win::RegKey( |
| 88 system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, | 166 system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, |
| 89 BuildKey(state_medium ? kRegPathClientStateMedium : kRegPathClientState, | 167 BuildKey(state_medium ? kRegPathClientStateMedium |
| 90 app_guid_).c_str(), | 168 : kRegPathClientState, |
| 91 KEY_SET_VALUE).WriteValue(kRegValueUsageStats, value); | 169 app_guid_) |
| 170 .c_str(), |
| 171 KEY_SET_VALUE) |
| 172 .WriteValue(kRegValueUsageStats, value); |
| 92 ASSERT_EQ(ERROR_SUCCESS, result); | 173 ASSERT_EQ(ERROR_SUCCESS, result); |
| 93 } | 174 } |
| 94 | 175 |
| 95 void SetMultiInstallStateInRegistry(bool system_install, bool multi) { | 176 void SetMultiInstallStateInRegistry(bool system_install, bool multi) { |
| 96 base::win::RegKey key( | 177 base::win::RegKey key( |
| 97 system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, | 178 system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, |
| 98 BuildKey(kRegPathClientState, kAppGuidGoogleChrome).c_str(), | 179 BuildKey(kRegPathClientState, kAppGuidGoogleChrome).c_str(), |
| 99 KEY_SET_VALUE); | 180 KEY_SET_VALUE); |
| 100 LONG result; | 181 LONG result; |
| 101 if (multi) { | 182 if (multi) { |
| 102 result = key.WriteValue(kUninstallArgumentsField, | 183 result = key.WriteValue(kUninstallArgumentsField, |
| 103 L"yadda yadda --multi-install yadda yadda"); | 184 L"yadda yadda --multi-install yadda yadda"); |
| 104 } else { | 185 } else { |
| 105 result = key.DeleteValue(kUninstallArgumentsField); | 186 result = key.DeleteValue(kUninstallArgumentsField); |
| 106 } | 187 } |
| 107 ASSERT_EQ(ERROR_SUCCESS, result); | 188 ASSERT_EQ(ERROR_SUCCESS, result); |
| 108 } | 189 } |
| 109 | 190 |
| 110 void SetChannelName(const base::string16& channel_name) { | 191 void SetChannelName(const base::string16& channel_name) { |
| 111 LONG result = base::win::RegKey( | 192 LONG result = |
| 112 system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, | 193 base::win::RegKey( |
| 113 BuildKey(kRegPathClientState, app_guid_).c_str(), | 194 system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, |
| 114 KEY_SET_VALUE).WriteValue(kRegApField, channel_name.c_str()); | 195 BuildKey(kRegPathClientState, app_guid_).c_str(), KEY_SET_VALUE) |
| 196 .WriteValue(kRegApField, channel_name.c_str()); |
| 115 ASSERT_EQ(ERROR_SUCCESS, result); | 197 ASSERT_EQ(ERROR_SUCCESS, result); |
| 116 } | 198 } |
| 117 | 199 |
| 118 // This function tests the install_static::GetChromeChannelName function and | 200 // This function tests the install_static::GetChromeChannelName function and |
| 119 // is based on the ChannelInfoTest.Channels in channel_info_unittest.cc. | 201 // is based on the ChannelInfoTest.Channels in channel_info_unittest.cc. |
| 120 // The |add_modifier| parameter controls whether we expect modifiers in the | 202 // The |add_modifier| parameter controls whether we expect modifiers in the |
| 121 // returned channel name. | 203 // returned channel name. |
| 122 void PerformChannelNameTests(bool add_modifier) { | 204 void PerformChannelNameTests(bool add_modifier) { |
| 123 // We can't test the channel name correctly for canary mode because the | 205 // 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 | 206 // install_static checks whether an exe is a canary executable is based on |
| 125 // the path where the exe is running from. | 207 // the path where the exe is running from. |
| 126 if (is_canary_) | 208 if (is_canary_) |
| 127 return; | 209 return; |
| 128 SetChannelName(L""); | 210 SetChannelName(L""); |
| 129 base::string16 channel; | 211 base::string16 channel; |
| 130 install_static::GetChromeChannelName(!system_level_, add_modifier, | 212 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 131 &channel); | 213 &channel); |
| 132 if (multi_install_ && add_modifier) { | 214 if (multi_install_ && add_modifier) { |
| 133 EXPECT_EQ(L"-m", channel); | 215 EXPECT_STREQ(L"-m", channel.c_str()); |
| 134 } else { | 216 } else { |
| 135 EXPECT_EQ(install_static::kChromeChannelStable, channel); | 217 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str()); |
| 136 } | 218 } |
| 137 | 219 |
| 138 SetChannelName(L"-full"); | 220 SetChannelName(L"-full"); |
| 139 install_static::GetChromeChannelName(!system_level_, add_modifier, | 221 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 140 &channel); | 222 &channel); |
| 141 if (multi_install_ && add_modifier) { | 223 if (multi_install_ && add_modifier) { |
| 142 EXPECT_EQ(L"-m", channel); | 224 EXPECT_STREQ(L"-m", channel.c_str()); |
| 143 } else { | 225 } else { |
| 144 EXPECT_EQ(install_static::kChromeChannelStable, channel); | 226 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str()); |
| 145 } | 227 } |
| 146 | 228 |
| 147 SetChannelName(L"1.1-beta"); | 229 SetChannelName(L"1.1-beta"); |
| 148 install_static::GetChromeChannelName(!system_level_, add_modifier, | 230 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 149 &channel); | 231 &channel); |
| 150 if (multi_install_ && add_modifier) { | 232 if (multi_install_ && add_modifier) { |
| 151 EXPECT_EQ(L"beta-m", channel); | 233 EXPECT_STREQ(L"beta-m", channel.c_str()); |
| 152 } else { | 234 } else { |
| 153 EXPECT_EQ(install_static::kChromeChannelBeta, channel); | 235 EXPECT_STREQ(install_static::kChromeChannelBeta, channel.c_str()); |
| 154 } | 236 } |
| 155 | 237 |
| 156 SetChannelName(L"1.1-beta"); | 238 SetChannelName(L"1.1-beta"); |
| 157 install_static::GetChromeChannelName(!system_level_, add_modifier, | 239 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 158 &channel); | 240 &channel); |
| 159 if (multi_install_ && add_modifier) { | 241 if (multi_install_ && add_modifier) { |
| 160 EXPECT_EQ(L"beta-m", channel); | 242 EXPECT_STREQ(L"beta-m", channel.c_str()); |
| 161 } else { | 243 } else { |
| 162 EXPECT_EQ(install_static::kChromeChannelBeta, channel); | 244 EXPECT_STREQ(install_static::kChromeChannelBeta, channel.c_str()); |
| 163 } | 245 } |
| 164 | 246 |
| 165 SetChannelName(L"1.1-bar"); | 247 SetChannelName(L"1.1-bar"); |
| 166 install_static::GetChromeChannelName(!system_level_, add_modifier, | 248 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 167 &channel); | 249 &channel); |
| 168 if (multi_install_ && add_modifier) { | 250 if (multi_install_ && add_modifier) { |
| 169 EXPECT_EQ(L"beta-m", channel); | 251 EXPECT_STREQ(L"beta-m", channel.c_str()); |
| 170 } else { | 252 } else { |
| 171 EXPECT_EQ(install_static::kChromeChannelBeta, channel); | 253 EXPECT_STREQ(install_static::kChromeChannelBeta, channel.c_str()); |
| 172 } | 254 } |
| 173 | 255 |
| 174 SetChannelName(L"1n1-foobar"); | 256 SetChannelName(L"1n1-foobar"); |
| 175 install_static::GetChromeChannelName(!system_level_, add_modifier, | 257 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 176 &channel); | 258 &channel); |
| 177 if (multi_install_ && add_modifier) { | 259 if (multi_install_ && add_modifier) { |
| 178 EXPECT_EQ(L"beta-m", channel); | 260 EXPECT_STREQ(L"beta-m", channel.c_str()); |
| 179 } else { | 261 } else { |
| 180 EXPECT_EQ(install_static::kChromeChannelBeta, channel); | 262 EXPECT_STREQ(install_static::kChromeChannelBeta, channel.c_str()); |
| 181 } | 263 } |
| 182 | 264 |
| 183 SetChannelName(L"foo-1.1-beta"); | 265 SetChannelName(L"foo-1.1-beta"); |
| 184 install_static::GetChromeChannelName(!system_level_, add_modifier, | 266 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 185 &channel); | 267 &channel); |
| 186 if (multi_install_ && add_modifier) { | 268 if (multi_install_ && add_modifier) { |
| 187 EXPECT_EQ(L"-m", channel); | 269 EXPECT_STREQ(L"-m", channel.c_str()); |
| 188 } else { | 270 } else { |
| 189 EXPECT_EQ(install_static::kChromeChannelStable, channel); | 271 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str()); |
| 190 } | 272 } |
| 191 SetChannelName(L"2.0-beta"); | 273 SetChannelName(L"2.0-beta"); |
| 192 install_static::GetChromeChannelName(!system_level_, add_modifier, | 274 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 193 &channel); | 275 &channel); |
| 194 if (multi_install_ && add_modifier) { | 276 if (multi_install_ && add_modifier) { |
| 195 EXPECT_EQ(L"-m", channel); | 277 EXPECT_STREQ(L"-m", channel.c_str()); |
| 196 } else { | 278 } else { |
| 197 EXPECT_EQ(install_static::kChromeChannelStable, channel); | 279 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str()); |
| 198 } | 280 } |
| 199 | 281 |
| 200 SetChannelName(L"2.0-dev"); | 282 SetChannelName(L"2.0-dev"); |
| 201 install_static::GetChromeChannelName(!system_level_, add_modifier, | 283 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 202 &channel); | 284 &channel); |
| 203 if (multi_install_ && add_modifier) { | 285 if (multi_install_ && add_modifier) { |
| 204 EXPECT_EQ(L"dev-m", channel); | 286 EXPECT_STREQ(L"dev-m", channel.c_str()); |
| 205 } else { | 287 } else { |
| 206 EXPECT_EQ(install_static::kChromeChannelDev, channel); | 288 EXPECT_STREQ(install_static::kChromeChannelDev, channel.c_str()); |
| 207 } | 289 } |
| 208 SetChannelName(L"2.0-DEV"); | 290 SetChannelName(L"2.0-DEV"); |
| 209 install_static::GetChromeChannelName(!system_level_, add_modifier, | 291 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 210 &channel); | 292 &channel); |
| 211 if (multi_install_ && add_modifier) { | 293 if (multi_install_ && add_modifier) { |
| 212 EXPECT_EQ(L"dev-m", channel); | 294 EXPECT_STREQ(L"dev-m", channel.c_str()); |
| 213 } else { | 295 } else { |
| 214 EXPECT_EQ(install_static::kChromeChannelDev, channel); | 296 EXPECT_STREQ(install_static::kChromeChannelDev, channel.c_str()); |
| 215 } | 297 } |
| 216 SetChannelName(L"2.0-dev-eloper"); | 298 SetChannelName(L"2.0-dev-eloper"); |
| 217 install_static::GetChromeChannelName(!system_level_, add_modifier, | 299 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 218 &channel); | 300 &channel); |
| 219 if (multi_install_ && add_modifier) { | 301 if (multi_install_ && add_modifier) { |
| 220 EXPECT_EQ(L"dev-m", channel); | 302 EXPECT_STREQ(L"dev-m", channel.c_str()); |
| 221 } else { | 303 } else { |
| 222 EXPECT_EQ(install_static::kChromeChannelDev, channel); | 304 EXPECT_STREQ(install_static::kChromeChannelDev, channel.c_str()); |
| 223 } | 305 } |
| 224 SetChannelName(L"2.0-doom"); | 306 SetChannelName(L"2.0-doom"); |
| 225 install_static::GetChromeChannelName(!system_level_, add_modifier, | 307 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 226 &channel); | 308 &channel); |
| 227 if (multi_install_ && add_modifier) { | 309 if (multi_install_ && add_modifier) { |
| 228 EXPECT_EQ(L"dev-m", channel); | 310 EXPECT_STREQ(L"dev-m", channel.c_str()); |
| 229 } else { | 311 } else { |
| 230 EXPECT_EQ(install_static::kChromeChannelDev, channel); | 312 EXPECT_STREQ(install_static::kChromeChannelDev, channel.c_str()); |
| 231 } | 313 } |
| 232 SetChannelName(L"250-doom"); | 314 SetChannelName(L"250-doom"); |
| 233 install_static::GetChromeChannelName(!system_level_, add_modifier, | 315 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 234 &channel); | 316 &channel); |
| 235 if (multi_install_ && add_modifier) { | 317 if (multi_install_ && add_modifier) { |
| 236 EXPECT_EQ(L"dev-m", channel); | 318 EXPECT_STREQ(L"dev-m", channel.c_str()); |
| 237 } else { | 319 } else { |
| 238 EXPECT_EQ(install_static::kChromeChannelDev, channel); | 320 EXPECT_STREQ(install_static::kChromeChannelDev, channel.c_str()); |
| 239 } | 321 } |
| 240 SetChannelName(L"bar-2.0-dev"); | 322 SetChannelName(L"bar-2.0-dev"); |
| 241 install_static::GetChromeChannelName(!system_level_, add_modifier, | 323 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 242 &channel); | 324 &channel); |
| 243 if (multi_install_ && add_modifier) { | 325 if (multi_install_ && add_modifier) { |
| 244 EXPECT_EQ(L"-m", channel); | 326 EXPECT_STREQ(L"-m", channel.c_str()); |
| 245 } else { | 327 } else { |
| 246 EXPECT_EQ(install_static::kChromeChannelStable, channel); | 328 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str()); |
| 247 } | 329 } |
| 248 SetChannelName(L"1.0-dev"); | 330 SetChannelName(L"1.0-dev"); |
| 249 install_static::GetChromeChannelName(!system_level_, add_modifier, | 331 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 250 &channel); | 332 &channel); |
| 251 if (multi_install_ && add_modifier) { | 333 if (multi_install_ && add_modifier) { |
| 252 EXPECT_EQ(L"-m", channel); | 334 EXPECT_STREQ(L"-m", channel.c_str()); |
| 253 } else { | 335 } else { |
| 254 EXPECT_EQ(install_static::kChromeChannelStable, channel); | 336 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str()); |
| 255 } | 337 } |
| 256 | 338 |
| 257 SetChannelName(L"x64-beta"); | 339 SetChannelName(L"x64-beta"); |
| 258 install_static::GetChromeChannelName(!system_level_, add_modifier, | 340 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 259 &channel); | 341 &channel); |
| 260 if (multi_install_ && add_modifier) { | 342 if (multi_install_ && add_modifier) { |
| 261 EXPECT_EQ(L"beta-m", channel); | 343 EXPECT_STREQ(L"beta-m", channel.c_str()); |
| 262 } else { | 344 } else { |
| 263 EXPECT_EQ(install_static::kChromeChannelBeta, channel); | 345 EXPECT_STREQ(install_static::kChromeChannelBeta, channel.c_str()); |
| 264 } | 346 } |
| 265 SetChannelName(L"bar-x64-beta"); | 347 SetChannelName(L"bar-x64-beta"); |
| 266 install_static::GetChromeChannelName(!system_level_, add_modifier, | 348 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 267 &channel); | 349 &channel); |
| 268 if (multi_install_ && add_modifier) { | 350 if (multi_install_ && add_modifier) { |
| 269 EXPECT_EQ(L"beta-m", channel); | 351 EXPECT_STREQ(L"beta-m", channel.c_str()); |
| 270 } else { | 352 } else { |
| 271 EXPECT_EQ(install_static::kChromeChannelBeta, channel); | 353 EXPECT_STREQ(install_static::kChromeChannelBeta, channel.c_str()); |
| 272 } | 354 } |
| 273 SetChannelName(L"x64-Beta"); | 355 SetChannelName(L"x64-Beta"); |
| 274 install_static::GetChromeChannelName(!system_level_, add_modifier, | 356 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 275 &channel); | 357 &channel); |
| 276 if (multi_install_ && add_modifier) { | 358 if (multi_install_ && add_modifier) { |
| 277 EXPECT_EQ(L"beta-m", channel); | 359 EXPECT_STREQ(L"beta-m", channel.c_str()); |
| 278 } else { | 360 } else { |
| 279 EXPECT_EQ(install_static::kChromeChannelBeta, channel); | 361 EXPECT_STREQ(install_static::kChromeChannelBeta, channel.c_str()); |
| 280 } | 362 } |
| 281 | 363 |
| 282 SetChannelName(L"x64-stable"); | 364 SetChannelName(L"x64-stable"); |
| 283 install_static::GetChromeChannelName(!system_level_, add_modifier, | 365 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 284 &channel); | 366 &channel); |
| 285 if (multi_install_ && add_modifier) { | 367 if (multi_install_ && add_modifier) { |
| 286 EXPECT_EQ(L"-m", channel); | 368 EXPECT_STREQ(L"-m", channel.c_str()); |
| 287 } else { | 369 } else { |
| 288 EXPECT_EQ(install_static::kChromeChannelStable, channel); | 370 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str()); |
| 289 } | 371 } |
| 290 SetChannelName(L"baz-x64-stable"); | 372 SetChannelName(L"baz-x64-stable"); |
| 291 install_static::GetChromeChannelName(!system_level_, add_modifier, | 373 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 292 &channel); | 374 &channel); |
| 293 if (multi_install_ && add_modifier) { | 375 if (multi_install_ && add_modifier) { |
| 294 EXPECT_EQ(L"-m", channel); | 376 EXPECT_STREQ(L"-m", channel.c_str()); |
| 295 } else { | 377 } else { |
| 296 EXPECT_EQ(install_static::kChromeChannelStable, channel); | 378 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str()); |
| 297 } | 379 } |
| 298 SetChannelName(L"x64-Stable"); | 380 SetChannelName(L"x64-Stable"); |
| 299 install_static::GetChromeChannelName(!system_level_, add_modifier, | 381 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 300 &channel); | 382 &channel); |
| 301 if (multi_install_ && add_modifier) { | 383 if (multi_install_ && add_modifier) { |
| 302 EXPECT_EQ(L"-m", channel); | 384 EXPECT_STREQ(L"-m", channel.c_str()); |
| 303 } else { | 385 } else { |
| 304 EXPECT_EQ(install_static::kChromeChannelStable, channel); | 386 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str()); |
| 305 } | 387 } |
| 306 | 388 |
| 307 SetChannelName(L"fuzzy"); | 389 SetChannelName(L"fuzzy"); |
| 308 install_static::GetChromeChannelName(!system_level_, add_modifier, | 390 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 309 &channel); | 391 &channel); |
| 310 if (multi_install_ && add_modifier) { | 392 if (multi_install_ && add_modifier) { |
| 311 EXPECT_EQ(L"-m", channel); | 393 EXPECT_STREQ(L"-m", channel.c_str()); |
| 312 } else { | 394 } else { |
| 313 EXPECT_EQ(install_static::kChromeChannelStable, channel); | 395 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str()); |
| 314 } | 396 } |
| 315 SetChannelName(L"foo"); | 397 SetChannelName(L"foo"); |
| 316 install_static::GetChromeChannelName(!system_level_, add_modifier, | 398 install_static::GetChromeChannelName(!system_level_, add_modifier, |
| 317 &channel); | 399 &channel); |
| 318 if (multi_install_ && add_modifier) { | 400 if (multi_install_ && add_modifier) { |
| 319 EXPECT_EQ(L"-m", channel); | 401 EXPECT_STREQ(L"-m", channel.c_str()); |
| 320 } else { | 402 } else { |
| 321 EXPECT_EQ(install_static::kChromeChannelStable, channel); | 403 EXPECT_STREQ(install_static::kChromeChannelStable, channel.c_str()); |
| 322 } | 404 } |
| 323 } | 405 } |
| 324 | 406 |
| 325 const wchar_t* app_guid_; | 407 const wchar_t* app_guid_; |
| 326 const wchar_t* chrome_path_; | 408 const wchar_t* chrome_path_; |
| 327 bool system_level_; | 409 bool system_level_; |
| 328 bool multi_install_; | 410 bool multi_install_; |
| 329 bool is_canary_; | 411 bool is_canary_; |
| 330 registry_util::RegistryOverrideManager override_manager_; | 412 registry_util::RegistryOverrideManager override_manager_; |
| 331 }; | 413 }; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 EXPECT_FALSE(GetCollectStatsConsentForTesting(kCanaryExePath)); | 461 EXPECT_FALSE(GetCollectStatsConsentForTesting(kCanaryExePath)); |
| 380 EXPECT_FALSE(GetCollectStatsConsentForTesting(kChromeUserExePath)); | 462 EXPECT_FALSE(GetCollectStatsConsentForTesting(kChromeUserExePath)); |
| 381 } | 463 } |
| 382 | 464 |
| 383 // TODO(ananta) | 465 // TODO(ananta) |
| 384 // Move this to install_static_unittests. | 466 // Move this to install_static_unittests. |
| 385 // http://crbug.com/604923 | 467 // http://crbug.com/604923 |
| 386 // This test tests the install_static::GetChromeChannelName function and is | 468 // This test tests the install_static::GetChromeChannelName function and is |
| 387 // based on the ChannelInfoTest.Channels in channel_info_unittest.cc | 469 // based on the ChannelInfoTest.Channels in channel_info_unittest.cc |
| 388 TEST_P(ChromeElfUtilTest, InstallStaticGetChannelNameTest) { | 470 TEST_P(ChromeElfUtilTest, InstallStaticGetChannelNameTest) { |
| 389 PerformChannelNameTests(true); // add_modifier | 471 PerformChannelNameTests(true); // add_modifier |
| 390 PerformChannelNameTests(false); // !add_modifier | 472 PerformChannelNameTests(false); // !add_modifier |
| 391 } | 473 } |
| 392 | 474 |
| 393 INSTANTIATE_TEST_CASE_P(Canary, ChromeElfUtilTest, | 475 INSTANTIATE_TEST_CASE_P(Canary, |
| 476 ChromeElfUtilTest, |
| 394 testing::Combine(testing::Values("canary"), | 477 testing::Combine(testing::Values("canary"), |
| 395 testing::Values("user"), | 478 testing::Values("user"), |
| 396 testing::Values("single"))); | 479 testing::Values("single"))); |
| 397 INSTANTIATE_TEST_CASE_P(GoogleChrome, ChromeElfUtilTest, | 480 INSTANTIATE_TEST_CASE_P(GoogleChrome, |
| 481 ChromeElfUtilTest, |
| 398 testing::Combine(testing::Values("google"), | 482 testing::Combine(testing::Values("google"), |
| 399 testing::Values("user", "system"), | 483 testing::Values("user", "system"), |
| 400 testing::Values("single", "multi"))); | 484 testing::Values("single", "multi"))); |
| 401 | 485 |
| 402 } // namespace | 486 } // namespace |
| OLD | NEW |