summaryrefslogtreecommitdiffstats
path: root/tests/auto/qprocess
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
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')
-rw-r--r--tests/auto/qprocess/testProcessSpacesArgs/main.cpp7
-rw-r--r--tests/auto/qprocess/tst_qprocess.cpp52
2 files changed, 58 insertions, 1 deletions
diff --git a/tests/auto/qprocess/testProcessSpacesArgs/main.cpp b/tests/auto/qprocess/testProcessSpacesArgs/main.cpp
index d842934d43..ae5d3aedf8 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 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()
{