OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "ui/gfx/test/ui_cocoa_test_helper.h" | 5 #import "ui/gfx/test/ui_cocoa_test_helper.h" |
6 | 6 |
7 #include "base/debug/debugger.h" | 7 #include "base/debug/debugger.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/test/mock_chrome_application_mac.h" |
10 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 // Some AppKit function leak intentionally, e.g. for caching purposes. | 15 // Some AppKit function leak intentionally, e.g. for caching purposes. |
15 // Force those leaks here, so there can be a unique calling path, allowing | 16 // Force those leaks here, so there can be a unique calling path, allowing |
16 // to flag intentional leaks without having to suppress all calls to | 17 // to flag intentional leaks without having to suppress all calls to |
17 // potentially leaky functions. | 18 // potentially leaky functions. |
18 void NOINLINE ForceSystemLeaks() { | 19 void NOINLINE ForceSystemLeaks() { |
| 20 // If a test suite hasn't already initialized NSApp, register the mock one |
| 21 // now. |
| 22 if (!NSApp) |
| 23 mock_cr_app::RegisterMockCrApp(); |
| 24 |
19 // First NSCursor push always leaks. | 25 // First NSCursor push always leaks. |
20 [[NSCursor openHandCursor] push]; | 26 [[NSCursor openHandCursor] push]; |
21 [NSCursor pop]; | 27 [NSCursor pop]; |
22 } | 28 } |
23 | 29 |
24 } // namespace. | 30 } // namespace. |
25 | 31 |
26 @implementation CocoaTestHelperWindow | 32 @implementation CocoaTestHelperWindow |
27 | 33 |
28 - (id)initWithContentRect:(NSRect)contentRect { | 34 - (id)initWithContentRect:(NSRect)contentRect { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 if (base::debug::BeingDebugged()) { | 212 if (base::debug::BeingDebugged()) { |
207 [test_window_ orderFront:nil]; | 213 [test_window_ orderFront:nil]; |
208 } else { | 214 } else { |
209 [test_window_ orderBack:nil]; | 215 [test_window_ orderBack:nil]; |
210 } | 216 } |
211 } | 217 } |
212 return test_window_; | 218 return test_window_; |
213 } | 219 } |
214 | 220 |
215 } // namespace ui | 221 } // namespace ui |
OLD | NEW |