| OLD | NEW |
| 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 #import "chrome/browser/web_applications/web_app_mac.h" | 5 #import "chrome/browser/web_applications/web_app_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <sys/xattr.h> | 10 #include <sys/xattr.h> |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 EXPECT_CALL(shortcut_creator, GetDestinationPath()) | 132 EXPECT_CALL(shortcut_creator, GetDestinationPath()) |
| 133 .WillRepeatedly(Return(dst_folder)); | 133 .WillRepeatedly(Return(dst_folder)); |
| 134 | 134 |
| 135 std::string expected_bundle_id = kFakeChromeBundleId; | 135 std::string expected_bundle_id = kFakeChromeBundleId; |
| 136 expected_bundle_id += ".app.Profile-1-" + info.extension_id; | 136 expected_bundle_id += ".app.Profile-1-" + info.extension_id; |
| 137 EXPECT_CALL(shortcut_creator, GetAppBundleById(expected_bundle_id)) | 137 EXPECT_CALL(shortcut_creator, GetAppBundleById(expected_bundle_id)) |
| 138 .WillOnce(Return(other_folder.Append(app_name))); | 138 .WillOnce(Return(other_folder.Append(app_name))); |
| 139 | 139 |
| 140 shortcut_creator.BuildShortcut(other_folder.Append(app_name)); | 140 shortcut_creator.BuildShortcut(other_folder.Append(app_name)); |
| 141 | 141 |
| 142 EXPECT_TRUE(file_util::Delete( | 142 EXPECT_TRUE(base::Delete( |
| 143 other_folder.Append(app_name).Append("Contents"), true)); | 143 other_folder.Append(app_name).Append("Contents"), true)); |
| 144 | 144 |
| 145 EXPECT_TRUE(shortcut_creator.UpdateShortcuts()); | 145 EXPECT_TRUE(shortcut_creator.UpdateShortcuts()); |
| 146 EXPECT_FALSE(file_util::PathExists(dst_folder.Append(app_name))); | 146 EXPECT_FALSE(file_util::PathExists(dst_folder.Append(app_name))); |
| 147 EXPECT_TRUE(file_util::PathExists( | 147 EXPECT_TRUE(file_util::PathExists( |
| 148 other_folder.Append(app_name).Append("Contents"))); | 148 other_folder.Append(app_name).Append("Contents"))); |
| 149 | 149 |
| 150 // Also test case where GetAppBundleById fails. | 150 // Also test case where GetAppBundleById fails. |
| 151 EXPECT_CALL(shortcut_creator, GetAppBundleById(expected_bundle_id)) | 151 EXPECT_CALL(shortcut_creator, GetAppBundleById(expected_bundle_id)) |
| 152 .WillOnce(Return(base::FilePath())); | 152 .WillOnce(Return(base::FilePath())); |
| 153 | 153 |
| 154 shortcut_creator.BuildShortcut(other_folder.Append(app_name)); | 154 shortcut_creator.BuildShortcut(other_folder.Append(app_name)); |
| 155 | 155 |
| 156 EXPECT_TRUE(file_util::Delete( | 156 EXPECT_TRUE(base::Delete( |
| 157 other_folder.Append(app_name).Append("Contents"), true)); | 157 other_folder.Append(app_name).Append("Contents"), true)); |
| 158 | 158 |
| 159 EXPECT_FALSE(shortcut_creator.UpdateShortcuts()); | 159 EXPECT_FALSE(shortcut_creator.UpdateShortcuts()); |
| 160 EXPECT_FALSE(file_util::PathExists(dst_folder.Append(app_name))); | 160 EXPECT_FALSE(file_util::PathExists(dst_folder.Append(app_name))); |
| 161 EXPECT_FALSE(file_util::PathExists( | 161 EXPECT_FALSE(file_util::PathExists( |
| 162 other_folder.Append(app_name).Append("Contents"))); | 162 other_folder.Append(app_name).Append("Contents"))); |
| 163 } | 163 } |
| 164 | 164 |
| 165 TEST(WebAppShortcutCreatorTest, CreateAppListShortcut) { | 165 TEST(WebAppShortcutCreatorTest, CreateAppListShortcut) { |
| 166 base::ScopedTempDir temp_dst_dir; | 166 base::ScopedTempDir temp_dst_dir; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 dst_path.Append("Contents").Append("Resources").Append("app.icns"); | 243 dst_path.Append("Contents").Append("Resources").Append("app.icns"); |
| 244 | 244 |
| 245 base::scoped_nsobject<NSImage> image([[NSImage alloc] | 245 base::scoped_nsobject<NSImage> image([[NSImage alloc] |
| 246 initWithContentsOfFile:base::mac::FilePathToNSString(icon_path)]); | 246 initWithContentsOfFile:base::mac::FilePathToNSString(icon_path)]); |
| 247 EXPECT_TRUE(image); | 247 EXPECT_TRUE(image); |
| 248 EXPECT_EQ(product_logo.Width(), [image size].width); | 248 EXPECT_EQ(product_logo.Width(), [image size].width); |
| 249 EXPECT_EQ(product_logo.Height(), [image size].height); | 249 EXPECT_EQ(product_logo.Height(), [image size].height); |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace web_app | 252 } // namespace web_app |
| OLD | NEW |