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/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/test/scoped_path_override.h" | 12 #include "base/test/scoped_path_override.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "base/test/test_shortcut_win.h" | 14 #include "base/test/test_shortcut_win.h" |
15 #include "base/win/shortcut.h" | 15 #include "base/win/shortcut.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/profiles/profile_shortcut_manager.h" | 18 #include "chrome/browser/profiles/profile_shortcut_manager.h" |
19 #include "chrome/browser/profiles/profile_shortcut_manager_win.h" | 19 #include "chrome/browser/profiles/profile_shortcut_manager_win.h" |
20 #include "chrome/installer/util/browser_distribution.h" | 20 #include "chrome/installer/util/browser_distribution.h" |
21 #include "chrome/installer/util/product.h" | 21 #include "chrome/installer/util/product.h" |
22 #include "chrome/installer/util/shell_util.h" | 22 #include "chrome/installer/util/shell_util.h" |
23 #include "chrome/test/base/testing_browser_process.h" | 23 #include "chrome/test/base/testing_browser_process.h" |
24 #include "chrome/test/base/testing_profile.h" | 24 #include "chrome/test/base/testing_profile.h" |
25 #include "chrome/test/base/testing_profile_manager.h" | 25 #include "chrome/test/base/testing_profile_manager.h" |
26 #include "content/public/test/test_browser_thread.h" | 26 #include "content/public/test/test_browser_thread.h" |
| 27 #include "grit/chromium_strings.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "ui/base/l10n/l10n_util.h" |
28 | 30 |
29 using content::BrowserThread; | 31 using content::BrowserThread; |
30 | 32 |
31 class ProfileShortcutManagerTest : public testing::Test { | 33 class ProfileShortcutManagerTest : public testing::Test { |
32 protected: | 34 protected: |
33 ProfileShortcutManagerTest() | 35 ProfileShortcutManagerTest() |
34 : ui_thread_(BrowserThread::UI, &message_loop_), | 36 : ui_thread_(BrowserThread::UI, &message_loop_), |
35 file_thread_(BrowserThread::FILE, &message_loop_), | 37 file_thread_(BrowserThread::FILE, &message_loop_), |
36 profile_shortcut_manager_(NULL), | 38 profile_shortcut_manager_(NULL), |
37 profile_info_cache_(NULL), | 39 profile_info_cache_(NULL), |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 string16 profile_2_name_; | 281 string16 profile_2_name_; |
280 FilePath profile_2_path_; | 282 FilePath profile_2_path_; |
281 string16 profile_3_name_; | 283 string16 profile_3_name_; |
282 FilePath profile_3_path_; | 284 FilePath profile_3_path_; |
283 }; | 285 }; |
284 | 286 |
285 TEST_F(ProfileShortcutManagerTest, ShortcutFilename) { | 287 TEST_F(ProfileShortcutManagerTest, ShortcutFilename) { |
286 const string16 kProfileName = L"Harry"; | 288 const string16 kProfileName = L"Harry"; |
287 BrowserDistribution* distribution = GetDistribution(); | 289 BrowserDistribution* distribution = GetDistribution(); |
288 const string16 expected_name = kProfileName + L" - " + | 290 const string16 expected_name = kProfileName + L" - " + |
289 distribution->GetAppShortCutName() + installer::kLnkExt; | 291 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME) + installer::kLnkExt; |
290 EXPECT_EQ(expected_name, | 292 EXPECT_EQ(expected_name, |
291 profiles::internal::GetShortcutFilenameForProfile(kProfileName, | 293 profiles::internal::GetShortcutFilenameForProfile(kProfileName, |
292 distribution)); | 294 distribution)); |
293 } | 295 } |
294 | 296 |
295 TEST_F(ProfileShortcutManagerTest, ShortcutLongFilenameIsTrimmed) { | 297 TEST_F(ProfileShortcutManagerTest, ShortcutLongFilenameIsTrimmed) { |
296 const string16 kLongProfileName = L"Harry Harry Harry Harry Harry Harry Harry" | 298 const string16 kLongProfileName = L"Harry Harry Harry Harry Harry Harry Harry" |
297 L"Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry" | 299 L"Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry" |
298 L"Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry"; | 300 L"Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry Harry"; |
299 const string16 file_name = | 301 const string16 file_name = |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); | 734 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
733 RunPendingTasks(); | 735 RunPendingTasks(); |
734 | 736 |
735 // Verify that only the system-level shortcut still exists. | 737 // Verify that only the system-level shortcut still exists. |
736 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); | 738 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); |
737 EXPECT_FALSE(file_util::PathExists( | 739 EXPECT_FALSE(file_util::PathExists( |
738 GetDefaultShortcutPathForProfile(string16()))); | 740 GetDefaultShortcutPathForProfile(string16()))); |
739 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path)); | 741 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path)); |
740 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); | 742 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); |
741 } | 743 } |
OLD | NEW |