blob: f41559ac90e14e4a2cf2281c72eed09ee5da3009 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#include "desktoptestcontrol.h"
#include <QDebug>
#include <QProcess>
using namespace Qt4Test;
DesktopTestControl* DesktopTestControl::instance()
{
static DesktopTestControl instance;
return &instance;
}
DesktopTestControl::DesktopTestControl()
: TestControl()
{
proc = 0;
}
DesktopTestControl::~DesktopTestControl()
{
}
bool DesktopTestControl::deviceConfiguration( QString &reply )
{
return false;
}
bool DesktopTestControl::startApplication( const QString &application, const QStringList &arguments,
bool styleQtUITest, const QStringList &environment, QString &reply )
{
proc = new Qt4Test::TestProcess(this);
proc->setEnvironment(environment);
// FIXME proc->test = this;
QStringList args = arguments;
if (styleQtUITest) {
args << "-style";
args << "qtuitest";
}
QByteArray defArgs = qgetenv("QTUITEST_DEFAULT_AUT_ARGS");
if (defArgs.length()) {
QList<QByteArray> defaultArgs = defArgs.split(' ');
foreach (QByteArray arg, defaultArgs) {
args << arg;
}
}
proc->start(application, args);
if (!proc->waitForStarted()) {
reply = QString("Failed to start process '%1': %2").arg(application).arg(proc->errorString());
delete proc;
return false;
}
return true;
}
bool DesktopTestControl::killApplication( const QString &application, QString &reply )
{
if (!proc)
return false;
proc->terminate();
if (!proc->waitForFinished(5000)) {
proc->kill();
proc->waitForFinished(5000);
}
return true;
}
|