jasmine-headless-webkit/ext/jasmine-webkit-specrunner/_old/Page_test.cpp

44 lines
1.2 KiB
C++
Raw Normal View History

2011-08-02 19:47:14 +00:00
#include <QtTest/QtTest>
2011-08-02 14:20:18 +00:00
2011-08-03 16:26:39 +00:00
#include "Page.h"
#include "Page_test.h"
2011-08-02 14:20:18 +00:00
2011-08-02 19:47:14 +00:00
PageTest::PageTest() : QObject(), internalLogCalled(false) {
2011-08-02 14:20:18 +00:00
}
void PageTest::internalLog(const QString &, const QString &) {
2011-08-02 14:20:18 +00:00
internalLogCalled = true;
}
void PageTest::consoleLog(const QString &, int, const QString &) {
2011-08-02 19:47:14 +00:00
consoleLogCalled = true;
2011-08-02 14:20:18 +00:00
}
void PageTest::testJavaScriptConfirmWithLog() {
2011-08-02 19:47:14 +00:00
connect(&page, SIGNAL(internalLog(QString, QString)), this, SLOT(internalLog(QString, QString)));
internalLogCalled = false;
2011-08-02 14:20:18 +00:00
page.mainFrame()->setHtml("<script>confirm('test')</script>");
2011-08-02 19:47:14 +00:00
QVERIFY(internalLogCalled);
2011-08-02 14:20:18 +00:00
}
2011-08-02 19:47:14 +00:00
void PageTest::testJavaScriptConfirmWithoutLog() {
connect(&page, SIGNAL(internalLog(QString, QString)), this, SLOT(internalLog(QString, QString)));
internalLogCalled = false;
page.oneFalseConfirm();
page.mainFrame()->setHtml("<script>confirm('test')</script>");
QVERIFY(!internalLogCalled);
}
void PageTest::testJavaScriptConsoleMessage() {
connect(&page, SIGNAL(consoleLog(QString, int, QString)), this, SLOT(consoleLog(QString, int, QString)));
consoleLogCalled = false;
page.mainFrame()->setHtml("<script>cats();</script>");
QVERIFY(consoleLogCalled);
}
2011-08-02 14:20:18 +00:00
2011-08-30 19:59:09 +00:00
QTEST_MAIN(PageTest);
2011-08-03 16:26:39 +00:00