summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2018-03-14 13:33:04 +0200
committerKatja Marttila <katja.marttila@qt.io>2018-03-26 08:46:30 +0000
commit6664ca85f09d6ae195ac30f83a60d53c2355da0f (patch)
treef5e5a80c9e5b47d7e77679f08ccad682c81fdd98 /tests
parent3f281b049c814602130dd433cedae84e44b28838 (diff)
Add findFiles method
Task-number: QTIFW-1094 Change-Id: Ibc37e9b568f7f54e37f6ed6a5b040940cab5aebd Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/installer/scriptengine/tst_scriptengine.cpp28
1 files changed, 28 insertions, 0 deletions
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()<<result.isArray();
+ qDebug()<<result.isObject();
+ qDebug()<<result.isString();
+ qDebug()<<result.isVariant();
+ QCOMPARE(result.isError(), false);
+ }
+
void loadSimpleComponentScript()
{
try {
@@ -585,6 +612,7 @@ private:
PackageManagerCore m_core;
Component *m_component;
ScriptEngine *m_scriptEngine;
+ QString m_applicatonDirPath;
};