[webkit-changes] cvs commit: WebKitTools/DumpRenderTree DumpRenderTree.m

Darin darin at opensource.apple.com
Mon Dec 19 11:56:25 PST 2005


darin       05/12/19 11:56:25

  Modified:    .        ChangeLog
               DumpRenderTree DumpRenderTree.m
  Log:
          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.
  
  Revision  Changes    Path
  1.131     +16 -0     WebKitTools/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebKitTools/ChangeLog,v
  retrieving revision 1.130
  retrieving revision 1.131
  diff -u -r1.130 -r1.131
  --- ChangeLog	16 Dec 2005 02:21:27 -0000	1.130
  +++ ChangeLog	19 Dec 2005 19:56:24 -0000	1.131
  @@ -1,3 +1,19 @@
  +2005-12-19  Darin Adler  <darin at 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 at apple.com>
   
           Reviewed by Tim Hatcher.
  
  
  
  1.21      +35 -12    WebKitTools/DumpRenderTree/DumpRenderTree.m
  
  Index: DumpRenderTree.m
  ===================================================================
  RCS file: /cvs/root/WebKitTools/DumpRenderTree/DumpRenderTree.m,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- DumpRenderTree.m	28 Nov 2005 22:16:15 -0000	1.20
  +++ DumpRenderTree.m	19 Dec 2005 19:56:25 -0000	1.21
  @@ -26,15 +26,10 @@
    * 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>
  @@ -42,12 +37,18 @@
   
   #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"
   
  + at interface DumpRenderTreePasteboard : NSPasteboard
  + at end
  +
   @interface WaitUntilDoneDelegate : NSObject
   @end
   
  @@ -80,11 +81,14 @@
   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;
       
  @@ -144,10 +148,12 @@
           }
       
       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];
  @@ -190,7 +196,11 @@
       [delegate release];
       [editingDelegate release];
   
  +    [localPasteboard releaseGlobally];
  +    localPasteboard = nil;
  +    
       [pool release];
  +
       return 0;
   }
   
  @@ -497,7 +507,7 @@
   - (void)mouseDown
   {
       [[[frame frameView] documentView] layout];
  -    if(GetCurrentEventTime() - lastClick >= 1)
  +    if (GetCurrentEventTime() - lastClick >= 1)
           clickCount = 1;
       else
           clickCount++;
  @@ -542,13 +552,14 @@
   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;
       }
  @@ -571,11 +582,13 @@
           [[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];
  @@ -591,3 +604,13 @@
   
       return [NSString stringWithUTF8String:hex];
   }
  +
  + at implementation DumpRenderTreePasteboard
  +
  +// Return a local pasteboard so we don't disturb the real pasteboard when running tests.
  ++ (NSPasteboard *)generalPasteboard
  +{
  +    return localPasteboard;
  +}
  +
  + at end
  
  
  



More information about the webkit-changes mailing list