| 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 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <sys/xattr.h> | 9 #include <sys/xattr.h> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/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/mac/scoped_nsobject.h" | 15 #include "base/mac/scoped_nsobject.h" |
| 16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/chrome_version_info.h" |
| 21 #import "chrome/common/mac/app_mode_common.h" | 22 #import "chrome/common/mac/app_mode_common.h" |
| 22 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
| 23 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #import "testing/gtest_mac.h" | 26 #import "testing/gtest_mac.h" |
| 26 #include "third_party/skia/include/core/SkBitmap.h" | 27 #include "third_party/skia/include/core/SkBitmap.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
| 28 #include "ui/gfx/image/image.h" | 29 #include "ui/gfx/image/image.h" |
| 29 | 30 |
| 30 using ::testing::_; | 31 using ::testing::_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 web_app::ShortcutInfo GetShortcutInfo() { | 63 web_app::ShortcutInfo GetShortcutInfo() { |
| 63 web_app::ShortcutInfo info; | 64 web_app::ShortcutInfo info; |
| 64 info.extension_id = "extensionid"; | 65 info.extension_id = "extensionid"; |
| 65 info.extension_path = base::FilePath("/fake/extension/path"); | 66 info.extension_path = base::FilePath("/fake/extension/path"); |
| 66 info.title = base::ASCIIToUTF16("Shortcut Title"); | 67 info.title = base::ASCIIToUTF16("Shortcut Title"); |
| 67 info.url = GURL("http://example.com/"); | 68 info.url = GURL("http://example.com/"); |
| 68 info.profile_path = base::FilePath("user_data_dir").Append("Profile 1"); | 69 info.profile_path = base::FilePath("user_data_dir").Append("Profile 1"); |
| 69 info.profile_name = "profile name"; | 70 info.profile_name = "profile name"; |
| 71 info.version_for_display = "stable 1.0"; |
| 70 return info; | 72 return info; |
| 71 } | 73 } |
| 72 | 74 |
| 73 class WebAppShortcutCreatorTest : public testing::Test { | 75 class WebAppShortcutCreatorTest : public testing::Test { |
| 74 protected: | 76 protected: |
| 75 WebAppShortcutCreatorTest() {} | 77 WebAppShortcutCreatorTest() {} |
| 76 | 78 |
| 77 void SetUp() override { | 79 void SetUp() override { |
| 78 base::mac::SetBaseBundleID(kFakeChromeBundleId); | 80 base::mac::SetBaseBundleID(kFakeChromeBundleId); |
| 79 | 81 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 shim_path_.Append("Contents").Append("Info.plist"); | 126 shim_path_.Append("Contents").Append("Info.plist"); |
| 125 NSDictionary* plist = [NSDictionary dictionaryWithContentsOfFile: | 127 NSDictionary* plist = [NSDictionary dictionaryWithContentsOfFile: |
| 126 base::mac::FilePathToNSString(plist_path)]; | 128 base::mac::FilePathToNSString(plist_path)]; |
| 127 EXPECT_NSEQ(base::SysUTF8ToNSString(info_.extension_id), | 129 EXPECT_NSEQ(base::SysUTF8ToNSString(info_.extension_id), |
| 128 [plist objectForKey:app_mode::kCrAppModeShortcutIDKey]); | 130 [plist objectForKey:app_mode::kCrAppModeShortcutIDKey]); |
| 129 EXPECT_NSEQ(base::SysUTF16ToNSString(info_.title), | 131 EXPECT_NSEQ(base::SysUTF16ToNSString(info_.title), |
| 130 [plist objectForKey:app_mode::kCrAppModeShortcutNameKey]); | 132 [plist objectForKey:app_mode::kCrAppModeShortcutNameKey]); |
| 131 EXPECT_NSEQ(base::SysUTF8ToNSString(info_.url.spec()), | 133 EXPECT_NSEQ(base::SysUTF8ToNSString(info_.url.spec()), |
| 132 [plist objectForKey:app_mode::kCrAppModeShortcutURLKey]); | 134 [plist objectForKey:app_mode::kCrAppModeShortcutURLKey]); |
| 133 | 135 |
| 136 EXPECT_NSEQ(base::SysUTF8ToNSString(chrome::VersionInfo().Version()), |
| 137 [plist objectForKey:app_mode::kCrBundleVersionKey]); |
| 138 EXPECT_NSEQ(base::SysUTF8ToNSString(info_.version_for_display), |
| 139 [plist objectForKey:app_mode::kCFBundleShortVersionStringKey]); |
| 140 |
| 134 // Make sure all values in the plist are actually filled in. | 141 // Make sure all values in the plist are actually filled in. |
| 135 for (id key in plist) { | 142 for (id key in plist) { |
| 136 id value = [plist valueForKey:key]; | 143 id value = [plist valueForKey:key]; |
| 137 if (!base::mac::ObjCCast<NSString>(value)) | 144 if (!base::mac::ObjCCast<NSString>(value)) |
| 138 continue; | 145 continue; |
| 139 | 146 |
| 140 EXPECT_EQ([value rangeOfString:@"@APP_"].location, NSNotFound) | 147 EXPECT_EQ([value rangeOfString:@"@APP_"].location, NSNotFound) |
| 141 << [key UTF8String] << ":" << [value UTF8String]; | 148 << [key UTF8String] << ":" << [value UTF8String]; |
| 142 } | 149 } |
| 143 } | 150 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 [file_handler_1 objectForKey:app_mode::kCFBundleTypeRoleKey]); | 351 [file_handler_1 objectForKey:app_mode::kCFBundleTypeRoleKey]); |
| 345 NSArray* file_handler_1_extensions = | 352 NSArray* file_handler_1_extensions = |
| 346 [file_handler_1 objectForKey:app_mode::kCFBundleTypeExtensionsKey]; | 353 [file_handler_1 objectForKey:app_mode::kCFBundleTypeExtensionsKey]; |
| 347 EXPECT_TRUE([file_handler_1_extensions containsObject:@"ext2"]); | 354 EXPECT_TRUE([file_handler_1_extensions containsObject:@"ext2"]); |
| 348 NSArray* file_handler_1_types = | 355 NSArray* file_handler_1_types = |
| 349 [file_handler_1 objectForKey:app_mode::kCFBundleTypeMIMETypesKey]; | 356 [file_handler_1 objectForKey:app_mode::kCFBundleTypeMIMETypesKey]; |
| 350 EXPECT_TRUE([file_handler_1_types containsObject:@"type2"]); | 357 EXPECT_TRUE([file_handler_1_types containsObject:@"type2"]); |
| 351 } | 358 } |
| 352 | 359 |
| 353 } // namespace web_app | 360 } // namespace web_app |
| OLD | NEW |