| 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 #import "ui/base/cocoa/tracking_area.h" |
| 7 #import "chrome/browser/ui/cocoa/tracking_area.h" | 7 #import "ui/base/test/ui_cocoa_test_helper.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 { |
| 11 @private | 11 @private |
| 12 NSUInteger messageCount_; | 12 NSUInteger messageCount_; |
| 13 } | 13 } |
| 14 @property(nonatomic, assign) NSUInteger messageCount; | 14 @property(nonatomic, assign) NSUInteger messageCount; |
| 15 - (void)performMessage; | 15 - (void)performMessage; |
| 16 @end | 16 @end |
| 17 | 17 |
| 18 @implementation TestTrackingAreaOwner | 18 @implementation TestTrackingAreaOwner |
| 19 @synthesize messageCount = messageCount_; | 19 @synthesize messageCount = messageCount_; |
| 20 - (void)performMessage { | 20 - (void)performMessage { |
| 21 ++messageCount_; | 21 ++messageCount_; |
| 22 } | 22 } |
| 23 @end | 23 @end |
| 24 | 24 |
| 25 namespace ui { |
| 26 |
| 25 class CrTrackingAreaTest : public CocoaTest { | 27 class CrTrackingAreaTest : public CocoaTest { |
| 26 public: | 28 public: |
| 27 CrTrackingAreaTest() | 29 CrTrackingAreaTest() |
| 28 : owner_([[TestTrackingAreaOwner alloc] init]), | 30 : owner_([[TestTrackingAreaOwner alloc] init]), |
| 29 trackingArea_([[CrTrackingArea alloc] | 31 trackingArea_([[CrTrackingArea alloc] |
| 30 initWithRect:NSMakeRect(0, 0, 100, 100) | 32 initWithRect:NSMakeRect(0, 0, 100, 100) |
| 31 options:NSTrackingMouseMoved | NSTrackingActiveInKeyWindow | 33 options:NSTrackingMouseMoved | NSTrackingActiveInKeyWindow |
| 32 owner:owner_.get() | 34 owner:owner_.get() |
| 33 userInfo:nil]) { | 35 userInfo:nil]) { |
| 34 } | 36 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 [[scoper.get() owner] performMessage]; | 90 [[scoper.get() owner] performMessage]; |
| 89 EXPECT_EQ(1U, [owner_ messageCount]); | 91 EXPECT_EQ(1U, [owner_ messageCount]); |
| 90 | 92 |
| 91 [[scoper.get() owner] performMessage]; | 93 [[scoper.get() owner] performMessage]; |
| 92 EXPECT_EQ(2U, [owner_ messageCount]); | 94 EXPECT_EQ(2U, [owner_ messageCount]); |
| 93 } | 95 } |
| 94 | 96 |
| 95 [[trackingArea_ owner] performMessage]; | 97 [[trackingArea_ owner] performMessage]; |
| 96 EXPECT_EQ(2U, [owner_ messageCount]); | 98 EXPECT_EQ(2U, [owner_ messageCount]); |
| 97 } | 99 } |
| 100 |
| 101 } // namespace ui |
| OLD | NEW |