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

Side by Side Diff: chrome/browser/ui/cocoa/autofill/save_card_bubble_view_unittest.mm

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
OLDNEW
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.
6
7 #include <memory>
8
5 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "base/values.h" 10 #include "base/values.h"
8 #include "chrome/browser/ui/autofill/save_card_bubble_controller.h" 11 #include "chrome/browser/ui/autofill/save_card_bubble_controller.h"
9 #import "chrome/browser/ui/cocoa/autofill/save_card_bubble_view_bridge.h" 12 #import "chrome/browser/ui/cocoa/autofill/save_card_bubble_view_bridge.h"
10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 13 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
11 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 14 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
12 #include "components/autofill/core/browser/credit_card.h" 15 #include "components/autofill/core/browser/credit_card.h"
13 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
14 #import "ui/events/test/cocoa_test_event_utils.h" 17 #import "ui/events/test/cocoa_test_event_utils.h"
15 18
16 #include <Carbon/Carbon.h> // For the kVK_* constants.
17
18 namespace autofill { 19 namespace autofill {
19 20
20 namespace { 21 namespace {
21 22
22 class TestSaveCardBubbleController : public SaveCardBubbleController { 23 class TestSaveCardBubbleController : public SaveCardBubbleController {
23 public: 24 public:
24 TestSaveCardBubbleController() { 25 TestSaveCardBubbleController() {
25 ParseLegalMessageJson(); 26 ParseLegalMessageJson();
26 27
27 on_save_button_was_called_ = false; 28 on_save_button_was_called_ = false;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 " \"url\": \"http://www.example.com/our_mission\"" 86 " \"url\": \"http://www.example.com/our_mission\""
86 " }," 87 " },"
87 " {" 88 " {"
88 " \"display_text\": \"privacy policy\"," 89 " \"display_text\": \"privacy policy\","
89 " \"url\": \"http://help.example.com/privacy_policy\"" 90 " \"url\": \"http://help.example.com/privacy_policy\""
90 " }" 91 " }"
91 " ]" 92 " ]"
92 " }" 93 " }"
93 " ]" 94 " ]"
94 "}"; 95 "}";
95 scoped_ptr<base::Value> value(base::JSONReader::Read(message_json)); 96 std::unique_ptr<base::Value> value(base::JSONReader::Read(message_json));
96 ASSERT_TRUE(value); 97 ASSERT_TRUE(value);
97 base::DictionaryValue* dictionary = nullptr; 98 base::DictionaryValue* dictionary = nullptr;
98 ASSERT_TRUE(value->GetAsDictionary(&dictionary)); 99 ASSERT_TRUE(value->GetAsDictionary(&dictionary));
99 LegalMessageLine::Parse(*dictionary, &lines_); 100 LegalMessageLine::Parse(*dictionary, &lines_);
100 } 101 }
101 102
102 LegalMessageLines lines_; 103 LegalMessageLines lines_;
103 104
104 bool on_save_button_was_called_; 105 bool on_save_button_was_called_;
105 bool on_cancel_button_was_called_; 106 bool on_cancel_button_was_called_;
(...skipping 20 matching lines...) Expand all
126 browser_window_controller_); 127 browser_window_controller_);
127 } 128 }
128 129
129 void TearDown() override { 130 void TearDown() override {
130 [browser_window_controller_ close]; 131 [browser_window_controller_ close];
131 CocoaProfileTest::TearDown(); 132 CocoaProfileTest::TearDown();
132 } 133 }
133 134
134 protected: 135 protected:
135 BrowserWindowController* browser_window_controller_; 136 BrowserWindowController* browser_window_controller_;
136 scoped_ptr<TestSaveCardBubbleController> bubble_controller_; 137 std::unique_ptr<TestSaveCardBubbleController> bubble_controller_;
137 SaveCardBubbleViewBridge* bridge_; 138 SaveCardBubbleViewBridge* bridge_;
138 }; 139 };
139 140
140 } // namespace 141 } // namespace
141 142
142 TEST_F(SaveCardBubbleViewTest, SaveShouldClose) { 143 TEST_F(SaveCardBubbleViewTest, SaveShouldClose) {
143 [bridge_->view_controller_ onSaveButton:nil]; 144 [bridge_->view_controller_ onSaveButton:nil];
144 145
145 EXPECT_TRUE(bubble_controller_->on_save_button_was_called()); 146 EXPECT_TRUE(bubble_controller_->on_save_button_was_called());
146 EXPECT_FALSE(bubble_controller_->on_cancel_button_was_called()); 147 EXPECT_FALSE(bubble_controller_->on_cancel_button_was_called());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 208
208 TEST_F(SaveCardBubbleViewTest, EscapeCloses) { 209 TEST_F(SaveCardBubbleViewTest, EscapeCloses) {
209 [[bridge_->view_controller_ window] 210 [[bridge_->view_controller_ window]
210 performKeyEquivalent:cocoa_test_event_utils::KeyEventWithKeyCode( 211 performKeyEquivalent:cocoa_test_event_utils::KeyEventWithKeyCode(
211 kVK_Escape, '\e', NSKeyDown, 0)]; 212 kVK_Escape, '\e', NSKeyDown, 0)];
212 213
213 EXPECT_TRUE(bubble_controller_->on_bubble_closed_was_called()); 214 EXPECT_TRUE(bubble_controller_->on_bubble_closed_was_called());
214 } 215 }
215 216
216 } // namespace autofill 217 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698