| 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 "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 using ::testing::_; | 23 using ::testing::_; |
| 24 using ::testing::Return; | 24 using ::testing::Return; |
| 25 using ::testing::NiceMock; | 25 using ::testing::NiceMock; |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 class WebAppShortcutCreatorMock : public web_app::WebAppShortcutCreator { | 29 class WebAppShortcutCreatorMock : public web_app::WebAppShortcutCreator { |
| 30 public: | 30 public: |
| 31 explicit WebAppShortcutCreatorMock( | 31 explicit WebAppShortcutCreatorMock( |
| 32 const ShellIntegration::ShortcutInfo& shortcut_info) | 32 const ShellIntegration::ShortcutInfo& shortcut_info) |
| 33 : WebAppShortcutCreator(shortcut_info, | 33 : WebAppShortcutCreator(FilePath(), |
| 34 UTF8ToUTF16("fake.cfbundleidentifier")) { | 34 shortcut_info, |
| 35 UTF8ToUTF16("fake.cfbundleidentifier")) { |
| 35 } | 36 } |
| 36 | 37 |
| 37 MOCK_CONST_METHOD1(GetDestinationPath, FilePath(const FilePath&)); | 38 MOCK_CONST_METHOD1(GetDestinationPath, FilePath(const FilePath&)); |
| 38 MOCK_CONST_METHOD1(RevealGeneratedBundleInFinder, void(const FilePath&)); | 39 MOCK_CONST_METHOD1(RevealGeneratedBundleInFinder, void(const FilePath&)); |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 ShellIntegration::ShortcutInfo GetShortcutInfo() { | 42 ShellIntegration::ShortcutInfo GetShortcutInfo() { |
| 42 ShellIntegration::ShortcutInfo info; | 43 ShellIntegration::ShortcutInfo info; |
| 43 info.extension_id = "extension_id"; | 44 info.extension_id = "extension_id"; |
| 44 info.title = ASCIIToUTF16("Shortcut Title"); | 45 info.title = ASCIIToUTF16("Shortcut Title"); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 94 } |
| 94 | 95 |
| 95 TEST(WebAppShortcutCreatorTest, UpdateIcon) { | 96 TEST(WebAppShortcutCreatorTest, UpdateIcon) { |
| 96 ScopedTempDir scoped_temp_dir; | 97 ScopedTempDir scoped_temp_dir; |
| 97 EXPECT_TRUE(scoped_temp_dir.CreateUniqueTempDir()); | 98 EXPECT_TRUE(scoped_temp_dir.CreateUniqueTempDir()); |
| 98 FilePath dst_path = scoped_temp_dir.path(); | 99 FilePath dst_path = scoped_temp_dir.path(); |
| 99 | 100 |
| 100 ShellIntegration::ShortcutInfo info = GetShortcutInfo(); | 101 ShellIntegration::ShortcutInfo info = GetShortcutInfo(); |
| 101 info.favicon = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 102 info.favicon = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 102 IDR_PRODUCT_LOGO_32).ToSkBitmap(); | 103 IDR_PRODUCT_LOGO_32).ToSkBitmap(); |
| 103 web_app::WebAppShortcutCreator shortcut_creator(info, string16()); | 104 WebAppShortcutCreatorMock shortcut_creator(info); |
| 104 | 105 |
| 105 shortcut_creator.UpdateIcon(dst_path); | 106 shortcut_creator.UpdateIcon(dst_path); |
| 106 FilePath icon_path = | 107 FilePath icon_path = |
| 107 dst_path.Append("Contents").Append("Resources").Append("app.icns"); | 108 dst_path.Append("Contents").Append("Resources").Append("app.icns"); |
| 108 | 109 |
| 109 scoped_nsobject<NSImage> image([[NSImage alloc] initWithContentsOfFile: | 110 scoped_nsobject<NSImage> image([[NSImage alloc] initWithContentsOfFile: |
| 110 base::mac::FilePathToNSString(icon_path)]); | 111 base::mac::FilePathToNSString(icon_path)]); |
| 111 EXPECT_TRUE(image); | 112 EXPECT_TRUE(image); |
| 112 EXPECT_EQ(info.favicon.width(), [image size].width); | 113 EXPECT_EQ(info.favicon.width(), [image size].width); |
| 113 EXPECT_EQ(info.favicon.height(), [image size].height); | 114 EXPECT_EQ(info.favicon.height(), [image size].height); |
| 114 } | 115 } |
| 115 | 116 |
| 116 } // namespace web_app | 117 } // namespace web_app |
| OLD | NEW |