Changeset 53526 in webkit


Ignore:
Timestamp:
Jan 20, 2010 12:20:59 AM (14 years ago)
Author:
vestbo@webkit.org
Message:

[Qt] Don't use QSocketNotifier in the DRT for reading stdin

Reviewed by Simon Hausmann.

QSocketNotifier is not available on Windows. Instead we read
stdin synchronously after each test using signals and slots.

  • DumpRenderTree/qt/DumpRenderTreeQt.cpp:
  • DumpRenderTree/qt/DumpRenderTreeQt.h:
  • DumpRenderTree/qt/main.cpp:
Location:
trunk/WebKitTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r53518 r53526  
     12010-01-19  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] Don't use QSocketNotifier in the DRT for reading stdin
     6
     7        QSocketNotifier is not available on Windows. Instead we read
     8        stdin synchronously after each test using signals and slots.
     9
     10        * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
     11        * DumpRenderTree/qt/DumpRenderTreeQt.h:
     12        * DumpRenderTree/qt/main.cpp:
     13
    1142010-01-19  Adam Barth  <abarth@webkit.org>
    215
  • trunk/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp

    r53281 r53526  
    311311    : m_dumpPixels(false)
    312312    , m_stdin(0)
    313     , m_notifier(0)
    314313    , m_enableTextOutput(false)
     314    , m_singleFileMode(false)
    315315{
    316316    qt_drt_overwritePluginDirectories();
     
    360360    delete m_mainView;
    361361    delete m_stdin;
    362     delete m_notifier;
    363 }
    364 
    365 void DumpRenderTree::open()
    366 {
    367     if (!m_stdin) {
    368         m_stdin = new QFile;
    369         m_stdin->open(stdin, QFile::ReadOnly);
    370     }
    371 
    372     if (!m_notifier) {
    373         m_notifier = new QSocketNotifier(STDIN_FILENO, QSocketNotifier::Read);
    374         connect(m_notifier, SIGNAL(activated(int)), this, SLOT(readStdin(int)));
    375     }
    376362}
    377363
     
    459445}
    460446
    461 void DumpRenderTree::readStdin(int /* socket */)
    462 {
    463     // Read incoming data from stdin...
    464     QByteArray line = m_stdin->readLine();
    465     if (line.endsWith('\n'))
    466         line.truncate(line.size()-1);
    467     //fprintf(stderr, "\n    opening %s\n", line.constData());
    468     if (line.isEmpty())
    469         quit();
    470 
    471     if (line.startsWith("http:") || line.startsWith("https:"))
     447void DumpRenderTree::readLine()
     448{
     449    if (!m_stdin) {
     450        m_stdin = new QFile;
     451        m_stdin->open(stdin, QFile::ReadOnly);
     452
     453        if (!m_stdin->isReadable()) {
     454            emit quit();
     455            return;
     456        }
     457    }
     458
     459    QByteArray line = m_stdin->readLine().trimmed();
     460
     461    if (line.isEmpty()) {
     462        emit quit();
     463        return;
     464    }
     465
     466    processLine(QString::fromLocal8Bit(line.constData(), line.length()));
     467}
     468
     469void DumpRenderTree::processLine(const QString &input)
     470{
     471    QString line = input;
     472
     473    if (line.startsWith(QLatin1String("http:"))
     474            || line.startsWith(QLatin1String("https:"))
     475            || line.startsWith(QLatin1String("file:"))) {
    472476        open(QUrl(line));
    473     else {
     477    } else {
    474478        QFileInfo fi(line);
     479
     480        if (!fi.exists()) {
     481            QDir currentDir = QDir::currentPath();
     482
     483            // Try to be smart about where the test is located
     484            if (currentDir.dirName() == QLatin1String("LayoutTests"))
     485                fi = QFileInfo(currentDir, line.replace(QRegExp(".*?LayoutTests/(.*)"), "\\1"));
     486            else if (!line.contains(QLatin1String("LayoutTests")))
     487                fi = QFileInfo(currentDir, line.prepend(QLatin1String("LayoutTests/")));
     488
     489            if (!fi.exists()) {
     490                if (isSingleFileMode())
     491                    emit quit();
     492                else
     493                    emit ready();
     494
     495                return;
     496            }
     497
     498        }
     499
    475500        open(QUrl::fromLocalFile(fi.absoluteFilePath()));
    476501    }
     
    618643    QWebFrame *mainFrame = m_page->mainFrame();
    619644
    620     //fprintf(stderr, "    Dumping\n");
    621     if (!m_notifier) {
    622         // Dump markup in single file mode...
     645    if (isSingleFileMode()) {
    623646        QString markup = mainFrame->toHtml();
    624647        fprintf(stdout, "Source:\n\n%s\n", markup.toUtf8().constData());
     
    698721    fflush(stderr);
    699722
    700     if (!m_notifier)
    701         quit(); // Exit now in single file mode...
     723    if (isSingleFileMode())
     724        emit quit();
     725    else
     726        emit ready();
    702727}
    703728
  • trunk/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h

    r52611 r53526  
    6969    virtual ~DumpRenderTree();
    7070
    71     // Initialize in multi-file mode, used by run-webkit-tests.
    72     void open();
    73 
    7471    // Initialize in single-file mode.
    7572    void open(const QUrl& url);
     
    7774    void setTextOutputEnabled(bool enable) { m_enableTextOutput = enable; }
    7875    bool isTextOutputEnabled() { return m_enableTextOutput; }
     76
     77    void setSingleFileMode(bool flag) { m_singleFileMode = flag; }
     78    bool isSingleFileMode() { return m_singleFileMode; }
    7979
    8080    void setDumpPixels(bool);
     
    101101public Q_SLOTS:
    102102    void initJSObjects();
    103     void readStdin(int);
     103
     104    void readLine();
     105    void processLine(const QString&);
     106
    104107    void dump();
    105108    void titleChanged(const QString &s);
     
    110113Q_SIGNALS:
    111114    void quit();
     115    void ready();
    112116
    113117private:
     
    127131
    128132    QFile *m_stdin;
    129     QSocketNotifier* m_notifier;
    130133
    131134    QList<QObject*> windows;
    132135    bool m_enableTextOutput;
     136    bool m_singleFileMode;
    133137};
    134138
  • trunk/WebKitTools/DumpRenderTree/qt/main.cpp

    r52150 r53526  
    4141#include <qwebdatabase.h>
    4242#include <qdesktopservices.h>
     43#include <qtimer.h>
    4344#include <qwindowsstyle.h>
    4445
     
    134135    QStringList args = app.arguments();
    135136    if (args.count() < 2) {
    136         qDebug() << "Usage: DumpRenderTree [-v] filename";
     137        qDebug() << "Usage: DumpRenderTree [-v|--pixel-tests] filename";
    137138        exit(0);
    138139    }
    139140
    140     // supress debug output from Qt if not started with -v
     141    // Suppress debug output from Qt if not started with -v
    141142    if (!args.contains(QLatin1String("-v")))
    142143        qInstallMsgHandler(messageHandler);
     
    144145    WebCore::DumpRenderTree dumper;
    145146
    146     if (args.contains("--pixel-tests"))
     147    if (args.contains(QLatin1String("--pixel-tests")))
    147148        dumper.setDumpPixels(true);
    148149
     
    151152    QWebDatabase::removeAllDatabases();
    152153
    153     if (args.last() == QLatin1String("-")) {
    154         dumper.open();
     154    if (args.contains(QLatin1String("-"))) {
     155        QObject::connect(&dumper, SIGNAL(ready()), &dumper, SLOT(readLine()), Qt::QueuedConnection);
     156        QTimer::singleShot(0, &dumper, SLOT(readLine()));
    155157    } else {
    156         if (!args.last().startsWith("/")
    157             && !args.last().startsWith("file:")
    158             && !args.last().startsWith("http:")
    159             && !args.last().startsWith("https:")) {
    160             QString path = QDir::currentPath();
    161             if (!path.endsWith('/'))
    162                 path.append('/');
    163             args.last().prepend(path);
     158        dumper.setSingleFileMode(true);
     159        for (int i = 1; i < args.size(); ++i) {
     160            if (!args.at(i).startsWith('-')) {
     161                dumper.processLine(args.at(i));
     162                break;
     163            }
    164164        }
    165         dumper.open(QUrl(args.last()));
    166165    }
     166
    167167    return app.exec();
     168
    168169#ifdef Q_WS_X11
    169170    FcConfigSetCurrent(0);
Note: See TracChangeset for help on using the changeset viewer.