Chromium Code Reviews| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 .WillRepeatedly(Return(FilePath("/non-existant/path/"))); | 82 .WillRepeatedly(Return(FilePath("/non-existant/path/"))); |
| 83 EXPECT_FALSE(shortcut_creator.CreateShortcut()); | 83 EXPECT_FALSE(shortcut_creator.CreateShortcut()); |
| 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); |
|
jeremy
2012/03/01 10:54:39
How hard would it be to add a test for a bitmap fo
sail
2012/03/04 04:59:56
There wasn't an easy way to do this. I'll look int
| |
| 94 WebAppShortcutCreatorMock 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.ToSkBitmap()->width(), [image size].width); |
| 104 EXPECT_EQ(info.favicon.height(), [image size].height); | 104 EXPECT_EQ(info.favicon.ToSkBitmap()->height(), [image size].height); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace web_app | 107 } // namespace web_app |
| OLD | NEW |