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

Side by Side Diff: chrome/browser/ui/autofill/card_unmask_prompt_view_browsertest.cc

Issue 2382963002: Views: Add two disabled tests for invoking the CC unmask prompt dialog. (Closed)
Patch Set: Rebase Created 4 years, 2 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 | « no previous file | chrome/test/BUILD.gn » ('j') | chrome/test/base/move_test_process_to_front_mac.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h"
6 #include "base/guid.h" 7 #include "base/guid.h"
7 #include "base/location.h" 8 #include "base/location.h"
8 #include "base/macros.h" 9 #include "base/macros.h"
9 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
10 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
11 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
12 #include "build/build_config.h" 13 #include "build/build_config.h"
13 #include "chrome/browser/ui/autofill/card_unmask_prompt_view_tester.h" 14 #include "chrome/browser/ui/autofill/card_unmask_prompt_view_tester.h"
14 #include "chrome/browser/ui/autofill/create_card_unmask_prompt_view.h" 15 #include "chrome/browser/ui/autofill/create_card_unmask_prompt_view.h"
15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/use_interactive_test_case.h"
18 #include "components/autofill/core/browser/autofill_test_utils.h" 20 #include "components/autofill/core/browser/autofill_test_utils.h"
19 #include "components/autofill/core/browser/card_unmask_delegate.h" 21 #include "components/autofill/core/browser/card_unmask_delegate.h"
20 #include "components/autofill/core/browser/ui/card_unmask_prompt_controller_impl .h" 22 #include "components/autofill/core/browser/ui/card_unmask_prompt_controller_impl .h"
21 #include "components/user_prefs/user_prefs.h" 23 #include "components/user_prefs/user_prefs.h"
22 #include "content/public/browser/browser_context.h" 24 #include "content/public/browser/browser_context.h"
23 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
24 #include "content/public/test/test_utils.h" 26 #include "content/public/test/test_utils.h"
25 27
26 namespace autofill { 28 namespace autofill {
27 29
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 90
89 ~CardUnmaskPromptViewBrowserTest() override {} 91 ~CardUnmaskPromptViewBrowserTest() override {}
90 92
91 void SetUpOnMainThread() override { 93 void SetUpOnMainThread() override {
92 runner_ = new content::MessageLoopRunner; 94 runner_ = new content::MessageLoopRunner;
93 contents_ = browser()->tab_strip_model()->GetActiveWebContents(); 95 contents_ = browser()->tab_strip_model()->GetActiveWebContents();
94 controller_.reset(new TestCardUnmaskPromptController(contents_, runner_)); 96 controller_.reset(new TestCardUnmaskPromptController(contents_, runner_));
95 delegate_.reset(new TestCardUnmaskDelegate()); 97 delegate_.reset(new TestCardUnmaskDelegate());
96 } 98 }
97 99
100 void ShowUI(bool expired) {
101 CardUnmaskPromptView* dialog =
102 CreateCardUnmaskPromptView(controller(), contents());
103 CreditCard cc;
tapted 2016/10/16 23:48:01 nit: CreditCard cc = expired ? test::GetMaske
Patti Lor 2016/10/17 23:26:09 Done.
104 if (expired)
105 cc = test::GetMaskedServerCard();
106 else
107 cc = test::GetMaskedServerCardAmex();
108 controller()->ShowPrompt(dialog, cc, AutofillClient::UNMASK_FOR_AUTOFILL,
109 delegate()->GetWeakPtr());
110 }
111
98 void FreeDelegate() { delegate_.reset(); } 112 void FreeDelegate() { delegate_.reset(); }
99 113
100 content::WebContents* contents() { return contents_; } 114 content::WebContents* contents() { return contents_; }
101 TestCardUnmaskPromptController* controller() { return controller_.get(); } 115 TestCardUnmaskPromptController* controller() { return controller_.get(); }
102 TestCardUnmaskDelegate* delegate() { return delegate_.get(); } 116 TestCardUnmaskDelegate* delegate() { return delegate_.get(); }
103 117
104 protected: 118 protected:
105 // This member must outlive the controller. 119 // This member must outlive the controller.
106 scoped_refptr<content::MessageLoopRunner> runner_; 120 scoped_refptr<content::MessageLoopRunner> runner_;
107 121
108 private: 122 private:
109 content::WebContents* contents_; 123 content::WebContents* contents_;
110 std::unique_ptr<TestCardUnmaskPromptController> controller_; 124 std::unique_ptr<TestCardUnmaskPromptController> controller_;
111 std::unique_ptr<TestCardUnmaskDelegate> delegate_; 125 std::unique_ptr<TestCardUnmaskDelegate> delegate_;
112 126
113 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViewBrowserTest); 127 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViewBrowserTest);
114 }; 128 };
115 129
130 IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest,
tapted 2016/10/16 23:48:01 nit: these need a comment
Patti Lor 2016/10/17 23:26:09 Done.
131 DISABLED_InvokeExpired) {
132 ShowUI(true);
133 RunTestInteractively();
134 }
135
136 IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest, DISABLED_InvokeValid) {
137 ShowUI(false);
138 RunTestInteractively();
139 }
140
116 IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest, DisplayUI) { 141 IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest, DisplayUI) {
117 controller()->ShowPrompt(CreateCardUnmaskPromptView(controller(), contents()), 142 ShowUI(true);
118 test::GetMaskedServerCard(),
119 AutofillClient::UNMASK_FOR_AUTOFILL,
120 delegate()->GetWeakPtr());
121 } 143 }
122 144
123 // TODO(bondd): bring up on Mac. 145 // TODO(bondd): bring up on Mac.
tapted 2016/10/16 23:48:01 hrmh - we need to do something about this. I don't
Patti Lor 2016/10/17 23:26:08 I don't think there's any ongoing work - the most
124 #if !defined(OS_MACOSX) 146 #if !defined(OS_MACOSX)
125 // Makes sure the user can close the dialog while the verification success 147 // Makes sure the user can close the dialog while the verification success
126 // message is showing. 148 // message is showing.
127 IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest, 149 IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest,
128 EarlyCloseAfterSuccess) { 150 EarlyCloseAfterSuccess) {
129 controller()->ShowPrompt(CreateCardUnmaskPromptView(controller(), contents()), 151 ShowUI(true);
130 test::GetMaskedServerCard(),
131 AutofillClient::UNMASK_FOR_AUTOFILL,
132 delegate()->GetWeakPtr());
133 controller()->OnUnmaskResponse(base::ASCIIToUTF16("123"), 152 controller()->OnUnmaskResponse(base::ASCIIToUTF16("123"),
134 base::ASCIIToUTF16("10"), 153 base::ASCIIToUTF16("10"),
135 base::ASCIIToUTF16("19"), false); 154 base::ASCIIToUTF16("19"), false);
136 EXPECT_EQ(base::ASCIIToUTF16("123"), delegate()->response().cvc); 155 EXPECT_EQ(base::ASCIIToUTF16("123"), delegate()->response().cvc);
137 controller()->OnVerificationResult(AutofillClient::SUCCESS); 156 controller()->OnVerificationResult(AutofillClient::SUCCESS);
138 157
139 // Simulate the user clicking [x] before the "Success!" message disappears. 158 // Simulate the user clicking [x] before the "Success!" message disappears.
140 CardUnmaskPromptViewTester::For(controller()->view())->Close(); 159 CardUnmaskPromptViewTester::For(controller()->view())->Close();
141 // Wait a little while; there should be no crash. 160 // Wait a little while; there should be no crash.
142 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 161 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
143 FROM_HERE, base::Bind(&content::MessageLoopRunner::Quit, 162 FROM_HERE, base::Bind(&content::MessageLoopRunner::Quit,
144 base::Unretained(runner_.get())), 163 base::Unretained(runner_.get())),
145 2 * controller()->GetSuccessMessageDuration()); 164 2 * controller()->GetSuccessMessageDuration());
146 runner_->Run(); 165 runner_->Run();
147 } 166 }
148 #endif 167 #endif
149 168
150 // Makes sure the tab can be closed while the dialog is showing. 169 // Makes sure the tab can be closed while the dialog is showing.
151 // https://crbug.com/484376 170 // https://crbug.com/484376
152 IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest, 171 IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewBrowserTest,
153 CloseTabWhileDialogShowing) { 172 CloseTabWhileDialogShowing) {
154 controller()->ShowPrompt(CreateCardUnmaskPromptView(controller(), contents()), 173 ShowUI(true);
155 test::GetMaskedServerCard(),
156 AutofillClient::UNMASK_FOR_AUTOFILL,
157 delegate()->GetWeakPtr());
158 // Simulate AutofillManager (the delegate in production code) being destroyed 174 // Simulate AutofillManager (the delegate in production code) being destroyed
159 // before CardUnmaskPromptViewBridge::OnConstrainedWindowClosed() is called. 175 // before CardUnmaskPromptViewBridge::OnConstrainedWindowClosed() is called.
160 FreeDelegate(); 176 FreeDelegate();
161 browser()->tab_strip_model()->GetActiveWebContents()->Close(); 177 browser()->tab_strip_model()->GetActiveWebContents()->Close();
162 178
163 content::RunAllPendingInMessageLoop(); 179 content::RunAllPendingInMessageLoop();
164 } 180 }
165 181
166 } // namespace 182 } // namespace
167 183
168 } // namespace autofill 184 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/test/BUILD.gn » ('j') | chrome/test/base/move_test_process_to_front_mac.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698