trying stuff
This commit is contained in:
parent
22577e0fdc
commit
370eb182d8
@ -1,36 +1,43 @@
|
|||||||
#include <QtGui>
|
#include <QtTest/QtTest>
|
||||||
#include <QtWebKit>
|
|
||||||
#include <unit++.h>
|
|
||||||
|
|
||||||
#include "HeadlessSpecRunner/Page.h"
|
#include "HeadlessSpecRunner/Page.h"
|
||||||
#include "Test/Page_test.h"
|
#include "Test/Page_test.h"
|
||||||
|
|
||||||
using namespace unitpp;
|
|
||||||
|
|
||||||
namespace HeadlessSpecRunner {
|
namespace HeadlessSpecRunner {
|
||||||
PageTestHelper::PageTestHelper() : QObject(), internalLogCalled(false) {}
|
PageTest::PageTest() : QObject(), internalLogCalled(false) {
|
||||||
|
|
||||||
void PageTestHelper::addPage(HeadlessSpecRunner::Page &page) {
|
|
||||||
connect(&page, SIGNAL(internalLog(QString, QString)), this, SLOT(internalLog(QString, QString)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageTestHelper::internalLog(const QString ¬e, const QString &msg) {
|
void PageTest::internalLog(const QString ¬e, const QString &msg) {
|
||||||
internalLogCalled = true;
|
internalLogCalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PageTest::PageTest() : suite("suite") {
|
void PageTest::consoleLog(const QString &message, int lineNumber, const QString &source) {
|
||||||
add("test", testcase(this, "test", &HeadlessSpecRunner::PageTest::testJavaScriptConfirmWithLog));
|
consoleLogCalled = true;
|
||||||
suite::main().add("test", this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageTest::testJavaScriptConfirmWithLog() {
|
void PageTest::testJavaScriptConfirmWithLog() {
|
||||||
helper.addPage(page);
|
connect(&page, SIGNAL(internalLog(QString, QString)), this, SLOT(internalLog(QString, QString)));
|
||||||
helper.internalLogCalled = false;
|
internalLogCalled = false;
|
||||||
|
|
||||||
page.mainFrame()->setHtml("<script>confirm('test')</script>");
|
page.mainFrame()->setHtml("<script>confirm('test')</script>");
|
||||||
assert_true("internal log called", helper.internalLogCalled);
|
QVERIFY(internalLogCalled);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HeadlessSpecRunner::PageTest *one = new HeadlessSpecRunner::PageTest();
|
|
||||||
|
|
||||||
|
@ -1,34 +1,29 @@
|
|||||||
#ifndef JHW_TEST_PAGE
|
#ifndef JHW_TEST_PAGE
|
||||||
#define JHW_TEST_PAGE
|
#define JHW_TEST_PAGE
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtTest/QtTest>
|
||||||
#include <QtWebKit>
|
|
||||||
#include <unit++.h>
|
|
||||||
|
|
||||||
#include "HeadlessSpecRunner/Page.h"
|
#include "HeadlessSpecRunner/Page.h"
|
||||||
|
|
||||||
using namespace unitpp;
|
|
||||||
|
|
||||||
namespace HeadlessSpecRunner {
|
namespace HeadlessSpecRunner {
|
||||||
class PageTestHelper : public QObject {
|
class PageTest : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
|
||||||
PageTestHelper();
|
|
||||||
bool internalLogCalled;
|
|
||||||
void addPage(HeadlessSpecRunner::Page &page);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void internalLog(const QString ¬e, const QString &msg);
|
|
||||||
};
|
|
||||||
|
|
||||||
class PageTest : public suite {
|
|
||||||
public:
|
public:
|
||||||
PageTest();
|
PageTest();
|
||||||
HeadlessSpecRunner::Page page;
|
|
||||||
HeadlessSpecRunner::PageTestHelper helper;
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool internalLogCalled;
|
||||||
|
bool consoleLogCalled;
|
||||||
|
HeadlessSpecRunner::Page page;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void internalLog(const QString ¬e, const QString &msg);
|
||||||
|
void consoleLog(const QString &message, int lineNumber, const QString &source);
|
||||||
void testJavaScriptConfirmWithLog();
|
void testJavaScriptConfirmWithLog();
|
||||||
|
void testJavaScriptConfirmWithoutLog();
|
||||||
|
void testJavaScriptConsoleMessage();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4,5 +4,7 @@ $: << File.expand_path("../../../lib", __FILE__)
|
|||||||
|
|
||||||
require 'qt/qmake'
|
require 'qt/qmake'
|
||||||
|
|
||||||
Qt::Qmake.make!('jasmine-headless-webkit')
|
Qt::Qmake.make!('jasmine-headless-webkit tests', 'specrunner_test.pro')
|
||||||
|
system %{jasmine-webkit-specrunner-test}
|
||||||
|
Qt::Qmake.make!('jasmine-headless-webkit', 'specrunner.pro')
|
||||||
|
|
||||||
|
Binary file not shown.
19
ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner.pro
Normal file
19
ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner.pro
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
######################################################################
|
||||||
|
# Automatically generated by qmake (2.01a) Tue Aug 2 10:37:48 2011
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
TARGET =
|
||||||
|
DEPENDPATH += . HeadlessSpecRunner Test
|
||||||
|
INCLUDEPATH += . HeadlessSpecRunner Test
|
||||||
|
|
||||||
|
# Input
|
||||||
|
HEADERS += HeadlessSpecRunner/ConsoleOutput.h \
|
||||||
|
HeadlessSpecRunner/Page.h \
|
||||||
|
HeadlessSpecRunner/Runner.h \
|
||||||
|
Test/Page_test.h
|
||||||
|
SOURCES += specrunner.cpp \
|
||||||
|
HeadlessSpecRunner/ConsoleOutput.cpp \
|
||||||
|
HeadlessSpecRunner/Page.cpp \
|
||||||
|
HeadlessSpecRunner/Runner.cpp \
|
||||||
|
Test/Page_test.cpp
|
10
ext/jasmine-webkit-specrunner/specrunner_test.cpp
Normal file
10
ext/jasmine-webkit-specrunner/specrunner_test.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include "Test/Page_test.h"
|
||||||
|
#include <QTest>
|
||||||
|
|
||||||
|
QTEST_MAIN
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
QCoreApplication app(argc, argv);
|
||||||
|
HeadlessSpecRunner::PageTest pageTest;
|
||||||
|
QTest::qExec(&pageTest);
|
||||||
|
}
|
||||||
|
|
@ -3,16 +3,14 @@ CONFIG -= app_bundle
|
|||||||
TARGET = jasmine-webkit-specrunner-test
|
TARGET = jasmine-webkit-specrunner-test
|
||||||
SOURCES = HeadlessSpecRunner/Page.cpp \
|
SOURCES = HeadlessSpecRunner/Page.cpp \
|
||||||
HeadlessSpecRunner/Runner.cpp \
|
HeadlessSpecRunner/Runner.cpp \
|
||||||
Test/Page_test.cpp
|
Test/Page_test.cpp \
|
||||||
|
specrunner_test.cpp
|
||||||
|
|
||||||
HEADERS = HeadlessSpecRunner/Page.h \
|
HEADERS = HeadlessSpecRunner/Page.h \
|
||||||
HeadlessSpecRunner/Runner.h \
|
HeadlessSpecRunner/Runner.h \
|
||||||
Test/Page_test.h
|
Test/Page_test.h
|
||||||
|
|
||||||
QT += network webkit
|
QT += network webkit testlib
|
||||||
QMAKE_INFO_PLIST = Info.plist
|
QMAKE_INFO_PLIST = Info.plist
|
||||||
QMAKESPEC = macx-gcc
|
QMAKESPEC = macx-gcc
|
||||||
|
|
||||||
LIBS += -L/Users/john/Projects/unit++/lib -lunit++
|
|
||||||
INCLUDEPATH += /Users/john/Projects/unit++/include
|
|
||||||
|
|
||||||
|
@ -16,24 +16,29 @@ module Qt
|
|||||||
make_path != nil
|
make_path != nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def command
|
def command(project_file = nil)
|
||||||
case platform
|
|
||||||
|
spec = (case platform
|
||||||
when :linux
|
when :linux
|
||||||
"#{path} -spec linux-g++"
|
"#{path} -spec linux-g++"
|
||||||
when :freebsd
|
when :freebsd
|
||||||
"#{path} -spec freebsd-g++"
|
"#{path} -spec freebsd-g++"
|
||||||
when :mac_os_x
|
when :mac_os_x
|
||||||
"#{path} -spec macx-g++"
|
"#{path} -spec macx-g++"
|
||||||
end
|
end)
|
||||||
|
|
||||||
|
command = "#{path} -spec #{spec}"
|
||||||
|
command << " #{project_file}" if project_file
|
||||||
|
command
|
||||||
end
|
end
|
||||||
|
|
||||||
def make!(name)
|
def make!(name, project_file = nil)
|
||||||
@name = name
|
@name = name
|
||||||
|
|
||||||
check_make!
|
check_make!
|
||||||
check_qmake!
|
check_qmake!
|
||||||
|
|
||||||
system command
|
system command(project_file)
|
||||||
system %{make}
|
system %{make}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user