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

Powered by Google App Engine
This is Rietveld 408576698