OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
Evan Stade
2015/02/17 20:44:09
what makes this test file cocoa specific?
bondd
2015/02/17 23:45:11
Done. Renamed it to be platform independent. Updat
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/guid.h" | |
6 #include "base/message_loop/message_loop.h" | |
7 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller_impl.h" | |
8 #include "chrome/browser/ui/autofill/card_unmask_prompt_view_tester.h" | |
9 #include "chrome/browser/ui/browser.h" | |
10 #import "chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h" | |
Evan Stade
2015/02/17 20:44:09
is this used?
bondd
2015/02/17 23:45:11
Nope! Done. Probably left over from a previous pat
Evan Stade
2015/02/18 00:39:38
agreed
Evan Stade
2015/02/18 00:40:09
oops, meant to say "agreed" to the other comment (
| |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
12 #include "chrome/test/base/in_process_browser_test.h" | |
13 #include "components/autofill/core/browser/card_unmask_delegate.h" | |
14 #include "content/public/browser/web_contents.h" | |
15 #include "content/public/test/test_utils.h" | |
16 | |
17 namespace autofill { | |
18 | |
19 namespace { | |
20 | |
21 class TestCardUnmaskPromptController : public CardUnmaskPromptControllerImpl, | |
22 public CardUnmaskDelegate { | |
23 public: | |
24 TestCardUnmaskPromptController( | |
25 content::WebContents* contents, | |
26 scoped_refptr<content::MessageLoopRunner> runner) | |
27 : CardUnmaskPromptControllerImpl(contents), | |
28 runner_(runner), | |
29 weak_factory_(this) {} | |
30 | |
31 ~TestCardUnmaskPromptController() {} | |
32 | |
33 // CardUnmaskPromptController implementation. | |
34 void OnUnmaskDialogClosed() override { | |
35 CardUnmaskPromptControllerImpl::OnUnmaskDialogClosed(); | |
36 runner_->Quit(); | |
37 } | |
38 | |
39 // CardUnmaskDelegate implementation. | |
40 void OnUnmaskResponse(const base::string16& cvc, | |
41 const base::string16& exp_month, | |
42 const base::string16& exp_year) override {} | |
43 void OnUnmaskPromptClosed() override {} | |
44 | |
45 void RunMessageLoop() { runner_->Run(); } | |
46 | |
47 scoped_ptr<CardUnmaskPromptViewTester> GetViewTester() { | |
48 return CardUnmaskPromptViewTester::For(view()).Pass(); | |
49 } | |
50 | |
51 base::WeakPtr<TestCardUnmaskPromptController> GetWeakPtr() { | |
52 return weak_factory_.GetWeakPtr(); | |
53 } | |
54 | |
55 private: | |
56 scoped_refptr<content::MessageLoopRunner> runner_; | |
57 base::WeakPtrFactory<TestCardUnmaskPromptController> weak_factory_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(TestCardUnmaskPromptController); | |
60 }; | |
61 | |
62 class CardUnmaskPromptViewCocoaBrowserTest : public InProcessBrowserTest { | |
63 public: | |
64 CardUnmaskPromptViewCocoaBrowserTest() : InProcessBrowserTest() {} | |
65 | |
66 ~CardUnmaskPromptViewCocoaBrowserTest() override {} | |
67 | |
68 void SetUpOnMainThread() override { | |
69 runner_ = new content::MessageLoopRunner; | |
70 controller_ = new TestCardUnmaskPromptController( | |
71 browser()->tab_strip_model()->GetActiveWebContents(), runner_); | |
72 } | |
73 | |
74 TestCardUnmaskPromptController* controller() { return controller_; } | |
75 | |
76 private: | |
77 // This member must outlive the controller. | |
78 scoped_refptr<content::MessageLoopRunner> runner_; | |
79 | |
80 // The controller owns itself. | |
81 TestCardUnmaskPromptController* controller_; | |
82 | |
83 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViewCocoaBrowserTest); | |
84 }; | |
85 | |
86 IN_PROC_BROWSER_TEST_F(CardUnmaskPromptViewCocoaBrowserTest, DisplayUI) { | |
87 CreditCard credit_card(base::GenerateGUID(), "https://www.example.com/"); | |
88 | |
89 controller()->ShowPrompt(credit_card, controller()->GetWeakPtr()); | |
90 controller()->GetViewTester()->CancelForTesting(); | |
91 | |
92 controller()->RunMessageLoop(); | |
93 } | |
94 | |
95 } // namespace | |
96 | |
97 } // namespace autofill | |
OLD | NEW |