+2005-12-19 Darin Adler <darin@apple.com>
+
+ Reviewed by Eric Seidel.
+
+ - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=4990
+ WebKit needs to use a local pasteboard during testing
+
+ * DumpRenderTree/DumpRenderTree.m:
+ (main): Call poseAs to substitute our NSPasteboard class for the default one.
+ Create a local pasteboard (really a global one with a unique name) and release
+ it when exiting from the function so we don't leave it in the pasteboard server.
+ (dumpRenderTree): Added an autorelease pool around one small bit of code that
+ ddn't have one. Fixed a leak in an unlikely error case.
+ (+[DumpRenderTreePasteboard generalPasteboard]): Override the default version
+ of this method to return our local pasteboard.
+
2005-12-15 Eric Seidel <eseidel@apple.com>
Reviewed by Tim Hatcher.
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import <Foundation/NSURLRequest.h>
-#import <Foundation/NSError.h>
-
#import <WebKit/DOMExtensions.h>
#import <WebKit/DOMRange.h>
#import <WebKit/WebCoreStatistics.h>
#import <WebKit/WebDataSource.h>
-#import <WebKit/WebFrame.h>
-#import <WebKit/WebFrameLoadDelegate.h>
#import <WebKit/WebEditingDelegate.h>
#import <WebKit/WebFrameView.h>
#import <WebKit/WebPreferences.h>
#import <Carbon/Carbon.h> // for GetCurrentEventTime()
+#import <objc/objc-runtime.h> // for class_poseAs
+
#define COMMON_DIGEST_FOR_OPENSSL
-#import <CommonCrypto/CommonDigest.h>
+#import <CommonCrypto/CommonDigest.h> // for MD5 functions
+
#import <getopt.h>
#import "TextInputController.h"
+@interface DumpRenderTreePasteboard : NSPasteboard
+@end
+
@interface WaitUntilDoneDelegate : NSObject
@end
static int dumpTree = YES;
static BOOL printSeparators;
static NSString *currentTest = nil;
+static NSPasteboard *localPasteboard;
int main(int argc, const char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ class_poseAs(objc_getClass("DumpRenderTreePasteboard"), objc_getClass("NSPasteboard"));
+
int width = 800;
int height = 600;
}
if ([[[NSFontManager sharedFontManager] availableMembersOfFontFamily:@"Ahem"] count] == 0) {
- fprintf(stderr, "\nAhem font is not available. This special simple font is used to construct certain types of predictable tests.\n\nTo run regression tests, please get it from <http://webkit.opendarwin.org/quality/Ahem.ttf>.\n");
- exit(1);
+ fprintf(stderr, "\nAhem font is not available. This special simple font is used to construct certain types of predictable tests.\n\nTo run regression tests, please get it from <http://webkit.opendarwin.org/quality/Ahem.ttf>.\n");
+ exit(1);
}
+ localPasteboard = [NSPasteboard pasteboardWithUniqueName];
+
WebView *webView = [[WebView alloc] initWithFrame:NSMakeRect(0, 0, width, height)];
WaitUntilDoneDelegate *delegate = [[WaitUntilDoneDelegate alloc] init];
EditingDelegate *editingDelegate = [[EditingDelegate alloc] init];
[delegate release];
[editingDelegate release];
+ [localPasteboard releaseGlobally];
+ localPasteboard = nil;
+
[pool release];
+
return 0;
}
- (void)mouseDown
{
[[[frame frameView] documentView] layout];
- if(GetCurrentEventTime() - lastClick >= 1)
+ if (GetCurrentEventTime() - lastClick >= 1)
clickCount = 1;
else
clickCount++;
static void dumpRenderTree(const char *filename)
{
CFStringRef filenameString = CFStringCreateWithCString(NULL, filename, kCFStringEncodingUTF8);
- if (filenameString == NULL) {
+ if (!filenameString) {
fprintf(stderr, "can't parse filename as UTF-8\n");
return;
}
CFURLRef URL = CFURLCreateWithFileSystemPath(NULL, filenameString, kCFURLPOSIXPathStyle, FALSE);
- if (URL == NULL) {
+ if (!URL) {
+ CFRelease(filenameString);
fprintf(stderr, "can't turn %s into a CFURL\n", filename);
return;
}
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]];
[pool release];
}
+ pool = [[NSAutoreleasePool alloc] init];
[[frame webView] setSelectedDOMRange:nil affinity:NSSelectionAffinityDownstream];
+ [pool release];
}
/* Hashes a bitmap and returns a text string for comparison and saving to a file */
-NSString *md5HashStringForBitmap(NSBitmapImageRep *bitmap)
+static NSString *md5HashStringForBitmap(NSBitmapImageRep *bitmap)
{
MD5_CTX md5Context;
unsigned char hash[16];
return [NSString stringWithUTF8String:hex];
}
+
+@implementation DumpRenderTreePasteboard
+
+// Return a local pasteboard so we don't disturb the real pasteboard when running tests.
++ (NSPasteboard *)generalPasteboard
+{
+ return localPasteboard;
+}
+
+@end