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