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

Unified Diff: chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc

Issue 10914109: Refactoring and tests for the highly undertested file_util::CreateOrUpdateShortcutLink() method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: namespace s/Win/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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/win/win_util.cc ('k') | chrome/browser/shell_integration_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
diff --git a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
index f1ddaed54812ae77caf8b703444feec244fdb364..826bb6d533b4276a9312767b3b3d5b8fa3c6fb30 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
+++ b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
@@ -7,6 +7,8 @@
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "base/utf_string_conversions.h"
+#include "base/test/test_shortcut_win.h"
+#include "base/win/shortcut.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_shortcut_manager.h"
@@ -25,10 +27,10 @@ using content::BrowserThread;
namespace {
-ShellUtil::VerifyShortcutStatus VerifyProfileShortcut(
+base::win::VerifyShortcutStatus VerifyProfileShortcut(
const string16& profile_name) {
FilePath exe_path;
- CHECK(PathService::Get(base::FILE_EXE, &exe_path));
+ EXPECT_TRUE(PathService::Get(base::FILE_EXE, &exe_path));
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
@@ -41,9 +43,13 @@ ShellUtil::VerifyShortcutStatus VerifyProfileShortcut(
&shortcut_name);
shortcut_path = shortcut_path.Append(shortcut_name);
- return ShellUtil::VerifyChromeShortcut(
- exe_path.value(), shortcut_path.value(), dist->GetAppDescription(),
- 0);
+ // TODO(hallielaine): With this new struct method for VerifyShortcut you can
+ // now test more properties like: arguments, icon, icon_index, and app_id.
+ base::win::ShortcutProperties expected_properties;
+ expected_properties.set_target(exe_path);
+ expected_properties.set_description(dist->GetAppDescription());
+ expected_properties.set_dual_mode(false);
+ return base::win::VerifyShortcut(shortcut_path, expected_properties);
}
} // namespace
@@ -94,7 +100,7 @@ class ProfileShortcutManagerTest : public testing::Test {
profile_path);
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_FAILURE_UNEXPECTED,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(profile_name));
ASSERT_FALSE(file_util::PathExists(profile_path.Append(
FILE_PATH_LITERAL("Google Profile.ico"))));
@@ -102,7 +108,7 @@ class ProfileShortcutManagerTest : public testing::Test {
}
void SetupDefaultProfileShortcut() {
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_FAILURE_UNEXPECTED,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(profile_name_));
profile_manager_->profile_info_cache()->AddProfileToCache(
@@ -113,15 +119,15 @@ class ProfileShortcutManagerTest : public testing::Test {
MessageLoop::current()->Run();
// We now have 1 profile, so we expect a new shortcut with no profile
// information.
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(string16()));
}
void SetupAndCreateTwoShortcuts() {
ASSERT_EQ(0, profile_manager_->profile_info_cache()->GetNumberOfProfiles());
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_FAILURE_UNEXPECTED,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(profile_name_));
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_FAILURE_UNEXPECTED,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(second_profile_name_));
profile_manager_->profile_info_cache()->AddProfileToCache(
@@ -134,9 +140,9 @@ class ProfileShortcutManagerTest : public testing::Test {
CreateProfileShortcut(second_dest_path_);
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(profile_name_));
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(second_profile_name_));
}
@@ -164,7 +170,7 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreate) {
// We now have 2 profiles, so we expect a new shortcut with profile
// information for this 2nd profile.
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(second_profile_name_));
ASSERT_TRUE(file_util::PathExists(second_dest_path_.Append(
FILE_PATH_LITERAL("Google Profile.ico"))));
@@ -175,7 +181,7 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsUpdate) {
return;
ProfileShortcutManagerTest::SetupDefaultProfileShortcut();
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_FAILURE_UNEXPECTED,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(second_profile_name_));
profile_manager_->profile_info_cache()->AddProfileToCache(
@@ -184,7 +190,7 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsUpdate) {
CreateProfileShortcut(second_dest_path_);
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(second_profile_name_));
// Cause an update in ProfileShortcutManager by modifying the profile info
@@ -196,9 +202,9 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsUpdate) {
new_profile_name);
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_FAILURE_UNEXPECTED,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(second_profile_name_));
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(new_profile_name));
}
@@ -212,15 +218,15 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsDeleteSecondToLast) {
second_dest_path_);
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_FAILURE_UNEXPECTED,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(second_profile_name_));
// Verify that the profile name has been removed from the remaining shortcut
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(string16()));
// Verify that an additional shortcut, with the default profile's name does
// not exist
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_FAILURE_UNEXPECTED,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(profile_name_));
}
@@ -236,11 +242,11 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreateSecond) {
MessageLoop::current()->Run();
// Verify that a default shortcut exists (no profile name/avatar)
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(string16()));
// Verify that an additional shortcut, with the default profile's name does
// not exist
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_FAILURE_UNEXPECTED,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(profile_name_));
// Create a second profile and shortcut
@@ -250,14 +256,14 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreateSecond) {
CreateProfileShortcut(second_dest_path_);
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(second_profile_name_));
// Verify that the original shortcut received the profile's name
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(profile_name_));
// Verify that a default shortcut no longer exists
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_FAILURE_UNEXPECTED,
+ EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(string16()));
}
« no previous file with comments | « base/win/win_util.cc ('k') | chrome/browser/shell_integration_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698