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 <stddef.h> | 9 #include <stddef.h> |
10 #include <sys/xattr.h> | 10 #include <sys/xattr.h> |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 EXPECT_CALL(shortcut_creator, RevealAppShimInFinder()) | 337 EXPECT_CALL(shortcut_creator, RevealAppShimInFinder()) |
338 .Times(0); | 338 .Times(0); |
339 EXPECT_TRUE(shortcut_creator.CreateShortcuts( | 339 EXPECT_TRUE(shortcut_creator.CreateShortcuts( |
340 SHORTCUT_CREATION_AUTOMATED, web_app::ShortcutLocations())); | 340 SHORTCUT_CREATION_AUTOMATED, web_app::ShortcutLocations())); |
341 | 341 |
342 EXPECT_CALL(shortcut_creator, RevealAppShimInFinder()); | 342 EXPECT_CALL(shortcut_creator, RevealAppShimInFinder()); |
343 EXPECT_TRUE(shortcut_creator.CreateShortcuts( | 343 EXPECT_TRUE(shortcut_creator.CreateShortcuts( |
344 SHORTCUT_CREATION_BY_USER, web_app::ShortcutLocations())); | 344 SHORTCUT_CREATION_BY_USER, web_app::ShortcutLocations())); |
345 } | 345 } |
346 | 346 |
347 TEST_F(WebAppShortcutCreatorTest, FileHandlers) { | |
348 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
349 switches::kEnableAppsFileAssociations); | |
350 extensions::FileHandlersInfo file_handlers_info; | |
351 extensions::FileHandlerInfo handler_0; | |
352 handler_0.extensions.insert("ext0"); | |
353 handler_0.extensions.insert("ext1"); | |
354 handler_0.types.insert("type0"); | |
355 handler_0.types.insert("type1"); | |
356 file_handlers_info.push_back(handler_0); | |
357 extensions::FileHandlerInfo handler_1; | |
358 handler_1.extensions.insert("ext2"); | |
359 handler_1.types.insert("type2"); | |
360 file_handlers_info.push_back(handler_1); | |
361 | |
362 NiceMock<WebAppShortcutCreatorMock> shortcut_creator( | |
363 app_data_dir_, info_.get(), file_handlers_info); | |
364 EXPECT_CALL(shortcut_creator, GetApplicationsDirname()) | |
365 .WillRepeatedly(Return(destination_dir_)); | |
366 EXPECT_TRUE(shortcut_creator.CreateShortcuts( | |
367 SHORTCUT_CREATION_AUTOMATED, web_app::ShortcutLocations())); | |
368 | |
369 base::FilePath plist_path = | |
370 shim_path_.Append("Contents").Append("Info.plist"); | |
371 NSDictionary* plist = [NSDictionary | |
372 dictionaryWithContentsOfFile:base::mac::FilePathToNSString(plist_path)]; | |
373 NSArray* file_handlers = | |
374 [plist objectForKey:app_mode::kCFBundleDocumentTypesKey]; | |
375 | |
376 NSDictionary* file_handler_0 = [file_handlers objectAtIndex:0]; | |
377 EXPECT_NSEQ(app_mode::kBundleTypeRoleViewer, | |
378 [file_handler_0 objectForKey:app_mode::kCFBundleTypeRoleKey]); | |
379 NSArray* file_handler_0_extensions = | |
380 [file_handler_0 objectForKey:app_mode::kCFBundleTypeExtensionsKey]; | |
381 EXPECT_TRUE([file_handler_0_extensions containsObject:@"ext0"]); | |
382 EXPECT_TRUE([file_handler_0_extensions containsObject:@"ext1"]); | |
383 NSArray* file_handler_0_types = | |
384 [file_handler_0 objectForKey:app_mode::kCFBundleTypeMIMETypesKey]; | |
385 EXPECT_TRUE([file_handler_0_types containsObject:@"type0"]); | |
386 EXPECT_TRUE([file_handler_0_types containsObject:@"type1"]); | |
387 | |
388 NSDictionary* file_handler_1 = [file_handlers objectAtIndex:1]; | |
389 EXPECT_NSEQ(app_mode::kBundleTypeRoleViewer, | |
390 [file_handler_1 objectForKey:app_mode::kCFBundleTypeRoleKey]); | |
391 NSArray* file_handler_1_extensions = | |
392 [file_handler_1 objectForKey:app_mode::kCFBundleTypeExtensionsKey]; | |
393 EXPECT_TRUE([file_handler_1_extensions containsObject:@"ext2"]); | |
394 NSArray* file_handler_1_types = | |
395 [file_handler_1 objectForKey:app_mode::kCFBundleTypeMIMETypesKey]; | |
396 EXPECT_TRUE([file_handler_1_types containsObject:@"type2"]); | |
397 } | |
398 | |
399 } // namespace web_app | 347 } // namespace web_app |
OLD | NEW |