| 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/test/run_loop_testing.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
| 12 #include "base/message_loop/message_pump_mac.h" | 12 #include "base/message_loop/message_pump_mac.h" |
| 13 | 13 |
| 14 // This class is scheduled with a delayed selector to quit the message pump. | 14 // This class is scheduled with a delayed selector to quit the message pump. |
| 15 @interface CocoaQuitTask : NSObject { | 15 @interface CocoaQuitTask : NSObject { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 void NSRunLoopRunAllPending() { | 41 void NSRunLoopRunAllPending() { |
| 42 std::unique_ptr<base::MessagePumpNSRunLoop> message_pump( | 42 std::unique_ptr<base::MessagePumpNSRunLoop> message_pump( |
| 43 new base::MessagePumpNSRunLoop); | 43 new base::MessagePumpNSRunLoop); |
| 44 | 44 |
| 45 // Put a delayed selector on the queue. All other pending delayed selectors | 45 // Put a delayed selector on the queue. All other pending delayed selectors |
| 46 // will run before this, after which the internal loop can end. | 46 // will run before this, after which the internal loop can end. |
| 47 base::scoped_nsobject<CocoaQuitTask> quit_task( | 47 base::scoped_nsobject<CocoaQuitTask> quit_task( |
| 48 [[CocoaQuitTask alloc] initWithMessagePump:message_pump.get()]); | 48 [[CocoaQuitTask alloc] initWithMessagePump:message_pump.get()]); |
| 49 | 49 |
| 50 [quit_task performSelector:@selector(doQuit) | 50 [quit_task performSelector:@selector(doQuit) withObject:nil afterDelay:0]; |
| 51 withObject:nil | |
| 52 afterDelay:0]; | |
| 53 | 51 |
| 54 // 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 |
| 55 // 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 |
| 56 // be pumped. | 54 // be pumped. |
| 57 message_pump->Run(NULL); | 55 message_pump->Run(NULL); |
| 58 } | 56 } |
| 59 | 57 |
| 60 } // namespace testing | 58 } // namespace testing |
| 61 } // namespace chrome | 59 } // namespace chrome |
| OLD | NEW |