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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
| 9 #include "base/string16.h" |
9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
10 #include "base/test/test_shortcut_win.h" | 11 #include "base/test/test_shortcut_win.h" |
11 #include "base/win/shortcut.h" | 12 #include "base/win/shortcut.h" |
12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chrome/browser/profiles/profile_shortcut_manager.h" | 15 #include "chrome/browser/profiles/profile_shortcut_manager.h" |
15 #include "chrome/installer/util/browser_distribution.h" | 16 #include "chrome/installer/util/browser_distribution.h" |
16 #include "chrome/installer/util/shell_util.h" | 17 #include "chrome/installer/util/shell_util.h" |
17 #include "chrome/test/base/testing_browser_process.h" | 18 #include "chrome/test/base/testing_browser_process.h" |
18 #include "chrome/test/base/testing_pref_service.h" | 19 #include "chrome/test/base/testing_pref_service.h" |
19 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
20 #include "chrome/test/base/testing_profile_manager.h" | 21 #include "chrome/test/base/testing_profile_manager.h" |
21 #include "content/public/test/test_browser_thread.h" | 22 #include "content/public/test/test_browser_thread.h" |
22 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
25 | 26 |
26 using content::BrowserThread; | 27 using content::BrowserThread; |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
30 // Sets |path| to the path to the shortcut for this profile. | 31 // Sets |path| to the path to the shortcut for this profile. |
31 // Automatically fails the test on failure to do so. | 32 // Automatically fails the test on failure to do so. |
32 void GetShortcutPathForProfile(BrowserDistribution* dist, | 33 void GetShortcutPathForProfile(BrowserDistribution* dist, |
33 const string16& profile_name, | 34 const string16& profile_name, |
34 FilePath* path) { | 35 FilePath* path) { |
35 string16 shortcut_name; | 36 EXPECT_TRUE(ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_DESKTOP, dist, |
36 EXPECT_TRUE(ShellUtil::GetDesktopPath(false, path)); | 37 ShellUtil::CURRENT_USER, path)); |
37 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, false, profile_name, | 38 string16 shortcut_name( |
38 &shortcut_name)); | 39 ProfileShortcutManager::GetShortcutNameForProfile(profile_name)); |
39 *path = path->Append(shortcut_name); | 40 *path = path->Append(shortcut_name); |
40 } | 41 } |
41 | 42 |
42 // Returns true if the shortcut for this profile exists. | 43 // Returns true if the shortcut for this profile exists. |
43 bool ProfileShortcutExists(BrowserDistribution* dist, | 44 bool ProfileShortcutExists(BrowserDistribution* dist, |
44 const string16& profile_name) { | 45 const string16& profile_name) { |
45 FilePath shortcut_path; | 46 FilePath shortcut_path; |
46 GetShortcutPathForProfile(dist, profile_name, &shortcut_path); | 47 GetShortcutPathForProfile(dist, profile_name, &shortcut_path); |
47 return file_util::PathExists(shortcut_path); | 48 return file_util::PathExists(shortcut_path); |
48 } | 49 } |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 CreateProfileShortcut(second_dest_path_); | 264 CreateProfileShortcut(second_dest_path_); |
264 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 265 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
265 MessageLoop::current()->Run(); | 266 MessageLoop::current()->Run(); |
266 ValidateProfileShortcut(dist_, second_profile_name_); | 267 ValidateProfileShortcut(dist_, second_profile_name_); |
267 | 268 |
268 // Verify that the original shortcut received the profile's name | 269 // Verify that the original shortcut received the profile's name |
269 ValidateProfileShortcut(dist_, profile_name_); | 270 ValidateProfileShortcut(dist_, profile_name_); |
270 // Verify that a default shortcut no longer exists | 271 // Verify that a default shortcut no longer exists |
271 EXPECT_FALSE(ProfileShortcutExists(dist_, string16())); | 272 EXPECT_FALSE(ProfileShortcutExists(dist_, string16())); |
272 } | 273 } |
OLD | NEW |