Esempio n. 1
0
void Browser::loadFinished(bool ok) {
    QUrl current_url(page->currentFrame()->baseUrl());

    // events trottling
    if (current_url == this->last_url)
    {
        qDebug() << this << QString("%1, loadFinished trottled.").arg(QDateTime::currentDateTime().toTime_t());
        return;
    }

    this->last_url = current_url;

    qDebug() << this << QString("%1, '%2', %3 ms.").arg(QDateTime::currentDateTime().toTime_t()).arg(current_url.toString()).arg(page_load_time.elapsed());

    if (!ok) {
        emit(errorHappened(page_load_time.elapsed(), page->currentFrame()->baseUrl()));
        restartTest(QString("its not ok, something wrong happened! (possibly 500) URL: %1").arg(page->currentFrame()->baseUrl().toString()));
        return;
     }

    QWebElement document= page->currentFrame()->documentElement();

    if (page->currentFrame()->baseUrl().host() != base_url.host())
    {
       restartTest("We've got outside the test site. Restarting.");
       return;
    }


    QWebElementCollection collection = document.findAll("a[href]");
    QWebElement link; QString link_href;

    if (collection.count() == 0)
    {
        restartTest("No links found on page. Restarting.");
        return;
    }

    // Ignoring javascript and empty links
    do
    {
       link = collection.at(qrand()%collection.count());
       link_href = link.attribute("href");
    }
    while ((link_href.count() == 0) || (link_href.at(0) == '#') || (link_href.contains("javascript:;")));

    emit(pageLoaded(page_load_time.elapsed(), page->currentFrame()->baseUrl()));

    link.evaluateJavaScript("var evObj = document.createEvent('MouseEvents');evObj.initEvent( 'click', true, true );this.dispatchEvent(evObj);");

    page_load_time.start();
    timeout_countdown->start();
}
Esempio n. 2
0
void MultiSceneTest::restartCallback(Object *sender)
{
    auto s = new NewRendererTestScene();
    s->addChild(restartTest());

    Director::getInstance()->replaceScene(s);
    s->release();
}
void BillBoardTest::restartCallback(Ref* sender)
{
    auto s = new (std::nothrow) BillBoardTestScene();
    s->addChild(restartTest());

    Director::getInstance()->replaceScene(s);
    s->release();
}
Esempio n. 4
0
void Browser::linkClicked(const QUrl & url) {
    restartTest(QString("We've got some problem - unknown link click handled! Link: ").append(url.toString()));
}
Esempio n. 5
0
void Browser::restartByTimer() {
    restartTest("Restarting by timer.");
}
Esempio n. 6
0
void Browser::start() {
    restartTest();
}