trying stuff

This commit is contained in:
John Bintz 2011-08-02 15:47:14 -04:00
parent 22577e0fdc
commit 370eb182d8
8 changed files with 83 additions and 47 deletions

View File

@ -1,36 +1,43 @@
#include <QtGui>
#include <QtWebKit>
#include <unit++.h>
#include <QtTest/QtTest>
#include "HeadlessSpecRunner/Page.h"
#include "Test/Page_test.h"
using namespace unitpp;
namespace HeadlessSpecRunner {
PageTestHelper::PageTestHelper() : QObject(), internalLogCalled(false) {}
void PageTestHelper::addPage(HeadlessSpecRunner::Page &page) {
connect(&page, SIGNAL(internalLog(QString, QString)), this, SLOT(internalLog(QString, QString)));
PageTest::PageTest() : QObject(), internalLogCalled(false) {
}
void PageTestHelper::internalLog(const QString &note, const QString &msg) {
void PageTest::internalLog(const QString &note, const QString &msg) {
internalLogCalled = true;
}
PageTest::PageTest() : suite("suite") {
add("test", testcase(this, "test", &HeadlessSpecRunner::PageTest::testJavaScriptConfirmWithLog));
suite::main().add("test", this);
void PageTest::consoleLog(const QString &message, int lineNumber, const QString &source) {
consoleLogCalled = true;
}
void PageTest::testJavaScriptConfirmWithLog() {
helper.addPage(page);
helper.internalLogCalled = false;
connect(&page, SIGNAL(internalLog(QString, QString)), this, SLOT(internalLog(QString, QString)));
internalLogCalled = false;
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();

View File

@ -1,34 +1,29 @@
#ifndef JHW_TEST_PAGE
#define JHW_TEST_PAGE
#include <QtGui>
#include <QtWebKit>
#include <unit++.h>
#include <QtTest/QtTest>
#include "HeadlessSpecRunner/Page.h"
using namespace unitpp;
namespace HeadlessSpecRunner {
class PageTestHelper : public QObject {
class PageTest : public QObject {
Q_OBJECT
public:
PageTestHelper();
bool internalLogCalled;
void addPage(HeadlessSpecRunner::Page &page);
public slots:
void internalLog(const QString &note, const QString &msg);
};
class PageTest : public suite {
public:
PageTest();
HeadlessSpecRunner::Page page;
HeadlessSpecRunner::PageTestHelper helper;
private:
bool internalLogCalled;
bool consoleLogCalled;
HeadlessSpecRunner::Page page;
private slots:
void internalLog(const QString &note, const QString &msg);
void consoleLog(const QString &message, int lineNumber, const QString &source);
void testJavaScriptConfirmWithLog();
void testJavaScriptConfirmWithoutLog();
void testJavaScriptConsoleMessage();
};
}
#endif

View File

@ -4,5 +4,7 @@ $: << File.expand_path("../../../lib", __FILE__)
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')

View 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

View 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);
}

View File

@ -3,16 +3,14 @@ CONFIG -= app_bundle
TARGET = jasmine-webkit-specrunner-test
SOURCES = HeadlessSpecRunner/Page.cpp \
HeadlessSpecRunner/Runner.cpp \
Test/Page_test.cpp
Test/Page_test.cpp \
specrunner_test.cpp
HEADERS = HeadlessSpecRunner/Page.h \
HeadlessSpecRunner/Runner.h \
Test/Page_test.h
QT += network webkit
QT += network webkit testlib
QMAKE_INFO_PLIST = Info.plist
QMAKESPEC = macx-gcc
LIBS += -L/Users/john/Projects/unit++/lib -lunit++
INCLUDEPATH += /Users/john/Projects/unit++/include

View File

@ -16,24 +16,29 @@ module Qt
make_path != nil
end
def command
case platform
def command(project_file = nil)
spec = (case platform
when :linux
"#{path} -spec linux-g++"
when :freebsd
"#{path} -spec freebsd-g++"
when :mac_os_x
"#{path} -spec macx-g++"
end
end)
command = "#{path} -spec #{spec}"
command << " #{project_file}" if project_file
command
end
def make!(name)
def make!(name, project_file = nil)
@name = name
check_make!
check_qmake!
system command
system command(project_file)
system %{make}
end