summaryrefslogtreecommitdiffstats
path: root/tests/auto/qprocess/tst_qprocess.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-07-06 13:56:38 +0200
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-07-06 14:10:47 +0200
commit4fe7291edcac2688f042a11ff5c23374c6c0375d (patch)
tree5875dabdc06b69b3d089e030348fa5e6c45336c2 /tests/auto/qprocess/tst_qprocess.cpp
parent92b6ca830f279cfa9d37946f1fd72843b24e704b (diff)
add setNativeArguments() and nativeArguments()
this function enables starting subprocesses which need command lines which cannot be constructed via the portable list-based api. such cases would be programs which need quoting rules which diverge from the msvc runtime. Reviewed-by: joerg Task-number: QTBUG-7620 (and various others which boil down to that)
Diffstat (limited to 'tests/auto/qprocess/tst_qprocess.cpp')
-rw-r--r--tests/auto/qprocess/tst_qprocess.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp
index 8242d30145..fd310f417b 100644
--- a/tests/auto/qprocess/tst_qprocess.cpp
+++ b/tests/auto/qprocess/tst_qprocess.cpp
@@ -132,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();
@@ -1630,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()
{