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

Unified Diff: ios/chrome/browser/ui/payments/credit_card_edit_view_controller_unittest.mm

Issue 2876603005: [Payment Request] Refactors the edit view controller (Closed)
Patch Set: Addressed comments Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/payments/credit_card_edit_view_controller_unittest.mm
diff --git a/ios/chrome/browser/ui/payments/credit_card_edit_view_controller_unittest.mm b/ios/chrome/browser/ui/payments/credit_card_edit_view_controller_unittest.mm
index 9eb67852b80fe7b35c4073af840f92740a37b997..90526978e772722bc1cf34dff2d5b0e2c4be7aea 100644
--- a/ios/chrome/browser/ui/payments/credit_card_edit_view_controller_unittest.mm
+++ b/ios/chrome/browser/ui/payments/credit_card_edit_view_controller_unittest.mm
@@ -10,13 +10,13 @@
#include "ios/chrome/browser/payments/payment_request_test_util.h"
#import "ios/chrome/browser/ui/autofill/autofill_ui_type.h"
#import "ios/chrome/browser/ui/autofill/cells/autofill_edit_item.h"
-#import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item.h"
#import "ios/chrome/browser/ui/collection_view/cells/test_utils.h"
#import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h"
#import "ios/chrome/browser/ui/payments/cells/accepted_payment_methods_item.h"
#import "ios/chrome/browser/ui/payments/cells/payment_method_item.h"
+#import "ios/chrome/browser/ui/payments/cells/payments_selector_edit_item.h"
#import "ios/chrome/browser/ui/payments/payment_request_editor_field.h"
#include "ios/web/public/payments/payment_request.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -34,40 +34,46 @@
@synthesize state = _state;
-- (CollectionViewItem*)serverCardSummaryItem {
+- (CollectionViewItem*)headerItem {
return [[PaymentMethodItem alloc] init];
}
-- (CollectionViewItem*)acceptedPaymentMethodsItem {
- return [[AcceptedPaymentMethodsItem alloc] init];
+- (BOOL)shouldHideBackgroundForHeaderItem {
+ return NO;
}
- (NSArray<EditorField*>*)editorFields {
return @[
[[EditorField alloc] initWithAutofillUIType:AutofillUITypeCreditCardNumber
+ fieldType:EditorFieldTypeTextField
label:@"Credit Card Number"
value:@"4111111111111111" /* Visa */
required:YES],
[[EditorField alloc]
initWithAutofillUIType:AutofillUITypeCreditCardHolderFullName
+ fieldType:EditorFieldTypeTextField
label:@"Cardholder Name"
value:@"John Doe"
required:YES],
[[EditorField alloc] initWithAutofillUIType:AutofillUITypeCreditCardExpMonth
+ fieldType:EditorFieldTypeTextField
label:@"Expiration Month"
value:@"12"
required:YES],
[[EditorField alloc] initWithAutofillUIType:AutofillUITypeCreditCardExpYear
+ fieldType:EditorFieldTypeTextField
label:@"Expiration Year"
value:@"2090"
required:YES],
+ [[EditorField alloc]
+ initWithAutofillUIType:AutofillUITypeCreditCardBillingAddress
+ fieldType:EditorFieldTypeSelector
+ label:@"Billing Address"
+ value:@"12345"
+ required:YES],
];
}
-- (NSString*)billingAddressLabelForProfileWithGUID:(NSString*)profileGUID {
- return nil;
-}
-
- (UIImage*)cardTypeIconFromCardNumber:(NSString*)cardNumber {
return nil;
}
@@ -99,15 +105,13 @@ TEST_F(PaymentRequestCreditCardEditViewControllerTest, TestModel) {
CreateController();
CheckController();
- [mediator_ setState:CreditCardEditViewControllerStateEdit];
+ [mediator_ setState:EditViewControllerStateEdit];
[GetCreditCardEditViewController() loadModel];
// There is one section containing the credit card type icons for the accepted
- // payment methods. In addition to that, there is one section for every
- // textfield (there are four textfields in total), one for the server card
- // summary section, one for the footer, and one for the billing address ID
- // item.
- ASSERT_EQ(8, NumberOfSections());
+ // payment methods. In addition to that, there is one section for every field
+ // (there are five form fields in total), and finally one for the footer.
+ ASSERT_EQ(7, NumberOfSections());
// The server card summary section is the first section and has one item of
// the type PaymentMethodItem.
@@ -115,13 +119,11 @@ TEST_F(PaymentRequestCreditCardEditViewControllerTest, TestModel) {
id item = GetCollectionViewItem(0, 0);
EXPECT_TRUE([item isMemberOfClass:[PaymentMethodItem class]]);
- // The next section is the accepted payment methods section and has one item
- // of the type AcceptedPaymentMethodsItem.
+ // The next four sections have only one item of the type AutofillEditItem.
ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(1)));
item = GetCollectionViewItem(1, 0);
- EXPECT_TRUE([item isMemberOfClass:[AcceptedPaymentMethodsItem class]]);
+ EXPECT_TRUE([item isMemberOfClass:[AutofillEditItem class]]);
- // The next four sections have only one item of the type AutofillEditItem.
ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(2)));
item = GetCollectionViewItem(2, 0);
EXPECT_TRUE([item isMemberOfClass:[AutofillEditItem class]]);
@@ -134,23 +136,19 @@ TEST_F(PaymentRequestCreditCardEditViewControllerTest, TestModel) {
item = GetCollectionViewItem(4, 0);
EXPECT_TRUE([item isMemberOfClass:[AutofillEditItem class]]);
+ // The billing address section contains one item which is of the type
+ // PaymentsSelectorEditItem.
ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(5)));
item = GetCollectionViewItem(5, 0);
- EXPECT_TRUE([item isMemberOfClass:[AutofillEditItem class]]);
-
- // The billing address section contains one item which is of the type
- // CollectionViewDetailItem.
- ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(6)));
- item = GetCollectionViewItem(6, 0);
- EXPECT_TRUE([item isMemberOfClass:[CollectionViewDetailItem class]]);
- CollectionViewDetailItem* billing_address_item = item;
+ EXPECT_TRUE([item isMemberOfClass:[PaymentsSelectorEditItem class]]);
+ PaymentsSelectorEditItem* billing_address_item = item;
EXPECT_EQ(MDCCollectionViewCellAccessoryDisclosureIndicator,
billing_address_item.accessoryType);
// The footer section contains one item which is of the type
// CollectionViewFooterItem.
- ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(7)));
- item = GetCollectionViewItem(7, 0);
+ ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(6)));
+ item = GetCollectionViewItem(6, 0);
EXPECT_TRUE([item isMemberOfClass:[CollectionViewFooterItem class]]);
}
@@ -161,17 +159,17 @@ TEST_F(PaymentRequestCreditCardEditViewControllerTest,
CreateController();
CheckController();
- [mediator_ setState:CreditCardEditViewControllerStateCreate];
+ [mediator_ setState:EditViewControllerStateCreate];
[GetCreditCardEditViewController() loadModel];
// There is an extra section containing a switch that allows the user to save
// the credit card locally.
- ASSERT_EQ(9, NumberOfSections());
+ ASSERT_EQ(8, NumberOfSections());
// The switch section is the last section before the footer and has one item
// of the type CollectionViewSwitchItem. The switch is on by defualt.
- ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(7)));
- id item = GetCollectionViewItem(7, 0);
+ ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(6)));
+ id item = GetCollectionViewItem(6, 0);
EXPECT_TRUE([item isMemberOfClass:[CollectionViewSwitchItem class]]);
CollectionViewSwitchItem* switch_item = item;
EXPECT_EQ(YES, [switch_item isOn]);

Powered by Google App Engine
This is Rietveld 408576698