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

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

Issue 2621453002: Selected shipping option in payment summary view + shipping option selection view (Closed)
Patch Set: Addressed comments by lpromero@ and jdonnelley@ Created 3 years, 11 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/payments/shipping_option_selection_view_controller.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 #include <vector>
6
7 #include "base/mac/foundation_util.h"
8 #import "ios/chrome/browser/payments/shipping_option_selection_view_controller.h "
9 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h "
10 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h "
11 #include "ios/chrome/grit/ios_strings.h"
12 #include "ios/web/public/payments/payment_request.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace {
16
17 class ShippingOptionSelectionViewControllerTest
18 : public CollectionViewControllerTest {
19 protected:
20 CollectionViewController* NewController() override NS_RETURNS_RETAINED {
21 return [[ShippingOptionSelectionViewController alloc] init];
22 }
23
24 ShippingOptionSelectionViewController* ShippingOptionSelectionController() {
25 return base::mac::ObjCCastStrict<ShippingOptionSelectionViewController>(
26 controller());
27 }
28 };
29
30 // Tests that the correct number of items are displayed after loading the model
31 // and that the correct item appears to be selected.
32 TEST_F(ShippingOptionSelectionViewControllerTest, TestModel) {
33 CreateController();
34 CheckController();
35 CheckTitleWithId(IDS_IOS_PAYMENT_REQUEST_SHIPPING_OPTION_SELECTION_TITLE);
36
37 std::unique_ptr<web::PaymentShippingOption> option1(
38 new web::PaymentShippingOption());
39 std::unique_ptr<web::PaymentShippingOption> option2(
40 new web::PaymentShippingOption());
41
42 std::vector<web::PaymentShippingOption*> shippingOptions;
43 shippingOptions.push_back(option1.get());
44 shippingOptions.push_back(option2.get());
45
46 [ShippingOptionSelectionController() setShippingOptions:shippingOptions];
47 [ShippingOptionSelectionController()
48 setSelectedShippingOption:shippingOptions[0]];
49 [ShippingOptionSelectionController() loadModel];
50
51 ASSERT_EQ(1, NumberOfSections());
52 // One item for each of shipping options.
53 EXPECT_EQ(shippingOptions.size(),
54 static_cast<unsigned int>(NumberOfItemsInSection(0)));
55
56 // The first option should appear to be selected.
57 CollectionViewTextItem* item = GetCollectionViewItem(0, 0);
58 EXPECT_EQ(MDCCollectionViewCellAccessoryCheckmark, item.accessoryType);
59 item = GetCollectionViewItem(0, 1);
60 EXPECT_EQ(MDCCollectionViewCellAccessoryNone, item.accessoryType);
61 }
62
63 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/payments/shipping_option_selection_view_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698