summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@theqtcompany.com>2015-07-08 16:56:22 +0200
committerKai Koehne <kai.koehne@theqtcompany.com>2015-07-09 13:38:42 +0000
commitb2a65ce68bce4fcd4b517d1aadedb40792bfc818 (patch)
treee3685aa349abe10148c250d963723c049919b5c9 /tests
parentd7f53290d9a8589752b9191131dfe2b500a23511 (diff)
Sanitize QDebug output
Prefer using the stream operator logic instead of using QString::fromLatin1. Add a noquote() where a QString should be printed without any quotes/escapes. This also fixes the tests with Qt 5.5, where QString's are further escaped. Change-Id: Ie3afd14b9355101d3c0b52f30f66ec759c76526c Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp4
-rw-r--r--tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp22
-rw-r--r--tests/auto/installer/scriptengine/tst_scriptengine.cpp34
-rw-r--r--tests/auto/installer/settings/tst_settings.cpp4
4 files changed, 30 insertions, 34 deletions
diff --git a/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp b/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp
index 3267ec00e..9515848aa 100644
--- a/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp
+++ b/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp
@@ -65,8 +65,8 @@ private slots:
void testDefaultAction()
{
- const char ignoreMessage[] = "\"Created critical message box TestError: \"A test error\", "
- "This is a test error message.\" ";
+ const char ignoreMessage[] = "Created critical message box \"TestError\": \"A test error\", "
+ "\"This is a test error message.\"";
srand(time(0)); /* initialize random seed: */
int standardButtons = QMessageBox::NoButton;
diff --git a/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp b/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp
index 42da15a80..0d9873729 100644
--- a/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp
+++ b/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp
@@ -90,23 +90,19 @@ class tst_PackageManagerCore : public QObject
private:
void setIgnoreMessage(const QString &testDirectory)
{
-#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
- const QString message = "\"\t- arguments: %1\" ";
-#else
- const QString message = "\"\\t- arguments: %1\" ";
-#endif
+ const QString message = "\t- arguments: %1";
QTest::ignoreMessage(QtDebugMsg, "Operations sanity check succeeded.");
- QTest::ignoreMessage(QtDebugMsg, "\"backup operation: Mkdir\" ");
+ QTest::ignoreMessage(QtDebugMsg, "backup operation: Mkdir");
QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(testDirectory)));
QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(testDirectory)));
QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(testDirectory)));
- QTest::ignoreMessage(QtDebugMsg, "\"perform operation: Mkdir\" ");
- QTest::ignoreMessage(QtDebugMsg, "Install size: 1 components ");
- QTest::ignoreMessage(QtDebugMsg, "ROLLING BACK operations= 1 ");
- QTest::ignoreMessage(QtDebugMsg, "\"undo operation: Mkdir\" ");
- QTest::ignoreMessage(QtDebugMsg, "Done ");
- QTest::ignoreMessage(QtDebugMsg, "Done ");
- QTest::ignoreMessage(QtDebugMsg, "Done ");
+ QTest::ignoreMessage(QtDebugMsg, "perform operation: Mkdir");
+ QTest::ignoreMessage(QtDebugMsg, "Install size: 1 components");
+ QTest::ignoreMessage(QtDebugMsg, "ROLLING BACK operations= 1");
+ QTest::ignoreMessage(QtDebugMsg, "undo operation: Mkdir");
+ QTest::ignoreMessage(QtDebugMsg, "Done");
+ QTest::ignoreMessage(QtDebugMsg, "Done");
+ QTest::ignoreMessage(QtDebugMsg, "Done");
}
private slots:
diff --git a/tests/auto/installer/scriptengine/tst_scriptengine.cpp b/tests/auto/installer/scriptengine/tst_scriptengine.cpp
index b208ff870..ccb785b70 100644
--- a/tests/auto/installer/scriptengine/tst_scriptengine.cpp
+++ b/tests/auto/installer/scriptengine/tst_scriptengine.cpp
@@ -251,7 +251,7 @@ private slots:
QCOMPARE(context.isError(), false);
// ignore Output from script
- setExpectedScriptOutput("\"function receive()\"");
+ setExpectedScriptOutput("function receive()");
QTest::ignoreMessage(QtWarningMsg, ":10: ReferenceError: foo is not defined");
emiter.produceSignal();
@@ -262,7 +262,7 @@ private slots:
void testScriptPrint()
{
- setExpectedScriptOutput("\"test\"");
+ setExpectedScriptOutput("test");
const QJSValue value = m_scriptEngine->evaluate("print(\"test\");");
if (value.isError()) {
QFAIL(qPrintable(QString::fromLatin1("ScriptEngine error:\n %1").arg(
@@ -272,7 +272,7 @@ private slots:
void testExistingInstallerObject()
{
- setExpectedScriptOutput("\"object\"");
+ setExpectedScriptOutput("object");
const QJSValue value = m_scriptEngine->evaluate("print(typeof installer)");
if (value.isError()) {
QFAIL(qPrintable(QString::fromLatin1("ScriptEngine error:\n %1").arg(
@@ -286,7 +286,7 @@ private slots:
"\n"
"print(component.name);").arg(m_component->name());
- setExpectedScriptOutput("\"component.test.name\"");
+ setExpectedScriptOutput("component.test.name");
const QJSValue value = m_scriptEngine->evaluate(script);
if (value.isError()) {
QFAIL(qPrintable(QString::fromLatin1("ScriptEngine error:\n %1").arg(
@@ -310,7 +310,7 @@ private slots:
"\n"
"print(components[0].name);");
- setExpectedScriptOutput("\"component.test.name\"");
+ setExpectedScriptOutput("component.test.name");
const QJSValue value = m_scriptEngine->evaluate(script);
if (value.isError()) {
QFAIL(qPrintable(QString::fromLatin1("ScriptEngine error:\n %1").arg(
@@ -322,28 +322,28 @@ private slots:
{
try {
// ignore retranslateUi which is called by loadComponentScript
- setExpectedScriptOutput("\"Component constructor - OK\"");
- setExpectedScriptOutput("\"retranslateUi - OK\"");
+ setExpectedScriptOutput("Component constructor - OK");
+ setExpectedScriptOutput("retranslateUi - OK");
m_component->loadComponentScript(":///data/component1.qs");
- setExpectedScriptOutput("\"retranslateUi - OK\"");
+ setExpectedScriptOutput("retranslateUi - OK");
m_component->languageChanged();
- setExpectedScriptOutput("\"createOperationsForPath - OK\"");
+ setExpectedScriptOutput("createOperationsForPath - OK");
m_component->createOperationsForPath(":///data/");
- setExpectedScriptOutput("\"createOperationsForArchive - OK\"");
+ setExpectedScriptOutput("createOperationsForArchive - OK");
// ignore createOperationsForPath which is called by createOperationsForArchive
- setExpectedScriptOutput("\"createOperationsForPath - OK\"");
+ setExpectedScriptOutput("createOperationsForPath - OK");
m_component->createOperationsForArchive("test.7z");
- setExpectedScriptOutput("\"beginInstallation - OK\"");
+ setExpectedScriptOutput("beginInstallation - OK");
m_component->beginInstallation();
- setExpectedScriptOutput("\"createOperations - OK\"");
+ setExpectedScriptOutput("createOperations - OK");
m_component->createOperations();
- setExpectedScriptOutput("\"isDefault - OK\"");
+ setExpectedScriptOutput("isDefault - OK");
bool returnIsDefault = m_component->isDefault();
QCOMPARE(returnIsDefault, false);
@@ -362,7 +362,7 @@ private slots:
try {
// ignore Output from script
- setExpectedScriptOutput("\"script function: Component\"");
+ setExpectedScriptOutput("script function: Component");
testComponent->loadComponentScript(":///data/component2.qs");
} catch (const Error &error) {
const QString debugMessage(
@@ -375,7 +375,7 @@ private slots:
void loadComponentUserInterfaces()
{
try {
- setExpectedScriptOutput("\"checked: false\"");
+ setExpectedScriptOutput("checked: false");
m_component->loadUserInterfaces(QDir(":///data"), QStringList() << QLatin1String("form.ui"));
m_component->loadComponentScript(":///data/userinterface.qs");
} catch (const Error &error) {
@@ -397,7 +397,7 @@ private slots:
QTest::ignoreMessage(QtWarningMsg, "Button with type: \"unknown button\" not found! ");
testGui.callProtectedDelayedExecuteControlScript(PackageManagerCore::ComponentSelection);
- setExpectedScriptOutput("\"FinishedPageCallback - OK\"");
+ setExpectedScriptOutput("FinishedPageCallback - OK");
testGui.callProtectedDelayedExecuteControlScript(PackageManagerCore::InstallationFinished);
} catch (const Error &error) {
QFAIL(qPrintable(error.message()));
diff --git a/tests/auto/installer/settings/tst_settings.cpp b/tests/auto/installer/settings/tst_settings.cpp
index 49385d4ee..036decc20 100644
--- a/tests/auto/installer/settings/tst_settings.cpp
+++ b/tests/auto/installer/settings/tst_settings.cpp
@@ -144,8 +144,8 @@ void tst_Settings::loadUnknownElementConfigInStrictParseMode()
void tst_Settings::loadUnknownElementConfigInRelaxedParseMode()
{
- QTest::ignoreMessage(QtWarningMsg, "\"Ignoring following settings reader error in "
- ":/data/unknown_element_config.xml, line 5, column 13: Unexpected element \"unknown\".\" ");
+ QTest::ignoreMessage(QtWarningMsg, "Ignoring following settings reader error in "
+ ":/data/unknown_element_config.xml, line 5, column 13: Unexpected element \"unknown\".");
try {
Settings settings = Settings::fromFileAndPrefix(":/data/unknown_element_config.xml", ":/data",
Settings::RelaxedParseMode);