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

Unified Diff: chrome/browser/ui/autofill/card_unmask_prompt_view_browsertest.cc

Issue 2532793002: Add a TestBrowserDialog helper class for testing browser dialogs in a consistent way. (Closed)
Patch Set: Split out browsertest into browsertest.cc Created 4 years 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
Index: chrome/browser/ui/autofill/card_unmask_prompt_view_browsertest.cc
diff --git a/chrome/browser/ui/autofill/card_unmask_prompt_view_browsertest.cc b/chrome/browser/ui/autofill/card_unmask_prompt_view_browsertest.cc
index dad2c88da275738acefc4bcc29d449f86bd13496..d787bca93e4004c6b1f8a94d31e45962207a372d 100644
--- a/chrome/browser/ui/autofill/card_unmask_prompt_view_browsertest.cc
+++ b/chrome/browser/ui/autofill/card_unmask_prompt_view_browsertest.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/ui/autofill/create_card_unmask_prompt_view.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/card_unmask_delegate.h"
@@ -22,13 +23,16 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/test_utils.h"
-#include "ui/base/test/user_interactive_test_case.h"
namespace autofill {
namespace {
-enum class CreditCardExpiry : uint8_t { EXPIRED, VALID };
+// Forms of the dialog that can be invoked.
+enum {
+ CARD_EXPIRY_EXPIRED, // Shows additional month/year controls.
+ CARD_EXPIRY_VALID, // Shows only the CCV Textfield.
+};
class TestCardUnmaskDelegate : public CardUnmaskDelegate {
public:
@@ -85,12 +89,13 @@ class TestCardUnmaskPromptController : public CardUnmaskPromptControllerImpl {
DISALLOW_COPY_AND_ASSIGN(TestCardUnmaskPromptController);
};
-class CardUnmaskPromptViewBrowserTest : public InProcessBrowserTest {
+class CardUnmaskPromptViewBrowserTest : public DialogBrowserTest {
public:
- CardUnmaskPromptViewBrowserTest() : InProcessBrowserTest() {}
+ CardUnmaskPromptViewBrowserTest() {}
~CardUnmaskPromptViewBrowserTest() override {}
+ // DialogBrowserTest:
void SetUpOnMainThread() override {
runner_ = new content::MessageLoopRunner;
contents_ = browser()->tab_strip_model()->GetActiveWebContents();
@@ -98,16 +103,20 @@ class CardUnmaskPromptViewBrowserTest : public InProcessBrowserTest {
delegate_.reset(new TestCardUnmaskDelegate());
}
- void ShowUI(CreditCardExpiry expired) {
+ void ShowDialog(int index) override {
CardUnmaskPromptView* dialog =
CreateCardUnmaskPromptView(controller(), contents());
- CreditCard card = (expired == CreditCardExpiry::EXPIRED)
+ CreditCard card = (index == CARD_EXPIRY_EXPIRED)
? test::GetMaskedServerCard()
: test::GetMaskedServerCardAmex();
controller()->ShowPrompt(dialog, card, AutofillClient::UNMASK_FOR_AUTOFILL,
delegate()->GetWeakPtr());
}
+ static std::vector<std::string> NameProvider() {
+ return {"Expired", "Valid"};
+ }
+
void FreeDelegate() { delegate_.reset(); }
content::WebContents* contents() { return contents_; }
@@ -126,23 +135,10 @@ class CardUnmaskPromptViewBrowserTest : public InProcessBrowserTest {
DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViewBrowserTest);
};
-// Permanently disabled test used to invoke the UI for the card unmask prompt
-// with an expired credit card, which shows additional month/year controls.
-IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest,
- DISABLED_InvokeExpired) {
- ShowUI(CreditCardExpiry::EXPIRED);
- ::test::RunTestInteractively();
-}
-
-// Permanently disabled test used to invoke the UI for the card unmask prompt
-// with a valid credit card, which only shows the CCV Textfield.
-IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest, DISABLED_InvokeValid) {
- ShowUI(CreditCardExpiry::VALID);
- ::test::RunTestInteractively();
-}
+TEST_BROWSER_DIALOG(CardUnmaskPromptViewBrowserTest);
IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest, DisplayUI) {
- ShowUI(CreditCardExpiry::EXPIRED);
+ ShowDialog(CARD_EXPIRY_EXPIRED);
}
// TODO(bondd): bring up on Mac.
@@ -151,7 +147,7 @@ IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest, DisplayUI) {
// message is showing.
IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest,
EarlyCloseAfterSuccess) {
- ShowUI(CreditCardExpiry::EXPIRED);
+ ShowDialog(CARD_EXPIRY_EXPIRED);
controller()->OnUnmaskResponse(base::ASCIIToUTF16("123"),
base::ASCIIToUTF16("10"),
base::ASCIIToUTF16("19"), false);
@@ -173,7 +169,7 @@ IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest,
// https://crbug.com/484376
IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest,
CloseTabWhileDialogShowing) {
- ShowUI(CreditCardExpiry::EXPIRED);
+ ShowDialog(CARD_EXPIRY_EXPIRED);
// Simulate AutofillManager (the delegate in production code) being destroyed
// before CardUnmaskPromptViewBridge::OnConstrainedWindowClosed() is called.
FreeDelegate();

Powered by Google App Engine
This is Rietveld 408576698