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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm
diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm b/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm
index 076789f442d409741ae5c084b4c83958f23e0572..ef8d415674f3b0f5ce234b54df07e1f06f07e004 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm
@@ -355,4 +355,38 @@ TEST_F(AutocompleteTextFieldCellTest, DrawingRectForBounds) {
EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect));
}
+// Test that the security icon is at the right side of the cell.
+TEST_F(AutocompleteTextFieldCellTest, HintImageFrame) {
+ AutocompleteTextFieldCell* cell =
+ static_cast<AutocompleteTextFieldCell*>([view_ cell]);
+ const NSRect bounds([view_ bounds]);
+ scoped_nsobject<NSImage> hintIcon(
+ [[NSImage alloc] initWithSize:NSMakeSize(20, 20)]);
+
+ NSRect iconRect = [cell hintImageFrameForFrame:bounds];
+ EXPECT_TRUE(NSIsEmptyRect(iconRect));
+
+ // Save the starting frame for after clear.
+ const NSRect originalIconRect(iconRect);
+
+ [cell setHintIcon:hintIcon];
+ iconRect = [cell hintImageFrameForFrame:bounds];
+ EXPECT_FALSE(NSIsEmptyRect(iconRect));
+ EXPECT_TRUE(NSContainsRect(bounds, iconRect));
+
+ // Make sure we are right of the |drawingRect|.
+ NSRect drawingRect = [cell drawingRectForBounds:bounds];
+ EXPECT_LE(NSMaxX(drawingRect), NSMinX(iconRect));
+
+ // Make sure we're right of the |textFrame|.
+ NSRect textFrame = [cell textFrameForFrame:bounds];
+ EXPECT_LE(NSMaxX(textFrame), NSMinX(iconRect));
+
+ // Make sure we clear correctly.
+ [cell setHintIcon:nil];
+ iconRect = [cell hintImageFrameForFrame:bounds];
+ EXPECT_TRUE(NSEqualRects(iconRect, originalIconRect));
+ EXPECT_TRUE(NSIsEmptyRect(iconRect));
+}
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698