Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc

Issue 10964007: Re-commit: Add new PathService paths for Windows' All Users Desktop and Quick Launch folders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windows only includes/pragma in the ifdef OS_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/browser/download/download_util.cc ('k') | chrome/browser/shell_integration_linux.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 "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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
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() OVERRIDE {
65 // Mock the user's Desktop into a temp directory.
66 ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir());
67 ASSERT_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
75 second_dest_path_ = 80 second_dest_path_ =
76 profile_manager_->profile_info_cache()->GetUserDataDir(); 81 profile_manager_->profile_info_cache()->GetUserDataDir();
77 second_dest_path_ = 82 second_dest_path_ =
78 second_dest_path_.Append(FILE_PATH_LITERAL("My profile 2")); 83 second_dest_path_.Append(FILE_PATH_LITERAL("My profile 2"));
79 file_util::CreateDirectoryW(second_dest_path_); 84 file_util::CreateDirectoryW(second_dest_path_);
80 second_profile_name_ = ASCIIToUTF16("My profile 2"); 85 second_profile_name_ = ASCIIToUTF16("My profile 2");
81 } 86 }
82 87
83 virtual void TearDown() { 88 virtual void TearDown() OVERRIDE {
84 message_loop_.RunAllPending(); 89 message_loop_.RunAllPending();
85 90
86 int num_profiles = 91 int num_profiles =
87 profile_manager_->profile_info_cache()->GetNumberOfProfiles(); 92 profile_manager_->profile_info_cache()->GetNumberOfProfiles();
88 93
89 // Remove all shortcuts except the last (since it will no longer have 94 // Remove all shortcuts except the last (since it will no longer have
90 // an appended name). 95 // an appended name).
91 for (int i = 0; i < num_profiles; ++i) { 96 for (int i = 0; i < num_profiles; ++i) {
92 const FilePath profile_path = 97 const FilePath profile_path =
93 profile_manager_->profile_info_cache()->GetPathOfProfileAtIndex(0); 98 profile_manager_->profile_info_cache()->GetPathOfProfileAtIndex(0);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « chrome/browser/download/download_util.cc ('k') | chrome/browser/shell_integration_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698