Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/payments/contact_info_edit_mediator.h" | 5 #import "ios/chrome/browser/ui/payments/contact_info_edit_mediator.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/test/scoped_task_environment.h" | 9 #include "base/test/scoped_task_environment.h" |
| 10 #include "components/autofill/core/browser/autofill_profile.h" | 10 #include "components/autofill/core/browser/autofill_profile.h" |
| 11 #include "components/autofill/core/browser/autofill_test_utils.h" | 11 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 12 #include "components/autofill/core/browser/test_personal_data_manager.h" | 12 #include "components/autofill/core/browser/test_personal_data_manager.h" |
| 13 #include "components/strings/grit/components_strings.h" | 13 #include "components/strings/grit/components_strings.h" |
| 14 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | |
| 14 #include "ios/chrome/browser/payments/payment_request_test_util.h" | 15 #include "ios/chrome/browser/payments/payment_request_test_util.h" |
| 15 #include "ios/chrome/browser/payments/test_payment_request.h" | 16 #include "ios/chrome/browser/payments/test_payment_request.h" |
| 16 #import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h" | 17 #import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h" |
| 17 #import "ios/chrome/browser/ui/payments/payment_request_edit_consumer.h" | 18 #import "ios/chrome/browser/ui/payments/payment_request_edit_consumer.h" |
| 18 #import "ios/chrome/browser/ui/payments/payment_request_editor_field.h" | 19 #import "ios/chrome/browser/ui/payments/payment_request_editor_field.h" |
| 20 #import "ios/web/public/test/fakes/test_web_state.h" | |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "testing/platform_test.h" | 22 #include "testing/platform_test.h" |
| 21 #include "third_party/ocmock/OCMock/OCMock.h" | 23 #include "third_party/ocmock/OCMock/OCMock.h" |
| 22 #include "third_party/ocmock/gtest_support.h" | 24 #include "third_party/ocmock/gtest_support.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 24 | 26 |
| 25 #if !defined(__has_feature) || !__has_feature(objc_arc) | 27 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 26 #error "This file requires ARC support." | 28 #error "This file requires ARC support." |
| 27 #endif | 29 #endif |
| 28 | 30 |
| 29 class PaymentRequestContactInfoEditMediatorTest : public PlatformTest { | 31 class PaymentRequestContactInfoEditMediatorTest : public PlatformTest { |
| 30 protected: | 32 protected: |
| 31 PaymentRequestContactInfoEditMediatorTest() | 33 PaymentRequestContactInfoEditMediatorTest() { |
| 32 : payment_request_(base::MakeUnique<payments::TestPaymentRequest>( | 34 TestChromeBrowserState::Builder test_cbs_builder; |
| 33 payment_request_test_util::CreateTestWebPaymentRequest(), | 35 chrome_browser_state_ = test_cbs_builder.Build(); |
| 34 &personal_data_manager_)) {} | 36 |
| 37 payment_request_ = base::MakeUnique<payments::TestPaymentRequest>( | |
| 38 payment_request_test_util::CreateTestWebPaymentRequest(), | |
| 39 chrome_browser_state_.get(), &web_state_, &personal_data_manager_); | |
| 40 } | |
| 35 | 41 |
| 36 base::test::ScopedTaskEnvironment scoped_task_evironment_; | 42 base::test::ScopedTaskEnvironment scoped_task_evironment_; |
| 37 | 43 |
| 44 web::TestWebState web_state_; | |
| 38 autofill::TestPersonalDataManager personal_data_manager_; | 45 autofill::TestPersonalDataManager personal_data_manager_; |
| 39 std::unique_ptr<payments::TestPaymentRequest> payment_request_; | 46 std::unique_ptr<payments::TestPaymentRequest> payment_request_; |
| 47 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; | |
|
please use gerrit instead
2017/07/06 14:52:25
Ditto
Moe
2017/07/07 02:24:54
Done.
| |
| 40 }; | 48 }; |
| 41 | 49 |
| 42 // Tests that the expected editor fields are created when creating a profile. | 50 // Tests that the expected editor fields are created when creating a profile. |
| 43 TEST_F(PaymentRequestContactInfoEditMediatorTest, TestFieldsWhenCreate) { | 51 TEST_F(PaymentRequestContactInfoEditMediatorTest, TestFieldsWhenCreate) { |
| 44 id check_block = ^BOOL(id value) { | 52 id check_block = ^BOOL(id value) { |
| 45 EXPECT_TRUE([value isKindOfClass:[NSArray class]]); | 53 EXPECT_TRUE([value isKindOfClass:[NSArray class]]); |
| 46 NSArray* fields = base::mac::ObjCCastStrict<NSArray>(value); | 54 NSArray* fields = base::mac::ObjCCastStrict<NSArray>(value); |
| 47 EXPECT_EQ(3U, fields.count); | 55 EXPECT_EQ(3U, fields.count); |
| 48 | 56 |
| 49 id field = fields[0]; | 57 id field = fields[0]; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 [OCMockObject mockForProtocol:@protocol(PaymentRequestEditConsumer)]; | 201 [OCMockObject mockForProtocol:@protocol(PaymentRequestEditConsumer)]; |
| 194 [[consumer expect] setEditorFields:[OCMArg checkWithBlock:check_block]]; | 202 [[consumer expect] setEditorFields:[OCMArg checkWithBlock:check_block]]; |
| 195 | 203 |
| 196 ContactInfoEditMediator* mediator = [[ContactInfoEditMediator alloc] | 204 ContactInfoEditMediator* mediator = [[ContactInfoEditMediator alloc] |
| 197 initWithPaymentRequest:payment_request_.get() | 205 initWithPaymentRequest:payment_request_.get() |
| 198 profile:nil]; | 206 profile:nil]; |
| 199 [mediator setConsumer:consumer]; | 207 [mediator setConsumer:consumer]; |
| 200 | 208 |
| 201 EXPECT_OCMOCK_VERIFY(consumer); | 209 EXPECT_OCMOCK_VERIFY(consumer); |
| 202 } | 210 } |
| OLD | NEW |