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

Side by Side Diff: chrome/browser/cocoa/infobar_controller_unittest.mm

Issue 1127001: Implement the confirm infobar with link for mac.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/cocoa/infobar_controller.mm ('k') | chrome/browser/cocoa/infobar_test_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/scoped_nsobject.h" 7 #include "base/scoped_nsobject.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #import "chrome/browser/cocoa/cocoa_test_helper.h" 10 #import "chrome/browser/cocoa/cocoa_test_helper.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // Check that clicking on the link calls LinkClicked() on the 173 // Check that clicking on the link calls LinkClicked() on the
174 // delegate. It should not close the infobar. 174 // delegate. It should not close the infobar.
175 [controller_ linkClicked]; 175 [controller_ linkClicked];
176 EXPECT_TRUE(delegate_.link_clicked); 176 EXPECT_TRUE(delegate_.link_clicked);
177 EXPECT_FALSE(delegate_.closed); 177 EXPECT_FALSE(delegate_.closed);
178 } 178 }
179 179
180 TEST_VIEW(ConfirmInfoBarControllerTest, [controller_ view]); 180 TEST_VIEW(ConfirmInfoBarControllerTest, [controller_ view]);
181 181
182 TEST_F(ConfirmInfoBarControllerTest, ShowAndDismiss) { 182 TEST_F(ConfirmInfoBarControllerTest, ShowAndDismiss) {
183 // Make sure someone looked at the message and icon. 183 // Make sure someone looked at the message, link, and icon.
184 EXPECT_TRUE(delegate_.message_text_accessed); 184 EXPECT_TRUE(delegate_.message_text_accessed);
185 EXPECT_TRUE(delegate_.link_text_accessed);
185 EXPECT_TRUE(delegate_.icon_accessed); 186 EXPECT_TRUE(delegate_.icon_accessed);
186 187
187 // Check to make sure the infobar message was set properly. 188 // Check to make sure the infobar message was set properly.
188 EXPECT_EQ(std::wstring(kMockConfirmInfoBarMessage), 189 EXPECT_EQ(std::wstring(kMockConfirmInfoBarMessage),
189 base::SysNSStringToWide([[controller_.get() label] stringValue])); 190 base::SysNSStringToWide([[controller_.get() label] stringValue]));
190 191
191 // Check that dismissing the infobar calls InfoBarClosed() on the delegate. 192 // Check that dismissing the infobar calls InfoBarClosed() on the delegate.
192 [controller_ dismiss:nil]; 193 [controller_ dismiss:nil];
193 EXPECT_FALSE(delegate_.ok_clicked); 194 EXPECT_FALSE(delegate_.ok_clicked);
194 EXPECT_FALSE(delegate_.cancel_clicked); 195 EXPECT_FALSE(delegate_.cancel_clicked);
196 EXPECT_FALSE(delegate_.link_clicked);
195 EXPECT_TRUE(delegate_.closed); 197 EXPECT_TRUE(delegate_.closed);
196 } 198 }
197 199
198 TEST_F(ConfirmInfoBarControllerTest, ShowAndClickOK) { 200 TEST_F(ConfirmInfoBarControllerTest, ShowAndClickOK) {
199 // Check that clicking the OK button calls Accept() and then closes 201 // Check that clicking the OK button calls Accept() and then closes
200 // the infobar. 202 // the infobar.
201 [controller_ ok:nil]; 203 [controller_ ok:nil];
202 EXPECT_TRUE(delegate_.ok_clicked); 204 EXPECT_TRUE(delegate_.ok_clicked);
203 EXPECT_FALSE(delegate_.cancel_clicked); 205 EXPECT_FALSE(delegate_.cancel_clicked);
206 EXPECT_FALSE(delegate_.link_clicked);
204 EXPECT_TRUE(delegate_.closed); 207 EXPECT_TRUE(delegate_.closed);
205 } 208 }
206 209
207 TEST_F(ConfirmInfoBarControllerTest, ShowAndClickOKWithoutClosing) { 210 TEST_F(ConfirmInfoBarControllerTest, ShowAndClickOKWithoutClosing) {
208 delegate_.closes_on_action = false; 211 delegate_.closes_on_action = false;
209 212
210 // Check that clicking the OK button calls Accept() but does not close 213 // Check that clicking the OK button calls Accept() but does not close
211 // the infobar. 214 // the infobar.
212 [controller_ ok:nil]; 215 [controller_ ok:nil];
213 EXPECT_TRUE(delegate_.ok_clicked); 216 EXPECT_TRUE(delegate_.ok_clicked);
214 EXPECT_FALSE(delegate_.cancel_clicked); 217 EXPECT_FALSE(delegate_.cancel_clicked);
218 EXPECT_FALSE(delegate_.link_clicked);
215 EXPECT_FALSE(delegate_.closed); 219 EXPECT_FALSE(delegate_.closed);
216 } 220 }
217 221
218 TEST_F(ConfirmInfoBarControllerTest, ShowAndClickCancel) { 222 TEST_F(ConfirmInfoBarControllerTest, ShowAndClickCancel) {
219 // Check that clicking the cancel button calls Cancel() and closes 223 // Check that clicking the cancel button calls Cancel() and closes
220 // the infobar. 224 // the infobar.
221 [controller_ cancel:nil]; 225 [controller_ cancel:nil];
222 EXPECT_FALSE(delegate_.ok_clicked); 226 EXPECT_FALSE(delegate_.ok_clicked);
223 EXPECT_TRUE(delegate_.cancel_clicked); 227 EXPECT_TRUE(delegate_.cancel_clicked);
228 EXPECT_FALSE(delegate_.link_clicked);
224 EXPECT_TRUE(delegate_.closed); 229 EXPECT_TRUE(delegate_.closed);
225 } 230 }
226 231
227 TEST_F(ConfirmInfoBarControllerTest, ShowAndClickCancelWithoutClosing) { 232 TEST_F(ConfirmInfoBarControllerTest, ShowAndClickCancelWithoutClosing) {
228 delegate_.closes_on_action = false; 233 delegate_.closes_on_action = false;
229 234
230 // Check that clicking the cancel button calls Cancel() but does not close 235 // Check that clicking the cancel button calls Cancel() but does not close
231 // the infobar. 236 // the infobar.
232 [controller_ cancel:nil]; 237 [controller_ cancel:nil];
233 EXPECT_FALSE(delegate_.ok_clicked); 238 EXPECT_FALSE(delegate_.ok_clicked);
234 EXPECT_TRUE(delegate_.cancel_clicked); 239 EXPECT_TRUE(delegate_.cancel_clicked);
240 EXPECT_FALSE(delegate_.link_clicked);
241 EXPECT_FALSE(delegate_.closed);
242 }
243
244 TEST_F(ConfirmInfoBarControllerTest, ShowAndClickLink) {
245 // Check that clicking on the link calls LinkClicked() on the
246 // delegate. It should also close the infobar.
247 [controller_ linkClicked];
248 EXPECT_FALSE(delegate_.ok_clicked);
249 EXPECT_FALSE(delegate_.cancel_clicked);
250 EXPECT_TRUE(delegate_.link_clicked);
251 EXPECT_TRUE(delegate_.closed);
252 }
253
254 TEST_F(ConfirmInfoBarControllerTest, ShowAndClickLinkWithoutClosing) {
255 delegate_.closes_on_action = false;
256
257 // Check that clicking on the link calls LinkClicked() on the
258 // delegate. It should not close the infobar.
259 [controller_ linkClicked];
260 EXPECT_FALSE(delegate_.ok_clicked);
261 EXPECT_FALSE(delegate_.cancel_clicked);
262 EXPECT_TRUE(delegate_.link_clicked);
235 EXPECT_FALSE(delegate_.closed); 263 EXPECT_FALSE(delegate_.closed);
236 } 264 }
237 265
238 } // namespace 266 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/infobar_controller.mm ('k') | chrome/browser/cocoa/infobar_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698