Index: ios/chrome/browser/payments/shipping_address_selection_coordinator_unittest.mm |
diff --git a/ios/chrome/browser/payments/shipping_address_selection_coordinator_unittest.mm b/ios/chrome/browser/payments/shipping_address_selection_coordinator_unittest.mm |
index c7b4965d71b726adcf0c3447e4b20e3f15e60b2c..59f825d74c5959b1fe4f1980f30b3bd64664fd92 100644 |
--- a/ios/chrome/browser/payments/shipping_address_selection_coordinator_unittest.mm |
+++ b/ios/chrome/browser/payments/shipping_address_selection_coordinator_unittest.mm |
@@ -8,12 +8,11 @@ |
#include "base/memory/ptr_util.h" |
#include "base/test/ios/wait_util.h" |
#include "components/autofill/core/browser/autofill_profile.h" |
-#include "components/autofill/core/browser/credit_card.h" |
+#include "components/autofill/core/browser/autofill_test_utils.h" |
#include "components/autofill/core/browser/test_personal_data_manager.h" |
#include "ios/chrome/browser/payments/payment_request.h" |
+#import "ios/chrome/browser/payments/payment_request_selector_view_controller.h" |
#include "ios/chrome/browser/payments/payment_request_test_util.h" |
-#import "ios/chrome/browser/payments/shipping_address_selection_view_controller.h" |
-#include "ios/web/public/payments/payment_request.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "testing/platform_test.h" |
#include "third_party/ocmock/OCMock/OCMock.h" |
@@ -26,18 +25,25 @@ |
class PaymentRequestShippingAddressSelectionCoordinatorTest |
: public PlatformTest { |
protected: |
- PaymentRequestShippingAddressSelectionCoordinatorTest() { |
+ PaymentRequestShippingAddressSelectionCoordinatorTest() |
+ : autofill_profile1_(autofill::test::GetFullProfile()), |
+ autofill_profile2_(autofill::test::GetFullProfile2()) { |
+ // Add testing profiles to autofill::TestPersonalDataManager. |
+ personal_data_manager_.AddTestingProfile(&autofill_profile1_); |
+ personal_data_manager_.AddTestingProfile(&autofill_profile2_); |
payment_request_ = base::MakeUnique<PaymentRequest>( |
payment_request_test_util::CreateTestWebPaymentRequest(), |
&personal_data_manager_); |
} |
+ autofill::AutofillProfile autofill_profile1_; |
+ autofill::AutofillProfile autofill_profile2_; |
autofill::TestPersonalDataManager personal_data_manager_; |
std::unique_ptr<PaymentRequest> payment_request_; |
}; |
// Tests that invoking start and stop on the coordinator presents and dismisses |
-// the ShippingAddressSelectionViewController, respectively. |
+// the PaymentRequestSelectorViewController, respectively. |
TEST_F(PaymentRequestShippingAddressSelectionCoordinatorTest, StartAndStop) { |
UIViewController* base_view_controller = [[UIViewController alloc] init]; |
UINavigationController* navigation_controller = |
@@ -59,7 +65,7 @@ TEST_F(PaymentRequestShippingAddressSelectionCoordinatorTest, StartAndStop) { |
UIViewController* view_controller = |
navigation_controller.visibleViewController; |
EXPECT_TRUE([view_controller |
- isMemberOfClass:[ShippingAddressSelectionViewController class]]); |
+ isMemberOfClass:[PaymentRequestSelectorViewController class]]); |
[coordinator stop]; |
// Short delay to allow animation to complete. |
@@ -85,9 +91,9 @@ TEST_F(PaymentRequestShippingAddressSelectionCoordinatorTest, |
// Mock the coordinator delegate. |
id delegate = [OCMockObject |
mockForProtocol:@protocol(ShippingAddressSelectionCoordinatorDelegate)]; |
- autofill::AutofillProfile profile; |
+ autofill::AutofillProfile* profile = payment_request_->shipping_profiles()[1]; |
[[delegate expect] shippingAddressSelectionCoordinator:coordinator |
- didSelectShippingAddress:&profile]; |
+ didSelectShippingAddress:profile]; |
[coordinator setDelegate:delegate]; |
EXPECT_EQ(1u, navigation_controller.viewControllers.count); |
@@ -98,11 +104,11 @@ TEST_F(PaymentRequestShippingAddressSelectionCoordinatorTest, |
EXPECT_EQ(2u, navigation_controller.viewControllers.count); |
// Call the controller delegate method. |
- ShippingAddressSelectionViewController* view_controller = |
- base::mac::ObjCCastStrict<ShippingAddressSelectionViewController>( |
+ PaymentRequestSelectorViewController* view_controller = |
+ base::mac::ObjCCastStrict<PaymentRequestSelectorViewController>( |
navigation_controller.visibleViewController); |
- [coordinator shippingAddressSelectionViewController:view_controller |
- didSelectShippingAddress:&profile]; |
+ [coordinator paymentRequestSelectorViewController:view_controller |
+ didSelectItemAtIndex:1]; |
// Wait for the coordinator delegate to be notified. |
base::test::ios::SpinRunLoopWithMinDelay(base::TimeDelta::FromSecondsD(0.5)); |
@@ -138,10 +144,10 @@ TEST_F(PaymentRequestShippingAddressSelectionCoordinatorTest, DidReturn) { |
EXPECT_EQ(2u, navigation_controller.viewControllers.count); |
// Call the controller delegate method. |
- ShippingAddressSelectionViewController* view_controller = |
- base::mac::ObjCCastStrict<ShippingAddressSelectionViewController>( |
+ PaymentRequestSelectorViewController* view_controller = |
+ base::mac::ObjCCastStrict<PaymentRequestSelectorViewController>( |
navigation_controller.visibleViewController); |
- [coordinator shippingAddressSelectionViewControllerDidReturn:view_controller]; |
+ [coordinator paymentRequestSelectorViewControllerDidFinish:view_controller]; |
EXPECT_OCMOCK_VERIFY(delegate); |
} |