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 #include "chrome/browser/web_applications/web_app_mac.h" | 5 #include "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(), shortcut_info) { |
34 } | 34 } |
35 | 35 |
36 MOCK_CONST_METHOD1(GetDestinationPath, FilePath(const FilePath&)); | 36 MOCK_CONST_METHOD1(GetDestinationPath, FilePath(const FilePath&)); |
37 }; | 37 }; |
38 | 38 |
39 ShellIntegration::ShortcutInfo GetShortcutInfo() { | 39 ShellIntegration::ShortcutInfo GetShortcutInfo() { |
40 ShellIntegration::ShortcutInfo info; | 40 ShellIntegration::ShortcutInfo info; |
41 info.extension_id = "extension_id"; | 41 info.extension_id = "extension_id"; |
42 info.title = ASCIIToUTF16("Shortcut Title"); | 42 info.title = ASCIIToUTF16("Shortcut Title"); |
43 info.url = GURL("http://example.com/"); | 43 info.url = GURL("http://example.com/"); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 TEST(WebAppShortcutCreatorTest, UpdateIcon) { | 86 TEST(WebAppShortcutCreatorTest, UpdateIcon) { |
87 ScopedTempDir scoped_temp_dir; | 87 ScopedTempDir scoped_temp_dir; |
88 ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDir()); | 88 ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDir()); |
89 FilePath dst_path = scoped_temp_dir.path(); | 89 FilePath dst_path = scoped_temp_dir.path(); |
90 | 90 |
91 ShellIntegration::ShortcutInfo info = GetShortcutInfo(); | 91 ShellIntegration::ShortcutInfo info = GetShortcutInfo(); |
92 info.favicon = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 92 info.favicon = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
93 IDR_PRODUCT_LOGO_32).ToSkBitmap(); | 93 IDR_PRODUCT_LOGO_32).ToSkBitmap(); |
94 web_app::WebAppShortcutCreator shortcut_creator(info); | 94 WebAppShortcutCreatorMock shortcut_creator(info); |
95 | 95 |
96 shortcut_creator.UpdateIcon(dst_path); | 96 shortcut_creator.UpdateIcon(dst_path); |
97 FilePath icon_path = | 97 FilePath icon_path = |
98 dst_path.Append("Contents").Append("Resources").Append("app.icns"); | 98 dst_path.Append("Contents").Append("Resources").Append("app.icns"); |
99 | 99 |
100 scoped_nsobject<NSImage> image([[NSImage alloc] initWithContentsOfFile: | 100 scoped_nsobject<NSImage> image([[NSImage alloc] initWithContentsOfFile: |
101 base::mac::FilePathToNSString(icon_path)]); | 101 base::mac::FilePathToNSString(icon_path)]); |
102 EXPECT_TRUE(image); | 102 EXPECT_TRUE(image); |
103 EXPECT_EQ(info.favicon.width(), [image size].width); | 103 EXPECT_EQ(info.favicon.width(), [image size].width); |
104 EXPECT_EQ(info.favicon.height(), [image size].height); | 104 EXPECT_EQ(info.favicon.height(), [image size].height); |
105 } | 105 } |
106 | 106 |
107 } // namespace web_app | 107 } // namespace web_app |
OLD | NEW |