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 <sys/xattr.h> | 9 #include <sys/xattr.h> |
10 #include <errno.h> | 10 #include <errno.h> |
11 | 11 |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
14 #include "base/mac/foundation_util.h" | 14 #include "base/mac/foundation_util.h" |
15 #include "base/memory/scoped_nsobject.h" | 15 #include "base/memory/scoped_nsobject.h" |
16 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
| 17 #include "chrome/browser/web_applications/web_app.h" |
17 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
18 #include "chrome/common/mac/app_mode_common.h" | 19 #include "chrome/common/mac/app_mode_common.h" |
19 #include "grit/theme_resources.h" | 20 #include "grit/theme_resources.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 #import "testing/gtest_mac.h" | 23 #import "testing/gtest_mac.h" |
23 #include "third_party/skia/include/core/SkBitmap.h" | 24 #include "third_party/skia/include/core/SkBitmap.h" |
24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
26 | 27 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 base::FilePath dst_folder = scoped_temp_dir.path(); | 67 base::FilePath dst_folder = scoped_temp_dir.path(); |
67 base::FilePath dst_path = dst_folder.Append(UTF16ToUTF8(info.title) + ".app"); | 68 base::FilePath dst_path = dst_folder.Append(UTF16ToUTF8(info.title) + ".app"); |
68 | 69 |
69 NiceMock<WebAppShortcutCreatorMock> shortcut_creator(info); | 70 NiceMock<WebAppShortcutCreatorMock> shortcut_creator(info); |
70 EXPECT_CALL(shortcut_creator, GetDestinationPath()) | 71 EXPECT_CALL(shortcut_creator, GetDestinationPath()) |
71 .WillRepeatedly(Return(dst_folder)); | 72 .WillRepeatedly(Return(dst_folder)); |
72 EXPECT_CALL(shortcut_creator, RevealGeneratedBundleInFinder(dst_path)); | 73 EXPECT_CALL(shortcut_creator, RevealGeneratedBundleInFinder(dst_path)); |
73 | 74 |
74 EXPECT_TRUE(shortcut_creator.CreateShortcut()); | 75 EXPECT_TRUE(shortcut_creator.CreateShortcut()); |
75 EXPECT_TRUE(file_util::PathExists(dst_path)); | 76 EXPECT_TRUE(file_util::PathExists(dst_path)); |
| 77 EXPECT_EQ(dst_path.value(), shortcut_creator.GetShortcutPath().value()); |
76 | 78 |
77 base::FilePath plist_path = dst_path.Append("Contents").Append("Info.plist"); | 79 base::FilePath plist_path = dst_path.Append("Contents").Append("Info.plist"); |
78 NSDictionary* plist = [NSDictionary dictionaryWithContentsOfFile: | 80 NSDictionary* plist = [NSDictionary dictionaryWithContentsOfFile: |
79 base::mac::FilePathToNSString(plist_path)]; | 81 base::mac::FilePathToNSString(plist_path)]; |
80 EXPECT_NSEQ(base::SysUTF8ToNSString(info.extension_id), | 82 EXPECT_NSEQ(base::SysUTF8ToNSString(info.extension_id), |
81 [plist objectForKey:app_mode::kCrAppModeShortcutIDKey]); | 83 [plist objectForKey:app_mode::kCrAppModeShortcutIDKey]); |
82 EXPECT_NSEQ(base::SysUTF16ToNSString(info.title), | 84 EXPECT_NSEQ(base::SysUTF16ToNSString(info.title), |
83 [plist objectForKey:app_mode::kCrAppModeShortcutNameKey]); | 85 [plist objectForKey:app_mode::kCrAppModeShortcutNameKey]); |
84 EXPECT_NSEQ(base::SysUTF8ToNSString(info.url.spec()), | 86 EXPECT_NSEQ(base::SysUTF8ToNSString(info.url.spec()), |
85 [plist objectForKey:app_mode::kCrAppModeShortcutURLKey]); | 87 [plist objectForKey:app_mode::kCrAppModeShortcutURLKey]); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 dst_path.Append("Contents").Append("Resources").Append("app.icns"); | 173 dst_path.Append("Contents").Append("Resources").Append("app.icns"); |
172 | 174 |
173 scoped_nsobject<NSImage> image([[NSImage alloc] initWithContentsOfFile: | 175 scoped_nsobject<NSImage> image([[NSImage alloc] initWithContentsOfFile: |
174 base::mac::FilePathToNSString(icon_path)]); | 176 base::mac::FilePathToNSString(icon_path)]); |
175 EXPECT_TRUE(image); | 177 EXPECT_TRUE(image); |
176 EXPECT_EQ(product_logo.Width(), [image size].width); | 178 EXPECT_EQ(product_logo.Width(), [image size].width); |
177 EXPECT_EQ(product_logo.Height(), [image size].height); | 179 EXPECT_EQ(product_logo.Height(), [image size].height); |
178 } | 180 } |
179 | 181 |
180 } // namespace web_app | 182 } // namespace web_app |
OLD | NEW |