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

Side by Side Diff: ios/chrome/browser/ui/payments/region_data_loader_unittest.mm

Issue 2893193002: [Payment Request] Region data loader (Closed)
Patch Set: Addressed comment 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 unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/ui/payments/region_data_loader.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/chrome/browser/ui/payments/region_data_loader.h"
6
7 #include <string>
8 #include <utility>
9 #include <vector>
10
11 #include "base/logging.h"
12 #include "base/strings/sys_string_conversions.h"
13 #include "components/autofill/core/browser/test_region_data_loader.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "testing/platform_test.h"
16 #include "third_party/ocmock/OCMock/OCMock.h"
17 #include "third_party/ocmock/gtest_support.h"
18
19 #if !defined(__has_feature) || !__has_feature(objc_arc)
20 #error "This file requires ARC support."
21 #endif
22
23 namespace {
24 const char kQuebec[] = "Quebec";
25 const char kOntario[] = "Ontario";
26 } // namespace
27
28 class PaymentRequestRegionDataLoaderTest : public PlatformTest {
29 protected:
30 PaymentRequestRegionDataLoaderTest() {}
31 ~PaymentRequestRegionDataLoaderTest() override {}
32
33 autofill::TestRegionDataLoader autofill_region_data_loader_;
34 };
35
36 // Tests that the two regions returned by the source are correctly returned.
37 TEST_F(PaymentRequestRegionDataLoaderTest, SourceSuccess) {
38 // Mock the consumer.
39 id consumer =
40 [OCMockObject mockForProtocol:@protocol(RegionDataLoaderConsumer)];
41 [[consumer expect] regionDataLoaderDidSucceedWithRegions:@[
42 base::SysUTF8ToNSString(kQuebec), base::SysUTF8ToNSString(kOntario)
43 ]];
44
45 RegionDataLoader region_data_loader(consumer);
46 region_data_loader.LoadRegionData("some country",
47 &autofill_region_data_loader_);
48
49 std::vector<std::pair<std::string, std::string>> regions;
50 regions.push_back(std::make_pair("QC", kQuebec));
51 regions.push_back(std::make_pair("ON", kOntario));
52 autofill_region_data_loader_.SendAsynchronousData(regions);
53
54 EXPECT_OCMOCK_VERIFY(consumer);
55 }
56
57 // Tests that the source emptiness/failure is properly handled.
58 TEST_F(PaymentRequestRegionDataLoaderTest, SourceFailure) {
59 // Mock the consumer.
60 id consumer =
61 [OCMockObject mockForProtocol:@protocol(RegionDataLoaderConsumer)];
62 [[consumer expect] regionDataLoaderDidSucceedWithRegions:@[]];
63
64 RegionDataLoader region_data_loader(consumer);
65 region_data_loader.LoadRegionData("some country",
66 &autofill_region_data_loader_);
67
68 autofill_region_data_loader_.SendAsynchronousData(
69 std::vector<std::pair<std::string, std::string>>());
70
71 EXPECT_OCMOCK_VERIFY(consumer);
72 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/payments/region_data_loader.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698