| 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 66 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 } |
| 87 |
| 88 TEST_F(CrTrackingAreaTest, ScoperInit) { |
| 89 { |
| 90 ScopedCrTrackingArea scoper([trackingArea_ retain]); |
| 91 [[scoper.get() owner] performMessage]; |
| 92 EXPECT_EQ(1U, [owner_ messageCount]); |
| 93 } |
| 94 |
| 95 [[trackingArea_ owner] performMessage]; |
| 96 EXPECT_EQ(1U, [owner_ messageCount]); |
| 97 } |
| 98 |
| 99 TEST_F(CrTrackingAreaTest, ScoperReset) { |
| 100 { |
| 101 ScopedCrTrackingArea scoper; |
| 102 EXPECT_FALSE(scoper.get()); |
| 103 |
| 104 scoper.reset([trackingArea_ retain]); |
| 105 [[scoper.get() owner] performMessage]; |
| 106 EXPECT_EQ(1U, [owner_ messageCount]); |
| 107 |
| 108 [[scoper.get() owner] performMessage]; |
| 109 EXPECT_EQ(2U, [owner_ messageCount]); |
| 110 } |
| 111 |
| 112 [[trackingArea_ owner] performMessage]; |
| 113 EXPECT_EQ(2U, [owner_ messageCount]); |
| 114 } |
| OLD | NEW |