OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <Carbon/Carbon.h> // For the kVK_* constants. | 5 #include <Carbon/Carbon.h> // For the kVK_* constants. |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/ui/autofill/save_card_bubble_controller.h" | |
12 #import "chrome/browser/ui/cocoa/autofill/save_card_bubble_view_bridge.h" | 11 #import "chrome/browser/ui/cocoa/autofill/save_card_bubble_view_bridge.h" |
13 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
14 #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" | 13 #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" |
15 #include "components/autofill/core/browser/credit_card.h" | 14 #include "components/autofill/core/browser/credit_card.h" |
| 15 #include "components/autofill/core/browser/ui/save_card_bubble_controller.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #import "ui/events/test/cocoa_test_event_utils.h" | 17 #import "ui/events/test/cocoa_test_event_utils.h" |
18 | 18 |
19 namespace autofill { | 19 namespace autofill { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 class TestSaveCardBubbleController : public SaveCardBubbleController { | 23 class TestSaveCardBubbleController : public SaveCardBubbleController { |
24 public: | 24 public: |
25 TestSaveCardBubbleController() { | 25 TestSaveCardBubbleController() { |
(...skipping 10 matching lines...) Expand all Loading... |
36 base::string16 GetWindowTitle() const override { return base::string16(); } | 36 base::string16 GetWindowTitle() const override { return base::string16(); } |
37 | 37 |
38 base::string16 GetExplanatoryMessage() const override { | 38 base::string16 GetExplanatoryMessage() const override { |
39 return base::string16(); | 39 return base::string16(); |
40 } | 40 } |
41 | 41 |
42 const CreditCard GetCard() const override { | 42 const CreditCard GetCard() const override { |
43 return CreditCard(); | 43 return CreditCard(); |
44 } | 44 } |
45 | 45 |
| 46 int GetCvcImageResourceId() const override { return int(); } |
| 47 |
| 48 bool ShouldRequestCvcFromUser() const override { return bool(); } |
| 49 |
| 50 void SetCvcEnteredByUser(const base::string16& cvc) override {} |
| 51 |
| 52 base::string16 GetCvcEnteredByUser() const override { |
| 53 return base::string16(); |
| 54 } |
| 55 |
46 void OnSaveButton() override { on_save_button_was_called_ = true; } | 56 void OnSaveButton() override { on_save_button_was_called_ = true; } |
47 void OnCancelButton() override { on_cancel_button_was_called_ = true; } | 57 void OnCancelButton() override { on_cancel_button_was_called_ = true; } |
48 void OnLearnMoreClicked() override { on_learn_more_was_called_ = true; } | 58 void OnLearnMoreClicked() override { on_learn_more_was_called_ = true; } |
49 void OnLegalMessageLinkClicked(const GURL& url) override { | 59 void OnLegalMessageLinkClicked(const GURL& url) override { |
50 on_legal_message_was_called_ = true; | 60 on_legal_message_was_called_ = true; |
51 legal_message_url_ = url.spec(); | 61 legal_message_url_ = url.spec(); |
52 } | 62 } |
53 void OnBubbleClosed() override { on_bubble_closed_was_called_ = true; } | 63 void OnBubbleClosed() override { on_bubble_closed_was_called_ = true; } |
54 | 64 |
55 const LegalMessageLines& GetLegalMessageLines() const override { | 65 const LegalMessageLines& GetLegalMessageLines() const override { |
56 return lines_; | 66 return lines_; |
57 } | 67 } |
58 | 68 |
| 69 bool InputCvcIsValid(const base::string16& input_text) const override { |
| 70 return bool(); |
| 71 } |
| 72 |
59 // Testing state. | 73 // Testing state. |
60 bool on_save_button_was_called() { return on_save_button_was_called_; } | 74 bool on_save_button_was_called() { return on_save_button_was_called_; } |
61 bool on_cancel_button_was_called() { return on_cancel_button_was_called_; } | 75 bool on_cancel_button_was_called() { return on_cancel_button_was_called_; } |
62 bool on_learn_more_was_called() { return on_learn_more_was_called_; } | 76 bool on_learn_more_was_called() { return on_learn_more_was_called_; } |
63 bool on_legal_message_was_called() { return on_legal_message_was_called_; } | 77 bool on_legal_message_was_called() { return on_legal_message_was_called_; } |
64 std::string legal_message_url() { return legal_message_url_; } | 78 std::string legal_message_url() { return legal_message_url_; } |
65 bool on_bubble_closed_was_called() { return on_bubble_closed_was_called_; } | 79 bool on_bubble_closed_was_called() { return on_bubble_closed_was_called_; } |
66 | 80 |
67 private: | 81 private: |
68 void ParseLegalMessageJson() { | 82 void ParseLegalMessageJson() { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 222 |
209 TEST_F(SaveCardBubbleViewTest, EscapeCloses) { | 223 TEST_F(SaveCardBubbleViewTest, EscapeCloses) { |
210 [[bridge_->view_controller_ window] | 224 [[bridge_->view_controller_ window] |
211 performKeyEquivalent:cocoa_test_event_utils::KeyEventWithKeyCode( | 225 performKeyEquivalent:cocoa_test_event_utils::KeyEventWithKeyCode( |
212 kVK_Escape, '\e', NSKeyDown, 0)]; | 226 kVK_Escape, '\e', NSKeyDown, 0)]; |
213 | 227 |
214 EXPECT_TRUE(bubble_controller_->on_bubble_closed_was_called()); | 228 EXPECT_TRUE(bubble_controller_->on_bubble_closed_was_called()); |
215 } | 229 } |
216 | 230 |
217 } // namespace autofill | 231 } // namespace autofill |
OLD | NEW |