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

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: 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
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 5f3ee45afdd72c8497bde500cc1d6a3efc313c5e..82b5d8f6711679517c2be74d80d0593dc3c12512 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
+++ b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
@@ -7,6 +7,7 @@
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "base/utf_string_conversions.h"
+#include "base/test/test_file_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_shortcut_manager.h"
#include "chrome/installer/util/browser_distribution.h"
@@ -24,10 +25,10 @@ using content::BrowserThread;
namespace {
-ShellUtil::VerifyShortcutStatus VerifyProfileShortcut(
+file_util::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();
@@ -40,9 +41,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.
+ file_util::ShortcutProperties expected_properties;
+ expected_properties.set_target(exe_path.value());
+ expected_properties.set_description(dist->GetAppDescription());
+ expected_properties.set_dual_mode(false);
+ return file_util::VerifyShortcut(shortcut_path.value(), expected_properties);
}
} // namespace
@@ -96,7 +101,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(file_util::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(profile_name));
ASSERT_FALSE(file_util::PathExists(profile_path.Append(
FILE_PATH_LITERAL("Google Profile.ico"))));
@@ -104,7 +109,7 @@ class ProfileShortcutManagerTest : public testing::Test {
}
void SetupDefaultProfileShortcut() {
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_FAILURE_UNEXPECTED,
+ EXPECT_EQ(file_util::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(profile_name_));
profile_manager_->profile_info_cache()->AddProfileToCache(
@@ -113,15 +118,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(file_util::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(file_util::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(profile_name_));
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_FAILURE_UNEXPECTED,
+ EXPECT_EQ(file_util::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(second_profile_name_));
profile_manager_->profile_info_cache()->AddProfileToCache(
@@ -131,9 +136,9 @@ class ProfileShortcutManagerTest : public testing::Test {
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(file_util::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(profile_name_));
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(file_util::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(second_profile_name_));
}
@@ -160,7 +165,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(file_util::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(second_profile_name_));
ASSERT_TRUE(file_util::PathExists(second_dest_path_.Append(
FILE_PATH_LITERAL("Google Profile.ico"))));
@@ -171,14 +176,14 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsUpdate) {
return;
ProfileShortcutManagerTest::SetupDefaultProfileShortcut();
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_FAILURE_UNEXPECTED,
+ EXPECT_EQ(file_util::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(second_profile_name_));
profile_manager_->profile_info_cache()->AddProfileToCache(
second_dest_path_, second_profile_name_, string16(), 0);
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(file_util::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(second_profile_name_));
// Cause an update in ProfileShortcutManager by modifying the profile info
@@ -190,9 +195,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(file_util::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(second_profile_name_));
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(file_util::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(new_profile_name));
}
@@ -206,15 +211,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(file_util::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(file_util::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(file_util::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(profile_name_));
}
@@ -230,11 +235,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(file_util::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(file_util::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(profile_name_));
// Create a second profile and shortcut
@@ -243,14 +248,14 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreateSecond) {
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_SUCCESS,
+ EXPECT_EQ(file_util::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(file_util::VERIFY_SHORTCUT_SUCCESS,
VerifyProfileShortcut(profile_name_));
// Verify that a default shortcut no longer exists
- EXPECT_EQ(ShellUtil::VERIFY_SHORTCUT_FAILURE_UNEXPECTED,
+ EXPECT_EQ(file_util::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND,
VerifyProfileShortcut(string16()));
}

Powered by Google App Engine
This is Rietveld 408576698