summaryrefslogtreecommitdiffstats
path: root/tests/auto/qprocess
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qprocess')
-rw-r--r--tests/auto/qprocess/testProcessSpacesArgs/main.cpp7
-rw-r--r--tests/auto/qprocess/tst_qprocess.cpp61
2 files changed, 67 insertions, 1 deletions
diff --git a/tests/auto/qprocess/testProcessSpacesArgs/main.cpp b/tests/auto/qprocess/testProcessSpacesArgs/main.cpp
index d842934..ae5d3ae 100644
--- a/tests/auto/qprocess/testProcessSpacesArgs/main.cpp
+++ b/tests/auto/qprocess/testProcessSpacesArgs/main.cpp
@@ -44,9 +44,14 @@
int main(int argc, char ** argv)
{
-#if defined(__SYMBIAN32__)
+#if defined(__SYMBIAN32__) || defined(WINCE) || defined(_WIN32_WCE)
+# if defined(__SYMBIAN32__)
// Printing to stdout messes up the out.txt, so open a file and print there.
FILE* file = fopen("c:\\logs\\qprocess_args_test.txt","w+");
+# else
+ // No pipes on this "OS"
+ FILE* file = fopen("\\temp\\qprocess_args_test.txt","w+");
+# endif
for (int i = 0; i < argc; ++i) {
if (i)
fprintf(file, "|");
diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp
index 8dae9a0..fd310f4 100644
--- a/tests/auto/qprocess/tst_qprocess.cpp
+++ b/tests/auto/qprocess/tst_qprocess.cpp
@@ -93,6 +93,7 @@ private slots:
void getSetCheck();
void constructing();
void simpleStart();
+ void execute();
void startDetached();
void crashTest();
void crashTest2();
@@ -131,6 +132,9 @@ private slots:
void waitForBytesWrittenInABytesWrittenSlot();
void spaceArgsTest_data();
void spaceArgsTest();
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ void nativeArguments();
+#endif
void exitCodeTest();
void setEnvironment_data();
void setEnvironment();
@@ -284,6 +288,14 @@ void tst_QProcess::simpleStart()
QCOMPARE(qVariantValue<QProcess::ProcessState>(spy.at(2).at(0)), QProcess::NotRunning);
}
//-----------------------------------------------------------------------------
+void tst_QProcess::execute()
+{
+ QCOMPARE(QProcess::execute("testProcessNormal/testProcessNormal",
+ QStringList() << "arg1" << "arg2"), 0);
+ QCOMPARE(QProcess::execute("nonexistingexe"), -2);
+}
+
+//-----------------------------------------------------------------------------
void tst_QProcess::startDetached()
{
QProcess proc;
@@ -1621,6 +1633,55 @@ void tst_QProcess::spaceArgsTest()
process = 0;
}
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+
+//-----------------------------------------------------------------------------
+void tst_QProcess::nativeArguments()
+{
+ QProcess proc;
+
+ // This doesn't actually need special quoting, so it is pointless to use
+ // native arguments here, but that's not the point of this test.
+ proc.setNativeArguments("hello kitty, \"*\"!");
+
+ proc.start(QString::fromLatin1("testProcessSpacesArgs/nospace"), QStringList());
+
+#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
+ QVERIFY(proc.waitForStarted(5000));
+ QVERIFY(proc.waitForFinished(5000));
+#else
+ QVERIFY(proc.waitForStarted(10000));
+ QVERIFY(proc.waitForFinished(10000));
+#endif
+
+#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE)
+ // Symbian test outputs to a file, so check that
+# ifdef Q_OS_SYMBIAN
+ FILE* file = fopen("c:\\logs\\qprocess_args_test.txt","r");
+# else
+ FILE* file = fopen("\\temp\\qprocess_args_test.txt","r");
+# endif
+ char buf[256];
+ fgets(buf, 256, file);
+ fclose(file);
+ QStringList actual = QString::fromLatin1(buf).split("|");
+#else
+ QStringList actual = QString::fromLatin1(proc.readAll()).split("|");
+#endif
+ QVERIFY(!actual.isEmpty());
+ // not interested in the program name, it might be different.
+ actual.removeFirst();
+ QStringList expected;
+#if defined(Q_OS_WINCE)
+ expected << "hello" << "kitty," << "\"*\"!"; // Weird, weird ...
+#else
+ expected << "hello" << "kitty," << "*!";
+#endif
+ QCOMPARE(actual, expected);
+}
+
+#endif
+
//-----------------------------------------------------------------------------
void tst_QProcess::exitCodeTest()
{