| OLD | NEW |
| 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/shell_util.h" | 5 #include "chrome/installer/util/shell_util.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/base_paths_win.h" | 10 #include "base/base_paths_win.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 fake_start_menu_.path() : fake_common_start_menu_.path(); | 106 fake_start_menu_.path() : fake_common_start_menu_.path(); |
| 107 expected_path = expected_path.Append( | 107 expected_path = expected_path.Append( |
| 108 dist_->GetStartMenuShortcutSubfolder( | 108 dist_->GetStartMenuShortcutSubfolder( |
| 109 BrowserDistribution::SUBFOLDER_CHROME)); | 109 BrowserDistribution::SUBFOLDER_CHROME)); |
| 110 break; | 110 break; |
| 111 default: | 111 default: |
| 112 ADD_FAILURE() << "Unknown location"; | 112 ADD_FAILURE() << "Unknown location"; |
| 113 return; | 113 return; |
| 114 } | 114 } |
| 115 | 115 |
| 116 string16 shortcut_name; | 116 base::string16 shortcut_name; |
| 117 if (properties.has_shortcut_name()) { | 117 if (properties.has_shortcut_name()) { |
| 118 shortcut_name = properties.shortcut_name; | 118 shortcut_name = properties.shortcut_name; |
| 119 } else { | 119 } else { |
| 120 shortcut_name = | 120 shortcut_name = |
| 121 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME); | 121 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME); |
| 122 } | 122 } |
| 123 shortcut_name.append(installer::kLnkExt); | 123 shortcut_name.append(installer::kLnkExt); |
| 124 expected_path = expected_path.Append(shortcut_name); | 124 expected_path = expected_path.Append(shortcut_name); |
| 125 | 125 |
| 126 base::win::ShortcutProperties expected_properties; | 126 base::win::ShortcutProperties expected_properties; |
| 127 if (properties.has_target()) { | 127 if (properties.has_target()) { |
| 128 expected_properties.set_target(properties.target); | 128 expected_properties.set_target(properties.target); |
| 129 expected_properties.set_working_dir(properties.target.DirName()); | 129 expected_properties.set_working_dir(properties.target.DirName()); |
| 130 } else { | 130 } else { |
| 131 expected_properties.set_target(chrome_exe_); | 131 expected_properties.set_target(chrome_exe_); |
| 132 expected_properties.set_working_dir(chrome_exe_.DirName()); | 132 expected_properties.set_working_dir(chrome_exe_.DirName()); |
| 133 } | 133 } |
| 134 | 134 |
| 135 if (properties.has_arguments()) | 135 if (properties.has_arguments()) |
| 136 expected_properties.set_arguments(properties.arguments); | 136 expected_properties.set_arguments(properties.arguments); |
| 137 else | 137 else |
| 138 expected_properties.set_arguments(string16()); | 138 expected_properties.set_arguments(base::string16()); |
| 139 | 139 |
| 140 if (properties.has_description()) | 140 if (properties.has_description()) |
| 141 expected_properties.set_description(properties.description); | 141 expected_properties.set_description(properties.description); |
| 142 else | 142 else |
| 143 expected_properties.set_description(dist->GetAppDescription()); | 143 expected_properties.set_description(dist->GetAppDescription()); |
| 144 | 144 |
| 145 if (properties.has_icon()) { | 145 if (properties.has_icon()) { |
| 146 expected_properties.set_icon(properties.icon, 0); | 146 expected_properties.set_icon(properties.icon, 0); |
| 147 } else { | 147 } else { |
| 148 int icon_index = dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME); | 148 int icon_index = dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 EXPECT_EQ(fake_user_desktop_.path(), path); | 197 EXPECT_EQ(fake_user_desktop_.path(), path); |
| 198 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 198 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 199 ShellUtil::SYSTEM_LEVEL, &path); | 199 ShellUtil::SYSTEM_LEVEL, &path); |
| 200 EXPECT_EQ(fake_common_desktop_.path(), path); | 200 EXPECT_EQ(fake_common_desktop_.path(), path); |
| 201 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist_, | 201 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist_, |
| 202 ShellUtil::CURRENT_USER, &path); | 202 ShellUtil::CURRENT_USER, &path); |
| 203 EXPECT_EQ(fake_user_quick_launch_.path(), path); | 203 EXPECT_EQ(fake_user_quick_launch_.path(), path); |
| 204 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist_, | 204 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist_, |
| 205 ShellUtil::SYSTEM_LEVEL, &path); | 205 ShellUtil::SYSTEM_LEVEL, &path); |
| 206 EXPECT_EQ(fake_default_user_quick_launch_.path(), path); | 206 EXPECT_EQ(fake_default_user_quick_launch_.path(), path); |
| 207 string16 start_menu_subfolder = | 207 base::string16 start_menu_subfolder = |
| 208 dist_->GetStartMenuShortcutSubfolder( | 208 dist_->GetStartMenuShortcutSubfolder( |
| 209 BrowserDistribution::SUBFOLDER_CHROME); | 209 BrowserDistribution::SUBFOLDER_CHROME); |
| 210 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR, | 210 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR, |
| 211 dist_, ShellUtil::CURRENT_USER, &path); | 211 dist_, ShellUtil::CURRENT_USER, &path); |
| 212 EXPECT_EQ(fake_start_menu_.path().Append(start_menu_subfolder), | 212 EXPECT_EQ(fake_start_menu_.path().Append(start_menu_subfolder), |
| 213 path); | 213 path); |
| 214 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR, | 214 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR, |
| 215 dist_, ShellUtil::SYSTEM_LEVEL, &path); | 215 dist_, ShellUtil::SYSTEM_LEVEL, &path); |
| 216 EXPECT_EQ(fake_common_start_menu_.path().Append(start_menu_subfolder), | 216 EXPECT_EQ(fake_common_start_menu_.path().Append(start_menu_subfolder), |
| 217 path); | 217 path); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 309 |
| 310 TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevel) { | 310 TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevel) { |
| 311 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 311 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 312 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 312 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 313 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL)); | 313 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL)); |
| 314 ValidateChromeShortcut(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 314 ValidateChromeShortcut(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 315 test_properties_); | 315 test_properties_); |
| 316 } | 316 } |
| 317 | 317 |
| 318 TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevelWithSystemLevelPresent) { | 318 TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevelWithSystemLevelPresent) { |
| 319 string16 shortcut_name( | 319 base::string16 shortcut_name( |
| 320 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + | 320 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + |
| 321 installer::kLnkExt); | 321 installer::kLnkExt); |
| 322 | 322 |
| 323 test_properties_.level = ShellUtil::SYSTEM_LEVEL; | 323 test_properties_.level = ShellUtil::SYSTEM_LEVEL; |
| 324 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 324 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 325 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 325 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 326 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 326 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 327 ASSERT_TRUE(base::PathExists( | 327 ASSERT_TRUE(base::PathExists( |
| 328 fake_common_desktop_.path().Append(shortcut_name))); | 328 fake_common_desktop_.path().Append(shortcut_name))); |
| 329 | 329 |
| 330 test_properties_.level = ShellUtil::CURRENT_USER; | 330 test_properties_.level = ShellUtil::CURRENT_USER; |
| 331 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 331 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 332 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 332 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 333 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL)); | 333 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL)); |
| 334 ASSERT_FALSE(base::PathExists( | 334 ASSERT_FALSE(base::PathExists( |
| 335 fake_user_desktop_.path().Append(shortcut_name))); | 335 fake_user_desktop_.path().Append(shortcut_name))); |
| 336 } | 336 } |
| 337 | 337 |
| 338 TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevelStartMenu) { | 338 TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevelStartMenu) { |
| 339 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 339 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 340 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR, | 340 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR, |
| 341 dist_, test_properties_, | 341 dist_, test_properties_, |
| 342 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL)); | 342 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL)); |
| 343 ValidateChromeShortcut(ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR, | 343 ValidateChromeShortcut(ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR, |
| 344 dist_, test_properties_); | 344 dist_, test_properties_); |
| 345 } | 345 } |
| 346 | 346 |
| 347 TEST_F(ShellUtilShortcutTest, CreateAlwaysUserWithSystemLevelPresent) { | 347 TEST_F(ShellUtilShortcutTest, CreateAlwaysUserWithSystemLevelPresent) { |
| 348 string16 shortcut_name( | 348 base::string16 shortcut_name( |
| 349 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + | 349 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + |
| 350 installer::kLnkExt); | 350 installer::kLnkExt); |
| 351 | 351 |
| 352 test_properties_.level = ShellUtil::SYSTEM_LEVEL; | 352 test_properties_.level = ShellUtil::SYSTEM_LEVEL; |
| 353 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 353 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 354 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 354 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 355 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 355 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 356 ASSERT_TRUE(base::PathExists( | 356 ASSERT_TRUE(base::PathExists( |
| 357 fake_common_desktop_.path().Append(shortcut_name))); | 357 fake_common_desktop_.path().Append(shortcut_name))); |
| 358 | 358 |
| 359 test_properties_.level = ShellUtil::CURRENT_USER; | 359 test_properties_.level = ShellUtil::CURRENT_USER; |
| 360 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 360 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 361 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 361 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 362 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 362 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 363 ASSERT_TRUE(base::PathExists( | 363 ASSERT_TRUE(base::PathExists( |
| 364 fake_user_desktop_.path().Append(shortcut_name))); | 364 fake_user_desktop_.path().Append(shortcut_name))); |
| 365 } | 365 } |
| 366 | 366 |
| 367 TEST_F(ShellUtilShortcutTest, RemoveChromeShortcut) { | 367 TEST_F(ShellUtilShortcutTest, RemoveChromeShortcut) { |
| 368 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 368 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 369 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 369 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 370 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 370 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 371 | 371 |
| 372 string16 shortcut_name( | 372 base::string16 shortcut_name( |
| 373 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + | 373 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + |
| 374 installer::kLnkExt); | 374 installer::kLnkExt); |
| 375 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); | 375 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); |
| 376 ASSERT_TRUE(base::PathExists(shortcut_path)); | 376 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 377 | 377 |
| 378 ASSERT_TRUE(ShellUtil::RemoveShortcuts( | 378 ASSERT_TRUE(ShellUtil::RemoveShortcuts( |
| 379 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, | 379 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, |
| 380 chrome_exe_)); | 380 chrome_exe_)); |
| 381 ASSERT_FALSE(base::PathExists(shortcut_path)); | 381 ASSERT_FALSE(base::PathExists(shortcut_path)); |
| 382 ASSERT_TRUE(base::PathExists(shortcut_path.DirName())); | 382 ASSERT_TRUE(base::PathExists(shortcut_path.DirName())); |
| 383 } | 383 } |
| 384 | 384 |
| 385 TEST_F(ShellUtilShortcutTest, RemoveSystemLevelChromeShortcut) { | 385 TEST_F(ShellUtilShortcutTest, RemoveSystemLevelChromeShortcut) { |
| 386 test_properties_.level = ShellUtil::SYSTEM_LEVEL; | 386 test_properties_.level = ShellUtil::SYSTEM_LEVEL; |
| 387 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 387 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 388 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 388 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 389 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 389 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 390 | 390 |
| 391 string16 shortcut_name( | 391 base::string16 shortcut_name( |
| 392 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + | 392 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + |
| 393 installer::kLnkExt); | 393 installer::kLnkExt); |
| 394 base::FilePath shortcut_path( | 394 base::FilePath shortcut_path( |
| 395 fake_common_desktop_.path().Append(shortcut_name)); | 395 fake_common_desktop_.path().Append(shortcut_name)); |
| 396 ASSERT_TRUE(base::PathExists(shortcut_path)); | 396 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 397 | 397 |
| 398 ASSERT_TRUE(ShellUtil::RemoveShortcuts( | 398 ASSERT_TRUE(ShellUtil::RemoveShortcuts( |
| 399 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::SYSTEM_LEVEL, | 399 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::SYSTEM_LEVEL, |
| 400 chrome_exe_)); | 400 chrome_exe_)); |
| 401 ASSERT_FALSE(base::PathExists(shortcut_path)); | 401 ASSERT_FALSE(base::PathExists(shortcut_path)); |
| 402 ASSERT_TRUE(base::PathExists(shortcut_path.DirName())); | 402 ASSERT_TRUE(base::PathExists(shortcut_path.DirName())); |
| 403 } | 403 } |
| 404 | 404 |
| 405 TEST_F(ShellUtilShortcutTest, RemoveMultipleChromeShortcuts) { | 405 TEST_F(ShellUtilShortcutTest, RemoveMultipleChromeShortcuts) { |
| 406 const wchar_t kShortcutName1[] = L"Chrome 1"; | 406 const wchar_t kShortcutName1[] = L"Chrome 1"; |
| 407 const wchar_t kShortcutName2[] = L"Chrome 2"; | 407 const wchar_t kShortcutName2[] = L"Chrome 2"; |
| 408 | 408 |
| 409 test_properties_.set_shortcut_name(kShortcutName1); | 409 test_properties_.set_shortcut_name(kShortcutName1); |
| 410 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 410 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 411 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 411 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 412 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 412 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 413 string16 shortcut1_name( | 413 base::string16 shortcut1_name( |
| 414 string16(kShortcutName1).append(installer::kLnkExt)); | 414 base::string16(kShortcutName1).append(installer::kLnkExt)); |
| 415 base::FilePath shortcut1_path( | 415 base::FilePath shortcut1_path( |
| 416 fake_user_desktop_.path().Append(shortcut1_name)); | 416 fake_user_desktop_.path().Append(shortcut1_name)); |
| 417 ASSERT_TRUE(base::PathExists(shortcut1_path)); | 417 ASSERT_TRUE(base::PathExists(shortcut1_path)); |
| 418 | 418 |
| 419 test_properties_.set_shortcut_name(kShortcutName2); | 419 test_properties_.set_shortcut_name(kShortcutName2); |
| 420 test_properties_.set_arguments(L"--profile-directory=\"Profile 2\""); | 420 test_properties_.set_arguments(L"--profile-directory=\"Profile 2\""); |
| 421 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 421 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 422 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 422 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 423 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 423 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 424 string16 shortcut2_name(string16(kShortcutName2).append(installer::kLnkExt)); | 424 base::string16 shortcut2_name( |
| 425 base::string16(kShortcutName2).append(installer::kLnkExt)); |
| 425 base::FilePath shortcut2_path( | 426 base::FilePath shortcut2_path( |
| 426 fake_user_desktop_.path().Append(shortcut2_name)); | 427 fake_user_desktop_.path().Append(shortcut2_name)); |
| 427 ASSERT_TRUE(base::PathExists(shortcut2_path)); | 428 ASSERT_TRUE(base::PathExists(shortcut2_path)); |
| 428 | 429 |
| 429 ASSERT_TRUE(ShellUtil::RemoveShortcuts( | 430 ASSERT_TRUE(ShellUtil::RemoveShortcuts( |
| 430 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, | 431 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, |
| 431 chrome_exe_)); | 432 chrome_exe_)); |
| 432 ASSERT_FALSE(base::PathExists(shortcut1_path)); | 433 ASSERT_FALSE(base::PathExists(shortcut1_path)); |
| 433 ASSERT_FALSE(base::PathExists(shortcut2_path)); | 434 ASSERT_FALSE(base::PathExists(shortcut2_path)); |
| 434 ASSERT_TRUE(base::PathExists(shortcut1_path.DirName())); | 435 ASSERT_TRUE(base::PathExists(shortcut1_path.DirName())); |
| 435 } | 436 } |
| 436 | 437 |
| 437 TEST_F(ShellUtilShortcutTest, UpdateChromeShortcutsWithArgs) { | 438 TEST_F(ShellUtilShortcutTest, UpdateChromeShortcutsWithArgs) { |
| 438 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 439 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 439 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 440 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 440 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 441 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 441 | 442 |
| 442 string16 shortcut_name( | 443 base::string16 shortcut_name( |
| 443 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + | 444 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + |
| 444 installer::kLnkExt); | 445 installer::kLnkExt); |
| 445 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); | 446 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); |
| 446 ASSERT_TRUE(base::PathExists(shortcut_path)); | 447 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 447 | 448 |
| 448 base::FilePath new_exe = temp_dir_.path().Append(kManganeseExe); | 449 base::FilePath new_exe = temp_dir_.path().Append(kManganeseExe); |
| 449 ShellUtil::ShortcutProperties updated_properties(ShellUtil::CURRENT_USER); | 450 ShellUtil::ShortcutProperties updated_properties(ShellUtil::CURRENT_USER); |
| 450 updated_properties.set_target(new_exe); | 451 updated_properties.set_target(new_exe); |
| 451 // |updated_properties| has arguments. | 452 // |updated_properties| has arguments. |
| 452 ASSERT_TRUE(ShellUtil::UpdateShortcutsWithArgs( | 453 ASSERT_TRUE(ShellUtil::UpdateShortcutsWithArgs( |
| 453 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, | 454 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, |
| 454 chrome_exe_, updated_properties)); | 455 chrome_exe_, updated_properties)); |
| 455 | 456 |
| 456 ShellUtil::ShortcutProperties expected_properties(test_properties_); | 457 ShellUtil::ShortcutProperties expected_properties(test_properties_); |
| 457 expected_properties.set_target(new_exe); | 458 expected_properties.set_target(new_exe); |
| 458 ValidateChromeShortcut(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 459 ValidateChromeShortcut(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 459 expected_properties); | 460 expected_properties); |
| 460 } | 461 } |
| 461 | 462 |
| 462 TEST_F(ShellUtilShortcutTest, UpdateSystemLevelChromeShortcutsWithArgs) { | 463 TEST_F(ShellUtilShortcutTest, UpdateSystemLevelChromeShortcutsWithArgs) { |
| 463 test_properties_.level = ShellUtil::SYSTEM_LEVEL; | 464 test_properties_.level = ShellUtil::SYSTEM_LEVEL; |
| 464 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 465 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 465 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 466 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 466 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 467 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 467 | 468 |
| 468 string16 shortcut_name( | 469 base::string16 shortcut_name( |
| 469 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + | 470 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + |
| 470 installer::kLnkExt); | 471 installer::kLnkExt); |
| 471 base::FilePath shortcut_path( | 472 base::FilePath shortcut_path( |
| 472 fake_common_desktop_.path().Append(shortcut_name)); | 473 fake_common_desktop_.path().Append(shortcut_name)); |
| 473 ASSERT_TRUE(base::PathExists(shortcut_path)); | 474 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 474 | 475 |
| 475 base::FilePath new_exe = temp_dir_.path().Append(kManganeseExe); | 476 base::FilePath new_exe = temp_dir_.path().Append(kManganeseExe); |
| 476 ShellUtil::ShortcutProperties updated_properties(ShellUtil::CURRENT_USER); | 477 ShellUtil::ShortcutProperties updated_properties(ShellUtil::CURRENT_USER); |
| 477 updated_properties.set_target(new_exe); | 478 updated_properties.set_target(new_exe); |
| 478 // |updated_properties| has arguments. | 479 // |updated_properties| has arguments. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 489 TEST_F(ShellUtilShortcutTest, UpdateMultipleChromeShortcutsWithArgs) { | 490 TEST_F(ShellUtilShortcutTest, UpdateMultipleChromeShortcutsWithArgs) { |
| 490 const wchar_t kShortcutName1[] = L"Chrome 1"; | 491 const wchar_t kShortcutName1[] = L"Chrome 1"; |
| 491 const wchar_t kShortcutName2[] = L"Chrome 2"; | 492 const wchar_t kShortcutName2[] = L"Chrome 2"; |
| 492 | 493 |
| 493 // Setup shortcut 1, which has empty arguments. | 494 // Setup shortcut 1, which has empty arguments. |
| 494 test_properties_.set_shortcut_name(kShortcutName1); | 495 test_properties_.set_shortcut_name(kShortcutName1); |
| 495 test_properties_.set_arguments(L""); | 496 test_properties_.set_arguments(L""); |
| 496 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 497 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 497 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 498 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 498 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 499 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 499 string16 shortcut1_name(string16(kShortcutName1).append(installer::kLnkExt)); | 500 base::string16 shortcut1_name( |
| 501 base::string16(kShortcutName1).append(installer::kLnkExt)); |
| 500 base::FilePath shortcut1_path( | 502 base::FilePath shortcut1_path( |
| 501 fake_user_desktop_.path().Append(shortcut1_name)); | 503 fake_user_desktop_.path().Append(shortcut1_name)); |
| 502 ShellUtil::ShortcutProperties expected_properties1(test_properties_); | 504 ShellUtil::ShortcutProperties expected_properties1(test_properties_); |
| 503 | 505 |
| 504 // Setup shortcut 2, which has non-empty arguments. | 506 // Setup shortcut 2, which has non-empty arguments. |
| 505 string16 shortcut2_args = L"--profile-directory=\"Profile 2\""; | 507 base::string16 shortcut2_args = L"--profile-directory=\"Profile 2\""; |
| 506 test_properties_.set_shortcut_name(kShortcutName2); | 508 test_properties_.set_shortcut_name(kShortcutName2); |
| 507 test_properties_.set_arguments(shortcut2_args); | 509 test_properties_.set_arguments(shortcut2_args); |
| 508 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 510 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 509 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 511 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 510 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 512 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 511 string16 shortcut2_name(string16(kShortcutName2).append(installer::kLnkExt)); | 513 base::string16 shortcut2_name( |
| 514 base::string16(kShortcutName2).append(installer::kLnkExt)); |
| 512 base::FilePath shortcut2_path( | 515 base::FilePath shortcut2_path( |
| 513 fake_user_desktop_.path().Append(shortcut2_name)); | 516 fake_user_desktop_.path().Append(shortcut2_name)); |
| 514 ASSERT_TRUE(base::PathExists(shortcut2_path)); | 517 ASSERT_TRUE(base::PathExists(shortcut2_path)); |
| 515 ShellUtil::ShortcutProperties expected_properties2(test_properties_); | 518 ShellUtil::ShortcutProperties expected_properties2(test_properties_); |
| 516 | 519 |
| 517 // Update shortcuts: target "manganese.exe" instead of "chrome.exe". | 520 // Update shortcuts: target "manganese.exe" instead of "chrome.exe". |
| 518 base::FilePath new_exe = temp_dir_.path().Append(kManganeseExe); | 521 base::FilePath new_exe = temp_dir_.path().Append(kManganeseExe); |
| 519 ShellUtil::ShortcutProperties updated_properties(ShellUtil::CURRENT_USER); | 522 ShellUtil::ShortcutProperties updated_properties(ShellUtil::CURRENT_USER); |
| 520 updated_properties.set_target(new_exe); | 523 updated_properties.set_target(new_exe); |
| 521 | 524 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 ASSERT_FALSE(base::PathExists(chrome_apps_shortcut_folder)); | 593 ASSERT_FALSE(base::PathExists(chrome_apps_shortcut_folder)); |
| 591 } | 594 } |
| 592 | 595 |
| 593 TEST_F(ShellUtilShortcutTest, | 596 TEST_F(ShellUtilShortcutTest, |
| 594 DeleteStartMenuRootShortcutWithoutRemovingFolder) { | 597 DeleteStartMenuRootShortcutWithoutRemovingFolder) { |
| 595 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 598 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 596 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, | 599 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, |
| 597 dist_, test_properties_, | 600 dist_, test_properties_, |
| 598 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 601 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 599 | 602 |
| 600 string16 shortcut_name( | 603 base::string16 shortcut_name( |
| 601 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + | 604 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + |
| 602 installer::kLnkExt); | 605 installer::kLnkExt); |
| 603 base::FilePath shortcut_path( | 606 base::FilePath shortcut_path( |
| 604 fake_start_menu_.path().Append(shortcut_name)); | 607 fake_start_menu_.path().Append(shortcut_name)); |
| 605 | 608 |
| 606 ASSERT_TRUE(base::PathExists(fake_start_menu_.path())); | 609 ASSERT_TRUE(base::PathExists(fake_start_menu_.path())); |
| 607 ASSERT_TRUE(base::PathExists(shortcut_path)); | 610 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 608 ASSERT_TRUE(ShellUtil::RemoveShortcuts( | 611 ASSERT_TRUE(ShellUtil::RemoveShortcuts( |
| 609 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist_, | 612 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist_, |
| 610 ShellUtil::CURRENT_USER, chrome_exe_)); | 613 ShellUtil::CURRENT_USER, chrome_exe_)); |
| 611 // The shortcut should be removed but the "Start Menu" root directory should | 614 // The shortcut should be removed but the "Start Menu" root directory should |
| 612 // remain. | 615 // remain. |
| 613 ASSERT_TRUE(base::PathExists(fake_start_menu_.path())); | 616 ASSERT_TRUE(base::PathExists(fake_start_menu_.path())); |
| 614 ASSERT_FALSE(base::PathExists(shortcut_path)); | 617 ASSERT_FALSE(base::PathExists(shortcut_path)); |
| 615 } | 618 } |
| 616 | 619 |
| 617 TEST_F(ShellUtilShortcutTest, DontRemoveChromeShortcutIfPointsToAnotherChrome) { | 620 TEST_F(ShellUtilShortcutTest, DontRemoveChromeShortcutIfPointsToAnotherChrome) { |
| 618 base::ScopedTempDir other_exe_dir; | 621 base::ScopedTempDir other_exe_dir; |
| 619 ASSERT_TRUE(other_exe_dir.CreateUniqueTempDir()); | 622 ASSERT_TRUE(other_exe_dir.CreateUniqueTempDir()); |
| 620 base::FilePath other_chrome_exe = | 623 base::FilePath other_chrome_exe = |
| 621 other_exe_dir.path().Append(installer::kChromeExe); | 624 other_exe_dir.path().Append(installer::kChromeExe); |
| 622 EXPECT_EQ(0, file_util::WriteFile(other_chrome_exe, "", 0)); | 625 EXPECT_EQ(0, file_util::WriteFile(other_chrome_exe, "", 0)); |
| 623 | 626 |
| 624 test_properties_.set_target(other_chrome_exe); | 627 test_properties_.set_target(other_chrome_exe); |
| 625 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 628 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 626 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 629 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 627 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 630 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 628 | 631 |
| 629 string16 shortcut_name( | 632 base::string16 shortcut_name( |
| 630 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + | 633 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + |
| 631 installer::kLnkExt); | 634 installer::kLnkExt); |
| 632 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); | 635 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); |
| 633 ASSERT_TRUE(base::PathExists(shortcut_path)); | 636 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 634 | 637 |
| 635 // The shortcut shouldn't be removed as it was installed pointing to | 638 // The shortcut shouldn't be removed as it was installed pointing to |
| 636 // |other_chrome_exe| and RemoveChromeShortcut() is being told that the | 639 // |other_chrome_exe| and RemoveChromeShortcut() is being told that the |
| 637 // removed shortcut should point to |chrome_exe_|. | 640 // removed shortcut should point to |chrome_exe_|. |
| 638 ASSERT_TRUE(ShellUtil::RemoveShortcuts( | 641 ASSERT_TRUE(ShellUtil::RemoveShortcuts( |
| 639 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, | 642 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, |
| 640 chrome_exe_)); | 643 chrome_exe_)); |
| 641 ASSERT_TRUE(base::PathExists(shortcut_path)); | 644 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 642 ASSERT_TRUE(base::PathExists(shortcut_path.DirName())); | 645 ASSERT_TRUE(base::PathExists(shortcut_path.DirName())); |
| 643 } | 646 } |
| 644 | 647 |
| 645 TEST(ShellUtilTest, BuildAppModelIdBasic) { | 648 TEST(ShellUtilTest, BuildAppModelIdBasic) { |
| 646 std::vector<string16> components; | 649 std::vector<base::string16> components; |
| 647 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 650 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 648 const string16 base_app_id(dist->GetBaseAppId()); | 651 const base::string16 base_app_id(dist->GetBaseAppId()); |
| 649 components.push_back(base_app_id); | 652 components.push_back(base_app_id); |
| 650 ASSERT_EQ(base_app_id, ShellUtil::BuildAppModelId(components)); | 653 ASSERT_EQ(base_app_id, ShellUtil::BuildAppModelId(components)); |
| 651 } | 654 } |
| 652 | 655 |
| 653 TEST(ShellUtilTest, BuildAppModelIdManySmall) { | 656 TEST(ShellUtilTest, BuildAppModelIdManySmall) { |
| 654 std::vector<string16> components; | 657 std::vector<base::string16> components; |
| 655 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 658 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 656 const string16 suffixed_app_id(dist->GetBaseAppId().append(L".gab")); | 659 const base::string16 suffixed_app_id(dist->GetBaseAppId().append(L".gab")); |
| 657 components.push_back(suffixed_app_id); | 660 components.push_back(suffixed_app_id); |
| 658 components.push_back(L"Default"); | 661 components.push_back(L"Default"); |
| 659 components.push_back(L"Test"); | 662 components.push_back(L"Test"); |
| 660 ASSERT_EQ(suffixed_app_id + L".Default.Test", | 663 ASSERT_EQ(suffixed_app_id + L".Default.Test", |
| 661 ShellUtil::BuildAppModelId(components)); | 664 ShellUtil::BuildAppModelId(components)); |
| 662 } | 665 } |
| 663 | 666 |
| 664 TEST(ShellUtilTest, BuildAppModelIdLongUsernameNormalProfile) { | 667 TEST(ShellUtilTest, BuildAppModelIdLongUsernameNormalProfile) { |
| 665 std::vector<string16> components; | 668 std::vector<base::string16> components; |
| 666 const string16 long_appname( | 669 const base::string16 long_appname( |
| 667 L"Chrome.a_user_who_has_a_crazy_long_name_with_some_weird@symbols_in_it_" | 670 L"Chrome.a_user_who_has_a_crazy_long_name_with_some_weird@symbols_in_it_" |
| 668 L"that_goes_over_64_characters"); | 671 L"that_goes_over_64_characters"); |
| 669 components.push_back(long_appname); | 672 components.push_back(long_appname); |
| 670 components.push_back(L"Default"); | 673 components.push_back(L"Default"); |
| 671 ASSERT_EQ(L"Chrome.a_user_wer_64_characters.Default", | 674 ASSERT_EQ(L"Chrome.a_user_wer_64_characters.Default", |
| 672 ShellUtil::BuildAppModelId(components)); | 675 ShellUtil::BuildAppModelId(components)); |
| 673 } | 676 } |
| 674 | 677 |
| 675 TEST(ShellUtilTest, BuildAppModelIdLongEverything) { | 678 TEST(ShellUtilTest, BuildAppModelIdLongEverything) { |
| 676 std::vector<string16> components; | 679 std::vector<base::string16> components; |
| 677 const string16 long_appname( | 680 const base::string16 long_appname(L"Chrome.a_user_who_has_a_crazy_long_name_" |
| 678 L"Chrome.a_user_who_has_a_crazy_long_name_with_some_weird@symbols_in_it_" | 681 L"with_some_weird@symbols_in_" |
| 679 L"that_goes_over_64_characters"); | 682 L"it_" L"that_goes_over_64_characters"); |
| 680 components.push_back(long_appname); | 683 components.push_back(long_appname); |
| 681 components.push_back( | 684 components.push_back( |
| 682 L"A_crazy_profile_name_not_even_sure_whether_that_is_possible"); | 685 L"A_crazy_profile_name_not_even_sure_whether_that_is_possible"); |
| 683 const string16 constructed_app_id(ShellUtil::BuildAppModelId(components)); | 686 const base::string16 constructed_app_id( |
| 687 ShellUtil::BuildAppModelId(components)); |
| 684 ASSERT_LE(constructed_app_id.length(), installer::kMaxAppModelIdLength); | 688 ASSERT_LE(constructed_app_id.length(), installer::kMaxAppModelIdLength); |
| 685 ASSERT_EQ(L"Chrome.a_user_wer_64_characters.A_crazy_profilethat_is_possible", | 689 ASSERT_EQ(L"Chrome.a_user_wer_64_characters.A_crazy_profilethat_is_possible", |
| 686 constructed_app_id); | 690 constructed_app_id); |
| 687 } | 691 } |
| 688 | 692 |
| 689 TEST(ShellUtilTest, GetUserSpecificRegistrySuffix) { | 693 TEST(ShellUtilTest, GetUserSpecificRegistrySuffix) { |
| 690 string16 suffix; | 694 base::string16 suffix; |
| 691 ASSERT_TRUE(ShellUtil::GetUserSpecificRegistrySuffix(&suffix)); | 695 ASSERT_TRUE(ShellUtil::GetUserSpecificRegistrySuffix(&suffix)); |
| 692 ASSERT_TRUE(StartsWith(suffix, L".", true)); | 696 ASSERT_TRUE(StartsWith(suffix, L".", true)); |
| 693 ASSERT_EQ(27, suffix.length()); | 697 ASSERT_EQ(27, suffix.length()); |
| 694 ASSERT_TRUE(ContainsOnlyChars(suffix.substr(1), | 698 ASSERT_TRUE(ContainsOnlyChars(suffix.substr(1), |
| 695 L"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")); | 699 L"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")); |
| 696 } | 700 } |
| 697 | 701 |
| 698 TEST(ShellUtilTest, GetOldUserSpecificRegistrySuffix) { | 702 TEST(ShellUtilTest, GetOldUserSpecificRegistrySuffix) { |
| 699 string16 suffix; | 703 base::string16 suffix; |
| 700 ASSERT_TRUE(ShellUtil::GetOldUserSpecificRegistrySuffix(&suffix)); | 704 ASSERT_TRUE(ShellUtil::GetOldUserSpecificRegistrySuffix(&suffix)); |
| 701 ASSERT_TRUE(StartsWith(suffix, L".", true)); | 705 ASSERT_TRUE(StartsWith(suffix, L".", true)); |
| 702 | 706 |
| 703 wchar_t user_name[256]; | 707 wchar_t user_name[256]; |
| 704 DWORD size = arraysize(user_name); | 708 DWORD size = arraysize(user_name); |
| 705 ASSERT_NE(0, ::GetUserName(user_name, &size)); | 709 ASSERT_NE(0, ::GetUserName(user_name, &size)); |
| 706 ASSERT_GE(size, 1U); | 710 ASSERT_GE(size, 1U); |
| 707 ASSERT_STREQ(user_name, suffix.substr(1).c_str()); | 711 ASSERT_STREQ(user_name, suffix.substr(1).c_str()); |
| 708 } | 712 } |
| 709 | 713 |
| 710 TEST(ShellUtilTest, ByteArrayToBase32) { | 714 TEST(ShellUtilTest, ByteArrayToBase32) { |
| 711 // Tests from http://tools.ietf.org/html/rfc4648#section-10. | 715 // Tests from http://tools.ietf.org/html/rfc4648#section-10. |
| 712 const unsigned char test_array[] = { 'f', 'o', 'o', 'b', 'a', 'r' }; | 716 const unsigned char test_array[] = { 'f', 'o', 'o', 'b', 'a', 'r' }; |
| 713 | 717 |
| 714 const string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", | 718 const base::string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", |
| 715 L"MZXW6YTB", L"MZXW6YTBOI"}; | 719 L"MZXW6YTB", L"MZXW6YTBOI"}; |
| 716 | 720 |
| 717 // Run the tests, with one more letter in the input every pass. | 721 // Run the tests, with one more letter in the input every pass. |
| 718 for (int i = 0; i < arraysize(expected); ++i) { | 722 for (int i = 0; i < arraysize(expected); ++i) { |
| 719 ASSERT_EQ(expected[i], | 723 ASSERT_EQ(expected[i], |
| 720 ShellUtil::ByteArrayToBase32(test_array, i)); | 724 ShellUtil::ByteArrayToBase32(test_array, i)); |
| 721 } | 725 } |
| 722 } | 726 } |
| OLD | NEW |