diff --git a/ext/jasmine-webkit-specrunner/Test/Page_test.cpp b/ext/jasmine-webkit-specrunner/Test/Page_test.cpp index c4e1ff7..fd0c288 100644 --- a/ext/jasmine-webkit-specrunner/Test/Page_test.cpp +++ b/ext/jasmine-webkit-specrunner/Test/Page_test.cpp @@ -1,36 +1,43 @@ -#include -#include -#include +#include #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 ¬e, const QString &msg) { + void PageTest::internalLog(const QString ¬e, 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(""); - 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(""); + QVERIFY(!internalLogCalled); + } + + void PageTest::testJavaScriptConsoleMessage() { + connect(&page, SIGNAL(consoleLog(QString, int, QString)), this, SLOT(consoleLog(QString, int, QString))); + consoleLogCalled = false; + + page.mainFrame()->setHtml(""); + QVERIFY(consoleLogCalled); } } -HeadlessSpecRunner::PageTest *one = new HeadlessSpecRunner::PageTest(); - diff --git a/ext/jasmine-webkit-specrunner/Test/Page_test.h b/ext/jasmine-webkit-specrunner/Test/Page_test.h index 4d344cf..7df1587 100644 --- a/ext/jasmine-webkit-specrunner/Test/Page_test.h +++ b/ext/jasmine-webkit-specrunner/Test/Page_test.h @@ -1,34 +1,29 @@ #ifndef JHW_TEST_PAGE #define JHW_TEST_PAGE -#include -#include -#include +#include #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 ¬e, 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 ¬e, const QString &msg); + void consoleLog(const QString &message, int lineNumber, const QString &source); void testJavaScriptConfirmWithLog(); + void testJavaScriptConfirmWithoutLog(); + void testJavaScriptConsoleMessage(); }; } #endif + diff --git a/ext/jasmine-webkit-specrunner/extconf.rb b/ext/jasmine-webkit-specrunner/extconf.rb index df888d3..d7e6907 100644 --- a/ext/jasmine-webkit-specrunner/extconf.rb +++ b/ext/jasmine-webkit-specrunner/extconf.rb @@ -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') diff --git a/ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner-test b/ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner-test index 8c4ca1a..897d9f4 100755 Binary files a/ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner-test and b/ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner-test differ diff --git a/ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner.pro b/ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner.pro new file mode 100644 index 0000000..e6710d1 --- /dev/null +++ b/ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner.pro @@ -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 diff --git a/ext/jasmine-webkit-specrunner/specrunner_test.cpp b/ext/jasmine-webkit-specrunner/specrunner_test.cpp new file mode 100644 index 0000000..08689cc --- /dev/null +++ b/ext/jasmine-webkit-specrunner/specrunner_test.cpp @@ -0,0 +1,10 @@ +#include "Test/Page_test.h" +#include + +QTEST_MAIN +int main(int argc, char *argv[]) { + QCoreApplication app(argc, argv); + HeadlessSpecRunner::PageTest pageTest; + QTest::qExec(&pageTest); +} + diff --git a/ext/jasmine-webkit-specrunner/specrunner_test.pro b/ext/jasmine-webkit-specrunner/specrunner_test.pro index f1ccd70..9a4f921 100644 --- a/ext/jasmine-webkit-specrunner/specrunner_test.pro +++ b/ext/jasmine-webkit-specrunner/specrunner_test.pro @@ -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 - diff --git a/lib/qt/qmake.rb b/lib/qt/qmake.rb index e4315ed..6f484da 100644 --- a/lib/qt/qmake.rb +++ b/lib/qt/qmake.rb @@ -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