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 "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/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
10 #include "base/message_loop/message_pump_mac.h" | 10 #include "base/message_loop/message_pump_mac.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 namespace chrome { | 36 namespace chrome { |
37 namespace testing { | 37 namespace testing { |
38 | 38 |
39 void NSRunLoopRunAllPending() { | 39 void NSRunLoopRunAllPending() { |
40 scoped_refptr<base::MessagePumpNSRunLoop> message_pump( | 40 scoped_refptr<base::MessagePumpNSRunLoop> message_pump( |
41 new base::MessagePumpNSRunLoop); | 41 new base::MessagePumpNSRunLoop); |
42 | 42 |
43 // Put a delayed selector on the queue. All other pending delayed selectors | 43 // Put a delayed selector on the queue. All other pending delayed selectors |
44 // will run before this, after which the internal loop can end. | 44 // will run before this, after which the internal loop can end. |
45 base::scoped_nsobject<CocoaQuitTask> quit_task( | 45 base::scoped_nsobject<CocoaQuitTask> quit_task( |
46 [[CocoaQuitTask alloc] initWithMessagePump:message_pump]); | 46 [[CocoaQuitTask alloc] initWithMessagePump:message_pump.get()]); |
47 | 47 |
48 [quit_task performSelector:@selector(doQuit) | 48 [quit_task performSelector:@selector(doQuit) |
49 withObject:nil | 49 withObject:nil |
50 afterDelay:0]; | 50 afterDelay:0]; |
51 | 51 |
52 // Spin the internal loop, running it until the quit task is pumped. Pass NULL | 52 // Spin the internal loop, running it until the quit task is pumped. Pass NULL |
53 // because there is no delegate MessageLoop; only the Cocoa work queues will | 53 // because there is no delegate MessageLoop; only the Cocoa work queues will |
54 // be pumped. | 54 // be pumped. |
55 message_pump->Run(NULL); | 55 message_pump->Run(NULL); |
56 } | 56 } |
57 | 57 |
58 } // namespace testing | 58 } // namespace testing |
59 } // namespace chrome | 59 } // namespace chrome |
OLD | NEW |