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

Unified Diff: chrome/browser/cocoa/autocomplete_text_field_unittest.mm

Issue 264037: Refactor security-icon code to a more general form (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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_unittest.mm
===================================================================
--- chrome/browser/cocoa/autocomplete_text_field_unittest.mm (revision 29797)
+++ chrome/browser/cocoa/autocomplete_text_field_unittest.mm (working copy)
@@ -11,6 +11,7 @@
#import "chrome/browser/cocoa/autocomplete_text_field_editor.h"
#import "chrome/browser/cocoa/autocomplete_text_field_unittest_helper.h"
#import "chrome/browser/cocoa/cocoa_test_helper.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
#import "third_party/ocmock/OCMock/OCMock.h"
@@ -27,7 +28,15 @@
@end
namespace {
+// Mock a SecurityImageView.
+class MockSecurityImageView : public LocationBarViewMac::SecurityImageView {
+ public:
+ MockSecurityImageView(Profile* profile, ToolbarModel* model)
+ : LocationBarViewMac::SecurityImageView(profile, model) {}
+ MOCK_METHOD0(OnMousePressed, bool());
+};
+
// Mock up an incrementing event number.
NSUInteger eventNumber = 0;
@@ -568,13 +577,18 @@
TEST_F(AutocompleteTextFieldTest, SecurityIconMouseDown) {
AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell];
- scoped_nsobject<NSImage> hintIcon(
- [[NSImage alloc] initWithSize:NSMakeSize(20, 20)]);
- [cell setHintIcon:hintIcon.get() label:nil color:nil];
- NSRect iconFrame([cell hintImageFrameForFrame:[field_ bounds]]);
+
+ MockSecurityImageView security_image_view(NULL, NULL);
+ [cell setSecurityImageView:&security_image_view];
+ security_image_view.SetImageShown(
+ LocationBarViewMac::SecurityImageView::LOCK);
+ security_image_view.SetVisible(true);
+
+ NSRect iconFrame([cell securityImageFrameForFrame:[field_ bounds]]);
NSPoint location(NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame)));
NSEvent* event(Event(field_, location, NSLeftMouseDown, 1));
- EXPECT_CALL(field_observer_, OnSecurityIconClicked());
+
+ EXPECT_CALL(security_image_view, OnMousePressed());
[field_ mouseDown:event];
}

Powered by Google App Engine
This is Rietveld 408576698