clean out the old cruft, getting really close
This commit is contained in:
parent
9289f97f16
commit
d9ade573c9
@ -1,149 +0,0 @@
|
||||
#include "ConsoleOutput.h"
|
||||
|
||||
ConsoleOutput::ConsoleOutput() : QObject(),
|
||||
showColors(false),
|
||||
consoleLogUsed(false) {
|
||||
outputIO = &std::cout;
|
||||
}
|
||||
|
||||
void ConsoleOutput::passed(const QString &specDetail) {
|
||||
green();
|
||||
*outputIO << '.';
|
||||
clear();
|
||||
outputIO->flush();
|
||||
|
||||
consoleLogUsed = false;
|
||||
successes.push(specDetail);
|
||||
}
|
||||
|
||||
void ConsoleOutput::failed(const QString &specDetail) {
|
||||
red();
|
||||
*outputIO << 'F';
|
||||
clear();
|
||||
outputIO->flush();
|
||||
|
||||
consoleLogUsed = false;
|
||||
failures.push(specDetail);
|
||||
}
|
||||
|
||||
void ConsoleOutput::green() {
|
||||
if (showColors) std::cout << "\033[0;32m";
|
||||
}
|
||||
|
||||
void ConsoleOutput::clear() {
|
||||
if (showColors) std::cout << "\033[m";
|
||||
}
|
||||
|
||||
void ConsoleOutput::red() {
|
||||
if (showColors) std::cout << "\033[0;31m";
|
||||
}
|
||||
|
||||
void ConsoleOutput::yellow()
|
||||
{
|
||||
if (showColors) std::cout << "\033[0;33m";
|
||||
}
|
||||
|
||||
void ConsoleOutput::errorLog(const QString &msg, int lineNumber, const QString &sourceID) {
|
||||
red();
|
||||
*outputIO << "[error] ";
|
||||
clear();
|
||||
*outputIO << qPrintable(sourceID) << ":" << lineNumber << " : " << qPrintable(msg);
|
||||
*outputIO << std::endl;
|
||||
}
|
||||
|
||||
void ConsoleOutput::internalLog(const QString ¬e, const QString &msg) {
|
||||
red();
|
||||
*outputIO << "[" << qPrintable(note) << "] ";
|
||||
clear();
|
||||
*outputIO << qPrintable(msg);
|
||||
*outputIO << std::endl;
|
||||
}
|
||||
|
||||
void ConsoleOutput::consoleLog(const QString &msg) {
|
||||
if (!consoleLogUsed) {
|
||||
*outputIO << std::endl;
|
||||
consoleLogUsed = true;
|
||||
}
|
||||
|
||||
green();
|
||||
*outputIO << "[console] ";
|
||||
if (msg.contains("\n"))
|
||||
*outputIO << std::endl;
|
||||
clear();
|
||||
*outputIO << qPrintable(msg);
|
||||
*outputIO << std::endl;
|
||||
}
|
||||
|
||||
void ConsoleOutput::logSpecFilename(const QString &name) {
|
||||
*outputIO << std::endl << std::endl;
|
||||
red();
|
||||
*outputIO << qPrintable(name) << std::endl;
|
||||
clear();
|
||||
}
|
||||
|
||||
void ConsoleOutput::logSpecResult(const QString &result) {
|
||||
QStringList lines = result.split("\n");
|
||||
QStringListIterator linesIterator(lines);
|
||||
|
||||
red();
|
||||
while (linesIterator.hasNext()) {
|
||||
QString line = linesIterator.next();
|
||||
if (!linesIterator.hasNext())
|
||||
yellow();
|
||||
*outputIO << " " << qPrintable(line) << std::endl;
|
||||
}
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
void ConsoleOutput::reportFailure(const QString &totalTests, const QString &failedTests, const QString &duration) {
|
||||
red();
|
||||
*outputIO << std::endl << "FAIL: ";
|
||||
formatTestResults(totalTests, failedTests, duration);
|
||||
*outputIO << std::endl;
|
||||
clear();
|
||||
}
|
||||
|
||||
void ConsoleOutput::reportSuccess(const QString &totalTests, const QString &failedTests, const QString &duration) {
|
||||
green();
|
||||
*outputIO << std::endl << "PASS: ";
|
||||
formatTestResults(totalTests, failedTests, duration);
|
||||
*outputIO << std::endl;
|
||||
clear();
|
||||
}
|
||||
|
||||
void ConsoleOutput::reportSuccessWithJSErrors(const QString &totalTests, const QString &failedTests, const QString &duration) {
|
||||
yellow();
|
||||
*outputIO << std::endl << "PASS with JS errors: ";
|
||||
formatTestResults(totalTests, failedTests, duration);
|
||||
*outputIO << std::endl;
|
||||
clear();
|
||||
}
|
||||
|
||||
void ConsoleOutput::formatTestResults(const QString &totalTests, const QString &failedTests, const QString &duration) {
|
||||
*outputIO << qPrintable(totalTests) << " ";
|
||||
if (totalTests == "1") {
|
||||
*outputIO << "test";
|
||||
} else {
|
||||
*outputIO << "tests";
|
||||
}
|
||||
|
||||
*outputIO << ", ";
|
||||
|
||||
*outputIO << qPrintable(failedTests) << " ";
|
||||
if (failedTests == "1") {
|
||||
*outputIO << "failure";
|
||||
} else {
|
||||
*outputIO << "failures";
|
||||
}
|
||||
|
||||
*outputIO << ", ";
|
||||
|
||||
*outputIO << qPrintable(duration) << " ";
|
||||
if (duration == "1") {
|
||||
*outputIO << "sec.";
|
||||
} else {
|
||||
*outputIO << "secs.";
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
#ifndef JHW_CONSOLE_OUTPUT
|
||||
#define JHW_CONSOLE_OUTPUT
|
||||
|
||||
#include <QObject>
|
||||
#include <iostream>
|
||||
#include <QStack>
|
||||
#include <QStringList>
|
||||
|
||||
class ConsoleOutput : public QObject {
|
||||
public:
|
||||
ConsoleOutput();
|
||||
|
||||
void passed(const QString &specDetail);
|
||||
void failed(const QString &specDetail);
|
||||
void errorLog(const QString &msg, int lineNumber, const QString &sourceID);
|
||||
void internalLog(const QString ¬e, const QString &msg);
|
||||
void consoleLog(const QString &msg);
|
||||
void logSpecFilename(const QString &name);
|
||||
void logSpecResult(const QString &result);
|
||||
|
||||
void reportFailure(const QString &totalTests, const QString &failedTests, const QString &duration);
|
||||
void reportSuccess(const QString &totalTests, const QString &failedTests, const QString &duration);
|
||||
void reportSuccessWithJSErrors(const QString &totalTests, const QString &failedTests, const QString &duration);
|
||||
|
||||
std::ostream *outputIO;
|
||||
QStack<QString> successes;
|
||||
QStack<QString> failures;
|
||||
|
||||
bool showColors;
|
||||
bool consoleLogUsed;
|
||||
private:
|
||||
void green();
|
||||
void clear();
|
||||
void red();
|
||||
void yellow();
|
||||
void formatTestResults(const QString &totalTests, const QString &failedTests, const QString &duration);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,129 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include "ConsoleOutput.h"
|
||||
#include "ConsoleOutput_test.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
ConsoleOutputTest::ConsoleOutputTest() : QObject() {}
|
||||
|
||||
void ConsoleOutputTest::testPassed() {
|
||||
stringstream buffer;
|
||||
ConsoleOutput output;
|
||||
|
||||
output.consoleLogUsed = true;
|
||||
output.outputIO = &buffer;
|
||||
output.passed("test");
|
||||
QVERIFY(buffer.str() == ".");
|
||||
QVERIFY(output.successes.size() == 1);
|
||||
QVERIFY(output.failures.size() == 0);
|
||||
QVERIFY(output.consoleLogUsed == false);
|
||||
}
|
||||
|
||||
void ConsoleOutputTest::testFailed() {
|
||||
stringstream buffer;
|
||||
ConsoleOutput output;
|
||||
|
||||
output.consoleLogUsed = true;
|
||||
output.outputIO = &buffer;
|
||||
output.failed("test");
|
||||
QVERIFY(buffer.str() == "F");
|
||||
QVERIFY(output.successes.size() == 0);
|
||||
QVERIFY(output.failures.size() == 1);
|
||||
QVERIFY(output.consoleLogUsed == false);
|
||||
}
|
||||
|
||||
void ConsoleOutputTest::testErrorLog() {
|
||||
stringstream buffer;
|
||||
ConsoleOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.errorLog("message", 1, "source");
|
||||
QVERIFY(buffer.str() == "[error] source:1 : message\n");
|
||||
}
|
||||
|
||||
void ConsoleOutputTest::testInternalLog() {
|
||||
stringstream buffer;
|
||||
ConsoleOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.internalLog("note", "message");
|
||||
QVERIFY(buffer.str() == "[note] message\n");
|
||||
}
|
||||
|
||||
void ConsoleOutputTest::testConsoleLog() {
|
||||
stringstream buffer;
|
||||
ConsoleOutput output;
|
||||
|
||||
output.consoleLogUsed = false;
|
||||
output.outputIO = &buffer;
|
||||
output.consoleLog("log");
|
||||
QVERIFY(buffer.str() == "\n[console] log\n");
|
||||
}
|
||||
|
||||
void ConsoleOutputTest::testConsoleLogUsed() {
|
||||
stringstream buffer;
|
||||
ConsoleOutput output;
|
||||
|
||||
output.consoleLogUsed = true;
|
||||
output.outputIO = &buffer;
|
||||
output.consoleLog("log");
|
||||
QVERIFY(buffer.str() == "[console] log\n");
|
||||
}
|
||||
|
||||
void ConsoleOutputTest::testLogSpecFilename() {
|
||||
stringstream buffer;
|
||||
ConsoleOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.logSpecFilename("whatever");
|
||||
QVERIFY(buffer.str() == "\n\nwhatever\n");
|
||||
}
|
||||
|
||||
void ConsoleOutputTest::testLogSpecResult() {
|
||||
stringstream buffer;
|
||||
ConsoleOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.logSpecResult("whatever");
|
||||
QVERIFY(buffer.str() == " whatever\n");
|
||||
}
|
||||
|
||||
void ConsoleOutputTest::testReportResultsFailedSingular() {
|
||||
stringstream buffer;
|
||||
ConsoleOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.reportFailure("1", "1", "1");
|
||||
QVERIFY(buffer.str() == "\nFAIL: 1 test, 1 failure, 1 sec.\n");
|
||||
}
|
||||
|
||||
void ConsoleOutputTest::testReportResultsFailedPlural() {
|
||||
stringstream buffer;
|
||||
ConsoleOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.reportFailure("2", "2", "2");
|
||||
QVERIFY(buffer.str() == "\nFAIL: 2 tests, 2 failures, 2 secs.\n");
|
||||
}
|
||||
|
||||
void ConsoleOutputTest::testReportResultsSucceeded() {
|
||||
stringstream buffer;
|
||||
ConsoleOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.reportSuccess("2", "2", "2");
|
||||
QVERIFY(buffer.str() == "\nPASS: 2 tests, 2 failures, 2 secs.\n");
|
||||
}
|
||||
|
||||
void ConsoleOutputTest::testReportResultsSucceededWithJSErrors() {
|
||||
stringstream buffer;
|
||||
ConsoleOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.reportSuccessWithJSErrors("2", "2", "2");
|
||||
QVERIFY(buffer.str() == "\nPASS with JS errors: 2 tests, 2 failures, 2 secs.\n");
|
||||
}
|
||||
|
||||
QTEST_MAIN(ConsoleOutputTest);
|
||||
|
@ -1,32 +0,0 @@
|
||||
#ifndef JHW_TEST_CONSOLE_OUTPUT
|
||||
#define JHW_TEST_CONSOLE_OUTPUT
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "ConsoleOutput.h"
|
||||
|
||||
class ConsoleOutputTest : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConsoleOutputTest();
|
||||
|
||||
private slots:
|
||||
void testPassed();
|
||||
void testFailed();
|
||||
void testErrorLog();
|
||||
void testInternalLog();
|
||||
void testConsoleLog();
|
||||
void testConsoleLogUsed();
|
||||
void testLogSpecFilename();
|
||||
void testLogSpecResult();
|
||||
|
||||
void testReportResultsFailedSingular();
|
||||
void testReportResultsFailedPlural();
|
||||
void testReportResultsSucceeded();
|
||||
void testReportResultsSucceededWithJSErrors();
|
||||
};
|
||||
|
||||
#endif
|
@ -1,7 +0,0 @@
|
||||
include(common.pri)
|
||||
include(test.pri)
|
||||
|
||||
SOURCES += ConsoleOutput_test.cpp
|
||||
HEADERS += ConsoleOutput_test.h
|
||||
|
||||
|
@ -1,54 +0,0 @@
|
||||
#include "ReportFileOutput.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
ReportFileOutput::ReportFileOutput() : QObject() {
|
||||
reset();
|
||||
}
|
||||
|
||||
void ReportFileOutput::reset() {
|
||||
buffer = new stringstream();
|
||||
|
||||
outputIO = buffer;
|
||||
}
|
||||
|
||||
void ReportFileOutput::passed(const QString &specDetail) {
|
||||
*outputIO << "PASS||" << qPrintable(specDetail) << std::endl;
|
||||
successes.push(specDetail);
|
||||
}
|
||||
|
||||
void ReportFileOutput::failed(const QString &specDetail) {
|
||||
*outputIO << "FAIL||" << qPrintable(specDetail) << std::endl;
|
||||
failures.push(specDetail);
|
||||
}
|
||||
|
||||
void ReportFileOutput::errorLog(const QString &msg, int lineNumber, const QString &sourceID) {
|
||||
*outputIO << "ERROR||" << qPrintable(msg) << "||" << qPrintable(sourceID) << ":" << lineNumber << std::endl;
|
||||
}
|
||||
|
||||
void ReportFileOutput::consoleLog(const QString &msg) {
|
||||
*outputIO << "CONSOLE||" << qPrintable(msg) << std::endl;
|
||||
}
|
||||
|
||||
void ReportFileOutput::internalLog(const QString &, const QString &) {}
|
||||
void ReportFileOutput::logSpecFilename(const QString &) {}
|
||||
void ReportFileOutput::logSpecResult(const QString &) {}
|
||||
|
||||
void ReportFileOutput::reportFailure(const QString &totalTests, const QString &failedTests, const QString &duration) {
|
||||
reportTotals(totalTests, failedTests, duration, false);
|
||||
}
|
||||
|
||||
void ReportFileOutput::reportSuccess(const QString &totalTests, const QString &failedTests, const QString &duration) {
|
||||
reportTotals(totalTests, failedTests, duration, false);
|
||||
}
|
||||
|
||||
void ReportFileOutput::reportSuccessWithJSErrors(const QString &totalTests, const QString &failedTests, const QString &duration) {
|
||||
reportTotals(totalTests, failedTests, duration, true);
|
||||
}
|
||||
|
||||
void ReportFileOutput::reportTotals(const QString &totalTests, const QString &failedTests, const QString &duration, bool hasJavaScriptError) {
|
||||
*outputIO << "TOTAL||" << qPrintable(totalTests) << "||" << qPrintable(failedTests) << "||" << qPrintable(duration) << "||";
|
||||
*outputIO << (hasJavaScriptError ? "T" : "F");
|
||||
*outputIO << std::endl;
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
#ifndef JHW_REPORT_FILE_OUTPUT
|
||||
#define JHW_REPORT_FILE_OUTPUT
|
||||
|
||||
#include <QObject>
|
||||
#include <iostream>
|
||||
#include <QStack>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class ReportFileOutput : public QObject {
|
||||
public:
|
||||
ReportFileOutput();
|
||||
|
||||
void passed(const QString &specDetail);
|
||||
void failed(const QString &specDetail);
|
||||
void errorLog(const QString &msg, int lineNumber, const QString &sourceID);
|
||||
void internalLog(const QString ¬e, const QString &msg);
|
||||
void consoleLog(const QString &msg);
|
||||
void logSpecFilename(const QString &name);
|
||||
void logSpecResult(const QString &result);
|
||||
|
||||
void reportFailure(const QString &totalTests, const QString &failedTests, const QString &duration);
|
||||
void reportSuccess(const QString &totalTests, const QString &failedTests, const QString &duration);
|
||||
void reportSuccessWithJSErrors(const QString &totalTests, const QString &failedTests, const QString &duration);
|
||||
|
||||
void reset();
|
||||
|
||||
stringstream *buffer;
|
||||
stringstream *outputIO;
|
||||
QStack<QString> successes;
|
||||
QStack<QString> failures;
|
||||
private:
|
||||
void reportTotals(const QString &totalTests, const QString &failedTests, const QString &duration, bool hasJavaScriptError);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,88 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include "ReportFileOutput.h"
|
||||
#include "ReportFileOutput_test.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
ReportFileOutputTest::ReportFileOutputTest() : QObject() {}
|
||||
|
||||
void ReportFileOutputTest::testPassed() {
|
||||
stringstream buffer;
|
||||
ReportFileOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.passed("test||done||file.js:23");
|
||||
QVERIFY(buffer.str() == "PASS||test||done||file.js:23\n");
|
||||
QVERIFY(output.successes.size() == 1);
|
||||
QVERIFY(output.failures.size() == 0);
|
||||
}
|
||||
|
||||
void ReportFileOutputTest::testFailed() {
|
||||
stringstream buffer;
|
||||
ReportFileOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.failed("test||done||file.js:23");
|
||||
QVERIFY(buffer.str() == "FAIL||test||done||file.js:23\n");
|
||||
QVERIFY(output.successes.size() == 0);
|
||||
QVERIFY(output.failures.size() == 1);
|
||||
}
|
||||
|
||||
void ReportFileOutputTest::testErrorLog() {
|
||||
stringstream buffer;
|
||||
ReportFileOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.errorLog("JS Error", 23, "file.js");
|
||||
QVERIFY(buffer.str() == "ERROR||JS Error||file.js:23\n");
|
||||
}
|
||||
|
||||
void ReportFileOutputTest::testConsoleLog() {
|
||||
stringstream buffer;
|
||||
ReportFileOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.consoleLog("Console");
|
||||
QVERIFY(buffer.str() == "CONSOLE||Console\n");
|
||||
}
|
||||
|
||||
void ReportFileOutputTest::testStubMethods() {
|
||||
stringstream buffer;
|
||||
ReportFileOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.internalLog("Internal", "Log");
|
||||
output.logSpecFilename("Filename");
|
||||
output.logSpecResult("REsult");
|
||||
}
|
||||
|
||||
void ReportFileOutputTest::testReportFailure() {
|
||||
stringstream buffer;
|
||||
ReportFileOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.reportFailure("5", "2", "1.5");
|
||||
QVERIFY(buffer.str() == "TOTAL||5||2||1.5||F\n");
|
||||
}
|
||||
|
||||
void ReportFileOutputTest::testReportSuccess() {
|
||||
stringstream buffer;
|
||||
ReportFileOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.reportSuccess("5", "0", "1.5");
|
||||
QVERIFY(buffer.str() == "TOTAL||5||0||1.5||F\n");
|
||||
}
|
||||
|
||||
void ReportFileOutputTest::testReportSuccessWithJSErrors() {
|
||||
stringstream buffer;
|
||||
ReportFileOutput output;
|
||||
|
||||
output.outputIO = &buffer;
|
||||
output.reportSuccessWithJSErrors("5", "0", "1.5");
|
||||
QVERIFY(buffer.str() == "TOTAL||5||0||1.5||T\n");
|
||||
}
|
||||
|
||||
QTEST_MAIN(ReportFileOutputTest);
|
||||
|
@ -1,26 +0,0 @@
|
||||
#ifndef JHW_TEST_REPORT_FILE_OUTPUT
|
||||
#define JHW_TEST_REPORT_FILE_OUTPUT
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "ReportFileOutput.h"
|
||||
|
||||
class ReportFileOutputTest : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ReportFileOutputTest();
|
||||
private slots:
|
||||
void testPassed();
|
||||
void testFailed();
|
||||
void testErrorLog();
|
||||
void testConsoleLog();
|
||||
void testStubMethods();
|
||||
void testReportFailure();
|
||||
void testReportSuccess();
|
||||
void testReportSuccessWithJSErrors();
|
||||
};
|
||||
|
||||
#endif
|
@ -1,7 +0,0 @@
|
||||
include(common.pri)
|
||||
include(test.pri)
|
||||
|
||||
SOURCES += ReportFileOutput_test.cpp
|
||||
HEADERS += ReportFileOutput_test.h
|
||||
|
||||
|
@ -92,6 +92,10 @@ void Runner::setColors(bool colors) {
|
||||
useColors = colors;
|
||||
}
|
||||
|
||||
void Runner::hasUsedConsole() {
|
||||
usedConsole = true;
|
||||
}
|
||||
|
||||
void Runner::reportFile(const QString &file) {
|
||||
reportFileName = file;
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ class Runner: public QObject {
|
||||
void timerPause();
|
||||
void timerDone();
|
||||
|
||||
void hasUsedConsole();
|
||||
|
||||
void print(const QString &fh, const QString &content);
|
||||
|
||||
void finishSuite();
|
||||
@ -35,8 +37,6 @@ class Runner: public QObject {
|
||||
void addJHW();
|
||||
void timerEvent();
|
||||
void handleError(const QString & message, int lineNumber, const QString & sourceID);
|
||||
protected:
|
||||
bool hasElement(const char *select);
|
||||
private:
|
||||
Page m_page;
|
||||
QTimer m_ticker;
|
||||
@ -48,7 +48,6 @@ class Runner: public QObject {
|
||||
bool useColors;
|
||||
|
||||
QQueue<QString> runnerFiles;
|
||||
QStack<QString> failedSpecs;
|
||||
|
||||
QString reportFileName;
|
||||
|
||||
|
@ -1,43 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include "Page.h"
|
||||
#include "Page_test.h"
|
||||
|
||||
PageTest::PageTest() : QObject(), internalLogCalled(false) {
|
||||
}
|
||||
|
||||
void PageTest::internalLog(const QString &, const QString &) {
|
||||
internalLogCalled = true;
|
||||
}
|
||||
|
||||
void PageTest::consoleLog(const QString &, int, const QString &) {
|
||||
consoleLogCalled = true;
|
||||
}
|
||||
|
||||
void PageTest::testJavaScriptConfirmWithLog() {
|
||||
connect(&page, SIGNAL(internalLog(QString, QString)), this, SLOT(internalLog(QString, QString)));
|
||||
internalLogCalled = false;
|
||||
|
||||
page.mainFrame()->setHtml("<script>confirm('test')</script>");
|
||||
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);
|
||||
}
|
||||
|
||||
QTEST_MAIN(PageTest);
|
||||
|
@ -1,27 +0,0 @@
|
||||
#ifndef JHW_TEST_PAGE
|
||||
#define JHW_TEST_PAGE
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include "Page.h"
|
||||
|
||||
class PageTest : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PageTest();
|
||||
|
||||
private:
|
||||
bool internalLogCalled;
|
||||
bool consoleLogCalled;
|
||||
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
|
||||
|
@ -1,6 +0,0 @@
|
||||
include(common.pri)
|
||||
include(test.pri)
|
||||
|
||||
SOURCES += Page_test.cpp
|
||||
HEADERS += Page_test.h
|
||||
|
@ -1,3 +0,0 @@
|
||||
TARGET = jhw-test
|
||||
QT += testlib
|
||||
|
@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'fileutils'
|
||||
|
||||
system %{make clean}
|
||||
|
||||
$: << File.expand_path("../../../lib", __FILE__)
|
||||
require 'qt/qmake'
|
||||
|
||||
result = 0
|
||||
|
||||
Dir['*_test.pro'].each do |test|
|
||||
FileUtils.rm_f('jhw-test')
|
||||
|
||||
Qt::Qmake.make!('jasmine-headless-webkit', test)
|
||||
|
||||
if File.file?('jhw-test')
|
||||
system %{./jhw-test}
|
||||
if $?.exitstatus != 0
|
||||
result = 1
|
||||
break
|
||||
end
|
||||
else
|
||||
result = 1
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
Qt::Qmake.make!('jasmine-headless-webkit', 'specrunner.pro')
|
||||
|
||||
exit result
|
@ -7,7 +7,7 @@ class jasmine.HeadlessReporter
|
||||
@results = []
|
||||
@failedCount = 0
|
||||
@length = 0
|
||||
@_hasError = false
|
||||
|
||||
reportRunnerResults: (runner) ->
|
||||
return if this.hasError()
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
this.results = [];
|
||||
this.failedCount = 0;
|
||||
this.length = 0;
|
||||
this._hasError = false;
|
||||
}
|
||||
HeadlessReporter.prototype.reportRunnerResults = function(runner) {
|
||||
var result, resultLine, runtime, _i, _len, _ref;
|
||||
|
@ -30,7 +30,7 @@ describe 'jasmine.HeadlessReporter', ->
|
||||
|
||||
reporter.reportSpecStarting(spec)
|
||||
|
||||
expect(spec.finish).not.toHaveBeenCalled()
|
||||
expect(spec.finish).toHaveBeenCalled()
|
||||
expect(suite.finish).toHaveBeenCalled()
|
||||
|
||||
describe 'jasmine.Suite.prototype.getSuiteSplitName', ->
|
||||
|
Loading…
Reference in New Issue
Block a user