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

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

Powered by Google App Engine
This is Rietveld 408576698