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

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

Issue 2588913002: EarlGrey tests for Payment Request (base CL) (Closed)
Patch Set: Moved everything except the egtest upsream Created 4 years 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_items_display_view_controller.h" 5 #import "ios/chrome/browser/payments/payment_items_display_view_controller.h"
6 6
7 #import "base/ios/weak_nsobject.h" 7 #import "base/ios/weak_nsobject.h"
8 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "components/autofill/core/browser/credit_card.h" 10 #include "components/autofill/core/browser/credit_card.h"
11 #include "components/strings/grit/components_strings.h"
11 #import "ios/chrome/browser/payments/cells/order_summary_line_item.h" 12 #import "ios/chrome/browser/payments/cells/order_summary_line_item.h"
12 #import "ios/chrome/browser/payments/cells/order_summary_total_item.h" 13 #import "ios/chrome/browser/payments/cells/order_summary_total_item.h"
13 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item .h" 14 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item .h"
14 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" 15 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
15 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 16 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
16 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" 17 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
17 #import "ios/chrome/browser/ui/icons/chrome_icon.h" 18 #import "ios/chrome/browser/ui/icons/chrome_icon.h"
18 #include "ios/chrome/browser/ui/rtl_geometry.h" 19 #include "ios/chrome/browser/ui/rtl_geometry.h"
19 #include "ios/chrome/grit/ios_strings.h" 20 #include "ios/chrome/grit/ios_strings.h"
20 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h" 21 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h"
21 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
22 23
23 NSString* const kPaymentItemsDisplayCollectionViewId = 24 NSString* const kPaymentItemsDisplayCollectionViewId =
24 @"kPaymentItemsDisplayCollectionViewId"; 25 @"kPaymentItemsDisplayCollectionViewId";
26 NSString* const kPaymentItemsDisplayItemId = @"kPaymentItemsDisplayItemId";
25 27
26 namespace { 28 namespace {
27 29
28 const CGFloat kButtonEdgeInset = 9; 30 const CGFloat kButtonEdgeInset = 9;
29 const CGFloat kSeparatorEdgeInset = 14; 31 const CGFloat kSeparatorEdgeInset = 14;
30 32
31 typedef NS_ENUM(NSInteger, SectionIdentifier) { 33 typedef NS_ENUM(NSInteger, SectionIdentifier) {
32 SectionIdentifierPayment = kSectionIdentifierEnumZero, 34 SectionIdentifierPayment = kSectionIdentifierEnumZero,
33 }; 35 };
34 36
(...skipping 24 matching lines...) Expand all
59 - (instancetype)initWithPayButtonEnabled:(BOOL)payButtonEnabled { 61 - (instancetype)initWithPayButtonEnabled:(BOOL)payButtonEnabled {
60 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { 62 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) {
61 [self setTitle:l10n_util::GetNSString( 63 [self setTitle:l10n_util::GetNSString(
62 IDS_IOS_PAYMENT_REQUEST_PAYMENT_ITEMS_TITLE)]; 64 IDS_IOS_PAYMENT_REQUEST_PAYMENT_ITEMS_TITLE)];
63 65
64 // Set up left (return) button. 66 // Set up left (return) button.
65 UIBarButtonItem* returnButton = 67 UIBarButtonItem* returnButton =
66 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon] 68 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon]
67 target:nil 69 target:nil
68 action:@selector(onReturn)]; 70 action:@selector(onReturn)];
71 [returnButton
72 setAccessibilityLabel:l10n_util::GetNSString(IDS_ACCNAME_BACK)];
69 [self navigationItem].leftBarButtonItem = returnButton; 73 [self navigationItem].leftBarButtonItem = returnButton;
70 74
71 // Set up right (pay) button. 75 // Set up right (pay) button.
72 _payButton.reset([[MDCFlatButton alloc] init]); 76 _payButton.reset([[MDCFlatButton alloc] init]);
73 [_payButton 77 [_payButton
74 setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAY_BUTTON) 78 setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAY_BUTTON)
75 forState:UIControlStateNormal]; 79 forState:UIControlStateNormal];
76 [_payButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500] 80 [_payButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500]
77 forState:UIControlStateNormal]; 81 forState:UIControlStateNormal];
78 [_payButton setInkColor:[UIColor colorWithWhite:1 alpha:0.2]]; 82 [_payButton setInkColor:[UIColor colorWithWhite:1 alpha:0.2]];
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 CollectionViewModel* model = self.collectionViewModel; 139 CollectionViewModel* model = self.collectionViewModel;
136 [model addSectionWithIdentifier:SectionIdentifierPayment]; 140 [model addSectionWithIdentifier:SectionIdentifierPayment];
137 141
138 NSNumberFormatter* currencyFormatter = 142 NSNumberFormatter* currencyFormatter =
139 [[[NSNumberFormatter alloc] init] autorelease]; 143 [[[NSNumberFormatter alloc] init] autorelease];
140 [currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; 144 [currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
141 145
142 // Add the total entry. 146 // Add the total entry.
143 OrderSummaryTotalItem* totalItem = [[[OrderSummaryTotalItem alloc] 147 OrderSummaryTotalItem* totalItem = [[[OrderSummaryTotalItem alloc]
144 initWithType:ItemTypePaymentItem] autorelease]; 148 initWithType:ItemTypePaymentItem] autorelease];
149 totalItem.accessibilityIdentifier = kPaymentItemsDisplayItemId;
145 totalItem.text = base::SysUTF16ToNSString(_total.label); 150 totalItem.text = base::SysUTF16ToNSString(_total.label);
146 151
147 NSString* currencyCode = base::SysUTF16ToNSString(_total.amount.currency); 152 NSString* currencyCode = base::SysUTF16ToNSString(_total.amount.currency);
148 NSDecimalNumber* value = [NSDecimalNumber 153 NSDecimalNumber* value = [NSDecimalNumber
149 decimalNumberWithString:SysUTF16ToNSString(_total.amount.value)]; 154 decimalNumberWithString:SysUTF16ToNSString(_total.amount.value)];
150 [currencyFormatter setCurrencyCode:currencyCode]; 155 [currencyFormatter setCurrencyCode:currencyCode];
151 totalItem.detailText = [currencyFormatter stringFromNumber:value]; 156 totalItem.detailText = [currencyFormatter stringFromNumber:value];
152 157
153 [model addItem:totalItem toSectionWithIdentifier:SectionIdentifierPayment]; 158 [model addItem:totalItem toSectionWithIdentifier:SectionIdentifierPayment];
154 159
155 // Add the line item entries. 160 // Add the line item entries.
156 for (size_t i = 0; i < _paymentItems.size(); ++i) { 161 for (size_t i = 0; i < _paymentItems.size(); ++i) {
157 web::PaymentItem paymentItem = _paymentItems[i]; 162 web::PaymentItem paymentItem = _paymentItems[i];
158 OrderSummaryLineItem* paymentItemItem = [[[OrderSummaryLineItem alloc] 163 OrderSummaryLineItem* paymentItemItem = [[[OrderSummaryLineItem alloc]
159 initWithType:ItemTypePaymentItem] autorelease]; 164 initWithType:ItemTypePaymentItem] autorelease];
165 paymentItemItem.accessibilityIdentifier = kPaymentItemsDisplayItemId;
160 paymentItemItem.text = base::SysUTF16ToNSString(paymentItem.label); 166 paymentItemItem.text = base::SysUTF16ToNSString(paymentItem.label);
161 167
162 NSString* currencyCode = 168 NSString* currencyCode =
163 base::SysUTF16ToNSString(paymentItem.amount.currency); 169 base::SysUTF16ToNSString(paymentItem.amount.currency);
164 NSDecimalNumber* value = [NSDecimalNumber 170 NSDecimalNumber* value = [NSDecimalNumber
165 decimalNumberWithString:SysUTF16ToNSString(paymentItem.amount.value)]; 171 decimalNumberWithString:SysUTF16ToNSString(paymentItem.amount.value)];
166 [currencyFormatter setCurrencyCode:currencyCode]; 172 [currencyFormatter setCurrencyCode:currencyCode];
167 paymentItemItem.detailText = [currencyFormatter stringFromNumber:value]; 173 paymentItemItem.detailText = [currencyFormatter stringFromNumber:value];
168 174
169 [model addItem:paymentItemItem 175 [model addItem:paymentItemItem
(...skipping 15 matching lines...) Expand all
185 #pragma mark MDCCollectionViewStylingDelegate 191 #pragma mark MDCCollectionViewStylingDelegate
186 192
187 // There are no effects from touching the payment items so there should not be 193 // There are no effects from touching the payment items so there should not be
188 // an ink ripple. 194 // an ink ripple.
189 - (BOOL)collectionView:(UICollectionView*)collectionView 195 - (BOOL)collectionView:(UICollectionView*)collectionView
190 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath { 196 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath {
191 return YES; 197 return YES;
192 } 198 }
193 199
194 @end 200 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698