summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordac <qt-info@nokia.com>2010-08-19 14:17:03 +1000
committerdac <qt-info@nokia.com>2010-08-19 14:17:03 +1000
commitafcafcb6d4ff90774d5aef5cfc77401bb1bfce65 (patch)
tree1e20d3793937d1d362bba63b349677bda6fae634
parentd6b25be5709965ffff916b2350e53ad84bbb6e67 (diff)
Add support for using "-testability" instead of "-style qtuitest" when
starting AUT.
-rw-r--r--libqsystemtest/desktoptestcontrol.cpp2
-rw-r--r--libqsystemtest/qsystemtest.cpp6
-rw-r--r--libqsystemtest/qsystemtest.h1
-rw-r--r--plugins/styles/qtuitest/qtuitest.pro22
-rw-r--r--plugins/styles/qtuitest/style.cpp112
-rw-r--r--plugins/styles/qtuitest/testability.cpp74
-rw-r--r--plugins/styles/qtuitest/testslaveserver.cpp155
-rw-r--r--plugins/styles/qtuitest/testslaveserver.h63
-rw-r--r--qtuitest.pro1
9 files changed, 319 insertions, 117 deletions
diff --git a/libqsystemtest/desktoptestcontrol.cpp b/libqsystemtest/desktoptestcontrol.cpp
index 2a284fc..8032718 100644
--- a/libqsystemtest/desktoptestcontrol.cpp
+++ b/libqsystemtest/desktoptestcontrol.cpp
@@ -40,6 +40,8 @@ bool DesktopTestControl::startApplication( const QString &application, const QSt
if (styleQtUITest) {
args << "-style";
args << "qtuitest";
+ } else {
+ args << "-testability";
}
QByteArray defArgs = qgetenv("QTUITEST_DEFAULT_AUT_ARGS");
diff --git a/libqsystemtest/qsystemtest.cpp b/libqsystemtest/qsystemtest.cpp
index 49a4fff..7f5c70e 100644
--- a/libqsystemtest/qsystemtest.cpp
+++ b/libqsystemtest/qsystemtest.cpp
@@ -236,6 +236,7 @@ QSystemTest::QSystemTest()
, m_silent_aut(false)
, m_no_aut(false)
, m_demo_mode(false)
+ , m_use_testability(false)
, m_verbose(false)
, m_strict_mode(false)
, m_visible_response_time(4000)
@@ -2230,7 +2231,7 @@ void QSystemTest::startApplication( const QString &application, const QStringLis
QString reply;
if (device_controller) {
- bool ok = device_controller->startApplication(app, args, true, m_run_environment, reply);
+ bool ok = device_controller->startApplication(app, args, !m_use_testability, m_run_environment, reply);
#ifdef QTCREATOR_QTEST
if (!ok) {
if (reply.isEmpty())
@@ -2697,6 +2698,9 @@ void QSystemTest::processCommandLine( QStringList &args )
} else if ( !arg.compare("-v", Qt::CaseInsensitive) ) {
it.remove();
m_verbose = true;
+ } else if ( !arg.compare("-nostyle", Qt::CaseInsensitive) ) {
+ it.remove();
+ m_use_testability = true;
}
}
QAbstractTest::processCommandLine(args);
diff --git a/libqsystemtest/qsystemtest.h b/libqsystemtest/qsystemtest.h
index 8ac6b91..b33156f 100644
--- a/libqsystemtest/qsystemtest.h
+++ b/libqsystemtest/qsystemtest.h
@@ -535,6 +535,7 @@ private:
bool m_silent_aut;
bool m_no_aut;
bool m_demo_mode;
+ bool m_use_testability;
bool m_verbose_perf;
bool m_verbose;
QString m_targetID;
diff --git a/plugins/styles/qtuitest/qtuitest.pro b/plugins/styles/qtuitest/qtuitest.pro
index b9f94bc..132e1a2 100644
--- a/plugins/styles/qtuitest/qtuitest.pro
+++ b/plugins/styles/qtuitest/qtuitest.pro
@@ -1,8 +1,21 @@
TEMPLATE=lib
-CONFIG+=plugin
-SOURCES+=style.cpp
-HEADERS+=style.h
-TARGET=qtuiteststyle
+
+testability {
+ message("Using -testability to load QtUiTest into AUT")
+ SOURCES+=testability.cpp
+ TARGET=testability
+ target.path=$$[QT_INSTALL_LIBS]
+} else {
+ message("Using style plugin to load QtUiTest into AUT")
+ CONFIG+=plugin
+ SOURCES+=style.cpp
+ HEADERS+=style.h
+ TARGET=qtuiteststyle
+ target.path=$$[QT_INSTALL_PLUGINS]/styles
+}
+
+SOURCES+=testslaveserver.cpp
+HEADERS+=testslaveserver.h
TARGET=$$qtLibraryTarget($$TARGET)
QT+=network
INCLUDEPATH+=$$SRCROOT/libqtslave
@@ -11,7 +24,6 @@ DEPENDPATH+=$$SRCROOT
include($$SRCROOT/libqtuitest/libqtuitest.pri)
-target.path=$$[QT_INSTALL_PLUGINS]/styles
unix:!symbian {
MOC_DIR=$$OUT_PWD/.moc
OBJECTS_DIR=$$OUT_PWD/.obj
diff --git a/plugins/styles/qtuitest/style.cpp b/plugins/styles/qtuitest/style.cpp
index c602969..5505ece 100644
--- a/plugins/styles/qtuitest/style.cpp
+++ b/plugins/styles/qtuitest/style.cpp
@@ -39,12 +39,11 @@
**
****************************************************************************/
-
+#include "testslaveserver.h"
#include <QWidget>
#include <QDebug>
#include <qtestslave.h>
#include "style.h"
-#include <QCoreApplication>
#ifdef Q_OS_SYMBIAN
# include <QS60Style>
# include <sys/socket.h>
@@ -57,115 +56,6 @@
extern Q_GUI_EXPORT bool qt_use_native_dialogs;
#endif
-struct TestSlaveServer : public QTcpServer
-{
- TestSlaveServer()
- : QTcpServer(), showDebug(false), started(false)
- {
- }
-
- ~TestSlaveServer()
- {
- close();
- }
-
- void incomingConnection(int sd)
- { slave.setSocket(sd); }
-
- void startService();
- void stopService();
-
-
- QTestSlave slave;
- bool showDebug;
- bool started;
-};
-
-Q_GLOBAL_STATIC(TestSlaveServer, testSlaveServer);
-
-
-void TestSlaveServer::startService()
-{
- short aut_port = DEFAULT_AUT_PORT;
- bool parseOk;
- bool setAutPort = false;
- QStringList args = QCoreApplication::arguments();
- QByteArray autPortEnvBa = qgetenv("QTUITEST_PORT");
- QString autPortEnv = QString(autPortEnvBa);
- QByteArray debugEnvBa = qgetenv("QTUITEST_DEBUG");
- QString debugEnv = QString(debugEnvBa);
-
-
-#ifndef QTUITEST_DEBUG
- int debugValue = debugEnv.toInt(&parseOk);
- if (parseOk && (debugValue > 0))
- showDebug = true;
-#else
- showDebug = true;
-#endif
-
- if (showDebug)
- qWarning("QtUiTest: Start service");
-
- for (int index = 0; index < args.count(); index++){
- if (args[index].endsWith("qtuitestrunner")) {
- if (showDebug)
- qWarning() << "QtUiTest: Not starting TestSlaveServer::startService for qtuitestrunner";
- return;
- }
- }
-
- if (started){
- if (showDebug)
- qWarning() << "QtUiTest: Closing TestSlaveServer connection";
-
- close();
- }
- if (!autPortEnv.isEmpty()) {
- aut_port = autPortEnv.toUShort(&parseOk);
- if (!parseOk){
- aut_port = DEFAULT_AUT_PORT;
- qWarning() << "QtUiTest: Unable to parse QTUITEST_PORT" << autPortEnv;
- } else {
- setAutPort = true;
- if (showDebug)
- qWarning() << "QtUiTest: Set port via QTUITEST_PORT to" << aut_port;
- }
- }
- for (int index = 0; index < args.count(); index++) {
- if ((args[index] == QLatin1String("-autport")) && (index + 1 < args.count())){
- aut_port = args[index + 1].toUShort(&parseOk);
- if (!parseOk) {
- aut_port = DEFAULT_AUT_PORT;
- qWarning() << "QtUiTest: Unable to parse -autport" << args[index];
- } else {
- setAutPort = true;
- if (showDebug)
- qWarning() << "QtUiTest: Set port via -autport to" << aut_port;
- }
- }
- }
-
- if (!listen(QHostAddress::Any, aut_port)) {
- qWarning() << "QtUiTest: couldn't listen for connections on " << aut_port << " :"
- << errorString() << " started :" << started;
- exit(-1);
- } else {
- started = true;
- if (showDebug)
- qWarning() << "QtUiTest: listening for connections on" << aut_port;
- }
-}
-
-void TestSlaveServer::stopService()
-{
- if (showDebug)
- qWarning("QtUiTest : Stoping service");
-
- close();
- started = false;
-}
-
QtUiTestStylePlugin::~QtUiTestStylePlugin()
{
testSlaveServer()->stopService();
diff --git a/plugins/styles/qtuitest/testability.cpp b/plugins/styles/qtuitest/testability.cpp
new file mode 100644
index 0000000..af8dfff
--- /dev/null
+++ b/plugins/styles/qtuitest/testability.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//#include "qtuitest_config.h"
+#include "testslaveserver.h"
+/*
+#include <QWidget>
+#include <QDebug>
+#include <qtestslave.h>
+#include <QCoreApplication>
+#ifdef Q_OS_SYMBIAN
+# include <sys/socket.h>
+# include <net/if.h>
+#endif
+*/
+#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
+extern Q_GUI_EXPORT bool qt_use_native_dialogs;
+#endif
+
+
+extern "C" void qt_testability_init()
+{
+#ifdef Q_OS_SYMBIAN
+ struct ifreq ifReq;
+ strcpy( ifReq.ifr_name, "qtuitest");
+ int err = setdefaultif( &ifReq );
+#endif
+
+ static TestSlaveServer slave;
+ slave.startService();
+
+#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
+ // Use QFileDialog instead of native OS file dialog
+ qt_use_native_dialogs = false;
+#endif
+}
diff --git a/plugins/styles/qtuitest/testslaveserver.cpp b/plugins/styles/qtuitest/testslaveserver.cpp
new file mode 100644
index 0000000..37b8f76
--- /dev/null
+++ b/plugins/styles/qtuitest/testslaveserver.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testslaveserver.h"
+#include "qtuitest_config.h"
+//#include <QWidget>
+//#include <QDebug>
+#include <qtestslave.h>
+//#include "style.h"
+#include <QCoreApplication>
+#include <QStringList>
+#ifdef Q_OS_SYMBIAN
+//# include <QS60Style>
+# include <sys/socket.h>
+# include <net/if.h>
+//#elif defined Q_OS_MAC
+//# include <QMacStyle>
+#endif
+
+#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
+extern Q_GUI_EXPORT bool qt_use_native_dialogs;
+#endif
+
+TestSlaveServer::TestSlaveServer()
+ : QTcpServer(), showDebug(false), started(false)
+{
+}
+
+TestSlaveServer::~TestSlaveServer()
+{
+ close();
+}
+
+void TestSlaveServer::incomingConnection(int sd)
+{ slave.setSocket(sd); }
+
+void TestSlaveServer::startService()
+{
+ short aut_port = DEFAULT_AUT_PORT;
+ bool parseOk;
+ bool setAutPort = false;
+ QStringList args = QCoreApplication::arguments();
+ QByteArray autPortEnvBa = qgetenv("QTUITEST_PORT");
+ QString autPortEnv = QString(autPortEnvBa);
+ QByteArray debugEnvBa = qgetenv("QTUITEST_DEBUG");
+ QString debugEnv = QString(debugEnvBa);
+
+
+#ifndef QTUITEST_DEBUG
+ int debugValue = debugEnv.toInt(&parseOk);
+ if (parseOk && (debugValue > 0))
+ showDebug = true;
+#else
+ showDebug = true;
+#endif
+
+ if (showDebug)
+ qWarning("QtUiTest: Start service");
+
+ for (int index = 0; index < args.count(); index++){
+ if (args[index].endsWith("qtuitestrunner")) {
+ if (showDebug)
+ qWarning() << "QtUiTest: Not starting TestSlaveServer::startService for qtuitestrunner";
+ return;
+ }
+ }
+
+ if (started){
+ if (showDebug)
+ qWarning() << "QtUiTest: Closing TestSlaveServer connection";
+
+ close();
+ }
+ if (!autPortEnv.isEmpty()) {
+ aut_port = autPortEnv.toUShort(&parseOk);
+ if (!parseOk){
+ aut_port = DEFAULT_AUT_PORT;
+ qWarning() << "QtUiTest: Unable to parse QTUITEST_PORT" << autPortEnv;
+ } else {
+ setAutPort = true;
+ if (showDebug)
+ qWarning() << "QtUiTest: Set port via QTUITEST_PORT to" << aut_port;
+ }
+ }
+ for (int index = 0; index < args.count(); index++) {
+ if ((args[index] == QLatin1String("-autport")) && (index + 1 < args.count())){
+ aut_port = args[index + 1].toUShort(&parseOk);
+ if (!parseOk) {
+ aut_port = DEFAULT_AUT_PORT;
+ qWarning() << "QtUiTest: Unable to parse -autport" << args[index];
+ } else {
+ setAutPort = true;
+ if (showDebug)
+ qWarning() << "QtUiTest: Set port via -autport to" << aut_port;
+ }
+ }
+ }
+
+ if (!listen(QHostAddress::Any, aut_port)) {
+ qWarning() << "QtUiTest: couldn't listen for connections on " << aut_port << " :"
+ << errorString() << " started :" << started;
+ exit(-1);
+ } else {
+ started = true;
+ if (showDebug)
+ qWarning() << "QtUiTest: listening for connections on" << aut_port;
+ }
+}
+
+void TestSlaveServer::stopService()
+{
+ if (showDebug)
+ qWarning("QtUiTest : Stoping service");
+
+ close();
+ started = false;
+}
diff --git a/plugins/styles/qtuitest/testslaveserver.h b/plugins/styles/qtuitest/testslaveserver.h
new file mode 100644
index 0000000..60d07bd
--- /dev/null
+++ b/plugins/styles/qtuitest/testslaveserver.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTSLAVESERVER_H
+#define QTESTSLAVESERVER_H
+
+#include <QTcpServer>
+#include <qtestslave.h>
+
+struct TestSlaveServer : public QTcpServer
+{
+ TestSlaveServer();
+ ~TestSlaveServer();
+ void incomingConnection(int);
+ void startService();
+ void stopService();
+
+ QTestSlave slave;
+ bool showDebug;
+ bool started;
+};
+
+Q_GLOBAL_STATIC(TestSlaveServer, testSlaveServer);
+
+#endif \ No newline at end of file
diff --git a/qtuitest.pro b/qtuitest.pro
index 329911b..c80c579 100644
--- a/qtuitest.pro
+++ b/qtuitest.pro
@@ -6,6 +6,7 @@ INCLUDEPATH += $$PWD
INCLUDEPATH += $$PWD/botan/build
system(echo QMAKEFEATURES+=$$PWD/features >> $$OUT_PWD/.qmake.cache)
+testability: system(echo CONFIG+=testability >> $$OUT_PWD/.qmake.cache)
unix:!mac:!symbian {
system(if ! [ -e $$OUT_PWD/features ]; then ln -sf $$PWD/features $$OUT_PWD/features; fi)