summaryrefslogtreecommitdiffstats
path: root/libqsystemtest
diff options
context:
space:
mode:
Diffstat (limited to 'libqsystemtest')
-rw-r--r--libqsystemtest/qabstracttest.cpp8
-rw-r--r--libqsystemtest/qsystemtest.cpp26
-rw-r--r--libqsystemtest/qsystemtest.h4
-rw-r--r--libqsystemtest/qsystemtest_p.cpp8
-rw-r--r--libqsystemtest/qtestide.cpp26
-rw-r--r--libqsystemtest/qtestide.h9
6 files changed, 50 insertions, 31 deletions
diff --git a/libqsystemtest/qabstracttest.cpp b/libqsystemtest/qabstracttest.cpp
index f441938..7b1a02a 100644
--- a/libqsystemtest/qabstracttest.cpp
+++ b/libqsystemtest/qabstracttest.cpp
@@ -332,8 +332,12 @@ int QAbstractTest::exec( int argc, char* argv[], char* filename )
}
processCommandLine(options);
- QString script = options.first();
- return runTest(script, options, QStringList());
+ if (options.isEmpty()) {
+ qWarning("No script specified");
+ exit(1);
+ }
+
+ return runTest(options.first(), options, QStringList());
}
#endif
diff --git a/libqsystemtest/qsystemtest.cpp b/libqsystemtest/qsystemtest.cpp
index f472166..3535df2 100644
--- a/libqsystemtest/qsystemtest.cpp
+++ b/libqsystemtest/qsystemtest.cpp
@@ -42,7 +42,7 @@
#include <qsystemtest.h>
#include "qsystemtestmaster_p.h"
#include "qtuitest_config.h"
-//#include "gracefulquit.h"
+#include "qtestide.h"
#include "ui_recorddlg.h"
#ifdef QTCREATOR_QTEST
@@ -250,13 +250,13 @@ QSystemTest::QSystemTest()
, m_config_id()
, m_recording_events(false)
, m_expect_app_close(false)
- , m_qtest_ide(new QTestIDE(this))
{
m_env.clear();
ssh_param.host = "127.0.0.1";
ssh_param.port = 22;
device_controller = 0;
+ QTestIDE::instance()->setSystemTest(this);
(void)qMetaTypeId<RecordEvent>();
(void)qMetaTypeId< QList<RecordEvent> >();
qRegisterMetaType<QTestMessage>("QTestMessage");
@@ -275,7 +275,6 @@ QSystemTest::~QSystemTest()
delete device_controller;
delete event_timer;
delete m_test_app;
- delete m_qtest_ide;
while (expected_msg_boxes.count() > 0)
delete expected_msg_boxes.takeFirst();
}
@@ -914,7 +913,7 @@ void QSystemTest::verifyImage( const QString &expectedName, const QString &query
if ( !actualIm.save(expectedFilename, "PNG", 0) ) {
QWARN(QString("Failed to save image to %1!").arg(expectedFilename).toLatin1());
} else {
- testIDE()->newTestData(expectedFilename);
+ QTestIDE::instance()->newTestData(expectedFilename);
}
snapshotOk = true;
} else {
@@ -2585,8 +2584,8 @@ void QSystemTest::processCommandLine( QStringList &args )
if (!ok)
qFatal("'%s' is not a valid host:port argument", qPrintable(host_port));
- testIDE()->openRemote( host, port );
- connect(testIDE(), SIGNAL(abort()), this, SLOT(abortTest()));
+ QTestIDE::instance()->openRemote( host, port );
+ connect(QTestIDE::instance(), SIGNAL(abort()), this, SLOT(abortTest()));
} else if ( !arg.compare("-autip", Qt::CaseInsensitive) || !arg.compare("-authost", Qt::CaseInsensitive) ) {
it.remove();
if (!it.hasNext()) qFatal("Expected a value after %s", qPrintable(arg));
@@ -2687,15 +2686,15 @@ bool QSystemTest::recordEvents( const QString &manualSteps, bool gui )
m_recorded_code = QString();
if (!queryPassed( "OK", "", QTestMessage("startEventRecording"))) return false;
if (gui) {
- if (testIDE()->isConnected()) {
- testIDE()->eventRecordingStarted(currentFile(), currentLine(), manualSteps);
+ if (QTestIDE::instance()->isConnected()) {
+ QTestIDE::instance()->eventRecordingStarted(currentFile(), currentLine(), manualSteps);
m_recording_events = true;
- while (!testIDE()->mustStopEventRecording()) {
+ while (!QTestIDE::instance()->mustStopEventRecording()) {
QTest::qWait( 50 );
}
m_recording_events = false;
- if (testIDE()->eventRecordingAborted()) {
+ if (QTestIDE::instance()->eventRecordingAborted()) {
skip("Event recording aborted.", SkipSingle );
}
} else {
@@ -2924,7 +2923,7 @@ bool QSystemTest::fail(QString const &message)
// If we saved it, let the IDE know.
QFileInfo info(currentDataPath() + "/failure_" + config + ".png");
if (info.exists()) {
- testIDE()->failureScreenshot(info.canonicalFilePath(), currentFile(), currentLine(), QTest::currentTestFunction());
+ QTestIDE::instance()->failureScreenshot(info.canonicalFilePath(), currentFile(), currentLine(), QTest::currentTestFunction());
}
}
@@ -3471,11 +3470,6 @@ bool QSystemTest::runAsManualTest(void)
return m_run_as_manual_test;
}
-QTestIDE *QSystemTest::testIDE()
-{
- return m_qtest_ide;
-}
-
/*!
\internal
Pass any configuration values to the system under test
diff --git a/libqsystemtest/qsystemtest.h b/libqsystemtest/qsystemtest.h
index 9d21db4..0486ced 100644
--- a/libqsystemtest/qsystemtest.h
+++ b/libqsystemtest/qsystemtest.h
@@ -44,7 +44,6 @@
#include "qabstracttest.h"
#include "qtestprotocol_p.h"
-#include "qtestide.h"
#include "recordevent_p.h"
#include <testcontrol.h>
@@ -470,8 +469,6 @@ public:
QString PATH();
QString which( const QString &appName );
- QTestIDE *testIDE();
-
signals:
void appGainedFocus(QString const &appName);
void appBecameIdle(QString const &appName);
@@ -556,7 +553,6 @@ private:
bool m_expect_app_close;
int m_query_count;
bool m_skip_current_function;
- QTestIDE *m_qtest_ide;
#ifdef Q_QDOC
/* Functions where implementation is in QtScript */
diff --git a/libqsystemtest/qsystemtest_p.cpp b/libqsystemtest/qsystemtest_p.cpp
index 200bdbe..dd0600c 100644
--- a/libqsystemtest/qsystemtest_p.cpp
+++ b/libqsystemtest/qsystemtest_p.cpp
@@ -42,7 +42,7 @@
#include <qsystemtest.h>
#include "qsystemtestmaster_p.h"
#include "qtestverifydlg_p.h"
-#include "qtestremote_p.h"
+#include "qtestide.h"
#include "recordevent_p.h"
#include "qtuitest_config.h"
#include "ui_manualverificationdlg.h"
@@ -77,8 +77,8 @@
*/
bool QSystemTest::learnImage(const QImage &actual, const QImage &expected, const QString &comment)
{
- if (m_qtest_ide->isConnected()) {
- return m_qtest_ide->verifyImage(actual.isNull() ? QPixmap() : QPixmap::fromImage(actual),
+ if (QTestIDE::instance()->isConnected()) {
+ return QTestIDE::instance()->verifyImage(actual.isNull() ? QPixmap() : QPixmap::fromImage(actual),
expected.isNull() ? QPixmap() : QPixmap::fromImage(expected),
comment);
} else {
@@ -695,7 +695,7 @@ void QSystemTest::recordEvents(QList<RecordEvent> const& events)
m_recorded_events_edit->moveCursor(QTextCursor::End);
m_recorded_events_edit->ensureCursorVisible();
}
- m_qtest_ide->recordedCode(m_recorded_code);
+ QTestIDE::instance()->recordedCode(m_recorded_code);
}
}
/*
diff --git a/libqsystemtest/qtestide.cpp b/libqsystemtest/qtestide.cpp
index 2e9decd..cb4a271 100644
--- a/libqsystemtest/qtestide.cpp
+++ b/libqsystemtest/qtestide.cpp
@@ -46,9 +46,15 @@
#include <QScriptValueIterator>
#include <QPixmap>
-QTestIDE::QTestIDE(QSystemTest *sysTest)
+QTestIDE* QTestIDE::instance()
+{
+ static QTestIDE instance;
+ return &instance;
+}
+
+QTestIDE::QTestIDE()
+ : m_sysTest(0)
{
- m_sysTest = sysTest;
must_stop_event_recording = false;
event_recording_aborted = false;
}
@@ -57,6 +63,11 @@ QTestIDE::~QTestIDE()
{
}
+void QTestIDE::setSystemTest(QSystemTest *sysTest)
+{
+ m_sysTest = sysTest;
+}
+
/*!
\internal
Opens a socket connection to a remote test tool and uses the connection to
@@ -72,6 +83,15 @@ bool QTestIDE::isConnected()
return m_remote.isConnected();
}
+void QTestIDE::scriptSyntaxError(const QString& errorMsg, const QString& file, int line)
+{
+ if (errorMsg.isEmpty()) {
+ qWarning(QString("Syntax Error in %1, near line %2").arg(file).arg(line).toLatin1());
+ } else {
+ qWarning(QString("Syntax Error in %1, near line %2: %3").arg(file).arg(line).arg(errorMsg).toLatin1());
+ }
+}
+
bool QTestIDE::queryBreakpoint(const QString& file, int line, const QString& function, int depth)
{
if (m_remote.isConnected()) {
@@ -192,7 +212,7 @@ void QTestIDE::contextToMap(const QScriptContext* scriptContext, QVariantMap &co
contextMap["line"] = ctxInfo.lineNumber();
if (ctxInfo.functionName().isEmpty()) {
- contextMap["function"] = m_sysTest->currentTestFunction();
+ contextMap["function"] = m_sysTest ? m_sysTest->currentTestFunction() : QString("unknown");
} else {
contextMap["function"] = ctxInfo.functionName();
contextMap["funcStart"] = ctxInfo.functionStartLineNumber();
diff --git a/libqsystemtest/qtestide.h b/libqsystemtest/qtestide.h
index 1f7b27c..0349b86 100644
--- a/libqsystemtest/qtestide.h
+++ b/libqsystemtest/qtestide.h
@@ -54,13 +54,17 @@ class QSYSTEMTEST_EXPORT QTestIDE : public QObject
Q_OBJECT
public:
- QTestIDE(QSystemTest*);
+ static QTestIDE* instance();
+
+ QTestIDE();
virtual ~QTestIDE();
-
+ void setSystemTest( QSystemTest* );
+
void openRemote( const QString &ip, int port );
bool isConnected();
// virtual void processMessage( QTestMessage *msg );
+ void scriptSyntaxError(const QString&, const QString&, int);
bool queryBreakpoint(const QString&, int, const QString&, int);
void breakpointContext(const QScriptContext*);
@@ -75,6 +79,7 @@ public:
signals:
void abort();
+ void syntaxError(const QString&, const QString&, int);
private:
void contextToMap(const QScriptContext* scriptContext, QVariantMap&);