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

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

Issue 180036: Make download items drag sources on OS X. (Closed)
Patch Set: comments Created 10 years, 10 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
« no previous file with comments | « chrome/browser/cocoa/draggable_button.mm ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/scoped_nsobject.h"
6 #import "chrome/browser/cocoa/bookmark_button.h"
7 #import "chrome/browser/cocoa/cocoa_test_helper.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "testing/platform_test.h"
10
11 NSEvent* Event(const NSPoint point, const NSEventType type) {
12 static NSUInteger eventNumber = 0; // thx shess
13 return [NSEvent mouseEventWithType:type
14 location:point
15 modifierFlags:0
16 timestamp:0
17 windowNumber:183 // picked out of thin air.
18 context:nil
19 eventNumber:eventNumber++
20 clickCount:1
21 pressure:0.0];
22 }
23
24 // Make sure the basic case of "click" still works.
25 TEST(DraggableButtonTest, DownUp) {
26 scoped_nsobject<NSMutableArray> array;
27 array.reset([[NSMutableArray alloc] init]);
28 [array addObject:@"foo"];
29 [array addObject:@"bar"];
30
31 scoped_nsobject<DraggableButton> button;
32 button.reset([[DraggableButton alloc] initWithFrame:NSMakeRect(0,0,500,500)]);
33
34 [button setTarget:array.get()];
35 [button setAction:@selector(removeAllObjects)];
36 EXPECT_FALSE([[button cell] isHighlighted]);
37
38 NSEvent* downEvent(Event(NSMakePoint(10,10), NSLeftMouseDown));
39 NSEvent* upEvent(Event(NSMakePoint(10,10), NSLeftMouseDown));
40 [button mouseDown:downEvent];
41 EXPECT_TRUE([[button cell] isHighlighted]);
42 [button mouseUp:upEvent];
43 EXPECT_FALSE([[button cell] isHighlighted]);
44 EXPECT_FALSE([array count]); // confirms target/action fired
45 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/draggable_button.mm ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698