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/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "base/test/test_shortcut_win.h" | 10 #include "base/test/test_shortcut_win.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 class ProfileShortcutManagerTest : public testing::Test { | 57 class ProfileShortcutManagerTest : public testing::Test { |
58 protected: | 58 protected: |
59 ProfileShortcutManagerTest() | 59 ProfileShortcutManagerTest() |
60 : ui_thread_(BrowserThread::UI, &message_loop_), | 60 : ui_thread_(BrowserThread::UI, &message_loop_), |
61 file_thread_(BrowserThread::FILE, &message_loop_) { | 61 file_thread_(BrowserThread::FILE, &message_loop_) { |
62 } | 62 } |
63 | 63 |
64 virtual void SetUp() { | 64 virtual void SetUp() { |
| 65 // Mock the user's Desktop into a temp directory. |
| 66 ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir()); |
| 67 EXPECT_TRUE(PathService::Override(base::DIR_USER_DESKTOP, |
| 68 fake_user_desktop_.path())); |
| 69 |
65 TestingBrowserProcess* browser_process = | 70 TestingBrowserProcess* browser_process = |
66 static_cast<TestingBrowserProcess*>(g_browser_process); | 71 static_cast<TestingBrowserProcess*>(g_browser_process); |
67 profile_manager_.reset(new TestingProfileManager(browser_process)); | 72 profile_manager_.reset(new TestingProfileManager(browser_process)); |
68 ASSERT_TRUE(profile_manager_->SetUp()); | 73 ASSERT_TRUE(profile_manager_->SetUp()); |
69 | 74 |
70 dest_path_ = profile_manager_->profile_info_cache()->GetUserDataDir(); | 75 dest_path_ = profile_manager_->profile_info_cache()->GetUserDataDir(); |
71 dest_path_ = dest_path_.Append(FILE_PATH_LITERAL("My profile")); | 76 dest_path_ = dest_path_.Append(FILE_PATH_LITERAL("My profile")); |
72 file_util::CreateDirectoryW(dest_path_); | 77 file_util::CreateDirectoryW(dest_path_); |
73 profile_name_ = ASCIIToUTF16("My profile"); | 78 profile_name_ = ASCIIToUTF16("My profile"); |
74 | 79 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, | 146 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, |
142 VerifyProfileShortcut(profile_name_)); | 147 VerifyProfileShortcut(profile_name_)); |
143 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, | 148 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, |
144 VerifyProfileShortcut(second_profile_name_)); | 149 VerifyProfileShortcut(second_profile_name_)); |
145 } | 150 } |
146 | 151 |
147 MessageLoopForUI message_loop_; | 152 MessageLoopForUI message_loop_; |
148 content::TestBrowserThread ui_thread_; | 153 content::TestBrowserThread ui_thread_; |
149 content::TestBrowserThread file_thread_; | 154 content::TestBrowserThread file_thread_; |
150 scoped_ptr<TestingProfileManager> profile_manager_; | 155 scoped_ptr<TestingProfileManager> profile_manager_; |
| 156 ScopedTempDir fake_user_desktop_; |
151 FilePath dest_path_; | 157 FilePath dest_path_; |
152 string16 profile_name_; | 158 string16 profile_name_; |
153 FilePath second_dest_path_; | 159 FilePath second_dest_path_; |
154 string16 second_profile_name_; | 160 string16 second_profile_name_; |
155 }; | 161 }; |
156 | 162 |
157 TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreate) { | 163 TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreate) { |
158 if (!profile_manager_->profile_manager()->profile_shortcut_manager()) | 164 if (!profile_manager_->profile_manager()->profile_shortcut_manager()) |
159 return; | 165 return; |
160 ProfileShortcutManagerTest::SetupDefaultProfileShortcut(); | 166 ProfileShortcutManagerTest::SetupDefaultProfileShortcut(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 VerifyProfileShortcut(second_profile_name_)); | 264 VerifyProfileShortcut(second_profile_name_)); |
259 | 265 |
260 // Verify that the original shortcut received the profile's name | 266 // Verify that the original shortcut received the profile's name |
261 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, | 267 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, |
262 VerifyProfileShortcut(profile_name_)); | 268 VerifyProfileShortcut(profile_name_)); |
263 // Verify that a default shortcut no longer exists | 269 // Verify that a default shortcut no longer exists |
264 EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND, | 270 EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND, |
265 VerifyProfileShortcut(string16())); | 271 VerifyProfileShortcut(string16())); |
266 } | 272 } |
267 | 273 |
OLD | NEW |