Changeset 67942 in webkit


Ignore:
Timestamp:
Sep 21, 2010 4:25:54 AM (14 years ago)
Author:
jocelyn.turcotte@nokia.com
Message:

[Qt] Add robot loader timeout and extra time options.
https://bugs.webkit.org/show_bug.cgi?id=46172

Reviewed by Andreas Kling.

[-robot-timeout <s>]: Load the next page after s seconds if the current
page didn't finish loading.
[-robot-extra-time <s>]: Wait s seconds after the current page finished
loading before loading the next one. This should allow some time for the
page's JavaScript to execute.

  • QtTestBrowser/launcherwindow.cpp:

(LauncherWindow::applyPrefs):

  • QtTestBrowser/main.cpp:

(LauncherApplication::robotTimeout):
(LauncherApplication::robotExtraTime):
(LauncherApplication::LauncherApplication):
(LauncherApplication::handleUserOptions):
(main):

  • QtTestBrowser/urlloader.cpp:

(UrlLoader::UrlLoader):
(UrlLoader::loadNext):
(UrlLoader::loadUrlList):

  • QtTestBrowser/urlloader.h:
Location:
trunk/WebKitTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r67934 r67942  
     12010-09-21  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
     2
     3        Reviewed by Andreas Kling.
     4
     5        [Qt] Add robot loader timeout and extra time options.
     6        https://bugs.webkit.org/show_bug.cgi?id=46172
     7
     8        [-robot-timeout <s>]: Load the next page after s seconds if the current
     9        page didn't finish loading.
     10        [-robot-extra-time <s>]: Wait s seconds after the current page finished
     11        loading before loading the next one. This should allow some time for the
     12        page's JavaScript to execute.
     13
     14        * QtTestBrowser/launcherwindow.cpp:
     15        (LauncherWindow::applyPrefs):
     16        * QtTestBrowser/main.cpp:
     17        (LauncherApplication::robotTimeout):
     18        (LauncherApplication::robotExtraTime):
     19        (LauncherApplication::LauncherApplication):
     20        (LauncherApplication::handleUserOptions):
     21        (main):
     22        * QtTestBrowser/urlloader.cpp:
     23        (UrlLoader::UrlLoader):
     24        (UrlLoader::loadNext):
     25        (UrlLoader::loadUrlList):
     26        * QtTestBrowser/urlloader.h:
     27
    1282010-09-21  Pavel Podivilov  <podivilov@chromium.org>
    229
  • trunk/WebKitTools/QtTestBrowser/main.cpp

    r65792 r67942  
    5555    QStringList urls() const { return m_urls; }
    5656    bool isRobotized() const { return m_isRobotized; }
     57    int robotTimeout() const { return m_robotTimeoutSeconds; }
     58    int robotExtraTime() const { return m_robotExtraTimeSeconds; }
    5759
    5860private:
     
    6264private:
    6365    bool m_isRobotized;
     66    int m_robotTimeoutSeconds;
     67    int m_robotExtraTimeSeconds;
    6468    QStringList m_urls;
    6569};
     
    7983    : QApplication(argc, argv, QApplication::GuiServer)
    8084    , m_isRobotized(false)
     85    , m_robotTimeoutSeconds(0)
     86    , m_robotExtraTimeSeconds(0)
    8187{
    8288    // To allow QWebInspector's configuration persistence
     
    116122             << "[-show-fps]"
    117123             << "[-r list]"
     124             << "[-robot-timeout seconds]"
     125             << "[-robot-extra-time seconds]"
    118126             << "[-inspector-url location]"
    119127             << "[-tiled-backing-store]"
     
    191199        m_isRobotized = true;
    192200        m_urls = QStringList(listFile);
    193         return;
    194     }
    195 
    196     int lastArg = args.lastIndexOf(QRegExp("^-.*"));
    197     m_urls = (lastArg != -1) ? args.mid(++lastArg) : args.mid(1);
     201    } else {
     202        int lastArg = args.lastIndexOf(QRegExp("^-.*"));
     203        m_urls = (lastArg != -1) ? args.mid(++lastArg) : args.mid(1);
     204    }
     205
     206    int robotTimeoutIndex = args.indexOf("-robot-timeout");
     207    if (robotTimeoutIndex != -1)
     208        m_robotTimeoutSeconds = takeOptionValue(&args, robotTimeoutIndex).toInt();
     209
     210    int robotExtraTimeIndex = args.indexOf("-robot-extra-time");
     211    if (robotExtraTimeIndex != -1)
     212        m_robotExtraTimeSeconds = takeOptionValue(&args, robotExtraTimeIndex).toInt();
    198213}
    199214
     
    205220    if (app.isRobotized()) {
    206221        LauncherWindow* window = new LauncherWindow();
    207         UrlLoader loader(window->page()->mainFrame(), app.urls().at(0));
    208         QObject::connect(window->page()->mainFrame(), SIGNAL(loadFinished(bool)), &loader, SLOT(loadNext()));
     222        UrlLoader loader(window->page()->mainFrame(), app.urls().at(0), app.robotTimeout(), app.robotExtraTime());
    209223        loader.loadNext();
    210224        window->show();
  • trunk/WebKitTools/QtTestBrowser/urlloader.cpp

    r53862 r67942  
    3232#include <QDebug>
    3333
    34 UrlLoader::UrlLoader(QWebFrame* frame, const QString& inputFileName)
     34UrlLoader::UrlLoader(QWebFrame* frame, const QString& inputFileName, int timeoutSeconds, int extraTimeSeconds)
    3535    : m_frame(frame)
    3636    , m_stdOut(stdout)
    3737    , m_loaded(0)
    3838{
    39     init(inputFileName);
     39    if (timeoutSeconds) {
     40        m_timeoutTimer.setInterval(timeoutSeconds * 1000);
     41        m_timeoutTimer.setSingleShot(true);
     42        connect(frame, SIGNAL(loadStarted()), &m_timeoutTimer, SLOT(start()));
     43        connect(&m_timeoutTimer, SIGNAL(timeout()), this, SLOT(loadNext()));
     44    }
     45    if (extraTimeSeconds) {
     46        m_extraTimeTimer.setInterval(extraTimeSeconds * 1000);
     47        m_extraTimeTimer.setSingleShot(true);
     48        connect(frame, SIGNAL(loadFinished(bool)), &m_extraTimeTimer, SLOT(start()));
     49        connect(&m_extraTimeTimer, SIGNAL(timeout()), this, SLOT(loadNext()));
     50    } else
     51        connect(frame, SIGNAL(loadFinished(bool)), this, SLOT(loadNext()));
     52    loadUrlList(inputFileName);
    4053}
    4154
    4255void UrlLoader::loadNext()
    4356{
     57    m_timeoutTimer.stop();
     58    m_extraTimeTimer.stop();
    4459    QString qstr;
    4560    if (getUrl(qstr)) {
     
    5469}
    5570
    56 void UrlLoader::init(const QString& inputFileName)
     71void UrlLoader::loadUrlList(const QString& inputFileName)
    5772{
    5873    QFile inputFile(inputFileName);
  • trunk/WebKitTools/QtTestBrowser/urlloader.h

    r53862 r67942  
    3333
    3434#include <QTextStream>
     35#include <QTimer>
    3536#include <QVector>
    3637
     
    3940
    4041public:
    41     UrlLoader(QWebFrame* frame, const QString& inputFileName);
     42    UrlLoader(QWebFrame* frame, const QString& inputFileName, int timeoutSeconds, int extraTimeSeconds);
    4243
    4344public slots:
     
    4546
    4647private:
    47     void init(const QString& inputFileName);
     48    void loadUrlList(const QString& inputFileName);
    4849    bool getUrl(QString& qstr);
    4950
     
    5455    QTextStream m_stdOut;
    5556    int m_loaded;
     57    QTimer m_timeoutTimer;
     58    QTimer m_extraTimeTimer;
    5659};
    5760
Note: See TracChangeset for help on using the changeset viewer.