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 <objbase.h> // For CoInitialize(). | 5 #include <objbase.h> // For CoInitialize(). |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 229 |
230 TEST_F(ProfileShortcutManagerTest, ShortcutFilename) { | 230 TEST_F(ProfileShortcutManagerTest, ShortcutFilename) { |
231 const string16 kProfileName = L"Harry"; | 231 const string16 kProfileName = L"Harry"; |
232 const string16 expected_name = kProfileName + L" - " + | 232 const string16 expected_name = kProfileName + L" - " + |
233 distribution_->GetAppShortCutName() + installer::kLnkExt; | 233 distribution_->GetAppShortCutName() + installer::kLnkExt; |
234 EXPECT_EQ(expected_name, | 234 EXPECT_EQ(expected_name, |
235 profiles::internal::GetShortcutFilenameForProfile(kProfileName, | 235 profiles::internal::GetShortcutFilenameForProfile(kProfileName, |
236 distribution_)); | 236 distribution_)); |
237 } | 237 } |
238 | 238 |
| 239 TEST_F(ProfileShortcutManagerTest, ShortcutLongFilenameIsTrimmed) { |
| 240 const string16 kLongProfileName = L"Harry Harry Harry Harry Harry Harry Harry" |
| 241 L"Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry" |
| 242 L"Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry"; |
| 243 string16 file_name = |
| 244 profiles::internal::GetShortcutFilenameForProfile( |
| 245 kLongProfileName, distribution_); |
| 246 EXPECT_LT(file_name.size(), kLongProfileName.size()); |
| 247 } |
| 248 |
| 249 TEST_F(ProfileShortcutManagerTest, ShortcutFilenameStripsReservedCharacters) { |
| 250 const string16 kProfileName = L"<Harry/>"; |
| 251 const string16 kSanitizedProfileName = L"Harry"; |
| 252 const string16 expected_name = kSanitizedProfileName + L" - " + |
| 253 distribution_->GetAppShortCutName() + installer::kLnkExt; |
| 254 EXPECT_EQ(expected_name, |
| 255 profiles::internal::GetShortcutFilenameForProfile(kProfileName, |
| 256 distribution_)); |
| 257 } |
| 258 |
239 TEST_F(ProfileShortcutManagerTest, UnbadgedShortcutFilename) { | 259 TEST_F(ProfileShortcutManagerTest, UnbadgedShortcutFilename) { |
240 EXPECT_EQ(distribution_->GetAppShortCutName() + installer::kLnkExt, | 260 EXPECT_EQ(distribution_->GetAppShortCutName() + installer::kLnkExt, |
241 profiles::internal::GetShortcutFilenameForProfile(string16(), | 261 profiles::internal::GetShortcutFilenameForProfile(string16(), |
242 distribution_)); | 262 distribution_)); |
243 } | 263 } |
244 | 264 |
245 TEST_F(ProfileShortcutManagerTest, ShortcutFlags) { | 265 TEST_F(ProfileShortcutManagerTest, ShortcutFlags) { |
246 const string16 kProfileName = L"MyProfileX"; | 266 const string16 kProfileName = L"MyProfileX"; |
247 const FilePath profile_path = | 267 const FilePath profile_path = |
248 profile_info_cache_->GetUserDataDir().Append(kProfileName); | 268 profile_info_cache_->GetUserDataDir().Append(kProfileName); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 CreateRegularShortcutWithName(FROM_HERE, L"MyChrome"); | 459 CreateRegularShortcutWithName(FROM_HERE, L"MyChrome"); |
440 | 460 |
441 // Add another profile and check that one shortcut was renamed and that the | 461 // Add another profile and check that one shortcut was renamed and that the |
442 // other shortcut was updated but kept the same name. | 462 // other shortcut was updated but kept the same name. |
443 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); | 463 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); |
444 EXPECT_FALSE(file_util::PathExists(regular_shortcut_path)); | 464 EXPECT_FALSE(file_util::PathExists(regular_shortcut_path)); |
445 ValidateProfileShortcutAtPath(FROM_HERE, customized_regular_shortcut_path, | 465 ValidateProfileShortcutAtPath(FROM_HERE, customized_regular_shortcut_path, |
446 profile_1_path_); | 466 profile_1_path_); |
447 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); | 467 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); |
448 } | 468 } |
OLD | NEW |