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

Side by Side Diff: chrome/installer/util/shell_util_unittest.cc

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 27 matching lines...) Expand all
38 protected: 38 protected:
39 ShellUtilShortcutTest() : test_properties_(ShellUtil::CURRENT_USER) {} 39 ShellUtilShortcutTest() : test_properties_(ShellUtil::CURRENT_USER) {}
40 40
41 virtual void SetUp() OVERRIDE { 41 virtual void SetUp() OVERRIDE {
42 dist_ = BrowserDistribution::GetDistribution(); 42 dist_ = BrowserDistribution::GetDistribution();
43 ASSERT_TRUE(dist_ != NULL); 43 ASSERT_TRUE(dist_ != NULL);
44 product_.reset(new installer::Product(dist_)); 44 product_.reset(new installer::Product(dist_));
45 45
46 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 46 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
47 chrome_exe_ = temp_dir_.path().Append(installer::kChromeExe); 47 chrome_exe_ = temp_dir_.path().Append(installer::kChromeExe);
48 EXPECT_EQ(0, file_util::WriteFile(chrome_exe_, "", 0)); 48 EXPECT_EQ(0, base::WriteFile(chrome_exe_, "", 0));
49 49
50 manganese_exe_ = temp_dir_.path().Append(kManganeseExe); 50 manganese_exe_ = temp_dir_.path().Append(kManganeseExe);
51 EXPECT_EQ(0, file_util::WriteFile(manganese_exe_, "", 0)); 51 EXPECT_EQ(0, base::WriteFile(manganese_exe_, "", 0));
52 52
53 iron_exe_ = temp_dir_.path().Append(kIronExe); 53 iron_exe_ = temp_dir_.path().Append(kIronExe);
54 EXPECT_EQ(0, file_util::WriteFile(iron_exe_, "", 0)); 54 EXPECT_EQ(0, base::WriteFile(iron_exe_, "", 0));
55 55
56 other_ico_ = temp_dir_.path().Append(kOtherIco); 56 other_ico_ = temp_dir_.path().Append(kOtherIco);
57 EXPECT_EQ(0, file_util::WriteFile(other_ico_, "", 0)); 57 EXPECT_EQ(0, base::WriteFile(other_ico_, "", 0));
58 58
59 ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir()); 59 ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir());
60 ASSERT_TRUE(fake_common_desktop_.CreateUniqueTempDir()); 60 ASSERT_TRUE(fake_common_desktop_.CreateUniqueTempDir());
61 ASSERT_TRUE(fake_user_quick_launch_.CreateUniqueTempDir()); 61 ASSERT_TRUE(fake_user_quick_launch_.CreateUniqueTempDir());
62 ASSERT_TRUE(fake_default_user_quick_launch_.CreateUniqueTempDir()); 62 ASSERT_TRUE(fake_default_user_quick_launch_.CreateUniqueTempDir());
63 ASSERT_TRUE(fake_start_menu_.CreateUniqueTempDir()); 63 ASSERT_TRUE(fake_start_menu_.CreateUniqueTempDir());
64 ASSERT_TRUE(fake_common_start_menu_.CreateUniqueTempDir()); 64 ASSERT_TRUE(fake_common_start_menu_.CreateUniqueTempDir());
65 user_desktop_override_.reset( 65 user_desktop_override_.reset(
66 new base::ScopedPathOverride(base::DIR_USER_DESKTOP, 66 new base::ScopedPathOverride(base::DIR_USER_DESKTOP,
67 fake_user_desktop_.path())); 67 fake_user_desktop_.path()));
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 // remain. 766 // remain.
767 ASSERT_TRUE(base::PathExists(fake_start_menu_.path())); 767 ASSERT_TRUE(base::PathExists(fake_start_menu_.path()));
768 ASSERT_FALSE(base::PathExists(shortcut_path)); 768 ASSERT_FALSE(base::PathExists(shortcut_path));
769 } 769 }
770 770
771 TEST_F(ShellUtilShortcutTest, DontRemoveChromeShortcutIfPointsToAnotherChrome) { 771 TEST_F(ShellUtilShortcutTest, DontRemoveChromeShortcutIfPointsToAnotherChrome) {
772 base::ScopedTempDir other_exe_dir; 772 base::ScopedTempDir other_exe_dir;
773 ASSERT_TRUE(other_exe_dir.CreateUniqueTempDir()); 773 ASSERT_TRUE(other_exe_dir.CreateUniqueTempDir());
774 base::FilePath other_chrome_exe = 774 base::FilePath other_chrome_exe =
775 other_exe_dir.path().Append(installer::kChromeExe); 775 other_exe_dir.path().Append(installer::kChromeExe);
776 EXPECT_EQ(0, file_util::WriteFile(other_chrome_exe, "", 0)); 776 EXPECT_EQ(0, base::WriteFile(other_chrome_exe, "", 0));
777 777
778 test_properties_.set_target(other_chrome_exe); 778 test_properties_.set_target(other_chrome_exe);
779 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( 779 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut(
780 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, 780 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_,
781 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); 781 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS));
782 782
783 base::string16 shortcut_name( 783 base::string16 shortcut_name(
784 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + 784 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) +
785 installer::kLnkExt); 785 installer::kLnkExt);
786 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); 786 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name));
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 868
869 const base::string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", 869 const base::string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ",
870 L"MZXW6YTB", L"MZXW6YTBOI"}; 870 L"MZXW6YTB", L"MZXW6YTBOI"};
871 871
872 // Run the tests, with one more letter in the input every pass. 872 // Run the tests, with one more letter in the input every pass.
873 for (int i = 0; i < arraysize(expected); ++i) { 873 for (int i = 0; i < arraysize(expected); ++i) {
874 ASSERT_EQ(expected[i], 874 ASSERT_EQ(expected[i],
875 ShellUtil::ByteArrayToBase32(test_array, i)); 875 ShellUtil::ByteArrayToBase32(test_array, i));
876 } 876 }
877 } 877 }
OLDNEW
« no previous file with comments | « chrome/installer/util/self_cleaning_temp_dir_unittest.cc ('k') | chrome/renderer/mock_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698