From 6664ca85f09d6ae195ac30f83a60d53c2355da0f Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Wed, 14 Mar 2018 13:33:04 +0200 Subject: Add findFiles method Task-number: QTIFW-1094 Change-Id: Ibc37e9b568f7f54e37f6ed6a5b040940cab5aebd Reviewed-by: Leena Miettinen Reviewed-by: Iikka Eklund --- .../installer/scriptengine/tst_scriptengine.cpp | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/auto/installer') diff --git a/tests/auto/installer/scriptengine/tst_scriptengine.cpp b/tests/auto/installer/scriptengine/tst_scriptengine.cpp index 2049e6323..7118d067d 100644 --- a/tests/auto/installer/scriptengine/tst_scriptengine.cpp +++ b/tests/auto/installer/scriptengine/tst_scriptengine.cpp @@ -198,6 +198,7 @@ private slots: m_core.appendRootComponent(component); m_scriptEngine = m_core.componentScriptEngine(); + m_applicatonDirPath = qApp->applicationDirPath(); } void testDefaultScriptEngineValues() @@ -234,6 +235,8 @@ private slots: .hasProperty(QLatin1String("displayName")), true); QCOMPARE(global.property(QLatin1String("QDesktopServices")) .hasProperty(QLatin1String("storageLocation")), true); + QCOMPARE(global.property(QLatin1String("QDesktopServices")) + .hasProperty(QLatin1String("findFiles")), true); QCOMPARE(global.hasProperty(QLatin1String("buttons")), true); QCOMPARE(global.hasProperty(QLatin1String("QInstaller")), true); @@ -342,6 +345,30 @@ private slots: } } + void testFindFiles() + { + const QString expectedOutput = QString::fromLatin1("Found file %1/tst_scriptengine.moc").arg(m_applicatonDirPath); + QByteArray array = expectedOutput.toLatin1(); + const char *c_str2 = array.data(); + + setExpectedScriptOutput(c_str2); + const QString script = QString::fromLatin1("var directory = \"C:/Qt/test\";" + "\n" + "var pattern = \"*.moc\";" + "\n" + "var fileArray = QDesktopServices.findFiles('%1', pattern)" + "\n" + "for (i = 0; i < fileArray.length; i++) {" + "print(\"Found file \"+fileArray[i]);" + "}").arg(m_applicatonDirPath); + const QJSValue result = m_scriptEngine->evaluate(script); + qDebug()<