Commit 2c7e31df authored by Alfonso Garza's avatar Alfonso Garza Committed by Commit Bot

[AF] Refactor CardExpirationDateFixFlowViewDelegateMobile for

cross-platform use.

This change updates CardExpirationDateFixFlow to follow the same pattern
as CardUnmaskPrompt and the next CL will add the iOS part.

Also adds tests for CardExpirationDateFixFlowControllerImpl as the
delegate was previously untested.

Bug: 993850
Change-Id: I87bfe2c0533a7f431baf16a1bde29d1e03f87e87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1863116Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Alfonso Garza <alfonsogarza@google.com>
Cr-Commit-Position: refs/heads/master@{#707614}
parent 977a5c49
......@@ -9,7 +9,8 @@
#include "chrome/android/chrome_jni_headers/AutofillExpirationDateFixFlowBridge_jni.h"
#include "chrome/browser/android/resource_mapper.h"
#include "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_view_delegate_mobile.h"
#include "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller.h"
#include "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_view.h"
#include "content/public/browser/web_contents.h"
#include "ui/android/view_android.h"
#include "ui/android/window_android.h"
......@@ -20,51 +21,56 @@ using base::android::ScopedJavaLocalRef;
namespace autofill {
CardExpirationDateFixFlowViewAndroid::CardExpirationDateFixFlowViewAndroid(
std::unique_ptr<CardExpirationDateFixFlowViewDelegateMobile> delegate,
CardExpirationDateFixFlowController* controller,
content::WebContents* web_contents)
: delegate_(std::move(delegate)), web_contents_(web_contents) {}
: controller_(controller), web_contents_(web_contents) {}
CardExpirationDateFixFlowViewAndroid::~CardExpirationDateFixFlowViewAndroid() {
JNIEnv* env = base::android::AttachCurrentThread();
Java_AutofillExpirationDateFixFlowBridge_dismiss(env, java_object_);
void CardExpirationDateFixFlowViewAndroid::OnUserAccept(
JNIEnv* env,
const JavaParamRef<jobject>& obj,
const JavaParamRef<jstring>& month,
const JavaParamRef<jstring>& year) {
controller_->OnAccepted(base::android::ConvertJavaStringToUTF16(env, month),
base::android::ConvertJavaStringToUTF16(env, year));
}
void CardExpirationDateFixFlowViewAndroid::PromptDismissed(
JNIEnv* env,
const JavaParamRef<jobject>& obj) {
controller_->OnDismissed();
delete this;
}
void CardExpirationDateFixFlowViewAndroid::Show() {
JNIEnv* env = base::android::AttachCurrentThread();
ui::ViewAndroid* view_android = web_contents_->GetNativeView();
ScopedJavaLocalRef<jstring> dialog_title =
base::android::ConvertUTF16ToJavaString(env, delegate_->GetTitleText());
base::android::ConvertUTF16ToJavaString(env, controller_->GetTitleText());
ScopedJavaLocalRef<jstring> confirm = base::android::ConvertUTF16ToJavaString(
env, delegate_->GetSaveButtonLabel());
env, controller_->GetSaveButtonLabel());
ScopedJavaLocalRef<jstring> card_label =
base::android::ConvertUTF16ToJavaString(env, delegate_->card_label());
base::android::ConvertUTF16ToJavaString(env, controller_->GetCardLabel());
java_object_.Reset(Java_AutofillExpirationDateFixFlowBridge_create(
env, reinterpret_cast<intptr_t>(this), dialog_title, confirm,
ResourceMapper::MapFromChromiumId(delegate_->GetIconId()), card_label));
ResourceMapper::MapFromChromiumId(controller_->GetIconId()), card_label));
Java_AutofillExpirationDateFixFlowBridge_show(
env, java_object_, view_android->GetWindowAndroid()->GetJavaObject());
delegate_->Shown();
env, java_object_,
web_contents_->GetTopLevelNativeWindow()->GetJavaObject());
}
void CardExpirationDateFixFlowViewAndroid::OnUserAccept(
JNIEnv* env,
const JavaParamRef<jobject>& obj,
const JavaParamRef<jstring>& month,
const JavaParamRef<jstring>& year) {
delegate_->Accept(base::android::ConvertJavaStringToUTF16(env, month),
base::android::ConvertJavaStringToUTF16(env, year));
void CardExpirationDateFixFlowViewAndroid::ControllerGone() {
controller_ = nullptr;
JNIEnv* env = base::android::AttachCurrentThread();
Java_AutofillExpirationDateFixFlowBridge_dismiss(env, java_object_);
}
void CardExpirationDateFixFlowViewAndroid::PromptDismissed(
JNIEnv* env,
const JavaParamRef<jobject>& obj) {
delegate_->Dismissed();
delete this;
CardExpirationDateFixFlowViewAndroid::~CardExpirationDateFixFlowViewAndroid() {
if (controller_)
controller_->OnDialogClosed();
}
} // namespace autofill
......@@ -12,6 +12,7 @@
#include "base/android/scoped_java_ref.h"
#include "base/macros.h"
#include "base/strings/string16.h"
#include "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_view.h"
namespace content {
class WebContents;
......@@ -19,16 +20,15 @@ class WebContents;
namespace autofill {
class CardExpirationDateFixFlowViewDelegateMobile;
class CardExpirationDateFixFlowController;
class CardExpirationDateFixFlowViewAndroid {
class CardExpirationDateFixFlowViewAndroid
: public CardExpirationDateFixFlowView {
public:
CardExpirationDateFixFlowViewAndroid(
std::unique_ptr<CardExpirationDateFixFlowViewDelegateMobile> delegate,
CardExpirationDateFixFlowController* controller,
content::WebContents* web_contents);
~CardExpirationDateFixFlowViewAndroid();
void OnUserAccept(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
const base::android::JavaParamRef<jstring>& month,
......@@ -36,13 +36,17 @@ class CardExpirationDateFixFlowViewAndroid {
void PromptDismissed(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
void Show();
// CardExpirationDateFixFlowView implementation.
void Show() override;
void ControllerGone() override;
private:
~CardExpirationDateFixFlowViewAndroid() override;
// The corresponding java object.
base::android::ScopedJavaGlobalRef<jobject> java_object_;
std::unique_ptr<CardExpirationDateFixFlowViewDelegateMobile> delegate_;
CardExpirationDateFixFlowController* controller_;
content::WebContents* web_contents_;
......
......@@ -76,7 +76,7 @@
#include "components/autofill/core/browser/payments/autofill_credit_card_filling_infobar_delegate_mobile.h"
#include "components/autofill/core/browser/payments/autofill_save_card_infobar_delegate_mobile.h"
#include "components/autofill/core/browser/payments/autofill_save_card_infobar_mobile.h"
#include "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_view_delegate_mobile.h"
#include "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_view.h"
#include "components/autofill/core/browser/ui/payments/card_name_fix_flow_view.h"
#include "components/infobars/core/infobar.h"
#include "ui/android/window_android.h"
......@@ -346,20 +346,13 @@ void ChromeAutofillClient::ConfirmExpirationDateFixFlow(
const CreditCard& card,
base::OnceCallback<void(const base::string16&, const base::string16&)>
callback) {
std::unique_ptr<CardExpirationDateFixFlowViewDelegateMobile>
card_expiration_date_fix_flow_view_delegate_mobile =
std::make_unique<CardExpirationDateFixFlowViewDelegateMobile>(
card,
/*upload_save_card_callback=*/std::move(callback));
// Destruction is handled by the fix flow dialog by explicitly calling delete
// when the prompt is dismissed.
CardExpirationDateFixFlowViewAndroid*
card_expiration_date_fix_flow_view_android =
new CardExpirationDateFixFlowViewAndroid(
std::move(card_expiration_date_fix_flow_view_delegate_mobile),
web_contents());
card_expiration_date_fix_flow_view_android->Show();
&card_expiration_date_fix_flow_controller_, web_contents());
card_expiration_date_fix_flow_controller_.Show(
card_expiration_date_fix_flow_view_android, card,
/*upload_save_card_callback=*/std::move(callback));
}
#endif
......
......@@ -24,6 +24,7 @@
#include "content/public/browser/web_contents_user_data.h"
#if defined(OS_ANDROID)
#include "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl.h"
#include "components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl.h"
#else // !OS_ANDROID
#include "chrome/browser/ui/autofill/payments/manage_migration_ui_controller.h"
......@@ -31,10 +32,6 @@
#include "components/zoom/zoom_observer.h"
#endif
#if defined(OS_ANDROID)
#include "components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl.h"
#endif // defined(OS_ANDROID)
namespace content {
class WebContents;
}
......@@ -173,6 +170,8 @@ class ChromeAutofillClient
CardUnmaskPromptControllerImpl unmask_controller_;
std::unique_ptr<LogManager> log_manager_;
#if defined(OS_ANDROID)
CardExpirationDateFixFlowControllerImpl
card_expiration_date_fix_flow_controller_;
CardNameFixFlowControllerImpl card_name_fix_flow_controller_;
#endif
......
......@@ -293,8 +293,10 @@ jumbo_static_library("browser") {
"payments/autofill_save_card_infobar_mobile.h",
"ui/mobile_label_formatter.cc",
"ui/mobile_label_formatter.h",
"ui/payments/card_expiration_date_fix_flow_view_delegate_mobile.cc",
"ui/payments/card_expiration_date_fix_flow_view_delegate_mobile.h",
"ui/payments/card_expiration_date_fix_flow_controller.h",
"ui/payments/card_expiration_date_fix_flow_controller_impl.cc",
"ui/payments/card_expiration_date_fix_flow_controller_impl.h",
"ui/payments/card_expiration_date_fix_flow_view.h",
"ui/payments/card_name_fix_flow_controller.h",
"ui/payments/card_name_fix_flow_controller_impl.cc",
"ui/payments/card_name_fix_flow_controller_impl.h",
......@@ -607,6 +609,7 @@ source_set("unit_tests") {
sources += [
"autofill_assistant_unittest.cc",
"ui/mobile_label_formatter_unittest.cc",
"ui/payments/card_expiration_date_fix_flow_controller_impl_unittest.cc",
"ui/payments/card_name_fix_flow_controller_impl_unittest.cc",
]
}
......
// Copyright 2019 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.
#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_CONTROLLER_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_CONTROLLER_H_
#include <memory>
#include "base/callback.h"
#include "base/macros.h"
#include "base/strings/string16.h"
#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
namespace autofill {
// Enables the user to accept or deny expiration date fix flow prompt.
// Only used on mobile.
class CardExpirationDateFixFlowController {
public:
virtual ~CardExpirationDateFixFlowController() {}
// Interaction.
virtual void OnAccepted(const base::string16& month,
const base::string16& year) = 0;
virtual void OnDismissed() = 0;
virtual void OnDialogClosed() = 0;
// State.
virtual int GetIconId() const = 0;
virtual base::string16 GetTitleText() const = 0;
virtual base::string16 GetSaveButtonLabel() const = 0;
virtual base::string16 GetCardLabel() const = 0;
};
} // namespace autofill
#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_CONTROLLER_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_view_delegate_mobile.h"
#include "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl.h"
#include <utility>
......@@ -11,72 +11,91 @@
#include "base/values.h"
#include "build/branding_buildflags.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_view.h"
#include "components/grit/components_scaled_resources.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
namespace autofill {
CardExpirationDateFixFlowViewDelegateMobile::
CardExpirationDateFixFlowViewDelegateMobile(
const CreditCard& card,
base::OnceCallback<void(const base::string16&, const base::string16&)>
upload_save_card_callback)
: upload_save_card_callback_(std::move(upload_save_card_callback)),
shown_(false),
had_user_interaction_(false),
card_label_(card.NetworkAndLastFourDigits()) {
DCHECK(!upload_save_card_callback_.is_null());
}
CardExpirationDateFixFlowControllerImpl::
CardExpirationDateFixFlowControllerImpl() {}
CardExpirationDateFixFlowControllerImpl::
~CardExpirationDateFixFlowControllerImpl() {
if (card_expiration_date_fix_flow_view_)
card_expiration_date_fix_flow_view_->ControllerGone();
CardExpirationDateFixFlowViewDelegateMobile::
~CardExpirationDateFixFlowViewDelegateMobile() {
if (shown_ && !had_user_interaction_)
if (shown_ && !had_user_interaction_) {
AutofillMetrics::LogExpirationDateFixFlowPromptEvent(
AutofillMetrics::ExpirationDateFixFlowPromptEvent::
EXPIRATION_DATE_FIX_FLOW_PROMPT_CLOSED_WITHOUT_INTERACTION);
}
}
int CardExpirationDateFixFlowViewDelegateMobile::GetIconId() const {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
return IDR_AUTOFILL_GOOGLE_PAY_WITH_DIVIDER;
#else
return 0;
#endif
}
void CardExpirationDateFixFlowControllerImpl::Show(
CardExpirationDateFixFlowView* card_expiration_date_fix_flow_view,
const CreditCard& card,
base::OnceCallback<void(const base::string16&, const base::string16&)>
callback) {
DCHECK(!callback.is_null());
DCHECK(card_expiration_date_fix_flow_view);
base::string16 CardExpirationDateFixFlowViewDelegateMobile::GetTitleText()
const {
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_UPDATE_EXPIRATION_DATE_TITLE);
}
card_label_ = card.NetworkAndLastFourDigits();
base::string16 CardExpirationDateFixFlowViewDelegateMobile::GetSaveButtonLabel()
const {
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_FIX_FLOW_PROMPT_SAVE_CARD_LABEL);
if (card_expiration_date_fix_flow_view_)
card_expiration_date_fix_flow_view_->ControllerGone();
card_expiration_date_fix_flow_view_ = card_expiration_date_fix_flow_view;
upload_save_card_callback_ = std::move(callback);
card_expiration_date_fix_flow_view_->Show();
AutofillMetrics::LogExpirationDateFixFlowPromptShown();
shown_ = true;
}
void CardExpirationDateFixFlowViewDelegateMobile::Accept(
void CardExpirationDateFixFlowControllerImpl::OnAccepted(
const base::string16& month,
const base::string16& year) {
std::move(upload_save_card_callback_).Run(month, year);
AutofillMetrics::LogExpirationDateFixFlowPromptEvent(
AutofillMetrics::ExpirationDateFixFlowPromptEvent::
EXPIRATION_DATE_FIX_FLOW_PROMPT_ACCEPTED);
had_user_interaction_ = true;
std::move(upload_save_card_callback_).Run(month, year);
}
void CardExpirationDateFixFlowViewDelegateMobile::Dismissed() {
void CardExpirationDateFixFlowControllerImpl::OnDismissed() {
AutofillMetrics::LogExpirationDateFixFlowPromptEvent(
AutofillMetrics::ExpirationDateFixFlowPromptEvent::
EXPIRATION_DATE_FIX_FLOW_PROMPT_DISMISSED);
had_user_interaction_ = true;
}
void CardExpirationDateFixFlowViewDelegateMobile::Shown() {
AutofillMetrics::LogExpirationDateFixFlowPromptShown();
shown_ = true;
void CardExpirationDateFixFlowControllerImpl::OnDialogClosed() {
card_expiration_date_fix_flow_view_ = nullptr;
}
int CardExpirationDateFixFlowControllerImpl::GetIconId() const {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
return IDR_AUTOFILL_GOOGLE_PAY_WITH_DIVIDER;
#else
return 0;
#endif
}
base::string16 CardExpirationDateFixFlowControllerImpl::GetTitleText() const {
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_UPDATE_EXPIRATION_DATE_TITLE);
}
base::string16 CardExpirationDateFixFlowControllerImpl::GetSaveButtonLabel()
const {
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_FIX_FLOW_PROMPT_SAVE_CARD_LABEL);
}
base::string16 CardExpirationDateFixFlowControllerImpl::GetCardLabel() const {
return card_label_;
}
} // namespace autofill
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_VIEW_DELEGATE_MOBILE_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_VIEW_DELEGATE_MOBILE_H_
#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_CONTROLLER_IMPL_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_CONTROLLER_IMPL_H_
#include <memory>
......@@ -12,49 +12,58 @@
#include "base/strings/string16.h"
#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller.h"
namespace autofill {
class CardExpirationDateFixFlowView;
// Enables the user to accept or deny expiration date fix flow prompt.
// Only used on mobile. This class is responsible for its destruction.
// Destruction is achieved by calling delete when the prompt is
// dismissed.
class CardExpirationDateFixFlowViewDelegateMobile {
class CardExpirationDateFixFlowControllerImpl
: public CardExpirationDateFixFlowController {
public:
CardExpirationDateFixFlowViewDelegateMobile(
const CreditCard& card,
base::OnceCallback<void(const base::string16&, const base::string16&)>
upload_save_card_callback);
~CardExpirationDateFixFlowViewDelegateMobile();
CardExpirationDateFixFlowControllerImpl();
~CardExpirationDateFixFlowControllerImpl() override;
const base::string16& card_label() const { return card_label_; }
void Show(CardExpirationDateFixFlowView* card_expiration_date_fix_flow_view,
const CreditCard& card,
base::OnceCallback<void(const base::string16&,
const base::string16&)> callback);
int GetIconId() const;
base::string16 GetTitleText() const;
base::string16 GetSaveButtonLabel() const;
void Accept(const base::string16& month, const base::string16& year);
void Dismissed();
void Shown();
// CardExpirationDateFixFlowController implementation.
void OnAccepted(const base::string16& month,
const base::string16& year) override;
void OnDismissed() override;
void OnDialogClosed() override;
int GetIconId() const override;
base::string16 GetTitleText() const override;
base::string16 GetSaveButtonLabel() const override;
base::string16 GetCardLabel() const override;
private:
// View that displays the fix flow prompt.
CardExpirationDateFixFlowView* card_expiration_date_fix_flow_view_ = nullptr;
// The callback to save the credit card to Google Payments once user accepts
// fix flow.
base::OnceCallback<void(const base::string16&, const base::string16&)>
upload_save_card_callback_;
// Whether the prompt was shown to the user.
bool shown_;
bool shown_ = false;
// Did the user ever explicitly accept or dismiss this prompt?
bool had_user_interaction_;
bool had_user_interaction_ = false;
// Label of the card describing the network and the last four digits.
base::string16 card_label_;
DISALLOW_COPY_AND_ASSIGN(CardExpirationDateFixFlowViewDelegateMobile);
DISALLOW_COPY_AND_ASSIGN(CardExpirationDateFixFlowControllerImpl);
};
} // namespace autofill
#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_VIEW_DELEGATE_MOBILE_H_
#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_CONTROLLER_IMPL_H_
// Copyright 2019 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 "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl.h"
#include <stddef.h>
#include <memory>
#include "base/bind.h"
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_view.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace autofill {
class TestCardExpirationDateFixFlowView : public CardExpirationDateFixFlowView {
public:
void Show() override {}
void ControllerGone() override {}
};
class CardExpirationDateFixFlowControllerImplGenericTest {
public:
CardExpirationDateFixFlowControllerImplGenericTest() {}
void ShowPrompt() {
controller_->Show(
test_card_expiration_date_fix_flow_view_.get(), autofill::CreditCard(),
base::BindOnce(
&CardExpirationDateFixFlowControllerImplGenericTest::OnAccepted,
weak_ptr_factory_.GetWeakPtr()));
}
protected:
std::unique_ptr<TestCardExpirationDateFixFlowView>
test_card_expiration_date_fix_flow_view_;
std::unique_ptr<CardExpirationDateFixFlowControllerImpl> controller_;
base::string16 accepted_month_;
base::string16 accepted_year_;
base::WeakPtrFactory<CardExpirationDateFixFlowControllerImplGenericTest>
weak_ptr_factory_{this};
private:
void OnAccepted(const base::string16& month, const base::string16& year) {
accepted_month_ = month;
accepted_year_ = year;
}
DISALLOW_COPY_AND_ASSIGN(CardExpirationDateFixFlowControllerImplGenericTest);
};
class CardExpirationDateFixFlowControllerImplTest
: public CardExpirationDateFixFlowControllerImplGenericTest,
public testing::Test {
public:
CardExpirationDateFixFlowControllerImplTest() {}
~CardExpirationDateFixFlowControllerImplTest() override {}
void SetUp() override {
test_card_expiration_date_fix_flow_view_.reset(
new TestCardExpirationDateFixFlowView());
controller_.reset(new CardExpirationDateFixFlowControllerImpl());
}
private:
DISALLOW_COPY_AND_ASSIGN(CardExpirationDateFixFlowControllerImplTest);
};
TEST_F(CardExpirationDateFixFlowControllerImplTest, LogShown) {
base::HistogramTester histogram_tester;
ShowPrompt();
histogram_tester.ExpectBucketCount(
"Autofill.ExpirationDateFixFlowPromptShown", true, 1);
}
TEST_F(CardExpirationDateFixFlowControllerImplTest, LogAccepted) {
base::HistogramTester histogram_tester;
ShowPrompt();
controller_->OnAccepted(base::ASCIIToUTF16("11"), base::ASCIIToUTF16("30"));
ASSERT_EQ(accepted_month_, base::ASCIIToUTF16("11"));
ASSERT_EQ(accepted_year_, base::ASCIIToUTF16("30"));
histogram_tester.ExpectBucketCount(
"Autofill.ExpirationDateFixFlowPrompt.Events",
AutofillMetrics::ExpirationDateFixFlowPromptEvent::
EXPIRATION_DATE_FIX_FLOW_PROMPT_ACCEPTED,
1);
}
TEST_F(CardExpirationDateFixFlowControllerImplTest, LogDismissed) {
base::HistogramTester histogram_tester;
ShowPrompt();
controller_->OnDismissed();
histogram_tester.ExpectBucketCount(
"Autofill.ExpirationDateFixFlowPrompt.Events",
AutofillMetrics::ExpirationDateFixFlowPromptEvent::
EXPIRATION_DATE_FIX_FLOW_PROMPT_DISMISSED,
1);
}
} // namespace autofill
// Copyright 2019 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.
#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_VIEW_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_VIEW_H_
#include "base/macros.h"
#include "base/strings/string16.h"
namespace autofill {
// The cross-platform UI interface which prompts the user to confirm the
// expiration date of their form of payment. This object is responsible for its
// own lifetime.
class CardExpirationDateFixFlowView {
public:
virtual void Show() = 0;
virtual void ControllerGone() = 0;
protected:
virtual ~CardExpirationDateFixFlowView() = default;
};
} // namespace autofill
#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_VIEW_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment