| 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/scoped_nsobject.h" | 5 #include "base/scoped_nsobject.h" |
| 6 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 6 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 7 #include "chrome/browser/ui/cocoa/objc_zombie.h" | 7 #include "chrome/browser/ui/cocoa/objc_zombie.h" |
| 8 #import "chrome/browser/ui/cocoa/tracking_area.h" | 8 #import "chrome/browser/ui/cocoa/tracking_area.h" |
| 9 | 9 |
| 10 // A test object that counts the number of times a message is sent to it. | 10 // A test object that counts the number of times a message is sent to it. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 @end | 24 @end |
| 25 | 25 |
| 26 class CrTrackingAreaTest : public CocoaTest { | 26 class CrTrackingAreaTest : public CocoaTest { |
| 27 public: | 27 public: |
| 28 CrTrackingAreaTest() | 28 CrTrackingAreaTest() |
| 29 : owner_([[TestTrackingAreaOwner alloc] init]), | 29 : owner_([[TestTrackingAreaOwner alloc] init]), |
| 30 trackingArea_([[CrTrackingArea alloc] | 30 trackingArea_([[CrTrackingArea alloc] |
| 31 initWithRect:NSMakeRect(0, 0, 100, 100) | 31 initWithRect:NSMakeRect(0, 0, 100, 100) |
| 32 options:NSTrackingMouseMoved | NSTrackingActiveInKeyWindow | 32 options:NSTrackingMouseMoved | NSTrackingActiveInKeyWindow |
| 33 owner:owner_.get() | 33 proxiedOwner:owner_.get() |
| 34 userInfo:nil]) { | 34 userInfo:nil]) { |
| 35 } | 35 } |
| 36 | 36 |
| 37 scoped_nsobject<TestTrackingAreaOwner> owner_; | 37 scoped_nsobject<TestTrackingAreaOwner> owner_; |
| 38 scoped_nsobject<CrTrackingArea> trackingArea_; | 38 scoped_nsobject<CrTrackingArea> trackingArea_; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 TEST_F(CrTrackingAreaTest, OwnerForwards) { | 41 TEST_F(CrTrackingAreaTest, OwnerForwards) { |
| 42 [[trackingArea_ owner] performMessage]; | 42 [[trackingArea_ owner] performMessage]; |
| 43 EXPECT_EQ(1U, [owner_ messageCount]); | 43 EXPECT_EQ(1U, [owner_ messageCount]); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 [owner_ shouldBecomeCrZombie]; | 78 [owner_ shouldBecomeCrZombie]; |
| 79 owner_.reset(); | 79 owner_.reset(); |
| 80 [trackingArea_ clearOwner]; | 80 [trackingArea_ clearOwner]; |
| 81 | 81 |
| 82 [[trackingArea_ owner] performMessage]; | 82 [[trackingArea_ owner] performMessage]; |
| 83 // Don't crash! | 83 // Don't crash! |
| 84 | 84 |
| 85 ObjcEvilDoers::ZombieDisable(); | 85 ObjcEvilDoers::ZombieDisable(); |
| 86 } | 86 } |
| OLD | NEW |