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 "base/test/mock_chrome_application_mac.h" | 5 #include "base/test/mock_chrome_application_mac.h" |
6 | 6 |
| 7 #include "base/auto_reset.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 | 9 |
9 @implementation MockCrApp | 10 @implementation MockCrApp |
| 11 |
| 12 + (NSApplication*)sharedApplication { |
| 13 NSApplication* app = [super sharedApplication]; |
| 14 DCHECK([app conformsToProtocol:@protocol(CrAppControlProtocol)]) |
| 15 << "Existing NSApp (class " << [[app className] UTF8String] |
| 16 << ") does not conform to required protocol."; |
| 17 return app; |
| 18 } |
| 19 |
| 20 - (void)sendEvent:(NSEvent*)event { |
| 21 AutoReset<BOOL> scoper(&handlingSendEvent_, YES); |
| 22 [super sendEvent:event]; |
| 23 } |
| 24 |
| 25 - (void)setHandlingSendEvent:(BOOL)handlingSendEvent { |
| 26 handlingSendEvent_ = handlingSendEvent; |
| 27 } |
| 28 |
10 - (BOOL)isHandlingSendEvent { | 29 - (BOOL)isHandlingSendEvent { |
11 return NO; | 30 return handlingSendEvent_; |
12 } | 31 } |
| 32 |
13 @end | 33 @end |
14 | 34 |
15 namespace mock_cr_app { | 35 namespace mock_cr_app { |
16 | 36 |
17 void RegisterMockCrApp() { | 37 void RegisterMockCrApp() { |
18 NSApplication* app = [MockCrApp sharedApplication]; | 38 [MockCrApp sharedApplication]; |
19 | |
20 // Would prefer ASSERT_TRUE() to provide better test failures, but | |
21 // this class is used by remoting/ for a non-test use. | |
22 DCHECK([app conformsToProtocol:@protocol(CrAppProtocol)]); | |
23 } | 39 } |
24 | 40 |
25 } // namespace mock_cr_app | 41 } // namespace mock_cr_app |
OLD | NEW |