OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_nsobject.h" | 5 #include "base/memory/scoped_nsobject.h" |
6 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 6 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
7 #import "chrome/browser/ui/cocoa/tracking_area.h" | 7 #import "chrome/browser/ui/cocoa/tracking_area.h" |
8 | 8 |
9 // A test object that counts the number of times a message is sent to it. | 9 // A test object that counts the number of times a message is sent to it. |
10 @interface TestTrackingAreaOwner : NSObject { | 10 @interface TestTrackingAreaOwner : NSObject { |
(...skipping 11 matching lines...) Expand all Loading... |
22 } | 22 } |
23 @end | 23 @end |
24 | 24 |
25 class CrTrackingAreaTest : public CocoaTest { | 25 class CrTrackingAreaTest : public CocoaTest { |
26 public: | 26 public: |
27 CrTrackingAreaTest() | 27 CrTrackingAreaTest() |
28 : owner_([[TestTrackingAreaOwner alloc] init]), | 28 : owner_([[TestTrackingAreaOwner alloc] init]), |
29 trackingArea_([[CrTrackingArea alloc] | 29 trackingArea_([[CrTrackingArea alloc] |
30 initWithRect:NSMakeRect(0, 0, 100, 100) | 30 initWithRect:NSMakeRect(0, 0, 100, 100) |
31 options:NSTrackingMouseMoved | NSTrackingActiveInKeyWindow | 31 options:NSTrackingMouseMoved | NSTrackingActiveInKeyWindow |
32 proxiedOwner:owner_.get() | 32 owner:owner_.get() |
33 userInfo:nil]) { | 33 userInfo:nil]) { |
34 } | 34 } |
35 | 35 |
36 scoped_nsobject<TestTrackingAreaOwner> owner_; | 36 scoped_nsobject<TestTrackingAreaOwner> owner_; |
37 scoped_nsobject<CrTrackingArea> trackingArea_; | 37 scoped_nsobject<CrTrackingArea> trackingArea_; |
38 }; | 38 }; |
39 | 39 |
40 TEST_F(CrTrackingAreaTest, OwnerForwards) { | 40 TEST_F(CrTrackingAreaTest, OwnerForwards) { |
41 [[trackingArea_ owner] performMessage]; | 41 [[trackingArea_ owner] performMessage]; |
42 EXPECT_EQ(1U, [owner_ messageCount]); | 42 EXPECT_EQ(1U, [owner_ messageCount]); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 [[scoper.get() owner] performMessage]; | 88 [[scoper.get() owner] performMessage]; |
89 EXPECT_EQ(1U, [owner_ messageCount]); | 89 EXPECT_EQ(1U, [owner_ messageCount]); |
90 | 90 |
91 [[scoper.get() owner] performMessage]; | 91 [[scoper.get() owner] performMessage]; |
92 EXPECT_EQ(2U, [owner_ messageCount]); | 92 EXPECT_EQ(2U, [owner_ messageCount]); |
93 } | 93 } |
94 | 94 |
95 [[trackingArea_ owner] performMessage]; | 95 [[trackingArea_ owner] performMessage]; |
96 EXPECT_EQ(2U, [owner_ messageCount]); | 96 EXPECT_EQ(2U, [owner_ messageCount]); |
97 } | 97 } |
OLD | NEW |