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

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

Issue 222020: [Mac] Show the page info window after clicking the security icon in the URL bar (Closed)
Patch Set: Unit tests Created 11 years, 2 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 (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 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h" 8 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h"
9 #import "chrome/browser/cocoa/cocoa_test_helper.h" 9 #import "chrome/browser/cocoa/cocoa_test_helper.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect)); 348 EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect));
349 EXPECT_TRUE(NSEqualRects(drawingRect, originalDrawingRect)); 349 EXPECT_TRUE(NSEqualRects(drawingRect, originalDrawingRect));
350 350
351 [cell setHintIcon:[NSImage imageNamed:@"NSComputer"]]; 351 [cell setHintIcon:[NSImage imageNamed:@"NSComputer"]];
352 textFrame = [cell textFrameForFrame:bounds]; 352 textFrame = [cell textFrameForFrame:bounds];
353 drawingRect = [cell drawingRectForBounds:bounds]; 353 drawingRect = [cell drawingRectForBounds:bounds];
354 EXPECT_FALSE(NSIsEmptyRect(drawingRect)); 354 EXPECT_FALSE(NSIsEmptyRect(drawingRect));
355 EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect)); 355 EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect));
356 } 356 }
357 357
358 // Test that the security icon is at the right side of the cell.
359 TEST_F(AutocompleteTextFieldCellTest, HintImageFrame) {
360 AutocompleteTextFieldCell* cell =
361 static_cast<AutocompleteTextFieldCell*>([view_ cell]);
362 const NSRect bounds([view_ bounds]);
363 scoped_nsobject<NSImage> hintIcon(
364 [[NSImage alloc] initWithSize:NSMakeSize(20, 20)]);
365
366 NSRect iconRect = [cell hintImageFrameForFrame:bounds];
367 EXPECT_TRUE(NSIsEmptyRect(iconRect));
368
369 // Save the starting frame for after clear.
370 const NSRect originalIconRect(iconRect);
371
372 [cell setHintIcon:hintIcon];
373 iconRect = [cell hintImageFrameForFrame:bounds];
374 EXPECT_FALSE(NSIsEmptyRect(iconRect));
375 EXPECT_TRUE(NSContainsRect(bounds, iconRect));
376
377 // Make sure we are right of the |drawingRect|.
378 NSRect drawingRect = [cell drawingRectForBounds:bounds];
379 EXPECT_LE(NSMaxX(drawingRect), NSMinX(iconRect));
380
381 // Make sure we're right of the |textFrame|.
382 NSRect textFrame = [cell textFrameForFrame:bounds];
383 EXPECT_LE(NSMaxX(textFrame), NSMinX(iconRect));
384
385 // Make sure we clear correctly.
386 [cell setHintIcon:nil];
387 iconRect = [cell hintImageFrameForFrame:bounds];
388 EXPECT_TRUE(NSEqualRects(iconRect, originalIconRect));
389 EXPECT_TRUE(NSIsEmptyRect(iconRect));
390 }
391
358 } // namespace 392 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698