Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: ios/chrome/browser/ui/activity_services/activity_service_controller_unittest.mm

Issue 2823883002: List Password Manager extensions in a static data structure (Closed)
Patch Set: removed dead comment Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/ui/activity_services/activity_type_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ios/chrome/browser/ui/activity_services/activity_service_controller.h" 5 #import "ios/chrome/browser/ui/activity_services/activity_service_controller.h"
6 6
7 #import <MobileCoreServices/MobileCoreServices.h> 7 #import <MobileCoreServices/MobileCoreServices.h>
8 8
9 #import "base/test/ios/wait_util.h" 9 #import "base/test/ios/wait_util.h"
10 #import "ios/chrome/browser/ui/activity_services/activity_type_util.h" 10 #import "ios/chrome/browser/ui/activity_services/activity_type_util.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 password:OCMOCK_ANY 180 password:OCMOCK_ANY
181 completionMessage:OCMOCK_ANY]; 181 completionMessage:OCMOCK_ANY];
182 [[[shareToDelegateMock stub] andDo:validationBlock] 182 [[[shareToDelegateMock stub] andDo:validationBlock]
183 passwordAppExDidFinish:ShareTo::ShareResult::SHARE_UNKNOWN_RESULT 183 passwordAppExDidFinish:ShareTo::ShareResult::SHARE_UNKNOWN_RESULT
184 username:OCMOCK_ANY 184 username:OCMOCK_ANY
185 password:OCMOCK_ANY 185 password:OCMOCK_ANY
186 completionMessage:OCMOCK_ANY]; 186 completionMessage:OCMOCK_ANY];
187 [activityController setShareToDelegateForTesting:(id)shareToDelegateMock]; 187 [activityController setShareToDelegateForTesting:(id)shareToDelegateMock];
188 188
189 // Sets up the returned item from a Password Management App Extension. 189 // Sets up the returned item from a Password Management App Extension.
190 NSString* activityType = activity_services::kAppExtensionLastPass; 190 NSString* activityType = @"com.lastpass.ilastpass.LastPassExt";
191 ShareTo::ShareResult result = ShareTo::ShareResult::SHARE_SUCCESS; 191 ShareTo::ShareResult result = ShareTo::ShareResult::SHARE_SUCCESS;
192 BOOL resetUI = 192 BOOL resetUI =
193 [activityController processItemsReturnedFromActivity:activityType 193 [activityController processItemsReturnedFromActivity:activityType
194 status:result 194 status:result
195 items:extensionItems]; 195 items:extensionItems];
196 ASSERT_EQ(expectedResetUI, resetUI); 196 ASSERT_EQ(expectedResetUI, resetUI);
197 base::test::ios::WaitUntilCondition(^{ 197 base::test::ios::WaitUntilCondition(^{
198 return blockCalled; 198 return blockCalled;
199 }); 199 });
200 EXPECT_OCMOCK_VERIFY(shareToDelegateMock); 200 EXPECT_OCMOCK_VERIFY(shareToDelegateMock);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 title:@"kung fu fighting" 267 title:@"kung fu fighting"
268 isOriginalTitle:YES 268 isOriginalTitle:YES
269 isPagePrintable:YES 269 isPagePrintable:YES
270 thumbnailGenerator:DummyThumbnailGeneratorBlock()]; 270 thumbnailGenerator:DummyThumbnailGeneratorBlock()];
271 NSArray* items = [activityController activityItemsForData:data]; 271 NSArray* items = [activityController activityItemsForData:data];
272 NSString* findLoginAction = 272 NSString* findLoginAction =
273 (NSString*)activity_services::kUTTypeAppExtensionFindLoginAction; 273 (NSString*)activity_services::kUTTypeAppExtensionFindLoginAction;
274 // Gets the list of NSExtensionItem objects returned by the array of 274 // Gets the list of NSExtensionItem objects returned by the array of
275 // id<UIActivityItemSource> objects returned by -activityItemsForData:. 275 // id<UIActivityItemSource> objects returned by -activityItemsForData:.
276 NSArray* extensionItems = FindItemsForActivityType( 276 NSArray* extensionItems = FindItemsForActivityType(
277 items, activity_services::kAppExtensionOnePassword); 277 items, @"com.agilebits.onepassword-ios.extension");
278 ASSERT_EQ(1U, [extensionItems count]); 278 ASSERT_EQ(1U, [extensionItems count]);
279 NSExtensionItem* item = extensionItems[0]; 279 NSExtensionItem* item = extensionItems[0];
280 EXPECT_EQ(1U, item.attachments.count); 280 EXPECT_EQ(1U, item.attachments.count);
281 NSItemProvider* itemProvider = item.attachments[0]; 281 NSItemProvider* itemProvider = item.attachments[0];
282 // Extracts the dictionary back from the ItemProvider and then check that 282 // Extracts the dictionary back from the ItemProvider and then check that
283 // it has the expected version and the page's URL. 283 // it has the expected version and the page's URL.
284 __block NSDictionary* result; 284 __block NSDictionary* result;
285 [itemProvider 285 [itemProvider
286 loadItemForTypeIdentifier:findLoginAction 286 loadItemForTypeIdentifier:findLoginAction
287 options:nil 287 options:nil
(...skipping 18 matching lines...) Expand all
306 EXPECT_NSEQ(@"https://chromium.org/login.html", appExUrlString); 306 EXPECT_NSEQ(@"https://chromium.org/login.html", appExUrlString);
307 307
308 // Checks that the list includes the page's title. 308 // Checks that the list includes the page's title.
309 NSArray* sources = FindItemsOfClass(items, [UIActivityURLSource class]); 309 NSArray* sources = FindItemsOfClass(items, [UIActivityURLSource class]);
310 EXPECT_EQ(1U, [sources count]); 310 EXPECT_EQ(1U, [sources count]);
311 UIActivityURLSource* actionSource = sources[0]; 311 UIActivityURLSource* actionSource = sources[0];
312 id mockActivityViewController = 312 id mockActivityViewController =
313 [OCMockObject niceMockForClass:[UIActivityViewController class]]; 313 [OCMockObject niceMockForClass:[UIActivityViewController class]];
314 NSString* title = [actionSource 314 NSString* title = [actionSource
315 activityViewController:mockActivityViewController 315 activityViewController:mockActivityViewController
316 subjectForActivityType:activity_services::kAppExtensionOnePassword]; 316 subjectForActivityType:@"com.agilebits.onepassword-ios.extension"];
317 EXPECT_NSEQ(@"kung fu fighting", title); 317 EXPECT_NSEQ(@"kung fu fighting", title);
318 } 318 }
319 319
320 // Verifies that a Share extension can fetch a URL when Password App Extension 320 // Verifies that a Share extension can fetch a URL when Password App Extension
321 // is enabled. 321 // is enabled.
322 TEST_F(ActivityServiceControllerTest, 322 TEST_F(ActivityServiceControllerTest,
323 ActivityItemsForDataWithPasswordAppExReturnsURL) { 323 ActivityItemsForDataWithPasswordAppExReturnsURL) {
324 ActivityServiceController* activityController = 324 ActivityServiceController* activityController =
325 [[ActivityServiceController alloc] init]; 325 [[ActivityServiceController alloc] init];
326 ShareToData* data = 326 ShareToData* data =
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 // public.url UTType in order to allow Share actions (e.g. Facebook, Twitter, 478 // public.url UTType in order to allow Share actions (e.g. Facebook, Twitter,
479 // etc) to appear on UIActivityViewController opened by Chrome). 479 // etc) to appear on UIActivityViewController opened by Chrome).
480 CFStringRef chromeFindLoginAction = reinterpret_cast<CFStringRef>( 480 CFStringRef chromeFindLoginAction = reinterpret_cast<CFStringRef>(
481 activity_services::kUTTypeAppExtensionFindLoginAction); 481 activity_services::kUTTypeAppExtensionFindLoginAction);
482 EXPECT_TRUE(UTTypeConformsTo(chromeFindLoginAction, kUTTypeURL)); 482 EXPECT_TRUE(UTTypeConformsTo(chromeFindLoginAction, kUTTypeURL));
483 EXPECT_TRUE( 483 EXPECT_TRUE(
484 UTTypeConformsTo(chromeFindLoginAction, onePasswordFindLoginAction)); 484 UTTypeConformsTo(chromeFindLoginAction, onePasswordFindLoginAction));
485 } 485 }
486 486
487 } // namespace 487 } // namespace
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/ui/activity_services/activity_type_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698