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

Side by Side Diff: ios/chrome/browser/payments/payment_request_view_controller.mm

Issue 2588913002: EarlGrey tests for Payment Request (base CL) (Closed)
Patch Set: Addressed comments by jdonnelly@ Created 3 years, 11 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/payments/payment_request_view_controller.h" 5 #import "ios/chrome/browser/payments/payment_request_view_controller.h"
6 6
7 #import "base/ios/weak_nsobject.h" 7 #import "base/ios/weak_nsobject.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/mac/objc_property_releaser.h" 9 #include "base/mac/objc_property_releaser.h"
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "components/autofill/core/browser/autofill_data_util.h" 12 #include "components/autofill/core/browser/autofill_data_util.h"
13 #include "components/autofill/core/browser/autofill_profile.h" 13 #include "components/autofill/core/browser/autofill_profile.h"
14 #include "components/autofill/core/browser/credit_card.h" 14 #include "components/autofill/core/browser/credit_card.h"
15 #include "components/autofill/core/browser/field_types.h" 15 #include "components/autofill/core/browser/field_types.h"
16 #include "components/autofill/core/browser/personal_data_manager.h" 16 #include "components/autofill/core/browser/personal_data_manager.h"
17 #include "components/strings/grit/components_strings.h"
17 #include "ios/chrome/browser/application_context.h" 18 #include "ios/chrome/browser/application_context.h"
18 #import "ios/chrome/browser/payments/cells/page_info_item.h" 19 #import "ios/chrome/browser/payments/cells/page_info_item.h"
19 #import "ios/chrome/browser/payments/cells/payment_method_item.h" 20 #import "ios/chrome/browser/payments/cells/payment_method_item.h"
20 #import "ios/chrome/browser/payments/cells/shipping_address_item.h" 21 #import "ios/chrome/browser/payments/cells/shipping_address_item.h"
21 #import "ios/chrome/browser/payments/payment_request_utils.h" 22 #import "ios/chrome/browser/payments/payment_request_utils.h"
22 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h" 23 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h"
23 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item .h" 24 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item .h"
24 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" 25 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
25 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h " 26 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h "
26 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 27 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
27 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" 28 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
28 #include "ios/chrome/browser/ui/rtl_geometry.h" 29 #include "ios/chrome/browser/ui/rtl_geometry.h"
29 #include "ios/chrome/grit/ios_strings.h" 30 #include "ios/chrome/grit/ios_strings.h"
30 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h" 31 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h"
31 #import "ios/third_party/material_components_ios/src/components/CollectionCells/ src/MaterialCollectionCells.h" 32 #import "ios/third_party/material_components_ios/src/components/CollectionCells/ src/MaterialCollectionCells.h"
32 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" 33 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h"
33 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
35 36
37 using payment_request_utils::NameLabelFromAutofillProfile;
38 using payment_request_utils::AddressLabelFromAutofillProfile;
39 using payment_request_utils::PhoneNumberLabelFromAutofillProfile;
40
36 NSString* const kPaymentRequestCollectionViewId = 41 NSString* const kPaymentRequestCollectionViewId =
37 @"kPaymentRequestCollectionViewId"; 42 @"kPaymentRequestCollectionViewId";
38 43
39 namespace { 44 namespace {
40 45
41 const CGFloat kButtonEdgeInset = 9; 46 const CGFloat kButtonEdgeInset = 9;
42 const CGFloat kSeparatorEdgeInset = 14; 47 const CGFloat kSeparatorEdgeInset = 14;
43 48
44 typedef NS_ENUM(NSInteger, SectionIdentifier) { 49 typedef NS_ENUM(NSInteger, SectionIdentifier) {
45 SectionIdentifierSummary = kSectionIdentifierEnumZero, 50 SectionIdentifierSummary = kSectionIdentifierEnumZero,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 _cancelButton.reset([[UIBarButtonItem alloc] 104 _cancelButton.reset([[UIBarButtonItem alloc]
100 initWithTitle:l10n_util::GetNSString( 105 initWithTitle:l10n_util::GetNSString(
101 IDS_IOS_PAYMENT_REQUEST_CANCEL_BUTTON) 106 IDS_IOS_PAYMENT_REQUEST_CANCEL_BUTTON)
102 style:UIBarButtonItemStylePlain 107 style:UIBarButtonItemStylePlain
103 target:nil 108 target:nil
104 action:@selector(onCancel)]); 109 action:@selector(onCancel)]);
105 [_cancelButton setTitleTextAttributes:@{ 110 [_cancelButton setTitleTextAttributes:@{
106 NSForegroundColorAttributeName : [UIColor lightGrayColor] 111 NSForegroundColorAttributeName : [UIColor lightGrayColor]
107 } 112 }
108 forState:UIControlStateDisabled]; 113 forState:UIControlStateDisabled];
114 [_cancelButton
115 setAccessibilityLabel:l10n_util::GetNSString(IDS_ACCNAME_CANCEL)];
109 [self navigationItem].leftBarButtonItem = _cancelButton; 116 [self navigationItem].leftBarButtonItem = _cancelButton;
110 117
111 // Set up right (pay) button. 118 // Set up right (pay) button.
112 _payButton.reset([[MDCFlatButton alloc] init]); 119 _payButton.reset([[MDCFlatButton alloc] init]);
113 [_payButton 120 [_payButton
114 setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAY_BUTTON) 121 setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAY_BUTTON)
115 forState:UIControlStateNormal]; 122 forState:UIControlStateNormal];
116 [_payButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500] 123 [_payButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500]
117 forState:UIControlStateNormal]; 124 forState:UIControlStateNormal];
118 [_payButton setInkColor:[UIColor colorWithWhite:1 alpha:0.2]]; 125 [_payButton setInkColor:[UIColor colorWithWhite:1 alpha:0.2]];
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 NSIndexPath* indexPath = 316 NSIndexPath* indexPath =
310 [self.collectionViewModel indexPathForItem:_selectedShippingAddressItem 317 [self.collectionViewModel indexPathForItem:_selectedShippingAddressItem
311 inSectionWithIdentifier:SectionIdentifierShipping]; 318 inSectionWithIdentifier:SectionIdentifierShipping];
312 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; 319 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]];
313 } 320 }
314 321
315 #pragma mark - Helper methods 322 #pragma mark - Helper methods
316 323
317 - (void)fillShippingAddressItem:(ShippingAddressItem*)item 324 - (void)fillShippingAddressItem:(ShippingAddressItem*)item
318 withAddress:(autofill::AutofillProfile*)address { 325 withAddress:(autofill::AutofillProfile*)address {
319 item.name = 326 item.name = NameLabelFromAutofillProfile(address);
320 base::SysUTF16ToNSString(address->GetRawInfo(autofill::NAME_FULL)); 327 item.address = AddressLabelFromAutofillProfile(address);
321 item.address = 328 item.phoneNumber = PhoneNumberLabelFromAutofillProfile(address);
322 payment_request_utils::AddressLabelFromAutofillProfile(address);
323 item.phoneNumber = base::SysUTF16ToNSString(
324 address->GetRawInfo(autofill::PHONE_HOME_WHOLE_NUMBER));
325 } 329 }
326 330
327 #pragma mark UICollectionViewDataSource 331 #pragma mark UICollectionViewDataSource
328 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView 332 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView
329 cellForItemAtIndexPath:(nonnull NSIndexPath*)indexPath { 333 cellForItemAtIndexPath:(nonnull NSIndexPath*)indexPath {
330 UICollectionViewCell* cell = 334 UICollectionViewCell* cell =
331 [super collectionView:collectionView cellForItemAtIndexPath:indexPath]; 335 [super collectionView:collectionView cellForItemAtIndexPath:indexPath];
332 336
333 NSInteger itemType = 337 NSInteger itemType =
334 [self.collectionViewModel itemTypeForIndexPath:indexPath]; 338 [self.collectionViewModel itemTypeForIndexPath:indexPath];
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; 402 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath];
399 if (type == ItemTypeSummaryTotal && 403 if (type == ItemTypeSummaryTotal &&
400 _paymentRequest.details.display_items.empty()) { 404 _paymentRequest.details.display_items.empty()) {
401 return YES; 405 return YES;
402 } else { 406 } else {
403 return NO; 407 return NO;
404 } 408 }
405 } 409 }
406 410
407 @end 411 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698