| 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" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/files/file_enumerator.h" | |
| 13 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 14 #include "base/md5.h" | 13 #include "base/md5.h" |
| 15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/string16.h" | 15 #include "base/string16.h" |
| 17 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 18 #include "base/test/scoped_path_override.h" | 17 #include "base/test/scoped_path_override.h" |
| 19 #include "base/test/test_shortcut_win.h" | 18 #include "base/test/test_shortcut_win.h" |
| 20 #include "base/win/shortcut.h" | 19 #include "base/win/shortcut.h" |
| 21 #include "base/win/windows_version.h" | 20 #include "base/win/windows_version.h" |
| 22 #include "chrome/installer/util/browser_distribution.h" | 21 #include "chrome/installer/util/browser_distribution.h" |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 dist_, *test_properties_, | 519 dist_, *test_properties_, |
| 521 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 520 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 522 test_properties_->set_shortcut_name(L"A second shortcut"); | 521 test_properties_->set_shortcut_name(L"A second shortcut"); |
| 523 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 522 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 524 ShellUtil::SHORTCUT_LOCATION_START_MENU, | 523 ShellUtil::SHORTCUT_LOCATION_START_MENU, |
| 525 dist_, *test_properties_, | 524 dist_, *test_properties_, |
| 526 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 525 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 527 | 526 |
| 528 base::FilePath shortcut_folder( | 527 base::FilePath shortcut_folder( |
| 529 fake_start_menu_.path().Append(dist_->GetAppShortCutName())); | 528 fake_start_menu_.path().Append(dist_->GetAppShortCutName())); |
| 530 base::FileEnumerator file_counter(shortcut_folder, false, | 529 file_util::FileEnumerator file_counter(shortcut_folder, false, |
| 531 base::FileEnumerator::FILES); | 530 file_util::FileEnumerator::FILES); |
| 532 int count = 0; | 531 int count = 0; |
| 533 while (!file_counter.Next().empty()) | 532 while (!file_counter.Next().empty()) |
| 534 ++count; | 533 ++count; |
| 535 EXPECT_EQ(2, count); | 534 EXPECT_EQ(2, count); |
| 536 | 535 |
| 537 ASSERT_TRUE(file_util::PathExists(shortcut_folder)); | 536 ASSERT_TRUE(file_util::PathExists(shortcut_folder)); |
| 538 ASSERT_TRUE(ShellUtil::RemoveShortcuts( | 537 ASSERT_TRUE(ShellUtil::RemoveShortcuts( |
| 539 ShellUtil::SHORTCUT_LOCATION_START_MENU, dist_, ShellUtil::CURRENT_USER, | 538 ShellUtil::SHORTCUT_LOCATION_START_MENU, dist_, ShellUtil::CURRENT_USER, |
| 540 chrome_exe_)); | 539 chrome_exe_)); |
| 541 ASSERT_FALSE(file_util::PathExists(shortcut_folder)); | 540 ASSERT_FALSE(file_util::PathExists(shortcut_folder)); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 | 638 |
| 640 const string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", | 639 const string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", |
| 641 L"MZXW6YTB", L"MZXW6YTBOI"}; | 640 L"MZXW6YTB", L"MZXW6YTBOI"}; |
| 642 | 641 |
| 643 // Run the tests, with one more letter in the input every pass. | 642 // Run the tests, with one more letter in the input every pass. |
| 644 for (int i = 0; i < arraysize(expected); ++i) { | 643 for (int i = 0; i < arraysize(expected); ++i) { |
| 645 ASSERT_EQ(expected[i], | 644 ASSERT_EQ(expected[i], |
| 646 ShellUtil::ByteArrayToBase32(test_array, i)); | 645 ShellUtil::ByteArrayToBase32(test_array, i)); |
| 647 } | 646 } |
| 648 } | 647 } |
| OLD | NEW |