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

Side by Side Diff: chrome/browser/ui/cocoa/run_loop_testing_unittest.mm

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
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 "chrome/browser/ui/cocoa/run_loop_testing.h" 5 #include "chrome/browser/ui/cocoa/run_loop_testing.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include "base/memory/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 @interface TestDelayed : NSObject { 12 @interface TestDelayed : NSObject {
13 @private 13 @private
14 BOOL didWork_; 14 BOOL didWork_;
15 TestDelayed* next_; 15 TestDelayed* next_;
16 } 16 }
17 @property(readonly, nonatomic) BOOL didWork; 17 @property(readonly, nonatomic) BOOL didWork;
18 @property(assign, nonatomic) TestDelayed* next; 18 @property(assign, nonatomic) TestDelayed* next;
19 @end 19 @end
20 20
21 @implementation TestDelayed 21 @implementation TestDelayed
22 @synthesize didWork = didWork_; 22 @synthesize didWork = didWork_;
23 @synthesize next = next_; 23 @synthesize next = next_;
24 24
25 - (id)init { 25 - (id)init {
26 if ((self = [super init])) { 26 if ((self = [super init])) {
27 [self performSelector:@selector(doWork) withObject:nil afterDelay:0]; 27 [self performSelector:@selector(doWork) withObject:nil afterDelay:0];
28 } 28 }
29 return self; 29 return self;
30 } 30 }
31 31
32 - (void)doWork { 32 - (void)doWork {
33 didWork_ = YES; 33 didWork_ = YES;
34 [next_ performSelector:@selector(doWork) withObject:nil afterDelay:0]; 34 [next_ performSelector:@selector(doWork) withObject:nil afterDelay:0];
35 } 35 }
36 @end 36 @end
37 37
38 TEST(RunLoopTesting, RunAllPending) { 38 TEST(RunLoopTesting, RunAllPending) {
39 scoped_nsobject<TestDelayed> tester([[TestDelayed alloc] init]); 39 base::scoped_nsobject<TestDelayed> tester([[TestDelayed alloc] init]);
40 EXPECT_FALSE([tester didWork]); 40 EXPECT_FALSE([tester didWork]);
41 41
42 chrome::testing::NSRunLoopRunAllPending(); 42 chrome::testing::NSRunLoopRunAllPending();
43 43
44 EXPECT_TRUE([tester didWork]); 44 EXPECT_TRUE([tester didWork]);
45 } 45 }
46 46
47 TEST(RunLoopTesting, NestedWork) { 47 TEST(RunLoopTesting, NestedWork) {
48 scoped_nsobject<TestDelayed> tester([[TestDelayed alloc] init]); 48 base::scoped_nsobject<TestDelayed> tester([[TestDelayed alloc] init]);
49 scoped_nsobject<TestDelayed> nested([[TestDelayed alloc] init]); 49 base::scoped_nsobject<TestDelayed> nested([[TestDelayed alloc] init]);
50 [tester setNext:nested]; 50 [tester setNext:nested];
51 51
52 EXPECT_FALSE([tester didWork]); 52 EXPECT_FALSE([tester didWork]);
53 EXPECT_FALSE([nested didWork]); 53 EXPECT_FALSE([nested didWork]);
54 54
55 chrome::testing::NSRunLoopRunAllPending(); 55 chrome::testing::NSRunLoopRunAllPending();
56 56
57 EXPECT_TRUE([tester didWork]); 57 EXPECT_TRUE([tester didWork]);
58 EXPECT_TRUE([nested didWork]); 58 EXPECT_TRUE([nested didWork]);
59 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698