diff options
author | Keith Isdale <keith.isdale@nokia.com> | 2010-07-26 10:44:41 +1000 |
---|---|---|
committer | Keith Isdale <keith.isdale@nokia.com> | 2010-07-26 10:44:41 +1000 |
commit | 619d92cfef29e653bfdf852e83888e50cfc4348f (patch) | |
tree | 4f6a6e2d3769367140179871de3c1564f9e71cdb /libqsystemtest/qsystemtest.cpp | |
parent | 80326b34a08ca7d8547f8c0c8ac6f857cddc643a (diff) | |
parent | eb2fbe409d1423c0b707b9986ee1e56fa19b355a (diff) |
Merge branch 'master' of git://git-nokia.trolltech.com.au/qtsoftware/research/qtuitest
Diffstat (limited to 'libqsystemtest/qsystemtest.cpp')
-rw-r--r-- | libqsystemtest/qsystemtest.cpp | 114 |
1 files changed, 91 insertions, 23 deletions
diff --git a/libqsystemtest/qsystemtest.cpp b/libqsystemtest/qsystemtest.cpp index 50808cd..7ae1ea3 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> >(); @@ -295,12 +301,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. @@ -2382,12 +2395,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; @@ -2404,13 +2416,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()) { @@ -2421,6 +2437,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)); @@ -2637,7 +2666,7 @@ QDateTime QSystemTest::getDateTime() */ bool QSystemTest::runsOnDevice() { - return m_aut_host != "127.0.0.1"; + return ssh_param.host != "127.0.0.1"; } /*! @@ -2753,12 +2782,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; @@ -2794,7 +2824,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; @@ -3317,7 +3388,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. @@ -3328,29 +3399,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); @@ -3605,19 +3667,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. |