summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-06-19 13:25:11 +0200
committerLiang Qi <liang.qi@qt.io>2017-06-19 16:12:34 +0200
commitce09ef431373f45d14ce0a6e7de24aee3666093d (patch)
tree7c998b21f02db55e233e7eeb1599663f1c6b51ca /tests/auto/corelib/io/qprocess/tst_qprocess.cpp
parent7ad55ca65f42351e231f31f7a9253ae6eaf1ebb3 (diff)
parent97eec16e4ff6367c233f8ea6c4a343c286c3a514 (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: src/corelib/io/qprocess_unix.cpp src/corelib/io/qprocess_win.cpp src/plugins/platforms/android/qandroidplatformintegration.h src/plugins/platforms/windows/qwindowscontext.cpp src/plugins/platforms/windows/windows.pri src/tools/uic/cpp/cppwriteinitialization.cpp src/widgets/doc/src/widgets-and-layouts/gallery.qdoc Change-Id: I8d0834c77f350ea7540140c2c7f372814afc2d0f
Diffstat (limited to 'tests/auto/corelib/io/qprocess/tst_qprocess.cpp')
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 6b1516600f..de6eb28503 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -94,6 +94,7 @@ private slots:
void setEnvironment();
void setProcessEnvironment_data();
void setProcessEnvironment();
+ void environmentIsSorted();
void spaceInName();
void setStandardInputFile();
void setStandardOutputFile_data();
@@ -1734,6 +1735,47 @@ void tst_QProcess::setProcessEnvironment()
}
}
+void tst_QProcess::environmentIsSorted()
+{
+ QProcessEnvironment env;
+ env.insert(QLatin1String("a"), QLatin1String("foo_a"));
+ env.insert(QLatin1String("B"), QLatin1String("foo_B"));
+ env.insert(QLatin1String("c"), QLatin1String("foo_c"));
+ env.insert(QLatin1String("D"), QLatin1String("foo_D"));
+ env.insert(QLatin1String("e"), QLatin1String("foo_e"));
+ env.insert(QLatin1String("F"), QLatin1String("foo_F"));
+ env.insert(QLatin1String("Path"), QLatin1String("foo_Path"));
+ env.insert(QLatin1String("SystemRoot"), QLatin1String("foo_SystemRoot"));
+
+ const QStringList envlist = env.toStringList();
+
+#ifdef Q_OS_WIN32
+ // The environment block passed to CreateProcess "[Requires that] All strings in the
+ // environment block must be sorted alphabetically by name. The sort is case-insensitive,
+ // Unicode order, without regard to locale."
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/ms682009(v=vs.85).aspx
+ // So on Windows we sort that way.
+ const QStringList expected = { QLatin1String("a=foo_a"),
+ QLatin1String("B=foo_B"),
+ QLatin1String("c=foo_c"),
+ QLatin1String("D=foo_D"),
+ QLatin1String("e=foo_e"),
+ QLatin1String("F=foo_F"),
+ QLatin1String("Path=foo_Path"),
+ QLatin1String("SystemRoot=foo_SystemRoot") };
+#else
+ const QStringList expected = { QLatin1String("B=foo_B"),
+ QLatin1String("D=foo_D"),
+ QLatin1String("F=foo_F"),
+ QLatin1String("Path=foo_Path"),
+ QLatin1String("SystemRoot=foo_SystemRoot"),
+ QLatin1String("a=foo_a"),
+ QLatin1String("c=foo_c"),
+ QLatin1String("e=foo_e") };
+#endif
+ QCOMPARE(envlist, expected);
+}
+
void tst_QProcess::systemEnvironment()
{
QVERIFY(!QProcess::systemEnvironment().isEmpty());