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/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
11 | 11 |
12 namespace { | |
13 | |
14 // Some AppKit function leak intentionally, e.g. for caching purposes. | |
Nico
2014/06/04 22:08:15
Does anything actually report these leaks? I would
| |
15 // 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 // potentially leaky functions. | |
18 void NOINLINE ForceSystemLeaks() { | |
19 // First NSCursor push always leaks. | |
20 [[NSCursor openHandCursor] push]; | |
21 [NSCursor pop]; | |
22 } | |
23 | |
24 } // namespace. | |
25 | |
12 @implementation CocoaTestHelperWindow | 26 @implementation CocoaTestHelperWindow |
13 | 27 |
14 - (id)initWithContentRect:(NSRect)contentRect { | 28 - (id)initWithContentRect:(NSRect)contentRect { |
15 return [self initWithContentRect:contentRect | 29 return [self initWithContentRect:contentRect |
16 styleMask:NSBorderlessWindowMask | 30 styleMask:NSBorderlessWindowMask |
17 backing:NSBackingStoreBuffered | 31 backing:NSBackingStoreBuffered |
18 defer:NO]; | 32 defer:NO]; |
19 } | 33 } |
20 | 34 |
21 - (id)init { | 35 - (id)init { |
(...skipping 22 matching lines...) Expand all Loading... | |
44 | 58 |
45 - (BOOL)isKeyWindow { | 59 - (BOOL)isKeyWindow { |
46 return pretendIsKeyWindow_; | 60 return pretendIsKeyWindow_; |
47 } | 61 } |
48 | 62 |
49 @end | 63 @end |
50 | 64 |
51 namespace ui { | 65 namespace ui { |
52 | 66 |
53 CocoaTest::CocoaTest() : called_tear_down_(false), test_window_(nil) { | 67 CocoaTest::CocoaTest() : called_tear_down_(false), test_window_(nil) { |
68 ForceSystemLeaks(); | |
54 Init(); | 69 Init(); |
55 } | 70 } |
56 | 71 |
57 CocoaTest::~CocoaTest() { | 72 CocoaTest::~CocoaTest() { |
58 // Must call CocoaTest's teardown from your overrides. | 73 // Must call CocoaTest's teardown from your overrides. |
59 DCHECK(called_tear_down_); | 74 DCHECK(called_tear_down_); |
60 } | 75 } |
61 | 76 |
62 void CocoaTest::Init() { | 77 void CocoaTest::Init() { |
63 // Set the duration of AppKit-evaluated animations (such as frame changes) | 78 // Set the duration of AppKit-evaluated animations (such as frame changes) |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 if (base::debug::BeingDebugged()) { | 206 if (base::debug::BeingDebugged()) { |
192 [test_window_ orderFront:nil]; | 207 [test_window_ orderFront:nil]; |
193 } else { | 208 } else { |
194 [test_window_ orderBack:nil]; | 209 [test_window_ orderBack:nil]; |
195 } | 210 } |
196 } | 211 } |
197 return test_window_; | 212 return test_window_; |
198 } | 213 } |
199 | 214 |
200 } // namespace ui | 215 } // namespace ui |
OLD | NEW |