diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-18 01:18:29 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-18 01:18:29 +0000 |
commit | a366880f8475fa9e0e70ace062af10654b297574 (patch) | |
tree | 5c2a777d77feebefc4b8c0f0c78525d57be93b16 | |
parent | c811184533d882af419cab0dabe0bf317c6c985f (diff) | |
download | chromium_src-a366880f8475fa9e0e70ace062af10654b297574.zip chromium_src-a366880f8475fa9e0e70ace062af10654b297574.tar.gz chromium_src-a366880f8475fa9e0e70ace062af10654b297574.tar.bz2 |
Remove CrApplication dependency from base
Add a @protocol CrAppProtocol that clients of base must implement in their NSApplication subclass, and let base depend only on this protocol.
Let MessagePumpNSApplication::DoRun() no longer initialize NSApplication (fixes a TODO).
Add a MockCrApplication that the simple unittests in base and app can use, move chrome_application to chrome/common.
Test shell might run nested run loops, so I gave it a real but simplified CrAppProtocol implementation.
BUG=62968,46929
TEST=Everything still works. The PDF plugin prints one fewer warning when loaded.
Review URL: http://codereview.chromium.org/5950003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69615 0039d316-1c4b-4281-b951-d872f2087c98
26 files changed, 144 insertions, 47 deletions
diff --git a/app/animation_container_unittest.cc b/app/animation_container_unittest.cc index 5375fc7..5aa3be6 100644 --- a/app/animation_container_unittest.cc +++ b/app/animation_container_unittest.cc @@ -109,13 +109,13 @@ TEST_F(AnimationContainerTest, Observer) { animation1.Start(); EXPECT_TRUE(container->is_running()); - // Run the message loop the delegate quits the message loop when notified. + // Run the message loop. The delegate quits the message loop when notified. MessageLoop::current()->Run(); // The timer should have finished. EXPECT_TRUE(delegate1.finished()); - // And the container should no longer be runnings. + // And the container should no longer be running. EXPECT_FALSE(container->is_running()); container->set_observer(NULL); diff --git a/app/test_suite.h b/app/test_suite.h index 7e9076c..1f05e13 100644 --- a/app/test_suite.h +++ b/app/test_suite.h @@ -13,6 +13,7 @@ #include "base/path_service.h" #if defined(OS_MACOSX) #include "base/mac_util.h" +#include "base/test/mock_chrome_application_mac.h" #endif #include "base/mac/scoped_nsautorelease_pool.h" #include "base/test/test_suite.h" @@ -25,6 +26,11 @@ class AppTestSuite : public base::TestSuite { protected: virtual void Initialize() { +#if defined(OS_MACOSX) + // Some of the app unit tests try to open windows. + mock_cr_app::RegisterMockCrApp(); +#endif + base::mac::ScopedNSAutoreleasePool autorelease_pool; TestSuite::Initialize(); diff --git a/base/base.gyp b/base/base.gyp index f4ddeb5..4c72e8b 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -257,6 +257,8 @@ ], 'sources': [ 'perftimer.cc', + 'test/mock_chrome_application_mac.h', + 'test/mock_chrome_application_mac.mm', 'test/multiprocess_test.cc', 'test/multiprocess_test.h', 'test/perf_test_suite.cc', diff --git a/base/base.gypi b/base/base.gypi index 3b38a0d..dd9236f 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -41,8 +41,6 @@ 'callback.h', 'cancellation_flag.cc', 'cancellation_flag.h', - 'chrome_application_mac.h', - 'chrome_application_mac.mm', 'cocoa_protocols_mac.h', 'command_line.cc', 'command_line.h', diff --git a/base/mac_util_unittest.mm b/base/mac_util_unittest.mm index 7999878..63ea9b2 100644 --- a/base/mac_util_unittest.mm +++ b/base/mac_util_unittest.mm @@ -7,10 +7,10 @@ #include "base/mac_util.h" -#import "base/chrome_application_mac.h" #include "base/file_path.h" #include "base/file_util.h" #include "base/mac/scoped_cftyperef.h" +#include "base/test/mock_chrome_application_mac.h" #include "base/scoped_nsobject.h" #include "base/scoped_ptr.h" #include "testing/gtest/include/gtest/gtest.h" @@ -54,7 +54,7 @@ TEST_F(MacUtilTest, TestLibraryPath) { TEST_F(MacUtilTest, TestGrabWindowSnapshot) { // Launch a test window so we can take a snapshot. - [CrApplication sharedApplication]; + [MockCrApp sharedApplication]; NSRect frame = NSMakeRect(0, 0, 400, 400); scoped_nsobject<NSWindow> window( [[NSWindow alloc] initWithContentRect:frame diff --git a/base/message_pump_mac.h b/base/message_pump_mac.h index e016d54..c30a8ea 100644 --- a/base/message_pump_mac.h +++ b/base/message_pump_mac.h @@ -36,11 +36,20 @@ #include <CoreFoundation/CoreFoundation.h> #include <IOKit/IOKitLib.h> -#if defined(__OBJC__) -@class NSAutoreleasePool; -#else // defined(__OBJC__) +#if !defined(__OBJC__) class NSAutoreleasePool; -#endif // defined(__OBJC__) +#else // !defined(__OBJC__) +#import <AppKit/AppKit.h> + +// Clients must subclass NSApplication and implement this protocol if they use +// MessagePumpMac. +@protocol CrAppProtocol +// Must return true if -[NSApplication sendEvent:] is currently on the stack. +// See the comment for |CreateAutoreleasePool()| in the cc file for why this is +// necessary. +- (BOOL)isHandlingSendEvent; +@end +#endif // !defined(__OBJC__) namespace base { diff --git a/base/message_pump_mac.mm b/base/message_pump_mac.mm index 9091006..8c5461c 100644 --- a/base/message_pump_mac.mm +++ b/base/message_pump_mac.mm @@ -11,7 +11,6 @@ #include <limits> -#import "base/chrome_application_mac.h" #include "base/logging.h" #include "base/time.h" @@ -673,10 +672,6 @@ MessagePumpNSApplication::MessagePumpNSApplication() void MessagePumpNSApplication::DoRun(Delegate* delegate) { bool last_running_own_loop_ = running_own_loop_; - // TODO(dmaclach): Get rid of this gratuitous sharedApplication. - // Tests should be setting up their applications on their own. - [CrApplication sharedApplication]; - if (![NSApp isRunning]) { running_own_loop_ = false; // NSApplication manages autorelease pools itself when run this way. @@ -749,12 +744,12 @@ void MessagePumpNSApplication::Quit() { // autorelease pool stack. // // CrApplication is responsible for setting handlingSendEvent to true just -// before it sends the event throught the event handling mechanism, and +// before it sends the event through the event handling mechanism, and // returning it to its previous value once the event has been sent. NSAutoreleasePool* MessagePumpNSApplication::CreateAutoreleasePool() { NSAutoreleasePool* pool = nil; - DCHECK([NSApp isKindOfClass:[CrApplication class]]); - if (![static_cast<CrApplication*>(NSApp) isHandlingSendEvent]) { + DCHECK([NSApp conformsToProtocol:@protocol(CrAppProtocol)]); + if (![NSApp isHandlingSendEvent]) { pool = MessagePumpCFRunLoopBase::CreateAutoreleasePool(); } return pool; diff --git a/base/test/mock_chrome_application_mac.h b/base/test/mock_chrome_application_mac.h new file mode 100644 index 0000000..e7e2c67 --- /dev/null +++ b/base/test/mock_chrome_application_mac.h @@ -0,0 +1,28 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_TEST_MOCK_CHROME_APPLICATION_MAC_H_ +#define BASE_TEST_MOCK_CHROME_APPLICATION_MAC_H_ +#pragma once + +#if defined(__OBJC__) + +#import <AppKit/AppKit.h> + +#include "base/message_pump_mac.h" + +// A mock implementation of CrAppProtocol that claims that -sendEvent: is never +// on the stack. This can be used in tests that need an NSApplication and use a +// runloop, but don't run nested message loops. +@interface MockCrApp : NSApplication<CrAppProtocol> +@end + +#endif + +// To be used to instantiate MockCrApp from C++ code. +namespace mock_cr_app { +void RegisterMockCrApp(); +} // namespace mock_cr_app + +#endif // BASE_TEST_MOCK_CHROME_APPLICATION_MAC_H_ diff --git a/base/test/mock_chrome_application_mac.mm b/base/test/mock_chrome_application_mac.mm new file mode 100644 index 0000000..f7010c4 --- /dev/null +++ b/base/test/mock_chrome_application_mac.mm @@ -0,0 +1,19 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/test/mock_chrome_application_mac.h" + +@implementation MockCrApp +- (BOOL)isHandlingSendEvent { + return NO; +} +@end + +namespace mock_cr_app { + +void RegisterMockCrApp() { + [MockCrApp sharedApplication]; +} + +} // namespace mock_cr_app diff --git a/chrome/browser/chrome_browser_application_mac.h b/chrome/browser/chrome_browser_application_mac.h index e599c63..a1ebb04 100644 --- a/chrome/browser/chrome_browser_application_mac.h +++ b/chrome/browser/chrome_browser_application_mac.h @@ -8,7 +8,7 @@ #ifdef __OBJC__ -#import "base/chrome_application_mac.h" +#import "chrome/common/chrome_application_mac.h" @interface BrowserCrApplication : CrApplication // Our implementation of |-terminate:| only attempts to terminate the @@ -36,6 +36,9 @@ void RecordExceptionWithUma(NSException* exception); namespace chrome_browser_application_mac { +// To be used to instantiate BrowserCrApplication from C++ code. +void RegisterBrowserCrApp(); + // Calls -[NSApp terminate:]. void Terminate(); diff --git a/chrome/browser/chrome_browser_application_mac.mm b/chrome/browser/chrome_browser_application_mac.mm index 4690fea..aea31b0 100644 --- a/chrome/browser/chrome_browser_application_mac.mm +++ b/chrome/browser/chrome_browser_application_mac.mm @@ -64,7 +64,8 @@ static IMP gOriginalInitIMP = NULL; BOOL fatal = NO; if (aName == NSInternalInconsistencyException) { NSString* const kNSMenuItemArrayBoundsCheck = - @"Invalid parameter not satisfying: (index >= 0) && (index < [_itemArray count])"; + @"Invalid parameter not satisfying: (index >= 0) && " + @"(index < [_itemArray count])"; if ([aReason isEqualToString:kNSMenuItemArrayBoundsCheck]) { fatal = YES; } @@ -141,6 +142,10 @@ void RecordExceptionWithUma(NSException* exception) { BinForException(exception), kUnknownNSException); } +void RegisterBrowserCrApp() { + [BrowserCrApplication sharedApplication]; +}; + void Terminate() { [NSApp terminate:nil]; } diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index 842bf9a..22175dc 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -8,7 +8,6 @@ #include "app/app_switches.h" #include "app/surface/io_surface_support_mac.h" -#import "base/chrome_application_mac.h" #include "base/command_line.h" #include "base/logging.h" #include "base/mac/scoped_cftyperef.h" diff --git a/chrome/browser/tab_contents/popup_menu_helper_mac.mm b/chrome/browser/tab_contents/popup_menu_helper_mac.mm index df8862c..aea6a7b 100644 --- a/chrome/browser/tab_contents/popup_menu_helper_mac.mm +++ b/chrome/browser/tab_contents/popup_menu_helper_mac.mm @@ -6,12 +6,12 @@ #include "chrome/browser/tab_contents/popup_menu_helper_mac.h" -#import "base/chrome_application_mac.h" #include "base/message_loop.h" #include "base/scoped_nsobject.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" #import "chrome/browser/ui/cocoa/base_view.h" +#import "chrome/common/chrome_application_mac.h" #include "chrome/common/notification_source.h" #include "webkit/glue/webmenurunner_mac.h" diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm index a6b111a..8d810dd 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.mm +++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm @@ -8,7 +8,6 @@ #include <string> -#import "base/chrome_application_mac.h" #include "chrome/browser/global_keyboard_shortcuts_mac.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/renderer_host/render_view_host_factory.h" @@ -24,6 +23,7 @@ #import "chrome/browser/ui/cocoa/web_drag_source.h" #import "chrome/browser/ui/cocoa/web_drop_target.h" #import "chrome/browser/ui/cocoa/view_id_util.h" +#import "chrome/common/chrome_application_mac.h" #include "chrome/common/notification_details.h" #include "chrome/common/notification_source.h" #include "chrome/common/notification_type.h" diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h index a9bca8a..64591ba 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h @@ -9,7 +9,6 @@ #import <Cocoa/Cocoa.h> #include <map> -#import "base/chrome_application_mac.h" #include "base/scoped_nsobject.h" #include "base/scoped_ptr.h" #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_bridge.h" @@ -18,6 +17,7 @@ #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" #include "chrome/browser/ui/cocoa/tab_strip_model_observer_bridge.h" +#import "chrome/common/chrome_application_mac.h" #include "webkit/glue/window_open_disposition.h" @class BookmarkBarController; diff --git a/chrome/browser/ui/cocoa/cocoa_test_helper.h b/chrome/browser/ui/cocoa/cocoa_test_helper.h index 3431925..0be5903 100644 --- a/chrome/browser/ui/cocoa/cocoa_test_helper.h +++ b/chrome/browser/ui/cocoa/cocoa_test_helper.h @@ -8,12 +8,12 @@ #import <Cocoa/Cocoa.h> -#import "base/chrome_application_mac.h" #include "base/debug_util.h" #include "base/mac_util.h" #include "base/path_service.h" #import "base/mac/scoped_nsautorelease_pool.h" #import "base/scoped_nsobject.h" +#import "chrome/common/chrome_application_mac.h" #include "chrome/common/chrome_constants.h" #include "testing/platform_test.h" diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index ca20862..45abad8 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -3744,7 +3744,7 @@ '../third_party/mozilla/ComplexTextInputPanel.mm', # Headers so that IB can find classes it needs to resolve classes # in XIB files. - '../base/chrome_application_mac.h', + 'common/chrome_application_mac.h', ], 'include_dirs': [ '../third_party/apple', diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index b8d4d5d..80c1b0e 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -28,6 +28,8 @@ 'common/app_mode_common_mac.h', 'common/app_mode_common_mac.mm', 'common/bindings_policy.h', + 'common/chrome_application_mac.h', + 'common/chrome_application_mac.mm', 'common/child_process.cc', 'common/child_process.h', 'common/child_process_info.cc', diff --git a/base/chrome_application_mac.h b/chrome/common/chrome_application_mac.h index 676959ec..585601d8 100644 --- a/base/chrome_application_mac.h +++ b/chrome/common/chrome_application_mac.h @@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef BASE_CHROME_APPLICATION_MAC_H_ -#define BASE_CHROME_APPLICATION_MAC_H_ +#ifndef CHROME_COMMON_CHROME_APPLICATION_MAC_H_ +#define CHROME_COMMON_CHROME_APPLICATION_MAC_H_ #pragma once #import <AppKit/AppKit.h> #include "base/basictypes.h" +#include "base/message_pump_mac.h" #include "base/scoped_nsobject.h" // Event hooks must implement this protocol. @@ -17,15 +18,13 @@ @end -@interface CrApplication : NSApplication { +@interface CrApplication : NSApplication<CrAppProtocol> { @private BOOL handlingSendEvent_; // Array of objects implementing the CrApplicationEventHookProtocol scoped_nsobject<NSMutableArray> eventHooks_; } -@property(readonly, - getter=isHandlingSendEvent, - nonatomic) BOOL handlingSendEvent; +- (BOOL)isHandlingSendEvent; // Add or remove an event hook to be called for every sendEvent: // that the application receives. These handlers are called before @@ -58,4 +57,4 @@ class ScopedSendingEvent { } // chrome_application_mac -#endif // BASE_CHROME_APPLICATION_MAC_H_ +#endif // CHROME_COMMON_CHROME_APPLICATION_MAC_H_ diff --git a/base/chrome_application_mac.mm b/chrome/common/chrome_application_mac.mm index a163534..9bd9f67 100644 --- a/base/chrome_application_mac.mm +++ b/chrome/common/chrome_application_mac.mm @@ -2,19 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "chrome_application_mac.h" +#import "chrome/common/chrome_application_mac.h" #include "base/logging.h" @interface CrApplication () -@property(readwrite, - getter=isHandlingSendEvent, - nonatomic) BOOL handlingSendEvent; +- (void)setHandlingSendEvent:(BOOL)handlingSendEvent; @end @implementation CrApplication -@synthesize handlingSendEvent = handlingSendEvent_; - // Initialize NSApplication using the custom subclass. Check whether NSApp // was already initialized using another class, because that would break // some things. @@ -35,6 +31,14 @@ return self; } +- (BOOL)isHandlingSendEvent { + return handlingSendEvent_; +} + +- (void)setHandlingSendEvent:(BOOL)handlingSendEvent { + handlingSendEvent_ = handlingSendEvent; +} + - (void)sendEvent:(NSEvent*)event { chrome_application_mac::ScopedSendingEvent sendingEventScoper; for (id<CrApplicationEventHookProtocol> handler in eventHooks_.get()) { diff --git a/chrome/common/sandbox_mac.mm b/chrome/common/sandbox_mac.mm index 58044cc..56ad0b1 100644 --- a/chrome/common/sandbox_mac.mm +++ b/chrome/common/sandbox_mac.mm @@ -17,7 +17,6 @@ extern "C" { #include "app/gfx/gl/gl_context.h" #include "base/basictypes.h" -#include "base/chrome_application_mac.h" #include "base/command_line.h" #include "base/file_util.h" #include "base/mac_util.h" @@ -29,6 +28,7 @@ extern "C" { #include "base/sys_info.h" #include "base/sys_string_conversions.h" #include "base/utf_string_conversions.h" +#include "chrome/common/chrome_application_mac.h" #include "chrome/common/chrome_switches.h" #include "unicode/uchar.h" diff --git a/chrome/nacl/nacl_main_platform_delegate_mac.mm b/chrome/nacl/nacl_main_platform_delegate_mac.mm index 6b7e8b6..39ba8c8 100644 --- a/chrome/nacl/nacl_main_platform_delegate_mac.mm +++ b/chrome/nacl/nacl_main_platform_delegate_mac.mm @@ -5,14 +5,12 @@ #include "chrome/nacl/nacl_main_platform_delegate.h" #import <Cocoa/Cocoa.h> -#import "base/chrome_application_mac.h" #include "base/command_line.h" #include "base/file_path.h" #include "base/logging.h" #include "base/native_library.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/sandbox_mac.h" -#include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h" NaClMainPlatformDelegate::NaClMainPlatformDelegate( const MainFunctionParams& parameters) diff --git a/chrome/plugin/plugin_main_mac.mm b/chrome/plugin/plugin_main_mac.mm index 2bde557..5d10a3b 100644 --- a/chrome/plugin/plugin_main_mac.mm +++ b/chrome/plugin/plugin_main_mac.mm @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/chrome_application_mac.h" #include "base/environment.h" #include "base/scoped_ptr.h" #include "base/string_util.h" +#include "chrome/common/chrome_application_mac.h" #include "chrome/common/plugin_carbon_interpose_constants_mac.h" #include "chrome/plugin/plugin_interpose_util_mac.h" diff --git a/chrome/renderer/renderer_main_platform_delegate_mac.mm b/chrome/renderer/renderer_main_platform_delegate_mac.mm index 2b14cd0..eb65d1a 100644 --- a/chrome/renderer/renderer_main_platform_delegate_mac.mm +++ b/chrome/renderer/renderer_main_platform_delegate_mac.mm @@ -6,8 +6,8 @@ #import <Cocoa/Cocoa.h> -#import "base/chrome_application_mac.h" #include "base/command_line.h" +#import "chrome/common/chrome_application_mac.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/sandbox_mac.h" #include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h" diff --git a/chrome/test/out_of_proc_test_runner.cc b/chrome/test/out_of_proc_test_runner.cc index fbf5ebb..1d2bb10 100644 --- a/chrome/test/out_of_proc_test_runner.cc +++ b/chrome/test/out_of_proc_test_runner.cc @@ -32,6 +32,10 @@ #include "sandbox/src/sandbox_types.h" #endif // defined(OS_WIN) +#if defined(OS_MACOSX) +#include "chrome/browser/chrome_browser_application_mac.h" +#endif // defined(OS_MACOSX) + #if defined(OS_WIN) // The entry point signature of chrome.dll. typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*, wchar_t*); @@ -454,6 +458,10 @@ void PrintUsage() { } // namespace int main(int argc, char** argv) { +#if defined(OS_MACOSX) + chrome_browser_application_mac::RegisterBrowserCrApp(); +#endif + CommandLine::Init(argc, argv); const CommandLine* command_line = CommandLine::ForCurrentProcess(); diff --git a/webkit/tools/test_shell/test_shell_platform_delegate_mac.mm b/webkit/tools/test_shell/test_shell_platform_delegate_mac.mm index b02da7d..5f1fcd0 100644 --- a/webkit/tools/test_shell/test_shell_platform_delegate_mac.mm +++ b/webkit/tools/test_shell/test_shell_platform_delegate_mac.mm @@ -10,9 +10,9 @@ #import <objc/objc-runtime.h> #include <mach/task.h> -#include "base/chrome_application_mac.h" #include "base/command_line.h" #include "base/logging.h" +#include "base/message_pump_mac.h" #include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h" #include "webkit/tools/test_shell/test_shell.h" #include "webkit/tools/test_shell/test_shell_platform_delegate.h" @@ -20,6 +20,26 @@ static NSAutoreleasePool *gTestShellAutoreleasePool = nil; +@interface CrApplication : NSApplication<CrAppProtocol> { + @private + BOOL handlingSendEvent_; +} +- (BOOL)isHandlingSendEvent; +@end + +@implementation CrApplication +- (BOOL)isHandlingSendEvent { + return handlingSendEvent_; +} + +- (void)sendEvent:(NSEvent*)event { + BOOL wasHandlingSendEvent = handlingSendEvent_; + handlingSendEvent_ = YES; + [super sendEvent:event]; + handlingSendEvent_ = wasHandlingSendEvent; +} +@end + static void SetDefaultsToLayoutTestValues(void) { // So we can match the WebKit layout tests, we want to force a bunch of // preferences that control appearance to match. @@ -90,10 +110,12 @@ static void ClearAnyDefaultsForLayoutTests(void) { #if OBJC_API_VERSION == 2 static void SwizzleAllMethods(Class imposter, Class original) { unsigned int imposterMethodCount = 0; - Method* imposterMethods = class_copyMethodList(imposter, &imposterMethodCount); + Method* imposterMethods = + class_copyMethodList(imposter, &imposterMethodCount); unsigned int originalMethodCount = 0; - Method* originalMethods = class_copyMethodList(original, &originalMethodCount); + Method* originalMethods = + class_copyMethodList(original, &originalMethodCount); for (unsigned int i = 0; i < imposterMethodCount; i++) { SEL imposterMethodName = method_getName(imposterMethods[i]); |