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

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

Issue 179043: (Mac) Added unit tests for ClickHoldButtonCell and DelayedMenuButton. (Closed)
Patch Set: Read gtest docs; using constructors instead of SetUp() is okay. Created 11 years, 4 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/clickhold_button_cell.mm
diff --git a/chrome/browser/cocoa/clickhold_button_cell.mm b/chrome/browser/cocoa/clickhold_button_cell.mm
index ce39d2a3cbb38651b04b1c46c2b73c308d9b4a20..67b3df6c6605bfd3ad373635e23b86f4ce59711a 100644
--- a/chrome/browser/cocoa/clickhold_button_cell.mm
+++ b/chrome/browser/cocoa/clickhold_button_cell.mm
@@ -13,6 +13,12 @@ static const NSTimeInterval kMaxTimeout = 3600.0;
// Drag distance threshold to activate click-hold; should be >= 0.
static const CGFloat kDragDistThreshold = 2.5;
+// See |-resetToDefaults| (and header file) for other default values.
+
+@interface ClickHoldButtonCell (Private)
+- (void)resetToDefaults;
+@end // @interface ClickHoldButtonCell (Private)
+
@implementation ClickHoldButtonCell
// Overrides:
@@ -21,22 +27,44 @@ static const CGFloat kDragDistThreshold = 2.5;
return NO;
}
+- (id)init {
+ if ((self = [super init]))
+ [self resetToDefaults];
+ return self;
+}
+
+- (id)initWithCoder:(NSCoder*)decoder {
+ if ((self = [super initWithCoder:decoder]))
+ [self resetToDefaults];
+ return self;
+}
+
+- (id)initImageCell:(NSImage*)image {
+ if ((self = [super initImageCell:image]))
+ [self resetToDefaults];
+ return self;
+}
+
+- (id)initTextCell:(NSString*)string {
+ if ((self = [super initTextCell:string]))
+ [self resetToDefaults];
+ return self;
+}
+
- (BOOL)startTrackingAt:(NSPoint)startPoint
inView:(NSView*)controlView {
- return enableClickHold_ ?
- YES :
- [super startTrackingAt:startPoint
- inView:controlView];
+ return enableClickHold_ ? YES :
+ [super startTrackingAt:startPoint
+ inView:controlView];
}
- (BOOL)continueTracking:(NSPoint)lastPoint
at:(NSPoint)currentPoint
inView:(NSView*)controlView {
- return enableClickHold_ ?
- YES :
- [super continueTracking:lastPoint
- at:currentPoint
- inView:controlView];
+ return enableClickHold_ ? YES :
+ [super continueTracking:lastPoint
+ at:currentPoint
+ inView:controlView];
}
- (BOOL)trackMouse:(NSEvent*)originalEvent
@@ -145,3 +173,18 @@ static const CGFloat kDragDistThreshold = 2.5;
@synthesize clickHoldAction = clickHoldAction_;
@end // @implementation ClickHoldButtonCell
+
+@implementation ClickHoldButtonCell (Private)
+
+// Resets various members to defaults indicated in the header file. (Those
+// without indicated defaults are *not* touched.) Please keep the values below
+// in sync with the header file, and please be aware of side-effects on code
+// which relies on the "published" defaults.
+- (void)resetToDefaults {
+ [self setEnableClickHold:NO];
+ [self setClickHoldTimeout:0.25];
+ [self setTrackOnlyInRect:NO];
+ [self setActivateOnDrag:YES];
+}
+
+@end // @implementation ClickHoldButtonCell (Private)
« no previous file with comments | « chrome/browser/cocoa/clickhold_button_cell.h ('k') | chrome/browser/cocoa/clickhold_button_cell_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698