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

Unified Diff: chrome/browser/web_applications/web_app_mac_unittest.mm

Issue 15724019: Recreate shortcuts on app update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Include profile dir in bundle id. Created 7 years, 6 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/web_applications/web_app_mac_unittest.mm
diff --git a/chrome/browser/web_applications/web_app_mac_unittest.mm b/chrome/browser/web_applications/web_app_mac_unittest.mm
index f99dd4891ff6fe81707775729a77a8655df4b03c..b0ecc4d71b6d1172eb3aa6cb195f595c886480e7 100644
--- a/chrome/browser/web_applications/web_app_mac_unittest.mm
+++ b/chrome/browser/web_applications/web_app_mac_unittest.mm
@@ -30,26 +30,29 @@ using ::testing::NiceMock;
namespace {
+const char kFakeChromeBundleId[] = "fake.cfbundleidentifier";
+
class WebAppShortcutCreatorMock : public web_app::WebAppShortcutCreator {
public:
explicit WebAppShortcutCreatorMock(
const ShellIntegration::ShortcutInfo& shortcut_info)
- : WebAppShortcutCreator(base::FilePath("/fake/path"), shortcut_info,
- UTF8ToUTF16("fake.cfbundleidentifier")) {
+ : WebAppShortcutCreator(base::FilePath("/fake/path"),
+ shortcut_info,
+ kFakeChromeBundleId) {
}
MOCK_CONST_METHOD0(GetDestinationPath, base::FilePath());
- MOCK_CONST_METHOD1(RevealGeneratedBundleInFinder,
- void (const base::FilePath&));
+ MOCK_CONST_METHOD0(RevealAppShimInFinder, void());
+ MOCK_CONST_METHOD1(GetAppBundleById, base::FilePath(const std::string&));
};
ShellIntegration::ShortcutInfo GetShortcutInfo() {
ShellIntegration::ShortcutInfo info;
- info.extension_id = "extension_id";
+ info.extension_id = "extensionid";
info.extension_path = base::FilePath("/fake/extension/path");
info.title = ASCIIToUTF16("Shortcut Title");
info.url = GURL("http://example.com/");
- info.profile_path = base::FilePath("Default");
+ info.profile_path = base::FilePath("Profile 1");
info.profile_name = "profile name";
return info;
}
@@ -71,11 +74,11 @@ TEST(WebAppShortcutCreatorTest, CreateShortcut) {
NiceMock<WebAppShortcutCreatorMock> shortcut_creator(info);
EXPECT_CALL(shortcut_creator, GetDestinationPath())
.WillRepeatedly(Return(dst_folder));
- EXPECT_CALL(shortcut_creator, RevealGeneratedBundleInFinder(dst_path));
+ EXPECT_CALL(shortcut_creator, RevealAppShimInFinder());
EXPECT_TRUE(shortcut_creator.CreateShortcut());
EXPECT_TRUE(file_util::PathExists(dst_path));
- EXPECT_EQ(dst_path.value(), shortcut_creator.GetShortcutPath().value());
+ EXPECT_EQ(dst_path.BaseName(), shortcut_creator.GetShortcutName());
base::FilePath plist_path = dst_path.Append("Contents").Append("Info.plist");
NSDictionary* plist = [NSDictionary dictionaryWithContentsOfFile:
@@ -98,6 +101,39 @@ TEST(WebAppShortcutCreatorTest, CreateShortcut) {
}
}
+TEST(WebAppShortcutCreatorTest, UpdateShortcuts) {
+ base::ScopedTempDir scoped_temp_dir;
+ EXPECT_TRUE(scoped_temp_dir.CreateUniqueTempDir());
+ base::ScopedTempDir scoped_temp_dir_other;
+ EXPECT_TRUE(scoped_temp_dir_other.CreateUniqueTempDir());
+
+ ShellIntegration::ShortcutInfo info = GetShortcutInfo();
+
+ base::FilePath app_name(
+ info.profile_path.value() + " " + info.extension_id + ".app");
+ base::FilePath dst_folder = scoped_temp_dir.path();
+ base::FilePath other_folder = scoped_temp_dir_other.path();
+
+ NiceMock<WebAppShortcutCreatorMock> shortcut_creator(info);
+ EXPECT_CALL(shortcut_creator, GetDestinationPath())
+ .WillRepeatedly(Return(dst_folder));
+
+ std::string expected_bundle_id = kFakeChromeBundleId;
+ expected_bundle_id += ".app.Profile-1." + info.extension_id;
+ EXPECT_CALL(shortcut_creator, GetAppBundleById(expected_bundle_id))
tapted 2013/06/18 06:54:59 Can you test the failure case, with GetAppBundleBy
jackhou1 2013/06/18 08:32:40 Done.
+ .WillRepeatedly(Return(other_folder.Append(app_name)));
+
+ shortcut_creator.BuildShortcut(other_folder.Append(app_name));
+
+ EXPECT_TRUE(file_util::Delete(
+ other_folder.Append(app_name).Append("Contents"), true));
+
+ EXPECT_TRUE(shortcut_creator.UpdateShortcuts());
+ EXPECT_FALSE(file_util::PathExists(dst_folder.Append(app_name)));
+ EXPECT_TRUE(file_util::PathExists(
+ other_folder.Append(app_name).Append("Contents")));
+}
+
TEST(WebAppShortcutCreatorTest, RunShortcut) {
base::ScopedTempDir scoped_temp_dir;
EXPECT_TRUE(scoped_temp_dir.CreateUniqueTempDir());
@@ -111,7 +147,6 @@ TEST(WebAppShortcutCreatorTest, RunShortcut) {
NiceMock<WebAppShortcutCreatorMock> shortcut_creator(info);
EXPECT_CALL(shortcut_creator, GetDestinationPath())
.WillRepeatedly(Return(dst_folder));
- EXPECT_CALL(shortcut_creator, RevealGeneratedBundleInFinder(dst_path));
EXPECT_TRUE(shortcut_creator.CreateShortcut());
EXPECT_TRUE(file_util::PathExists(dst_path));

Powered by Google App Engine
This is Rietveld 408576698