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 <shlobj.h> | 5 #include <shlobj.h> |
6 | 6 |
7 #include <fstream> | 7 #include <fstream> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/md5.h" | 12 #include "base/md5.h" |
13 #include "base/scoped_temp_dir.h" | 13 #include "base/scoped_temp_dir.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/test/test_file_util.h" |
16 #include "base/win/windows_version.h" | 17 #include "base/win/windows_version.h" |
17 #include "chrome/installer/util/browser_distribution.h" | 18 #include "chrome/installer/util/browser_distribution.h" |
18 #include "chrome/installer/util/master_preferences.h" | 19 #include "chrome/installer/util/master_preferences.h" |
19 #include "chrome/installer/util/shell_util.h" | 20 #include "chrome/installer/util/shell_util.h" |
20 #include "chrome/installer/util/util_constants.h" | 21 #include "chrome/installer/util/util_constants.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 class ShellUtilTestWithDirAndDist : public testing::Test { | 26 class ShellUtilTestWithDirAndDist : public testing::Test { |
26 protected: | 27 protected: |
27 virtual void SetUp() { | 28 virtual void SetUp() { |
28 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 29 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
29 dist_ = BrowserDistribution::GetDistribution(); | 30 dist_ = BrowserDistribution::GetDistribution(); |
30 ASSERT_TRUE(dist_ != NULL); | 31 ASSERT_TRUE(dist_ != NULL); |
31 } | 32 } |
32 | 33 |
33 BrowserDistribution* dist_; | 34 BrowserDistribution* dist_; |
34 | 35 |
35 ScopedTempDir temp_dir_; | 36 ScopedTempDir temp_dir_; |
36 }; | 37 }; |
37 | 38 |
| 39 // Returns the status of a call to file_util::VerifyShorcut for the properties |
| 40 // passed in. |
| 41 // TODO(gab): This is only temporary while waiting for my upcoming CL that will |
| 42 // massively refactor the shell_util shortcut methods' interface (i.e. I didn't |
| 43 // want to adapt every test here for this half-changed state as they will change |
| 44 // again very soon). |
| 45 file_util::VerifyShortcutStatus VerifyChromeShortcut( |
| 46 const string16& exe_path, |
| 47 const string16& shortcut_path, |
| 48 const string16& description, |
| 49 int icon_index) { |
| 50 file_util::ShortcutProperties expected_properties; |
| 51 expected_properties.set_target(exe_path); |
| 52 expected_properties.set_description(description); |
| 53 expected_properties.set_icon(exe_path, icon_index); |
| 54 return file_util::VerifyShortcut(shortcut_path, expected_properties); |
| 55 } |
| 56 |
38 } | 57 } |
39 | 58 |
40 // Test that we can open archives successfully. | 59 // Test that we can open archives successfully. |
41 TEST_F(ShellUtilTestWithDirAndDist, UpdateChromeShortcutTest) { | 60 TEST_F(ShellUtilTestWithDirAndDist, UpdateChromeShortcutTest) { |
42 // Create an executable in test path by copying ourself to it. | 61 // Create an executable in test path by copying ourself to it. |
43 wchar_t exe_full_path_str[MAX_PATH]; | 62 wchar_t exe_full_path_str[MAX_PATH]; |
44 EXPECT_FALSE(::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH) == 0); | 63 EXPECT_FALSE(::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH) == 0); |
45 FilePath exe_full_path(exe_full_path_str); | 64 FilePath exe_full_path(exe_full_path_str); |
46 | 65 |
47 FilePath exe_path = temp_dir_.path().AppendASCII("setup.exe"); | 66 FilePath exe_path = temp_dir_.path().AppendASCII("setup.exe"); |
48 EXPECT_TRUE(file_util::CopyFile(exe_full_path, exe_path)); | 67 EXPECT_TRUE(file_util::CopyFile(exe_full_path, exe_path)); |
49 | 68 |
50 FilePath shortcut_path = temp_dir_.path().AppendASCII("shortcut.lnk"); | 69 FilePath shortcut_path = temp_dir_.path().AppendASCII("shortcut.lnk"); |
51 const string16 description(L"dummy description"); | 70 const string16 description(L"dummy description"); |
52 EXPECT_TRUE(ShellUtil::UpdateChromeShortcut( | 71 EXPECT_TRUE(ShellUtil::UpdateChromeShortcut( |
53 dist_, | 72 dist_, |
54 exe_path.value(), | 73 exe_path.value(), |
55 shortcut_path.value(), | 74 shortcut_path.value(), |
56 L"", | 75 string16(), |
57 description, | 76 description, |
58 exe_path.value(), | 77 exe_path.value(), |
59 dist_->GetIconIndex(), | 78 dist_->GetIconIndex(), |
60 ShellUtil::SHORTCUT_CREATE_ALWAYS)); | 79 ShellUtil::SHORTCUT_CREATE_ALWAYS)); |
61 EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS, | 80 EXPECT_EQ(file_util::VERIFY_SHORTCUT_SUCCESS, |
62 ShellUtil::VerifyChromeShortcut( | 81 VerifyChromeShortcut( |
63 exe_path.value(), shortcut_path.value(), description, 0)); | 82 exe_path.value(), shortcut_path.value(), description, 0)); |
64 | 83 |
65 // Now specify an icon index in master prefs and make sure it works. | 84 // Now specify an icon index in master prefs and make sure it works. |
66 FilePath prefs_path = temp_dir_.path().AppendASCII( | 85 FilePath prefs_path = temp_dir_.path().AppendASCII( |
67 installer::kDefaultMasterPrefs); | 86 installer::kDefaultMasterPrefs); |
68 std::ofstream file; | 87 std::ofstream file; |
69 file.open(prefs_path.value().c_str()); | 88 file.open(prefs_path.value().c_str()); |
70 ASSERT_TRUE(file.is_open()); | 89 ASSERT_TRUE(file.is_open()); |
71 file << | 90 file << |
72 "{" | 91 "{" |
73 " \"distribution\":{" | 92 " \"distribution\":{" |
74 " \"chrome_shortcut_icon_index\" : 1" | 93 " \"chrome_shortcut_icon_index\" : 1" |
75 " }" | 94 " }" |
76 "}"; | 95 "}"; |
77 file.close(); | 96 file.close(); |
78 ASSERT_TRUE(file_util::Delete(shortcut_path, false)); | 97 ASSERT_TRUE(file_util::Delete(shortcut_path, false)); |
79 EXPECT_TRUE(ShellUtil::UpdateChromeShortcut( | 98 EXPECT_TRUE(ShellUtil::UpdateChromeShortcut( |
80 dist_, | 99 dist_, |
81 exe_path.value(), | 100 exe_path.value(), |
82 shortcut_path.value(), | 101 shortcut_path.value(), |
83 L"", | 102 string16(), |
84 description, | 103 description, |
85 exe_path.value(), | 104 exe_path.value(), |
86 dist_->GetIconIndex(), | 105 dist_->GetIconIndex(), |
87 ShellUtil::SHORTCUT_CREATE_ALWAYS)); | 106 ShellUtil::SHORTCUT_CREATE_ALWAYS)); |
88 EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS, | 107 EXPECT_EQ(file_util::VERIFY_SHORTCUT_SUCCESS, |
89 ShellUtil::VerifyChromeShortcut( | 108 VerifyChromeShortcut( |
90 exe_path.value(), shortcut_path.value(), description, 1)); | 109 exe_path.value(), shortcut_path.value(), description, 1)); |
91 | 110 |
92 // Now change only description to update shortcut and make sure icon index | 111 // Now change only description to update shortcut and make sure icon index |
93 // doesn't change. | 112 // doesn't change. |
94 const string16 description2(L"dummy description 2"); | 113 const string16 description2(L"dummy description 2"); |
95 EXPECT_TRUE(ShellUtil::UpdateChromeShortcut(dist_, | 114 EXPECT_TRUE(ShellUtil::UpdateChromeShortcut(dist_, |
96 exe_path.value(), | 115 exe_path.value(), |
97 shortcut_path.value(), | 116 shortcut_path.value(), |
98 L"", | 117 string16(), |
99 description2, | 118 description2, |
100 exe_path.value(), | 119 exe_path.value(), |
101 dist_->GetIconIndex(), | 120 dist_->GetIconIndex(), |
102 ShellUtil::SHORTCUT_NO_OPTIONS)); | 121 ShellUtil::SHORTCUT_NO_OPTIONS)); |
103 EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS, | 122 EXPECT_EQ(file_util::VERIFY_SHORTCUT_SUCCESS, |
104 ShellUtil::VerifyChromeShortcut( | 123 VerifyChromeShortcut( |
105 exe_path.value(), shortcut_path.value(), description2, 1)); | 124 exe_path.value(), shortcut_path.value(), description2, 1)); |
106 } | 125 } |
107 | 126 |
108 TEST_F(ShellUtilTestWithDirAndDist, CreateChromeDesktopShortcutTest) { | 127 TEST_F(ShellUtilTestWithDirAndDist, CreateChromeDesktopShortcutTest) { |
109 // Run this test on Vista+ only if we are running elevated. | 128 // Run this test on Vista+ only if we are running elevated. |
110 if (base::win::GetVersion() > base::win::VERSION_XP && !IsUserAnAdmin()) { | 129 if (base::win::GetVersion() > base::win::VERSION_XP && !IsUserAnAdmin()) { |
111 LOG(ERROR) << "Must be admin to run this test on Vista+"; | 130 LOG(ERROR) << "Must be admin to run this test on Vista+"; |
112 return; | 131 return; |
113 } | 132 } |
114 | 133 |
115 // Create an executable in test path by copying ourself to it. | 134 // Create an executable in test path by copying ourself to it. |
116 wchar_t exe_full_path_str[MAX_PATH]; | 135 wchar_t exe_full_path_str[MAX_PATH]; |
117 EXPECT_FALSE(::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH) == 0); | 136 EXPECT_FALSE(::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH) == 0); |
118 FilePath exe_full_path(exe_full_path_str); | 137 FilePath exe_full_path(exe_full_path_str); |
119 | 138 |
120 FilePath exe_path = temp_dir_.path().AppendASCII("setup.exe"); | 139 FilePath exe_path = temp_dir_.path().AppendASCII("setup.exe"); |
121 EXPECT_TRUE(file_util::CopyFile(exe_full_path, exe_path)); | 140 EXPECT_TRUE(file_util::CopyFile(exe_full_path, exe_path)); |
122 | 141 |
123 const string16 description(L"dummy description"); | 142 const string16 description(L"dummy description"); |
124 | 143 |
125 FilePath user_desktop_path; | 144 FilePath user_desktop_path; |
126 EXPECT_TRUE(ShellUtil::GetDesktopPath(false, &user_desktop_path)); | 145 EXPECT_TRUE(ShellUtil::GetDesktopPath(false, &user_desktop_path)); |
127 FilePath system_desktop_path; | 146 FilePath system_desktop_path; |
128 EXPECT_TRUE(ShellUtil::GetDesktopPath(true, &system_desktop_path)); | 147 EXPECT_TRUE(ShellUtil::GetDesktopPath(true, &system_desktop_path)); |
129 | 148 |
130 string16 shortcut_name; | 149 string16 shortcut_name; |
131 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist_, false, L"", | 150 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist_, false, string16(), |
132 &shortcut_name)); | 151 &shortcut_name)); |
133 | 152 |
134 string16 default_profile_shortcut_name; | 153 string16 default_profile_shortcut_name; |
135 const string16 default_profile_user_name = L"Minsk"; | 154 const string16 default_profile_user_name = L"Minsk"; |
136 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist_, false, | 155 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist_, false, |
137 default_profile_user_name, | 156 default_profile_user_name, |
138 &default_profile_shortcut_name)); | 157 &default_profile_shortcut_name)); |
139 | 158 |
140 string16 second_profile_shortcut_name; | 159 string16 second_profile_shortcut_name; |
141 const string16 second_profile_user_name = L"Pinsk"; | 160 const string16 second_profile_user_name = L"Pinsk"; |
142 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist_, false, | 161 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist_, false, |
143 second_profile_user_name, | 162 second_profile_user_name, |
144 &second_profile_shortcut_name)); | 163 &second_profile_shortcut_name)); |
145 | 164 |
146 FilePath user_shortcut_path = user_desktop_path.Append(shortcut_name); | 165 FilePath user_shortcut_path = user_desktop_path.Append(shortcut_name); |
147 FilePath system_shortcut_path = system_desktop_path.Append(shortcut_name); | 166 FilePath system_shortcut_path = system_desktop_path.Append(shortcut_name); |
148 FilePath default_profile_shortcut_path = user_desktop_path.Append( | 167 FilePath default_profile_shortcut_path = user_desktop_path.Append( |
149 default_profile_shortcut_name); | 168 default_profile_shortcut_name); |
150 FilePath second_profile_shortcut_path = user_desktop_path.Append( | 169 FilePath second_profile_shortcut_path = user_desktop_path.Append( |
151 second_profile_shortcut_name); | 170 second_profile_shortcut_name); |
152 | 171 |
153 // Test simple creation of a user-level shortcut. | 172 // Test simple creation of a user-level shortcut. |
154 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( | 173 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( |
155 dist_, | 174 dist_, |
156 exe_path.value(), | 175 exe_path.value(), |
157 description, | 176 description, |
158 L"", | 177 string16(), |
159 L"", | 178 string16(), |
160 exe_path.value(), | 179 exe_path.value(), |
161 dist_->GetIconIndex(), | 180 dist_->GetIconIndex(), |
162 ShellUtil::CURRENT_USER, | 181 ShellUtil::CURRENT_USER, |
163 ShellUtil::SHORTCUT_CREATE_ALWAYS)); | 182 ShellUtil::SHORTCUT_CREATE_ALWAYS)); |
164 EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS, | 183 EXPECT_EQ(file_util::VERIFY_SHORTCUT_SUCCESS, |
165 ShellUtil::VerifyChromeShortcut( | 184 VerifyChromeShortcut( |
166 exe_path.value(), user_shortcut_path.value(), description, 0)); | 185 exe_path.value(), user_shortcut_path.value(), description, 0)); |
167 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( | 186 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( |
168 dist_, | 187 dist_, |
169 ShellUtil::CURRENT_USER, | 188 ShellUtil::CURRENT_USER, |
170 ShellUtil::SHORTCUT_NO_OPTIONS)); | 189 ShellUtil::SHORTCUT_NO_OPTIONS)); |
171 | 190 |
172 // Test simple creation of a system-level shortcut. | 191 // Test simple creation of a system-level shortcut. |
173 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( | 192 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( |
174 dist_, | 193 dist_, |
175 exe_path.value(), | 194 exe_path.value(), |
176 description, | 195 description, |
177 L"", | 196 string16(), |
178 L"", | 197 string16(), |
179 exe_path.value(), | 198 exe_path.value(), |
180 dist_->GetIconIndex(), | 199 dist_->GetIconIndex(), |
181 ShellUtil::SYSTEM_LEVEL, | 200 ShellUtil::SYSTEM_LEVEL, |
182 ShellUtil::SHORTCUT_CREATE_ALWAYS)); | 201 ShellUtil::SHORTCUT_CREATE_ALWAYS)); |
183 EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS, | 202 EXPECT_EQ(file_util::VERIFY_SHORTCUT_SUCCESS, |
184 ShellUtil::VerifyChromeShortcut( | 203 VerifyChromeShortcut( |
185 exe_path.value(), system_shortcut_path.value(), description, | 204 exe_path.value(), system_shortcut_path.value(), description, |
186 0)); | 205 0)); |
187 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( | 206 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( |
188 dist_, | 207 dist_, |
189 ShellUtil::SYSTEM_LEVEL, | 208 ShellUtil::SYSTEM_LEVEL, |
190 ShellUtil::SHORTCUT_NO_OPTIONS)); | 209 ShellUtil::SHORTCUT_NO_OPTIONS)); |
191 | 210 |
192 // Test creation of a user-level shortcut when a system-level shortcut | 211 // Test creation of a user-level shortcut when a system-level shortcut |
193 // is already present (should fail). | 212 // is already present (should fail). |
194 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( | 213 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( |
195 dist_, | 214 dist_, |
196 exe_path.value(), | 215 exe_path.value(), |
197 description, | 216 description, |
198 L"", | 217 string16(), |
199 L"", | 218 string16(), |
200 exe_path.value(), | 219 exe_path.value(), |
201 dist_->GetIconIndex(), | 220 dist_->GetIconIndex(), |
202 ShellUtil::SYSTEM_LEVEL, | 221 ShellUtil::SYSTEM_LEVEL, |
203 ShellUtil::SHORTCUT_CREATE_ALWAYS)); | 222 ShellUtil::SHORTCUT_CREATE_ALWAYS)); |
204 EXPECT_FALSE(ShellUtil::CreateChromeDesktopShortcut( | 223 EXPECT_FALSE(ShellUtil::CreateChromeDesktopShortcut( |
205 dist_, | 224 dist_, |
206 exe_path.value(), | 225 exe_path.value(), |
207 description, | 226 description, |
208 L"", | 227 string16(), |
209 L"", | 228 string16(), |
210 exe_path.value(), | 229 exe_path.value(), |
211 dist_->GetIconIndex(), | 230 dist_->GetIconIndex(), |
212 ShellUtil::CURRENT_USER, | 231 ShellUtil::CURRENT_USER, |
213 ShellUtil::SHORTCUT_CREATE_ALWAYS)); | 232 ShellUtil::SHORTCUT_CREATE_ALWAYS)); |
214 EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS, | 233 EXPECT_EQ(file_util::VERIFY_SHORTCUT_SUCCESS, |
215 ShellUtil::VerifyChromeShortcut( | 234 VerifyChromeShortcut( |
216 exe_path.value(), system_shortcut_path.value(), description, | 235 exe_path.value(), system_shortcut_path.value(), description, |
217 0)); | 236 0)); |
218 EXPECT_FALSE(file_util::PathExists(user_shortcut_path)); | 237 EXPECT_FALSE(file_util::PathExists(user_shortcut_path)); |
219 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( | 238 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( |
220 dist_, | 239 dist_, |
221 ShellUtil::SYSTEM_LEVEL, | 240 ShellUtil::SYSTEM_LEVEL, |
222 ShellUtil::SHORTCUT_NO_OPTIONS)); | 241 ShellUtil::SHORTCUT_NO_OPTIONS)); |
223 | 242 |
224 // Test creation of a system-level shortcut when a user-level shortcut | 243 // Test creation of a system-level shortcut when a user-level shortcut |
225 // is already present (should succeed). | 244 // is already present (should succeed). |
226 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( | 245 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( |
227 dist_, | 246 dist_, |
228 exe_path.value(), | 247 exe_path.value(), |
229 description, | 248 description, |
230 L"", | 249 string16(), |
231 L"", | 250 string16(), |
232 exe_path.value(), | 251 exe_path.value(), |
233 dist_->GetIconIndex(), | 252 dist_->GetIconIndex(), |
234 ShellUtil::CURRENT_USER, | 253 ShellUtil::CURRENT_USER, |
235 ShellUtil::SHORTCUT_CREATE_ALWAYS)); | 254 ShellUtil::SHORTCUT_CREATE_ALWAYS)); |
236 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( | 255 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( |
237 dist_, | 256 dist_, |
238 exe_path.value(), | 257 exe_path.value(), |
239 description, | 258 description, |
240 L"", | 259 string16(), |
241 L"", | 260 string16(), |
242 exe_path.value(), | 261 exe_path.value(), |
243 dist_->GetIconIndex(), | 262 dist_->GetIconIndex(), |
244 ShellUtil::SYSTEM_LEVEL, | 263 ShellUtil::SYSTEM_LEVEL, |
245 ShellUtil::SHORTCUT_CREATE_ALWAYS)); | 264 ShellUtil::SHORTCUT_CREATE_ALWAYS)); |
246 EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS, | 265 EXPECT_EQ(file_util::VERIFY_SHORTCUT_SUCCESS, |
247 ShellUtil::VerifyChromeShortcut( | 266 VerifyChromeShortcut( |
248 exe_path.value(), user_shortcut_path.value(), description, 0)); | 267 exe_path.value(), user_shortcut_path.value(), description, 0)); |
249 EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS, | 268 EXPECT_EQ(file_util::VERIFY_SHORTCUT_SUCCESS, |
250 ShellUtil::VerifyChromeShortcut( | 269 VerifyChromeShortcut( |
251 exe_path.value(), system_shortcut_path.value(), description, | 270 exe_path.value(), system_shortcut_path.value(), description, |
252 0)); | 271 0)); |
253 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( | 272 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( |
254 dist_, | 273 dist_, |
255 ShellUtil::CURRENT_USER, | 274 ShellUtil::CURRENT_USER, |
256 ShellUtil::SHORTCUT_NO_OPTIONS)); | 275 ShellUtil::SHORTCUT_NO_OPTIONS)); |
257 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( | 276 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut( |
258 dist_, | 277 dist_, |
259 ShellUtil::SYSTEM_LEVEL, | 278 ShellUtil::SYSTEM_LEVEL, |
260 ShellUtil::SHORTCUT_NO_OPTIONS)); | 279 ShellUtil::SHORTCUT_NO_OPTIONS)); |
261 | 280 |
262 // Test creation of two profile-specific shortcuts (these are always | 281 // Test creation of two profile-specific shortcuts (these are always |
263 // user-level). | 282 // user-level). |
264 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( | 283 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( |
265 dist_, | 284 dist_, |
266 exe_path.value(), | 285 exe_path.value(), |
267 description, | 286 description, |
268 default_profile_user_name, | 287 default_profile_user_name, |
269 L"--profile-directory=\"Default\"", | 288 L"--profile-directory=\"Default\"", |
270 exe_path.value(), | 289 exe_path.value(), |
271 dist_->GetIconIndex(), | 290 dist_->GetIconIndex(), |
272 ShellUtil::CURRENT_USER, | 291 ShellUtil::CURRENT_USER, |
273 ShellUtil::SHORTCUT_CREATE_ALWAYS)); | 292 ShellUtil::SHORTCUT_CREATE_ALWAYS)); |
274 EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS, | 293 EXPECT_EQ(file_util::VERIFY_SHORTCUT_SUCCESS, |
275 ShellUtil::VerifyChromeShortcut( | 294 VerifyChromeShortcut( |
276 exe_path.value(), default_profile_shortcut_path.value(), | 295 exe_path.value(), default_profile_shortcut_path.value(), |
277 description, 0)); | 296 description, 0)); |
278 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( | 297 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( |
279 dist_, | 298 dist_, |
280 exe_path.value(), | 299 exe_path.value(), |
281 description, | 300 description, |
282 second_profile_user_name, | 301 second_profile_user_name, |
283 L"--profile-directory=\"Profile 1\"", | 302 L"--profile-directory=\"Profile 1\"", |
284 exe_path.value(), | 303 exe_path.value(), |
285 dist_->GetIconIndex(), | 304 dist_->GetIconIndex(), |
286 ShellUtil::CURRENT_USER, | 305 ShellUtil::CURRENT_USER, |
287 ShellUtil::SHORTCUT_CREATE_ALWAYS)); | 306 ShellUtil::SHORTCUT_CREATE_ALWAYS)); |
288 EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS, | 307 EXPECT_EQ(file_util::VERIFY_SHORTCUT_SUCCESS, |
289 ShellUtil::VerifyChromeShortcut( | 308 VerifyChromeShortcut( |
290 exe_path.value(), second_profile_shortcut_path.value(), | 309 exe_path.value(), second_profile_shortcut_path.value(), |
291 description, 0)); | 310 description, 0)); |
292 std::vector<string16> profile_names; | 311 std::vector<string16> profile_names; |
293 profile_names.push_back(default_profile_shortcut_name); | 312 profile_names.push_back(default_profile_shortcut_name); |
294 profile_names.push_back(second_profile_shortcut_name); | 313 profile_names.push_back(second_profile_shortcut_name); |
295 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcutsWithAppendedNames( | 314 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcutsWithAppendedNames( |
296 profile_names)); | 315 profile_names)); |
297 } | 316 } |
298 | 317 |
299 TEST_F(ShellUtilTestWithDirAndDist, BuildAppModelIdBasic) { | 318 TEST_F(ShellUtilTestWithDirAndDist, BuildAppModelIdBasic) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 384 |
366 const string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", | 385 const string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", |
367 L"MZXW6YTB", L"MZXW6YTBOI"}; | 386 L"MZXW6YTB", L"MZXW6YTBOI"}; |
368 | 387 |
369 // Run the tests, with one more letter in the input every pass. | 388 // Run the tests, with one more letter in the input every pass. |
370 for (int i = 0; i < arraysize(expected); ++i) { | 389 for (int i = 0; i < arraysize(expected); ++i) { |
371 ASSERT_EQ(expected[i], | 390 ASSERT_EQ(expected[i], |
372 ShellUtil::ByteArrayToBase32(test_array, i)); | 391 ShellUtil::ByteArrayToBase32(test_array, i)); |
373 } | 392 } |
374 } | 393 } |
OLD | NEW |