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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/payments/shipping_option_selection_view_controller_unittest.mm
diff --git a/ios/chrome/browser/payments/shipping_option_selection_view_controller_unittest.mm b/ios/chrome/browser/payments/shipping_option_selection_view_controller_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..6da7236bde4f6370d0ecc0eec5b43c8d0156d031
--- /dev/null
+++ b/ios/chrome/browser/payments/shipping_option_selection_view_controller_unittest.mm
@@ -0,0 +1,63 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <vector>
+
+#include "base/mac/foundation_util.h"
+#import "ios/chrome/browser/payments/shipping_option_selection_view_controller.h"
+#import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h"
+#import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h"
+#include "ios/chrome/grit/ios_strings.h"
+#include "ios/web/public/payments/payment_request.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+class ShippingOptionSelectionViewControllerTest
+ : public CollectionViewControllerTest {
+ protected:
+ CollectionViewController* NewController() override NS_RETURNS_RETAINED {
+ return [[ShippingOptionSelectionViewController alloc] init];
+ }
+
+ ShippingOptionSelectionViewController* ShippingOptionSelectionController() {
+ return base::mac::ObjCCastStrict<ShippingOptionSelectionViewController>(
+ controller());
+ }
+};
+
+// Tests that the correct number of items are displayed after loading the model
+// and that the correct item appears to be selected.
+TEST_F(ShippingOptionSelectionViewControllerTest, TestModel) {
+ CreateController();
+ CheckController();
+ CheckTitleWithId(IDS_IOS_PAYMENT_REQUEST_SHIPPING_OPTION_SELECTION_TITLE);
+
+ std::unique_ptr<web::PaymentShippingOption> option1(
+ new web::PaymentShippingOption());
+ std::unique_ptr<web::PaymentShippingOption> option2(
+ new web::PaymentShippingOption());
+
+ std::vector<web::PaymentShippingOption*> shippingOptions;
+ shippingOptions.push_back(option1.get());
+ shippingOptions.push_back(option2.get());
+
+ [ShippingOptionSelectionController() setShippingOptions:shippingOptions];
+ [ShippingOptionSelectionController()
+ setSelectedShippingOption:shippingOptions[0]];
+ [ShippingOptionSelectionController() loadModel];
+
+ ASSERT_EQ(1, NumberOfSections());
+ // One item for each of shipping options.
+ EXPECT_EQ(shippingOptions.size(),
+ static_cast<unsigned int>(NumberOfItemsInSection(0)));
+
+ // The first option should appear to be selected.
+ CollectionViewTextItem* item = GetCollectionViewItem(0, 0);
+ EXPECT_EQ(MDCCollectionViewCellAccessoryCheckmark, item.accessoryType);
+ item = GetCollectionViewItem(0, 1);
+ EXPECT_EQ(MDCCollectionViewCellAccessoryNone, item.accessoryType);
+}
+
+} // namespace
« 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