| 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/auto_reset.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 | 9 |
| 10 @implementation MockCrApp | 10 @implementation MockCrApp |
| 11 | 11 |
| 12 + (NSApplication*)sharedApplication { | 12 + (NSApplication*)sharedApplication { |
| 13 NSApplication* app = [super sharedApplication]; | 13 NSApplication* app = [super sharedApplication]; |
| 14 DCHECK([app conformsToProtocol:@protocol(CrAppControlProtocol)]) | 14 DCHECK([app conformsToProtocol:@protocol(CrAppControlProtocol)]) |
| 15 << "Existing NSApp (class " << [[app className] UTF8String] | 15 << "Existing NSApp (class " << [[app className] UTF8String] |
| 16 << ") does not conform to required protocol."; | 16 << ") does not conform to required protocol."; |
| 17 DCHECK(base::MessagePumpMac::UsingCrApp()) |
| 18 << "MessagePumpMac::Create() was called before " |
| 19 << "+[MockCrApp sharedApplication]"; |
| 17 return app; | 20 return app; |
| 18 } | 21 } |
| 19 | 22 |
| 20 - (void)sendEvent:(NSEvent*)event { | 23 - (void)sendEvent:(NSEvent*)event { |
| 21 AutoReset<BOOL> scoper(&handlingSendEvent_, YES); | 24 AutoReset<BOOL> scoper(&handlingSendEvent_, YES); |
| 22 [super sendEvent:event]; | 25 [super sendEvent:event]; |
| 23 } | 26 } |
| 24 | 27 |
| 25 - (void)setHandlingSendEvent:(BOOL)handlingSendEvent { | 28 - (void)setHandlingSendEvent:(BOOL)handlingSendEvent { |
| 26 handlingSendEvent_ = handlingSendEvent; | 29 handlingSendEvent_ = handlingSendEvent; |
| 27 } | 30 } |
| 28 | 31 |
| 29 - (BOOL)isHandlingSendEvent { | 32 - (BOOL)isHandlingSendEvent { |
| 30 return handlingSendEvent_; | 33 return handlingSendEvent_; |
| 31 } | 34 } |
| 32 | 35 |
| 33 @end | 36 @end |
| 34 | 37 |
| 35 namespace mock_cr_app { | 38 namespace mock_cr_app { |
| 36 | 39 |
| 37 void RegisterMockCrApp() { | 40 void RegisterMockCrApp() { |
| 38 [MockCrApp sharedApplication]; | 41 [MockCrApp sharedApplication]; |
| 39 } | 42 } |
| 40 | 43 |
| 41 } // namespace mock_cr_app | 44 } // namespace mock_cr_app |
| OLD | NEW |