| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 // #include <Carbon/Carbon.h> | 7 // #include <Carbon/Carbon.h> |
| 8 // #include <ApplicationServices/ApplicationServices.h> | 8 // #include <ApplicationServices/ApplicationServices.h> |
| 9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
| 10 #import <objc/objc-runtime.h> | 10 #import <objc/objc-runtime.h> |
| 11 #include <mach/task.h> | 11 #include <mach/task.h> |
| 12 | 12 |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/message_pump_mac.h" | 15 #include "base/message_pump_mac.h" |
| 16 #import "base/test/mock_chrome_application_mac.h" |
| 16 #include "third_party/WebKit/Source/WebKit/mac/WebCoreSupport/WebSystemInterface
.h" | 17 #include "third_party/WebKit/Source/WebKit/mac/WebCoreSupport/WebSystemInterface
.h" |
| 17 #include "webkit/tools/test_shell/test_shell.h" | 18 #include "webkit/tools/test_shell/test_shell.h" |
| 18 #include "webkit/tools/test_shell/test_shell_platform_delegate.h" | 19 #include "webkit/tools/test_shell/test_shell_platform_delegate.h" |
| 19 #include "webkit/tools/test_shell/test_shell_switches.h" | 20 #include "webkit/tools/test_shell/test_shell_switches.h" |
| 20 | 21 |
| 21 static NSAutoreleasePool *gTestShellAutoreleasePool = nil; | 22 static NSAutoreleasePool *gTestShellAutoreleasePool = nil; |
| 22 | 23 |
| 23 @interface CrApplication : NSApplication<CrAppProtocol> { | |
| 24 @private | |
| 25 BOOL handlingSendEvent_; | |
| 26 } | |
| 27 - (BOOL)isHandlingSendEvent; | |
| 28 @end | |
| 29 | |
| 30 @implementation CrApplication | |
| 31 - (BOOL)isHandlingSendEvent { | |
| 32 return handlingSendEvent_; | |
| 33 } | |
| 34 | |
| 35 - (void)sendEvent:(NSEvent*)event { | |
| 36 BOOL wasHandlingSendEvent = handlingSendEvent_; | |
| 37 handlingSendEvent_ = YES; | |
| 38 [super sendEvent:event]; | |
| 39 handlingSendEvent_ = wasHandlingSendEvent; | |
| 40 } | |
| 41 @end | |
| 42 | |
| 43 static void SetDefaultsToLayoutTestValues(void) { | 24 static void SetDefaultsToLayoutTestValues(void) { |
| 44 // So we can match the WebKit layout tests, we want to force a bunch of | 25 // So we can match the WebKit layout tests, we want to force a bunch of |
| 45 // preferences that control appearance to match. | 26 // preferences that control appearance to match. |
| 46 // (We want to do this as early as possible in application startup so | 27 // (We want to do this as early as possible in application startup so |
| 47 // the settings are in before any higher layers could cache values.) | 28 // the settings are in before any higher layers could cache values.) |
| 48 | 29 |
| 49 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | 30 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; |
| 50 | 31 |
| 51 const NSInteger kMinFontSizeCGSmoothes = 4; | 32 const NSInteger kMinFontSizeCGSmoothes = 4; |
| 52 const NSInteger kNoFontSmoothing = 0; | 33 const NSInteger kNoFontSmoothing = 0; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 SwizzleAllMethods(imposterClass, originalClass); | 146 SwizzleAllMethods(imposterClass, originalClass); |
| 166 // and then class methods. | 147 // and then class methods. |
| 167 SwizzleAllMethods(object_getClass(imposterClass), | 148 SwizzleAllMethods(object_getClass(imposterClass), |
| 168 object_getClass(originalClass)); | 149 object_getClass(originalClass)); |
| 169 #endif | 150 #endif |
| 170 } | 151 } |
| 171 | 152 |
| 172 TestShellPlatformDelegate::TestShellPlatformDelegate( | 153 TestShellPlatformDelegate::TestShellPlatformDelegate( |
| 173 const CommandLine &command_line) | 154 const CommandLine &command_line) |
| 174 : command_line_(command_line) { | 155 : command_line_(command_line) { |
| 156 gTestShellAutoreleasePool = [[NSAutoreleasePool alloc] init]; |
| 175 // Force AppKit to init itself, but don't start the runloop yet | 157 // Force AppKit to init itself, but don't start the runloop yet |
| 176 [CrApplication sharedApplication]; | 158 [MockCrApp sharedApplication]; |
| 177 gTestShellAutoreleasePool = [[NSAutoreleasePool alloc] init]; | |
| 178 InitWebCoreSystemInterface(); | 159 InitWebCoreSystemInterface(); |
| 179 [NSBundle loadNibNamed:@"MainMenu" owner:NSApp]; | 160 [NSBundle loadNibNamed:@"MainMenu" owner:NSApp]; |
| 180 } | 161 } |
| 181 | 162 |
| 182 TestShellPlatformDelegate::~TestShellPlatformDelegate() { | 163 TestShellPlatformDelegate::~TestShellPlatformDelegate() { |
| 183 [gTestShellAutoreleasePool release]; | 164 [gTestShellAutoreleasePool drain]; |
| 184 } | 165 } |
| 185 | 166 |
| 186 bool TestShellPlatformDelegate::CheckLayoutTestSystemDependencies() { | 167 bool TestShellPlatformDelegate::CheckLayoutTestSystemDependencies() { |
| 187 return true; | 168 return true; |
| 188 } | 169 } |
| 189 | 170 |
| 190 void TestShellPlatformDelegate::InitializeGUI() { | 171 void TestShellPlatformDelegate::InitializeGUI() { |
| 191 // Make sure any settings from a previous layout run are cleared | 172 // Make sure any settings from a previous layout run are cleared |
| 192 ClearAnyDefaultsForLayoutTests(); | 173 ClearAnyDefaultsForLayoutTests(); |
| 193 } | 174 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 208 | 189 |
| 209 // If we die during tests, we don't want to be spamming the user's crash | 190 // If we die during tests, we don't want to be spamming the user's crash |
| 210 // reporter. Set our exception port to null and add signal handlers. | 191 // reporter. Set our exception port to null and add signal handlers. |
| 211 // Both of these are necessary to avoid the crash reporter. Although, we do | 192 // Both of these are necessary to avoid the crash reporter. Although, we do |
| 212 // still seem to be missing some cases. | 193 // still seem to be missing some cases. |
| 213 if (!parsed_command_line.HasSwitch(test_shell::kGDB)) { | 194 if (!parsed_command_line.HasSwitch(test_shell::kGDB)) { |
| 214 task_set_exception_ports(mach_task_self(), EXC_MASK_ALL, MACH_PORT_NULL, | 195 task_set_exception_ports(mach_task_self(), EXC_MASK_ALL, MACH_PORT_NULL, |
| 215 EXCEPTION_DEFAULT, THREAD_STATE_NONE); | 196 EXCEPTION_DEFAULT, THREAD_STATE_NONE); |
| 216 } | 197 } |
| 217 } | 198 } |
| OLD | NEW |