| Index: chrome/browser/profiles/profile_manager_unittest.cc
|
| ===================================================================
|
| --- chrome/browser/profiles/profile_manager_unittest.cc (revision 150342)
|
| +++ chrome/browser/profiles/profile_manager_unittest.cc (working copy)
|
| @@ -23,12 +23,15 @@
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/profiles/profile_info_cache.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| +#include "chrome/browser/profiles/profile_shortcut_manager.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/common/chrome_constants.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| #include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/pref_names.h"
|
| +#include "chrome/installer/util/browser_distribution.h"
|
| +#include "chrome/installer/util/shell_util.h"
|
| #include "chrome/test/base/test_browser_window.h"
|
| #include "chrome/test/base/testing_browser_process.h"
|
| #include "chrome/test/base/testing_pref_service.h"
|
| @@ -37,6 +40,7 @@
|
| #include "content/public/test/test_browser_thread.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| +#include "ui/base/resource/resource_bundle.h"
|
|
|
| #if defined(OS_CHROMEOS)
|
| #include "chrome/browser/chromeos/cros/cros_library.h"
|
| @@ -77,13 +81,6 @@
|
|
|
| return new TestingProfile(path, this);
|
| }
|
| -
|
| -#if defined(OS_WIN)
|
| - virtual ProfileShortcutManagerWin* CreateShortcutManager() OVERRIDE {
|
| - // We should avoid creating shortcuts in these tests.
|
| - return NULL;
|
| - }
|
| -#endif
|
| };
|
|
|
| } // namespace testing
|
| @@ -121,6 +118,10 @@
|
| CommandLine *cl = CommandLine::ForCurrentProcess();
|
| cl->AppendSwitch(switches::kTestType);
|
| #endif
|
| +#if defined(OS_WIN)
|
| + CommandLine *c1 = CommandLine::ForCurrentProcess();
|
| + c1->AppendSwitch(switches::kProfileDesktopShortcuts);
|
| +#endif
|
| }
|
|
|
| virtual void TearDown() {
|
| @@ -287,13 +288,16 @@
|
|
|
| profile_manager->CreateProfileAsync(dest_path,
|
| base::Bind(&MockObserver::OnProfileCreated,
|
| - base::Unretained(&mock_observer1)), string16(), string16());
|
| + base::Unretained(&mock_observer1)),
|
| + string16(), string16());
|
| profile_manager->CreateProfileAsync(dest_path,
|
| base::Bind(&MockObserver::OnProfileCreated,
|
| - base::Unretained(&mock_observer2)), string16(), string16());
|
| + base::Unretained(&mock_observer2)),
|
| + string16(), string16());
|
| profile_manager->CreateProfileAsync(dest_path,
|
| base::Bind(&MockObserver::OnProfileCreated,
|
| - base::Unretained(&mock_observer3)), string16(), string16());
|
| + base::Unretained(&mock_observer3)),
|
| + string16(), string16());
|
|
|
| message_loop_.RunAllPending();
|
| }
|
| @@ -569,3 +573,65 @@
|
| ASSERT_EQ(0U, last_opened_profiles.size());
|
| }
|
| #endif // !defined(OS_ANDROID)
|
| +
|
| +#if defined(OS_WIN)
|
| +TEST_F(ProfileManagerTest, WinDesktopShortcutsIconExists) {
|
| + FilePath dest_path = temp_dir_.path();
|
| + string16 profile_name = ASCIIToUTF16("My Profile");
|
| +
|
| + ProfileManager* profile_manager = g_browser_process->profile_manager();
|
| +
|
| + gfx::Image& avatar = ResourceBundle::GetSharedInstance().
|
| + GetNativeImageNamed(profile_manager->GetProfileInfoCache().
|
| + GetDefaultAvatarIconResourceIDAtIndex(0));
|
| +
|
| + ProfileShortcutManager::CreateChromeDesktopShortcut(dest_path,
|
| + profile_name, avatar);
|
| +
|
| + ASSERT_TRUE(file_util::ContainsPath(temp_dir_.path(), dest_path.Append(
|
| + (FILE_PATH_LITERAL("Google Profile.ico")))));
|
| +
|
| + ProfileShortcutManager::DeleteChromeDesktopShortcut(dest_path);
|
| +}
|
| +
|
| +TEST_F(ProfileManagerTest, WinDesktopShortcutsLnk) {
|
| + FilePath dest_path = temp_dir_.path();
|
| + dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile 1"));
|
| +
|
| + ProfileManager* profile_manager = g_browser_process->profile_manager();
|
| +
|
| + // Successfully create the profile.
|
| + TestingProfile* profile =
|
| + static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path));
|
| + ASSERT_TRUE(profile);
|
| +
|
| + profile->SetName(ASCIIToWide("My Profile"));
|
| +
|
| + gfx::Image& avatar = ResourceBundle::GetSharedInstance().
|
| + GetNativeImageNamed(profile_manager->GetProfileInfoCache().
|
| + GetDefaultAvatarIconResourceIDAtIndex(0));
|
| +
|
| + ProfileShortcutManager::CreateChromeDesktopShortcut(dest_path,
|
| + profile->GetName(), avatar);
|
| +
|
| + FilePath exe_path;
|
| + ASSERT_TRUE(PathService::Get(base::FILE_EXE, &exe_path));
|
| +
|
| + FilePath shortcut;
|
| + string16 shortcut_name;
|
| + BrowserDistribution* dist = BrowserDistribution::GetDistribution();
|
| +
|
| + // Get the desktop path of the current user
|
| + ShellUtil::GetDesktopPath(false, &shortcut);
|
| + // Get the name of the shortcut with profile attached
|
| + ShellUtil::GetChromeShortcutName(dist, false, profile->GetName(),
|
| + &shortcut_name);
|
| + shortcut = shortcut.Append(shortcut_name);
|
| +
|
| + EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
|
| + ShellUtil::VerifyChromeShortcut(exe_path.value(),
|
| + shortcut.value(), dist->GetAppDescription(), 0));
|
| +
|
| + ProfileShortcutManager::DeleteChromeDesktopShortcut(dest_path);
|
| +}
|
| +#endif // defined(OS_WIN)
|
|
|