summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/test_event_utils.mm
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-07 22:20:14 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-07 22:20:14 +0000
commit35b1eb2a2e8bca7732421539e9094813fc7e77e2 (patch)
tree7145b80fb0892e45a5eb8737833f63cabad6a0b9 /chrome/browser/cocoa/test_event_utils.mm
parent9281f8359ca7e19cb067ca9e4995ff158252f44c (diff)
downloadchromium_src-35b1eb2a2e8bca7732421539e9094813fc7e77e2.zip
chromium_src-35b1eb2a2e8bca7732421539e9094813fc7e77e2.tar.gz
chromium_src-35b1eb2a2e8bca7732421539e9094813fc7e77e2.tar.bz2
[Mac] Don't change state from stop to reload when hovered.
Hold the reload button state change from stop to reload until the mouse exits. Also short-circuit the stop message when the real state should be reload. Also prevent multi-clicks from sending multiple actions. Toolbar.xib: reload button made kind of ReloadButton. BUG=47184 TEST=Browse to a slow page, mouse over stop button. Should not go to reload button when throbber (in tab) stops. TEST=After page loaded, click stop. Should not crash. TEST=Hover over reload button. Command-r should start a reload and change the button to stop button. Review URL: http://codereview.chromium.org/2847051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51787 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/test_event_utils.mm')
-rw-r--r--chrome/browser/cocoa/test_event_utils.mm24
1 files changed, 21 insertions, 3 deletions
diff --git a/chrome/browser/cocoa/test_event_utils.mm b/chrome/browser/cocoa/test_event_utils.mm
index 23b0535..8016111 100644
--- a/chrome/browser/cocoa/test_event_utils.mm
+++ b/chrome/browser/cocoa/test_event_utils.mm
@@ -49,20 +49,38 @@ NSEvent* MakeMouseEvent(NSEventType type, NSUInteger modifiers) {
return MouseEventAtPoint(NSMakePoint(0, 0), type, modifiers);
}
-NSEvent* LeftMouseDownAtPointInWindow(NSPoint point, NSWindow* window) {
- return [NSEvent mouseEventWithType:NSLeftMouseDown
+static NSEvent* MouseEventAtPointInWindow(NSPoint point,
+ NSEventType type,
+ NSWindow* window,
+ NSUInteger clickCount) {
+ return [NSEvent mouseEventWithType:type
location:point
modifierFlags:0
timestamp:0
windowNumber:[window windowNumber]
context:nil
eventNumber:0
- clickCount:1
+ clickCount:clickCount
pressure:1.0];
}
+NSEvent* LeftMouseDownAtPointInWindow(NSPoint point, NSWindow* window) {
+ return MouseEventAtPointInWindow(point, NSLeftMouseDown, window, 1);
+}
+
NSEvent* LeftMouseDownAtPoint(NSPoint point) {
return LeftMouseDownAtPointInWindow(point, nil);
}
+std::pair<NSEvent*,NSEvent*> MouseClickInView(NSView* view,
+ NSUInteger clickCount) {
+ const NSRect bounds = [view convertRect:[view bounds] toView:nil];
+ const NSPoint mid_point = NSMakePoint(NSMidX(bounds), NSMidY(bounds));
+ NSEvent* down = MouseEventAtPointInWindow(mid_point, NSLeftMouseDown,
+ [view window], clickCount);
+ NSEvent* up = MouseEventAtPointInWindow(mid_point, NSLeftMouseUp,
+ [view window], clickCount);
+ return std::make_pair(down, up);
+}
+
} // namespace test_event_utils