summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Baak <ed.baak@nokia.com>2010-07-26 10:22:34 +1000
committerEd Baak <ed.baak@nokia.com>2010-07-26 10:22:34 +1000
commit3988c9601839fe3447be30907733adb947b8aa5d (patch)
tree0fc78b9f6260c6f6c7a63d0e3197b4bc0df68898
parent164242deb126f5d3c798d27e6c80e880a33031c5 (diff)
Experimental submit ... use Creator's ssh connection classes to start/stop an application on Maemo.
-rw-r--r--interpreter/qscriptsystemtest.cpp5
-rw-r--r--libqsystemtest/qabstracttest.cpp2
-rw-r--r--libqsystemtest/qsystemtest.cpp114
-rw-r--r--libqsystemtest/qsystemtest.h29
4 files changed, 113 insertions, 37 deletions
diff --git a/interpreter/qscriptsystemtest.cpp b/interpreter/qscriptsystemtest.cpp
index 2dbe531..3d2305b 100644
--- a/interpreter/qscriptsystemtest.cpp
+++ b/interpreter/qscriptsystemtest.cpp
@@ -494,7 +494,6 @@ int QScriptSystemTest::runTest(const QString &fname, const QStringList &paramete
const QStringList &environment)
{
m_env = environment;
- qDebug() << "Running " << fname;
filename = fname;
QFile file(filename);
@@ -647,7 +646,7 @@ int QScriptSystemTest::runTest(int argc, char *argv[])
m_engine.setAgent(m_agent);
}
- int retval = QTest::qExec(&tc, c_argc, c_argv);
+ int retval = QTest::qExec(testObject, c_argc, c_argv);
testObject = 0;
@@ -857,6 +856,8 @@ void QScriptSystemTest::processMessage(const QTestMessage& message)
*/
void QScriptSystemTest::processCommandLine( int &argc, char *argv[] )
{
+ qDebug() << "QScriptSytsemTest::processCommandLine()";
+
int offset = 0;
for (int i=1; i<argc; ++i) {
diff --git a/libqsystemtest/qabstracttest.cpp b/libqsystemtest/qabstracttest.cpp
index bf6ea0b..61b6896 100644
--- a/libqsystemtest/qabstracttest.cpp
+++ b/libqsystemtest/qabstracttest.cpp
@@ -395,6 +395,8 @@ void QAbstractTest::printUsage( int argc, char* argv[] ) const
*/
void QAbstractTest::processCommandLine( int &argc, char* argv[] )
{
+ qDebug() << "QAbstractTest::processCommandLine()";
+
int offset = 0;
for (int i = 1; i < argc; ++i) {
if ( !strcasecmp(argv[i], "-data") ) {
diff --git a/libqsystemtest/qsystemtest.cpp b/libqsystemtest/qsystemtest.cpp
index 947b4bc..f590b58 100644
--- a/libqsystemtest/qsystemtest.cpp
+++ b/libqsystemtest/qsystemtest.cpp
@@ -45,6 +45,10 @@
#include "gracefulquit.h"
#include "ui_recorddlg.h"
+#ifdef QTCREATOR_QTEST
+# include "testoutputwindow.h"
+#endif
+
#include <QDir>
#include <QProcess>
#include <QMessageBox>
@@ -230,7 +234,6 @@ QSystemTest::QSystemTest()
, m_loc_line(-1)
, m_auto_mode(false)
, m_run_as_manual_test(false)
- , m_aut_host("127.0.0.1")
, m_aut_port(DEFAULT_AUT_PORT)
, m_keep_aut(false)
, m_silent_aut(false)
@@ -251,6 +254,9 @@ QSystemTest::QSystemTest()
, m_expect_app_close(false)
{
m_env.clear();
+ ssh_param.host = "127.0.0.1";
+ ssh_param.port = 22;
+ device_control = 0;
(void)qMetaTypeId<RecordEvent>();
(void)qMetaTypeId< QList<RecordEvent> >();
@@ -276,12 +282,19 @@ QSystemTest::~QSystemTest()
}
}
+ delete device_control;
delete event_timer;
delete m_test_app;
while (expected_msg_boxes.count() > 0)
delete expected_msg_boxes.takeFirst();
}
+void QSystemTest::setConnectionParameters( Core::SshConnectionParameters param )
+{
+ ssh_param = param;
+ device_control = new Qt4Test::TestDeviceControl(param);
+}
+
/*!
Returns the signature of the currently active window.
@@ -2363,12 +2376,11 @@ void QSystemTest::startApplication( const QString &application, const QStringLis
} else {
// Running on device
- qLog(QtUitest) << "Running on device...";
-
QProcess proc;
if (!(flags & BackgroundCurrentApplication)) {
// If we aren't backgrounding the current app, then we want to kill it.
+/*
while (m_remote_aut.count()) {
QString aut = m_remote_aut.takeFirst();
QStringList args;
@@ -2385,13 +2397,17 @@ void QSystemTest::startApplication( const QString &application, const QStringLis
}
m_test_app->disconnect();
}
+*/
}
+ if (device_control)
+ device_control->killApplication();
// setup configuration for target, used by configTarget() later
QByteArray defTargetID = qgetenv("QTUITEST_TARGETID");
if (!defTargetID.isEmpty())
m_targetID = QString(defTargetID);
+/*
args.prepend(app);
static QByteArray startProcess = qgetenv("QTUITEST_START_PROCESS");
if (startProcess.isEmpty()) {
@@ -2402,6 +2418,19 @@ void QSystemTest::startApplication( const QString &application, const QStringLis
proc.kill();
proc.waitForFinished(5000);
}
+*/
+
+ QString reply;
+// control.deviceConfiguration(reply);
+#ifdef QTCREATOR_QTEST
+// testOutputPane()->append(reply);
+#endif
+
+ if (device_control)
+ device_control->runCustomCommand("run-standalone.sh " + application + " -style qtuitest", 3000, reply);
+#ifdef QTCREATOR_QTEST
+ testOutputPane()->append(reply);
+#endif
if (!connectToAut(timeout)) {
fail(QString("Could not connect to remote process '%1'.").arg(app));
@@ -2618,7 +2647,7 @@ QDateTime QSystemTest::getDateTime()
*/
bool QSystemTest::runsOnDevice()
{
- return m_aut_host != "127.0.0.1";
+ return ssh_param.host != "127.0.0.1";
}
/*!
@@ -2734,12 +2763,13 @@ void QSystemTest::expectApplicationClose( bool value )
*/
void QSystemTest::processCommandLine( int &argc, char *argv[] )
{
+ qDebug() << "QSystemTest::processCommandLine()";
+
int offset = 0;
// Whenever we discover an option that 'we' understand, eat away the option (and its parameters) so that QTest doesn't get
// confused by them.
for (int i=1; i<argc; ++i) {
-
if ( !strcasecmp(argv[i], "-remote") ) {
argv[i] = 0;
++offset;
@@ -2775,7 +2805,48 @@ void QSystemTest::processCommandLine( int &argc, char *argv[] )
if ( i+1 >= argc || !strlen(argv[i+1]) )
qFatal("Expected a host specifier after %s", given_arg);
- m_aut_host = argv[i+1];
+ ssh_param.host = argv[i+1];
+ argv[i+1] = 0;
+ ++offset;
+ ++i;
+
+ qDebug() << "authost=" << ssh_param.host;
+
+ } else if ( !strcasecmp(argv[i], "-username") ) {
+ char *given_arg = argv[i];
+
+ argv[i] = 0;
+ ++offset;
+ if ( i+1 >= argc || !strlen(argv[i+1]) )
+ qFatal("Expected a user name after %s", given_arg);
+
+ ssh_param.uname = argv[i+1];
+ argv[i+1] = 0;
+ ++offset;
+ ++i;
+
+ } else if ( !strcasecmp(argv[i], "-pwd") ) {
+ char *given_arg = argv[i];
+
+ argv[i] = 0;
+ ++offset;
+ if ( i+1 >= argc || !strlen(argv[i+1]) )
+ qFatal("Expected a password after %s", given_arg);
+
+ ssh_param.pwd = argv[i+1];
+ argv[i+1] = 0;
+ ++offset;
+ ++i;
+
+ } else if ( !strcasecmp(argv[i], "-private-key-file") ) {
+ char *given_arg = argv[i];
+
+ argv[i] = 0;
+ ++offset;
+ if ( i+1 >= argc || !strlen(argv[i+1]) )
+ qFatal("Expected a private key file after %s", given_arg);
+
+ ssh_param.privateKeyFile = argv[i+1];
argv[i+1] = 0;
++offset;
++i;
@@ -3298,7 +3369,7 @@ int QSystemTest::runTest(int argc, char *argv[]) {
/*!
\internal
- Attempts to launch the aut script, and returns whether it was successful.
+ Attempts to launch the AUT (Application Under Test), and returns whether it was successful.
The \c -remote command line argument is appended to the script with the IP set to the address of the
local machine. This is to allow the test system to connect to the machine the test is running on.
@@ -3309,29 +3380,20 @@ bool QSystemTest::connectToAut(int timeout)
if (!m_test_app)
m_test_app = new QSystemTestMaster( this );
- bool first_time = true;
QTime t;
t.start();
while (t.elapsed() < timeout && !isConnected()) {
- m_test_app->connect( m_aut_host, m_aut_port );
+ m_test_app->connect( ssh_param.host, m_aut_port );
m_test_app->waitForConnected(2000);
- if (!m_test_app->isConnected()) {
- if (m_test_app->error() == QAbstractSocket::ConnectionRefusedError) {
- if (first_time) {
- qLog(QtUitest) << qPrintable(QString("Connection refused while trying to connect to test app on %1:%2. Retrying ... ").arg(m_aut_host).arg(m_aut_port)) ;
- first_time = false;
- }
- }
- }
}
if (!m_test_app->isConnected()) {
+ qLog(QtUitest) << qPrintable(QString("'%1' while trying to connect to test app on %2:%3. ").arg(m_test_app->errorStr()).arg(ssh_param.host).arg(m_aut_port)) ;
return false;
}
- // Don't try to reconnect of connection is lost
- // ... it's pointless
- m_test_app->enableReconnect(false, 10000);
+ // Don't try to reconnect if connection is lost ... it's pointless
+ m_test_app->enableReconnect(false, 0);
if (m_demo_mode) setDemoMode(true);
@@ -3586,19 +3648,25 @@ void QSystemTest::setDemoMode( bool enabled )
\internal
*/
bool QSystemTest::demoMode() const
-{ return m_demo_mode; }
+{
+ return m_demo_mode;
+}
/*!
\internal
*/
QString QSystemTest::autHost() const
-{ return m_aut_host; }
+{
+ return ssh_param.host;
+}
/*!
\internal
*/
int QSystemTest::autPort() const
-{ return m_aut_port; }
+{
+ return m_aut_port;
+}
/*!
Uses the \a reason to mark the current testfunction as expected to fail.
diff --git a/libqsystemtest/qsystemtest.h b/libqsystemtest/qsystemtest.h
index 733cc72..c8ec39b 100644
--- a/libqsystemtest/qsystemtest.h
+++ b/libqsystemtest/qsystemtest.h
@@ -46,6 +46,7 @@
#include "qtestprotocol_p.h"
#include "qtestremote_p.h"
#include "recordevent_p.h"
+#include "testdevicecontrol.h"
#include <QStringList>
#include <QDir>
@@ -375,17 +376,20 @@ public slots:
void qtuitest_post_test_function();
// These public slots come from QSystemTestPrivate
- QTestMessage query( const QTestMessage &message, const QString &queryPath = QString(),
- int timeout = DEFAULT_QUERY_TIMEOUT );
- bool queryPassed( const QStringList &passResult, const QStringList &failResult,
- const QTestMessage &message, const QString &queryPath = QString(),
- QTestMessage *reply = 0, int timeout = DEFAULT_QUERY_TIMEOUT );
- bool queryPassed( const QString &passResult, const QString &failResult,
- const QTestMessage &message, const QString &queryPath = QString(),
- QTestMessage *reply = 0, int timeout = DEFAULT_QUERY_TIMEOUT );
- void recordPrompt();
- bool recentEventRecorded();
- void resetEventTimer();
+ QTestMessage query( const QTestMessage &message, const QString &queryPath = QString(),
+ int timeout = DEFAULT_QUERY_TIMEOUT );
+ bool queryPassed( const QStringList &passResult, const QStringList &failResult,
+ const QTestMessage &message, const QString &queryPath = QString(),
+ QTestMessage *reply = 0, int timeout = DEFAULT_QUERY_TIMEOUT );
+ bool queryPassed( const QString &passResult, const QString &failResult,
+ const QTestMessage &message, const QString &queryPath = QString(),
+ QTestMessage *reply = 0, int timeout = DEFAULT_QUERY_TIMEOUT );
+ void recordPrompt();
+ bool recentEventRecorded();
+ void resetEventTimer();
+
+public:
+ void setConnectionParameters( Core::SshConnectionParameters param );
protected slots:
void abortPrompt();
@@ -529,7 +533,8 @@ private:
bool isConnected();
// the following parameters are used to start an Application_Under_Test
- QString m_aut_host;
+ Qt4Test::TestDeviceControl *device_control;
+ Core::SshConnectionParameters ssh_param;
quint16 m_aut_port;
bool m_keep_aut;
bool m_silent_aut;