1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/payments/content/secure_payment_confirmation_model.h"
#include <string>
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/vector_icon_types.h"
namespace payments {
class SecurePaymentConfirmationModelTest : public testing::Test {};
TEST_F(SecurePaymentConfirmationModelTest, SmokeTest) {
SecurePaymentConfirmationModel model;
std::u16string title(u"Use Touch ID to verify and complete your purchase?");
std::u16string merchant_label(u"Store");
std::u16string merchant_name(u"Test Merchant");
std::u16string merchant_origin(u"merchant.com");
std::u16string instrument_label(u"Payment");
std::u16string instrument_value(u"Mastercard ****4444");
SkBitmap instrument_icon;
std::u16string network_label(u"Network");
std::u16string network_value(u"Mastercard");
SkBitmap network_icon;
std::u16string issuer_label(u"Issuer");
std::u16string issuer_value(u"Chase");
SkBitmap issuer_icon;
std::u16string total_label(u"Total");
std::u16string total_value(u"$20.00 USD");
std::u16string verify_button_label(u"Verify");
std::u16string cancel_button_label(u"Cancel");
std::u16string opt_out_label(u"Opt Out");
std::u16string opt_out_link_text(u"Opt Out Link");
std::u16string relying_party_id(u"example.test");
model.set_title(title);
EXPECT_EQ(title, model.title());
model.set_merchant_label(merchant_label);
EXPECT_EQ(merchant_label, model.merchant_label());
model.set_merchant_name(merchant_name);
EXPECT_EQ(merchant_name, model.merchant_name());
model.set_merchant_origin(merchant_origin);
EXPECT_EQ(merchant_origin, model.merchant_origin());
model.set_instrument_label(instrument_label);
EXPECT_EQ(instrument_label, model.instrument_label());
model.set_instrument_value(instrument_value);
EXPECT_EQ(instrument_value, model.instrument_value());
model.set_instrument_icon(&instrument_icon);
EXPECT_EQ(&instrument_icon, model.instrument_icon());
model.set_network_label(network_label);
EXPECT_EQ(network_label, model.network_label());
model.set_network_value(network_value);
EXPECT_EQ(network_value, model.network_value());
model.set_network_icon(&network_icon);
EXPECT_EQ(&network_icon, model.network_icon());
model.set_issuer_label(issuer_label);
EXPECT_EQ(issuer_label, model.issuer_label());
model.set_issuer_value(issuer_value);
EXPECT_EQ(issuer_value, model.issuer_value());
model.set_issuer_icon(&issuer_icon);
EXPECT_EQ(&issuer_icon, model.issuer_icon());
model.set_total_label(total_label);
EXPECT_EQ(total_label, model.total_label());
model.set_total_value(total_value);
EXPECT_EQ(total_value, model.total_value());
model.set_verify_button_label(verify_button_label);
EXPECT_EQ(verify_button_label, model.verify_button_label());
model.set_cancel_button_label(cancel_button_label);
EXPECT_EQ(cancel_button_label, model.cancel_button_label());
model.set_opt_out_label(opt_out_label);
EXPECT_EQ(opt_out_label, model.opt_out_label());
model.set_opt_out_link_label(opt_out_link_text);
EXPECT_EQ(opt_out_link_text, model.opt_out_link_label());
model.set_relying_party_id(relying_party_id);
EXPECT_EQ(relying_party_id, model.relying_party_id());
// Default values for visibility and enabled states
EXPECT_FALSE(model.progress_bar_visible());
EXPECT_TRUE(model.verify_button_enabled());
EXPECT_TRUE(model.verify_button_visible());
EXPECT_TRUE(model.cancel_button_enabled());
EXPECT_TRUE(model.cancel_button_visible());
EXPECT_FALSE(model.opt_out_visible());
model.set_progress_bar_visible(true);
model.set_verify_button_enabled(false);
model.set_verify_button_visible(false);
model.set_cancel_button_enabled(false);
model.set_cancel_button_visible(false);
model.set_opt_out_visible(true);
EXPECT_TRUE(model.progress_bar_visible());
EXPECT_FALSE(model.verify_button_enabled());
EXPECT_FALSE(model.verify_button_visible());
EXPECT_FALSE(model.cancel_button_enabled());
EXPECT_FALSE(model.cancel_button_visible());
EXPECT_TRUE(model.opt_out_visible());
}
} // namespace payments
|