summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordac <qt-info@nokia.com>2010-07-29 14:01:43 +1000
committerdac <qt-info@nokia.com>2010-07-29 14:01:43 +1000
commit999d674f62b11ed5fe242a6254cb0749be9aaab7 (patch)
treee5521b29f962e4aaa4cfb837ed83a37412d78510
parent533711dbd5534efa85d22a1519f233bb9e1ceefd (diff)
More Creator integration
-rw-r--r--interpreter/qscriptsystemtest.cpp13
-rw-r--r--interpreter/qtscript_bindings.cpp22
-rw-r--r--interpreter/qtscript_bindings.h11
-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
-rw-r--r--qtuitest-host.pri2
-rw-r--r--qtuitestrunner.pro4
11 files changed, 88 insertions, 45 deletions
diff --git a/interpreter/qscriptsystemtest.cpp b/interpreter/qscriptsystemtest.cpp
index 2b6a2f4..5e67c22 100644
--- a/interpreter/qscriptsystemtest.cpp
+++ b/interpreter/qscriptsystemtest.cpp
@@ -536,6 +536,11 @@ int QScriptSystemTest::runTest(const QString &fname, const QStringList &paramete
script.append("\n}");
QtScriptTest tc(filename, script, &m_engine);
+
+ if (tc.status() != QtScriptTest::StatusNormal) {
+ return -1;
+ }
+
testObject = &tc;
qScriptRegisterMetaType(&m_engine, variantToScriptValue, variantFromScriptValue);
@@ -554,7 +559,7 @@ int QScriptSystemTest::runTest(const QString &fname, const QStringList &paramete
return 0;
// If an IDE is connected, set the agent to enable script debugging
- if (testIDE() && testIDE()->isConnected()) {
+ if (QTestIDE::instance()->isConnected()) {
m_engine.setAgent(m_agent);
}
@@ -794,8 +799,8 @@ void QScriptSystemTest::scriptPositionChange(qint64 scriptId, int line, int colu
} else {
functionName = ctxInfo.functionName();
}
- if (testIDE()->queryBreakpoint(ctxInfo.fileName(), ctxInfo.lineNumber(), functionName, m_contextDepth)) {
- testIDE()->breakpointContext(m_engine.currentContext());
+ if (QTestIDE::instance()->queryBreakpoint(ctxInfo.fileName(), ctxInfo.lineNumber(), functionName, m_contextDepth)) {
+ QTestIDE::instance()->breakpointContext(m_engine.currentContext());
}
}
}
@@ -806,4 +811,4 @@ void QScriptSystemTest::scriptContextChange(bool isNew)
++m_contextDepth;
else
--m_contextDepth;
-};
+} \ No newline at end of file
diff --git a/interpreter/qtscript_bindings.cpp b/interpreter/qtscript_bindings.cpp
index 10ada0c..b93aeff 100644
--- a/interpreter/qtscript_bindings.cpp
+++ b/interpreter/qtscript_bindings.cpp
@@ -41,6 +41,7 @@
#include <QtTest/QtTest>
+#include <qtestide.h>
#include "qscriptengine.h"
#include "qscriptvalue.h"
#include "qscriptvalueiterator.h"
@@ -48,7 +49,6 @@
#include "qscriptcontextinfo.h"
#include "qtscript_bindings.h"
-//#include "qtscript_qtcore.h"
QStringList builtinFiles;
@@ -197,7 +197,7 @@ int QtScriptTest::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
}
QtScriptTest::QtScriptTest(QString const &testFilePath, QString const &scriptData, QScriptEngine *engine)
- : QObject(), m_testFilePath(testFilePath), m_engine(engine)
+ : QObject(), m_testFilePath(testFilePath), m_engine(engine), m_status(StatusNotStarted)
{
if (m_testFilePath.isEmpty())
m_testFilePath = qgetenv("Q_TEST_FILE");
@@ -224,8 +224,9 @@ QtScriptTest::QtScriptTest(QString const &testFilePath, QString const &scriptDat
if (!script.isEmpty()) {
QScriptSyntaxCheckResult synChk = m_engine->checkSyntax(script);
if (synChk.state() != QScriptSyntaxCheckResult::Valid) {
- qFatal("SyntaxError: %s at %s:%d", qPrintable(synChk.errorMessage()),
- qPrintable(m_testFilePath), synChk.errorLineNumber());
+ QTestIDE::instance()->scriptSyntaxError(synChk.errorMessage(), m_testFilePath, synChk.errorLineNumber());
+ m_status = StatusSyntaxError;
+ return;
}
QScriptValue ret = m_engine->evaluate(script, m_testFilePath);
@@ -237,8 +238,10 @@ QtScriptTest::QtScriptTest(QString const &testFilePath, QString const &scriptDat
}
if (!error.isEmpty()) {
QString backtrace = m_engine->uncaughtExceptionBacktrace().join("\n");
- qFatal("%s\n%s", qPrintable(error),
- qPrintable(backtrace));
+ m_status = StatusException;
+ return;
+// qFatal("%s\n%s", qPrintable(error),
+// qPrintable(backtrace));
}
QScriptValue testcase = m_engine->globalObject().property("testcase");
QScriptValueIterator it(testcase);
@@ -296,8 +299,15 @@ QtScriptTest::QtScriptTest(QString const &testFilePath, QString const &scriptDat
staticMetaObject.d.stringdata = stringdata->constData();
staticMetaObject.d.data = data->constData();
staticMetaObject.d.extradata = 0;
+
+ m_status = StatusNormal;
}
QtScriptTest::~QtScriptTest()
{
}
+
+QtScriptTest::Status QtScriptTest::status()
+{
+ return m_status;
+} \ No newline at end of file
diff --git a/interpreter/qtscript_bindings.h b/interpreter/qtscript_bindings.h
index 0df2a64..b60f746 100644
--- a/interpreter/qtscript_bindings.h
+++ b/interpreter/qtscript_bindings.h
@@ -51,6 +51,15 @@ class QtScriptTest : public QObject
{
public:
+
+ enum Status
+ {
+ StatusNotStarted,
+ StatusNormal,
+ StatusSyntaxError,
+ StatusException
+ };
+
QtScriptTest(QString const &testFilePath = QString(), QString const &scriptData = QString(), QScriptEngine *engine = 0);
virtual ~QtScriptTest();
@@ -62,10 +71,12 @@ public:
QString testFilePath() const { return m_testFilePath; }
QScriptEngine* engine() { return m_engine; }
+ Status status();
private:
QString m_testFilePath;
QScriptEngine* m_engine;
+ Status m_status;
};
#endif
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&);
diff --git a/qtuitest-host.pri b/qtuitest-host.pri
index 7f579a2..10869b3 100644
--- a/qtuitest-host.pri
+++ b/qtuitest-host.pri
@@ -50,8 +50,6 @@ HEADERS +=\
$$QTUITEST_SRC/libqsystemtest/meegotestcontrol.h
SOURCES +=\
- # $$QTUITEST_SRC/libqsystemtest/gracefulquit.cpp \
- $$QTUITEST_SRC/libqsystemtest/qtestide.cpp \
$$QTUITEST_SRC/libqsystemtest/qabstracttest.cpp \
$$QTUITEST_SRC/libqsystemtest/qtestremote.cpp \
$$QTUITEST_SRC/libqsystemtest/qtestverifydlg.cpp \
diff --git a/qtuitestrunner.pro b/qtuitestrunner.pro
index 08b24a7..9f4991b 100644
--- a/qtuitestrunner.pro
+++ b/qtuitestrunner.pro
@@ -19,13 +19,11 @@ BOTAN_SRC=$$QTUITEST_SRC/botan/src
include($$BOTAN_SRC/botan.pri)
HEADERS +=\
-# $$QTUITEST_SRC/libqsystemtest/gracefulquit.h\
$$QTUITEST_SRC/libqtuitest/qtestprotocol_p.h\
$$QTUITEST_SRC/libqtuitest/qtuitestelapsedtimer_p.h
SOURCES +=\
-# $$QTUITEST_SRC/libqsystemtest/gracefulquit.cpp\
$$QTUITEST_SRC/libqtuitest/qtestprotocol.cpp\
$$QTUITEST_SRC/libqtuitest/qtuitestelapsedtimer.cpp\
$$QTUITEST_SRC/interpreter/main.cpp
@@ -82,6 +80,8 @@ SOURCES +=\
$$QTUITEST_SRC/coreplugin/ssh/sshremoteprocess.cpp \
$$QTUITEST_SRC/coreplugin/ssh/sshsendfacility.cpp
+SOURCES += $$QTUITEST_SRC/libqsystemtest/qtestide.cpp
+
!symbian {
MOC_DIR=$$OUT_PWD/.moc
OBJECTS_DIR=$$OUT_PWD/.obj