OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/infobars/confirm_infobar_controller.h" | 5 #import "chrome/browser/ui/cocoa/infobars/confirm_infobar_controller.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 class ConfirmInfoBarControllerTest : public CocoaProfileTest, | 87 class ConfirmInfoBarControllerTest : public CocoaProfileTest, |
88 public MockConfirmInfoBarDelegate::Owner { | 88 public MockConfirmInfoBarDelegate::Owner { |
89 public: | 89 public: |
90 void SetUp() override { | 90 void SetUp() override { |
91 CocoaProfileTest::SetUp(); | 91 CocoaProfileTest::SetUp(); |
92 web_contents_.reset( | 92 web_contents_.reset( |
93 WebContents::Create(WebContents::CreateParams(profile()))); | 93 WebContents::Create(WebContents::CreateParams(profile()))); |
94 InfoBarService::CreateForWebContents(web_contents_.get()); | 94 InfoBarService::CreateForWebContents(web_contents_.get()); |
95 | 95 |
96 scoped_ptr<infobars::InfoBarDelegate> delegate( | 96 std::unique_ptr<infobars::InfoBarDelegate> delegate( |
97 new MockConfirmInfoBarDelegate(this)); | 97 new MockConfirmInfoBarDelegate(this)); |
98 infobar_ = new InfoBarCocoa(std::move(delegate)); | 98 infobar_ = new InfoBarCocoa(std::move(delegate)); |
99 infobar_->SetOwner(InfoBarService::FromWebContents(web_contents_.get())); | 99 infobar_->SetOwner(InfoBarService::FromWebContents(web_contents_.get())); |
100 | 100 |
101 controller_.reset([[TestConfirmInfoBarController alloc] | 101 controller_.reset([[TestConfirmInfoBarController alloc] |
102 initWithInfoBar:infobar_]); | 102 initWithInfoBar:infobar_]); |
103 infobar_->set_controller(controller_); | 103 infobar_->set_controller(controller_); |
104 | 104 |
105 container_.reset( | 105 container_.reset( |
106 [[InfoBarContainerTest alloc] initWithController:controller_]); | 106 [[InfoBarContainerTest alloc] initWithController:controller_]); |
(...skipping 26 matching lines...) Expand all Loading... |
133 | 133 |
134 private: | 134 private: |
135 void OnInfoBarDelegateClosed(MockConfirmInfoBarDelegate* delegate) override { | 135 void OnInfoBarDelegateClosed(MockConfirmInfoBarDelegate* delegate) override { |
136 closed_delegate_ok_clicked_ = delegate->ok_clicked(); | 136 closed_delegate_ok_clicked_ = delegate->ok_clicked(); |
137 closed_delegate_cancel_clicked_ = delegate->cancel_clicked(); | 137 closed_delegate_cancel_clicked_ = delegate->cancel_clicked(); |
138 closed_delegate_link_clicked_ = delegate->link_clicked(); | 138 closed_delegate_link_clicked_ = delegate->link_clicked(); |
139 delegate_closed_ = true; | 139 delegate_closed_ = true; |
140 controller_.reset(); | 140 controller_.reset(); |
141 } | 141 } |
142 | 142 |
143 scoped_ptr<WebContents> web_contents_; | 143 std::unique_ptr<WebContents> web_contents_; |
144 InfoBarCocoa* infobar_; // Weak, will delete itself. | 144 InfoBarCocoa* infobar_; // Weak, will delete itself. |
145 bool delegate_closed_; | 145 bool delegate_closed_; |
146 }; | 146 }; |
147 | 147 |
148 | 148 |
149 TEST_VIEW(ConfirmInfoBarControllerTest, [controller_ view]); | 149 TEST_VIEW(ConfirmInfoBarControllerTest, [controller_ view]); |
150 | 150 |
151 TEST_F(ConfirmInfoBarControllerTest, ShowAndDismiss) { | 151 TEST_F(ConfirmInfoBarControllerTest, ShowAndDismiss) { |
152 // Make sure someone looked at the message, link, and icon. | 152 // Make sure someone looked at the message, link, and icon. |
153 EXPECT_TRUE(delegate()->message_text_accessed()); | 153 EXPECT_TRUE(delegate()->message_text_accessed()); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 const CGFloat width = 20; | 240 const CGFloat width = 20; |
241 NSRect newViewFrame = [[controller_ view] frame]; | 241 NSRect newViewFrame = [[controller_ view] frame]; |
242 newViewFrame.size.width += width; | 242 newViewFrame.size.width += width; |
243 [[controller_ view] setFrame:newViewFrame]; | 243 [[controller_ view] setFrame:newViewFrame]; |
244 | 244 |
245 NSRect newLabelFrame = [controller_ labelFrame]; | 245 NSRect newLabelFrame = [controller_ labelFrame]; |
246 EXPECT_EQ(NSWidth(newLabelFrame), NSWidth(originalLabelFrame) + width); | 246 EXPECT_EQ(NSWidth(newLabelFrame), NSWidth(originalLabelFrame) + width); |
247 } | 247 } |
248 | 248 |
249 } // namespace | 249 } // namespace |
OLD | NEW |