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

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

Issue 2321573002: //chrome misc: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Fix Win compilation Created 4 years, 3 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 class ShellUtilShortcutTest : public testing::Test { 54 class ShellUtilShortcutTest : public testing::Test {
55 protected: 55 protected:
56 ShellUtilShortcutTest() : test_properties_(ShellUtil::CURRENT_USER) {} 56 ShellUtilShortcutTest() : test_properties_(ShellUtil::CURRENT_USER) {}
57 57
58 void SetUp() override { 58 void SetUp() override {
59 dist_ = BrowserDistribution::GetDistribution(); 59 dist_ = BrowserDistribution::GetDistribution();
60 ASSERT_TRUE(dist_ != NULL); 60 ASSERT_TRUE(dist_ != NULL);
61 product_.reset(new installer::Product(dist_)); 61 product_.reset(new installer::Product(dist_));
62 62
63 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 63 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
64 chrome_exe_ = temp_dir_.path().Append(installer::kChromeExe); 64 chrome_exe_ = temp_dir_.GetPath().Append(installer::kChromeExe);
65 EXPECT_EQ(0, base::WriteFile(chrome_exe_, "", 0)); 65 EXPECT_EQ(0, base::WriteFile(chrome_exe_, "", 0));
66 66
67 manganese_exe_ = temp_dir_.path().Append(kManganeseExe); 67 manganese_exe_ = temp_dir_.GetPath().Append(kManganeseExe);
68 EXPECT_EQ(0, base::WriteFile(manganese_exe_, "", 0)); 68 EXPECT_EQ(0, base::WriteFile(manganese_exe_, "", 0));
69 69
70 iron_exe_ = temp_dir_.path().Append(kIronExe); 70 iron_exe_ = temp_dir_.GetPath().Append(kIronExe);
71 EXPECT_EQ(0, base::WriteFile(iron_exe_, "", 0)); 71 EXPECT_EQ(0, base::WriteFile(iron_exe_, "", 0));
72 72
73 other_ico_ = temp_dir_.path().Append(kOtherIco); 73 other_ico_ = temp_dir_.GetPath().Append(kOtherIco);
74 EXPECT_EQ(0, base::WriteFile(other_ico_, "", 0)); 74 EXPECT_EQ(0, base::WriteFile(other_ico_, "", 0));
75 75
76 ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir()); 76 ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir());
77 ASSERT_TRUE(fake_common_desktop_.CreateUniqueTempDir()); 77 ASSERT_TRUE(fake_common_desktop_.CreateUniqueTempDir());
78 ASSERT_TRUE(fake_user_quick_launch_.CreateUniqueTempDir()); 78 ASSERT_TRUE(fake_user_quick_launch_.CreateUniqueTempDir());
79 ASSERT_TRUE(fake_default_user_quick_launch_.CreateUniqueTempDir()); 79 ASSERT_TRUE(fake_default_user_quick_launch_.CreateUniqueTempDir());
80 ASSERT_TRUE(fake_start_menu_.CreateUniqueTempDir()); 80 ASSERT_TRUE(fake_start_menu_.CreateUniqueTempDir());
81 ASSERT_TRUE(fake_common_start_menu_.CreateUniqueTempDir()); 81 ASSERT_TRUE(fake_common_start_menu_.CreateUniqueTempDir());
82 user_desktop_override_.reset( 82 user_desktop_override_.reset(
83 new base::ScopedPathOverride(base::DIR_USER_DESKTOP, 83 new base::ScopedPathOverride(base::DIR_USER_DESKTOP,
84 fake_user_desktop_.path())); 84 fake_user_desktop_.path()));
85 common_desktop_override_.reset( 85 common_desktop_override_.reset(
86 new base::ScopedPathOverride(base::DIR_COMMON_DESKTOP, 86 new base::ScopedPathOverride(base::DIR_COMMON_DESKTOP,
87 fake_common_desktop_.path())); 87 fake_common_desktop_.path()));
88 user_quick_launch_override_.reset( 88 user_quick_launch_override_.reset(
89 new base::ScopedPathOverride(base::DIR_USER_QUICK_LAUNCH, 89 new base::ScopedPathOverride(base::DIR_USER_QUICK_LAUNCH,
90 fake_user_quick_launch_.path())); 90 fake_user_quick_launch_.path()));
91 start_menu_override_.reset( 91 start_menu_override_.reset(
92 new base::ScopedPathOverride(base::DIR_START_MENU, 92 new base::ScopedPathOverride(base::DIR_START_MENU,
93 fake_start_menu_.path())); 93 fake_start_menu_.path()));
94 common_start_menu_override_.reset( 94 common_start_menu_override_.reset(
95 new base::ScopedPathOverride(base::DIR_COMMON_START_MENU, 95 new base::ScopedPathOverride(base::DIR_COMMON_START_MENU,
96 fake_common_start_menu_.path())); 96 fake_common_start_menu_.path()));
97 97
98 base::FilePath icon_path; 98 base::FilePath icon_path;
99 base::CreateTemporaryFileInDir(temp_dir_.path(), &icon_path); 99 base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &icon_path);
100 test_properties_.set_target(chrome_exe_); 100 test_properties_.set_target(chrome_exe_);
101 test_properties_.set_arguments(L"--test --chrome"); 101 test_properties_.set_arguments(L"--test --chrome");
102 test_properties_.set_description(L"Makes polar bears dance."); 102 test_properties_.set_description(L"Makes polar bears dance.");
103 test_properties_.set_icon(icon_path, 7); 103 test_properties_.set_icon(icon_path, 7);
104 test_properties_.set_app_id(L"Polar.Bear"); 104 test_properties_.set_app_id(L"Polar.Bear");
105 } 105 }
106 106
107 // Returns the expected path of a test shortcut. Returns an empty FilePath on 107 // Returns the expected path of a test shortcut. Returns an empty FilePath on
108 // failure. 108 // failure.
109 base::FilePath GetExpectedShortcutPath( 109 base::FilePath GetExpectedShortcutPath(
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 // The shortcut should be removed but the "Start Menu" root directory should 785 // The shortcut should be removed but the "Start Menu" root directory should
786 // remain. 786 // remain.
787 ASSERT_TRUE(base::PathExists(fake_start_menu_.path())); 787 ASSERT_TRUE(base::PathExists(fake_start_menu_.path()));
788 ASSERT_FALSE(base::PathExists(shortcut_path)); 788 ASSERT_FALSE(base::PathExists(shortcut_path));
789 } 789 }
790 790
791 TEST_F(ShellUtilShortcutTest, DontRemoveChromeShortcutIfPointsToAnotherChrome) { 791 TEST_F(ShellUtilShortcutTest, DontRemoveChromeShortcutIfPointsToAnotherChrome) {
792 base::ScopedTempDir other_exe_dir; 792 base::ScopedTempDir other_exe_dir;
793 ASSERT_TRUE(other_exe_dir.CreateUniqueTempDir()); 793 ASSERT_TRUE(other_exe_dir.CreateUniqueTempDir());
794 base::FilePath other_chrome_exe = 794 base::FilePath other_chrome_exe =
795 other_exe_dir.path().Append(installer::kChromeExe); 795 other_exe_dir.GetPath().Append(installer::kChromeExe);
796 EXPECT_EQ(0, base::WriteFile(other_chrome_exe, "", 0)); 796 EXPECT_EQ(0, base::WriteFile(other_chrome_exe, "", 0));
797 797
798 test_properties_.set_target(other_chrome_exe); 798 test_properties_.set_target(other_chrome_exe);
799 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( 799 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut(
800 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, 800 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_,
801 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); 801 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS));
802 802
803 base::string16 shortcut_name(dist_->GetShortcutName() + installer::kLnkExt); 803 base::string16 shortcut_name(dist_->GetShortcutName() + installer::kLnkExt);
804 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); 804 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name));
805 ASSERT_TRUE(base::PathExists(shortcut_path)); 805 ASSERT_TRUE(base::PathExists(shortcut_path));
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 ASSERT_TRUE(ShellUtil::GetOldUserSpecificRegistrySuffix(&suffix)); 998 ASSERT_TRUE(ShellUtil::GetOldUserSpecificRegistrySuffix(&suffix));
999 ASSERT_TRUE(base::StartsWith(suffix, L".", base::CompareCase::SENSITIVE)); 999 ASSERT_TRUE(base::StartsWith(suffix, L".", base::CompareCase::SENSITIVE));
1000 1000
1001 wchar_t user_name[256]; 1001 wchar_t user_name[256];
1002 DWORD size = arraysize(user_name); 1002 DWORD size = arraysize(user_name);
1003 ASSERT_NE(0, ::GetUserName(user_name, &size)); 1003 ASSERT_NE(0, ::GetUserName(user_name, &size));
1004 ASSERT_GE(size, 1U); 1004 ASSERT_GE(size, 1U);
1005 ASSERT_STREQ(user_name, suffix.substr(1).c_str()); 1005 ASSERT_STREQ(user_name, suffix.substr(1).c_str());
1006 } 1006 }
1007 1007
OLDNEW
« no previous file with comments | « chrome/installer/util/self_cleaning_temp_dir_unittest.cc ('k') | chrome/service/cloud_print/connector_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698