Changeset 66834 in webkit


Ignore:
Timestamp:
Sep 6, 2010 9:14:36 AM (14 years ago)
Author:
Martin Robinson
Message:

2010-09-06 Martin Robinson <mrobinson@igalia.com>

Reviewed by Xan Lopez.

[GTK] Small code cleanup in DumpRenderTreeGtk.cpp
https://bugs.webkit.org/show_bug.cgi?id=45213

  • DumpRenderTree/gtk/DumpRenderTree.cpp: (initializeFonts): Made this function do nothing for non-X11 platforms, so we don't have to surround the invocation with #ifdefs. (useLongRunningServerMode): Added. (runTestingServerLoop): Added. (initializeGlobalsFromCommandLineOptions): Added. (runTest): Removed ifdefs. (main): Use new helper functions.
Location:
trunk/WebKitTools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r66829 r66834  
     12010-09-06  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [GTK] Small code cleanup in DumpRenderTreeGtk.cpp
     6        https://bugs.webkit.org/show_bug.cgi?id=45213
     7
     8        * DumpRenderTree/gtk/DumpRenderTree.cpp:
     9        (initializeFonts): Made this function do nothing for non-X11 platforms, so we don't
     10        have to surround the invocation with #ifdefs.
     11        (useLongRunningServerMode): Added.
     12        (runTestingServerLoop): Added.
     13        (initializeGlobalsFromCommandLineOptions): Added.
     14        (runTest): Removed ifdefs.
     15        (main): Use new helper functions.
     16
    1172010-09-06  Martin Robinson  <mrobinson@igalia.com>
    218
  • trunk/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp

    r64082 r66834  
    9797const unsigned historyItemIndent = 8;
    9898
     99static void runTest(const string& testPathOrURL);
     100
    99101static bool shouldLogFrameLoadDelegates(const string& pathOrURL)
    100102{
     
    129131}
    130132
     133static void initializeFonts()
     134{
    131135#if PLATFORM(X11)
    132 static void initializeFonts()
    133 {
    134136    static int numFonts = -1;
     137
     138    FcInit();
    135139
    136140    // Some tests may add or remove fonts via the @font-face rule.
     
    161165    appFontSet = FcConfigGetFonts(config, FcSetApplication);
    162166    numFonts = appFontSet->nfont;
    163 }
    164167#endif
     168}
    165169
    166170static gchar* dumpFramesAsText(WebKitWebFrame* frame)
     
    358362}
    359363
     364static bool useLongRunningServerMode(int argc, char *argv[])
     365{
     366    // This assumes you've already called getopt_long
     367    return (argc == optind+1 && !strcmp(argv[optind], "-"));
     368}
     369
     370static void runTestingServerLoop()
     371{
     372    // When DumpRenderTree runs in server mode, we just wait around for file names
     373    // to be passed to us and read each in turn, passing the results back to the client
     374    char filenameBuffer[2048];
     375    while (fgets(filenameBuffer, sizeof(filenameBuffer), stdin)) {
     376        char* newLineCharacter = strchr(filenameBuffer, '\n');
     377        if (newLineCharacter)
     378            *newLineCharacter = '\0';
     379
     380        if (!strlen(filenameBuffer))
     381            continue;
     382
     383        runTest(filenameBuffer);
     384    }
     385}
     386
     387static void initializeGlobalsFromCommandLineOptions(int argc, char *argv[])
     388{
     389    struct option options[] = {
     390        {"notree", no_argument, &dumpTree, false},
     391        {"pixel-tests", no_argument, &dumpPixels, true},
     392        {"tree", no_argument, &dumpTree, true},
     393        {NULL, 0, NULL, 0}
     394    };
     395   
     396    int option;
     397    while ((option = getopt_long(argc, (char * const *)argv, "", options, NULL)) != -1) {
     398        switch (option) {
     399        case '?': // unknown or ambiguous option
     400        case ':': // missing argument
     401            exit(1);
     402            break;
     403        }
     404    }
     405}
     406
     407
    360408void dump()
    361409{
     
    517565        g_object_ref(prevTestBFItem);
    518566
    519 #if PLATFORM(X11)
    520567    initializeFonts();
    521 #endif
    522568
    523569    // Focus the web view before loading the test to avoid focusing problems
     
    942988    g_log_set_default_handler(logHandler, 0);
    943989
    944 #if PLATFORM(X11)
    945     FcInit();
     990    initializeGlobalsFromCommandLineOptions(argc, argv);
    946991    initializeFonts();
    947 #endif
    948 
    949     struct option options[] = {
    950         {"notree", no_argument, &dumpTree, false},
    951         {"pixel-tests", no_argument, &dumpPixels, true},
    952         {"tree", no_argument, &dumpTree, true},
    953         {NULL, 0, NULL, 0}
    954     };
    955 
    956     int option;
    957     while ((option = getopt_long(argc, (char* const*)argv, "", options, NULL)) != -1)
    958         switch (option) {
    959             case '?':   // unknown or ambiguous option
    960             case ':':   // missing argument
    961                 exit(1);
    962                 break;
    963         }
    964992
    965993    window = gtk_window_new(GTK_WINDOW_POPUP);
     
    9811009    axController = new AccessibilityController();
    9821010
    983     if (argc == optind+1 && strcmp(argv[optind], "-") == 0) {
    984         char filenameBuffer[2048];
     1011    if (useLongRunningServerMode(argc, argv)) {
    9851012        printSeparators = true;
    986         while (fgets(filenameBuffer, sizeof(filenameBuffer), stdin)) {
    987             char* newLineCharacter = strchr(filenameBuffer, '\n');
    988             if (newLineCharacter)
    989                 *newLineCharacter = '\0';
    990 
    991             if (strlen(filenameBuffer) == 0)
    992                 continue;
    993 
    994             runTest(filenameBuffer);
    995         }
     1013        runTestingServerLoop();
    9961014    } else {
    9971015        printSeparators = (optind < argc-1 || (dumpPixels && dumpTree));
Note: See TracChangeset for help on using the changeset viewer.