Commit b52fca40 authored by Christian Stenger's avatar Christian Stenger
Browse files

Tests: Re-enable qml auto tests



Change-Id: I424caba6b79423d1bf680fab3bd0ec089c564ace
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 32aeb579
......@@ -19,6 +19,12 @@ SUBDIRS += \
filesearch \
valgrind
#contains (QT_CONFIG, declarative) {
#SUBDIRS += qml
#}
lessThan(QT_MAJOR_VERSION, 5) {
contains(QT_CONFIG, declarative) {
SUBDIRS += qml
}
} else {
qtHaveModule(declarative) {
SUBDIRS += qml
}
}
import QtQuick 2.0
Item {
Item { // 324 1 4
x: {
switch (a) {
case 1:
......
QTC_LIB_DEPENDS += qmljs
include(../../../qttest.pri)
DEFINES+=QTCREATORDIR=\\\"$$IDE_SOURCE_TREE\\\"
DEFINES+=TESTSRCDIR=\\\"$$PWD\\\"
include($$IDE_SOURCE_TREE/src/libs/utils/utils-lib.pri)
include($$IDE_SOURCE_TREE/src/libs/languageutils/languageutils-lib.pri)
include($$IDE_SOURCE_TREE/src/libs/qmljs/qmljs-lib.pri)
TARGET = tst_codemodel_check
SOURCES += \
......
......@@ -5,7 +5,6 @@ Autotest {
name: "QML code model check autotest"
Depends { name: "LanguageUtils" }
Depends { name: "QmlJS" }
Depends { name: "Utils" }
Depends { name: "Qt.widgets" }
files: "tst_check.cpp"
cpp.defines: base.concat([
......
QTC_LIB_DEPENDS += qmljs
include(../../qttest.pri)
DEFINES+=QTCREATORDIR=\\\"$$IDE_SOURCE_TREE\\\"
DEFINES+=TESTSRCDIR=\\\"$$PWD\\\"
include($$IDE_SOURCE_TREE/src/libs/utils/utils-lib.pri)
include($$IDE_SOURCE_TREE/src/libs/languageutils/languageutils-lib.pri)
include($$IDE_SOURCE_TREE/src/libs/qmljs/qmljs-lib.pri)
DEFINES+=TESTSRCDIR=\\\"$$_PRO_FILE_PWD_\\\"
TARGET = tst_trie_check
......@@ -15,7 +12,6 @@ SOURCES += \
tst_testtrie.cpp
TEMPLATE = app
TARGET = tester
DEFINES += QMLJS_BUILD_DIR
OTHER_FILES += \
......
import qbs
import "../../autotest.qbs" as Autotest
Autotest {
name: "QML persistenttrie autotest"
Depends { name: "QmlJS" }
Depends { name: "Qt.widgets" } // TODO: Remove when qbs bug is fixed
files: [ "tst_testtrie.h", "tst_testtrie.cpp" ]
cpp.defines: base.concat([
'QMLJS_BUILD_DIR',
'QTCREATORDIR="' + project.ide_source_tree + '"',
'TESTSRCDIR="' + path + '"'
])
}
......@@ -45,7 +45,7 @@ void tst_TestTrie::initTestCase() {
const bool VERBOSE=false;
tst_TestTrie::tst_TestTrie() { QObject::QObject(); }
tst_TestTrie::tst_TestTrie() { }
void tst_TestTrie::testListAll_data()
{
......
TEMPLATE = subdirs
SUBDIRS += qmldesigner \
SUBDIRS += \
#qmldesigner \
qmleditor \
qmljssimplereader \
qmlprojectmanager \
codemodel \
reformatter \
qrcparser
qrcparser \
persistenttrie
......@@ -9,6 +9,7 @@ Project {
"qmljssimplereader/qmljssimplereader.qbs",
"qmlprojectmanager/qmlprojectmanager.qbs",
"qrcparser/qrcparser.qbs",
"reformatter/reformatter.qbs"
"reformatter/reformatter.qbs",
"persistenttrie/persistenttrie.qbs"
]
}
QTC_LIB_DEPENDS += qmljs
QTC_PLUGIN_DEPENDS += qmljstools
include(../../../qttest.pri)
SRCDIR = ../../../../../src
SRCDIR = $$IDE_SOURCE_TREE/src
include($$SRCDIR/libs/qmljs/qmljs-lib.pri)
include($$SRCDIR/libs/utils/utils-lib.pri)
include($$SRCDIR/libs/languageutils/languageutils-lib.pri)
LIBS += -L$$IDE_PLUGIN_PATH/QtProject
SOURCES += \
tst_qmlcodeformatter.cpp \
$$SRCDIR/plugins/qmljstools/qmljsqtstylecodeformatter.cpp \
$$SRCDIR/plugins/texteditor/basetextdocumentlayout.cpp \
$$SRCDIR/plugins/texteditor/itextmark.cpp
HEADERS += \
$$SRCDIR/plugins/qmljstools/qmljsqtstylecodeformatter.h \
$$SRCDIR/plugins/texteditor/basetextdocumentlayout.h \
$$SRCDIR/plugins/texteditor/itextmark.h
tst_qmlcodeformatter.cpp
......@@ -3,10 +3,8 @@ import "../../../autotest.qbs" as Autotest
Autotest {
name: "QML code formatter autotest"
Depends { name: "LanguageUtils" }
Depends { name: "QmlJS" }
Depends { name: "QmlJSTools" }
Depends { name: "Utils" }
Depends { name: "Qt.widgets" } // TODO: Remove when qbs bug is fixed
files: "tst_qmlcodeformatter.cpp"
}
QTC_LIB_DEPENDS += qmljs
include(../../qttest.pri)
DEFINES+=QTCREATORDIR=\\\"$$IDE_SOURCE_TREE\\\"
DEFINES+=TESTSRCDIR=\\\"$$PWD\\\"
include($$IDE_SOURCE_TREE/src/libs/utils/utils.pri)
include($$IDE_SOURCE_TREE/src/libs/qmljs/qmljs.pri)
DEFINES+=TESTSRCDIR=\\\"$$_PRO_FILE_PWD_\\\"
TARGET = tst_qmljssimplereader
......
......@@ -4,7 +4,6 @@ import "../../autotest.qbs" as Autotest
Autotest {
name: "QMLJS simple reader autotest"
Depends { name: "QmlJS" }
Depends { name: "Utils" }
Depends { name: "Qt.widgets" } // TODO: Remove when qbs bug is fixed
files: "tst_qmljssimplereader.cpp"
cpp.defines: base.concat(["QT_CREATOR"])
......
import QmlProject 1.0
Project {
QmlFiles {
recursive: false
}
}
import QmlProject 1.0
Project {
QmlFiles {
directory: "subdir"
}
}
import QmlProject 1.0
Project {
QmlFiles {
directory: "."
recursive: false
}
QmlFiles {
directory: "subdir"
}
}
import QmlProject 1.0
Project {
QmlFiles {
paths: [ "file1.qml",
"file2.qml" ]
}
}
import QmlProject 1.0
Project {
ImageFiles {
directory: "."
}
}
import QmlProject 1.0
Project {
ImageFiles {
filter: "?mage.[gf]if"
}
}
import QmlProject 1.1
Project {
Files {
filter: "image.gif"
}
}
import QmlProject 1.0
Project {
importPaths: [ "../otherLibrary", "library" ]
}
import QmlProject 1.1
Project {
mainFile: "file1.qml"
}
import QmlProject 1.0
Project {
QmlFiles {
recursive: true
}
JavaScriptFiles {
paths: ["script.js"]
}
}
QTC_LIB_DEPENDS += qmljs
include(../../../qttest.pri)
QT += script \
declarative
PLUGIN_DIR=../../../../../src/plugins/qmlprojectmanager
PLUGIN_DIR=$$IDE_SOURCE_TREE/src/plugins/qmlprojectmanager
include($$PLUGIN_DIR/fileformat/fileformat.pri)
include($$IDE_SOURCE_TREE/src/libs/utils/utils-lib.pri)
include($$IDE_SOURCE_TREE/src/libs/utils/utils_dependencies.pri)
INCLUDEPATH += $$PLUGIN_DIR/fileformat
DEFINES += SRCDIR=\\\"$$PWD\\\"
DEFINES += SRCDIR=\\\"$$_PRO_FILE_PWD_\\\"
TEMPLATE = app
SOURCES += tst_fileformat.cpp
......@@ -2,7 +2,6 @@ import qbs
import "../../../autotest.qbs" as Autotest
Autotest {
condition: false
name: "QmlProjectManager file format autotest"
Depends { name: "QmlProjectManager" }
Depends { name: "Utils" }
......
......@@ -54,33 +54,25 @@ private slots:
tst_FileFormat::tst_FileFormat()
{
QmlProjectFileFormat::registerDeclarativeTypes();
}
QString testDataDir = QLatin1String(SRCDIR "/data");
static QmlProjectItem *loadQmlProject(QString name, QString *error)
{
return QmlProjectFileFormat::parseProjectFile(testDataDir + "/" + name + ".qmlproject", error);
}
void tst_FileFormat::testFileFilter()
{
QString error;
//
// Search for qml files in directory + subdirectories
//
QString projectFile = QLatin1String(
"import QmlProject 1.0\n"
"Project {\n"
" QmlFiles {"
" }"
"}\n");
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine);
component.setData(projectFile.toUtf8(), QUrl());
if (!component.isReady())
qDebug() << component.errorString();
QVERIFY(component.isReady());
QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter1"), &error);
QVERIFY(project);
QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
......@@ -88,88 +80,47 @@ void tst_FileFormat::testFileFilter()
<< testDataDir + "/file2.qml"
<< testDataDir + "/subdir/file3.qml");
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
delete project;
}
//
// search for all qml files in directory
//
projectFile = QLatin1String(
"import QmlProject 1.0\n"
"Project {\n"
" QmlFiles {\n"
" recursive: false\n"
" }\n"
"}\n");
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine);
component.setData(projectFile.toUtf8(), QUrl());
if (!component.isReady())
qDebug() << component.errorString();
QVERIFY(component.isReady());
QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter2"), &error);
QVERIFY(project);
QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << testDataDir + "/file1.qml"
<< testDataDir + "/file2.qml");
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
delete project;
}
//
// search for all qml files in subdirectory
//
projectFile = QLatin1String(
"import QmlProject 1.0\n"
"Project {\n"
" QmlFiles {\n"
" directory: \"subdir\"\n"
" }\n"
"}\n");
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine);
component.setData(projectFile.toUtf8(), QUrl());
QVERIFY(component.isReady());
QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter3"), &error);
QVERIFY(project);
QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << testDataDir + "/subdir/file3.qml");
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
delete project;
}
//
// multiple entries
//
projectFile = QLatin1String(
"import QmlProject 1.0\n"
"Project {\n"
" QmlFiles {\n"
" directory: \".\"\n"
" recursive: false\n"
" }"
" QmlFiles {\n"
" directory: \"subdir\"\n"
" }\n"
"}\n");
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine);
component.setData(projectFile.toUtf8(), QUrl());
if (!component.isReady())
qDebug() << component.errorString();
QVERIFY(component.isReady());
QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter4"), &error);
QVERIFY(project);
QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
......@@ -178,151 +129,83 @@ void tst_FileFormat::testFileFilter()
<< testDataDir + "/subdir/file3.qml");
QCOMPARE(project->files().size(), 3);
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
delete project;
}
//
// include specific list
//
projectFile = QLatin1String(
"import QmlProject 1.0\n"
"Project {\n"
" QmlFiles {\n"
" paths: [ \"file1.qml\",\n"
"\"file2.qml\" ]\n"
" }\n"
"}\n");
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine);
component.setData(projectFile.toUtf8(), QUrl());
if (!component.isReady())
qDebug() << component.errorString();
QVERIFY(component.isReady());
QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter5"), &error);
QVERIFY(project);
QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << testDataDir + "/file1.qml"
<< testDataDir + "/file2.qml");
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
delete project;
}
//
// include specific list
//
projectFile = QLatin1String(
"import QmlProject 1.0\n"
"Project {\n"
" ImageFiles {\n"
" directory: \".\"\n"
" }\n"
"}\n");
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine);
component.setData(projectFile.toUtf8(), QUrl());
if (!component.isReady())
qDebug() << component.errorString();
QVERIFY(component.isReady());
QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter6"), &error);
QVERIFY(project);
QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << testDataDir + "/image.gif");
qDebug() << project->files().toSet() << expectedFiles.toSet();
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
delete project;
}
//
// use wildcards
//
projectFile = QLatin1String(
"import QmlProject 1.0\n"
"Project {\n"
" ImageFiles {\n"
" filter: \"?mage.[gf]if\"\n"
" }\n"
"}\n");
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine);
component.setData(projectFile.toUtf8(), QUrl());
if (!component.isReady())
qDebug() << component.errorString();
QVERIFY(component.isReady());
QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter7"), &error);
QVERIFY(project);
QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << testDataDir + "/image.gif");
qDebug() << project->files().toSet() << expectedFiles.toSet();
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
delete project;
}
//
// use Files element (1.1)
//
projectFile = QLatin1String(
"import QmlProject 1.1\n"
"Project {\n"
" Files {\n"
" filter: \"image.gif\"\n"
" }\n"
"}\n");
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine);
component.setData(projectFile.toUtf8(), QUrl());
if (!component.isReady())
qDebug() << component.errorString();
QVERIFY(component.isReady());
QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter8"), &error);
QVERIFY(project);
QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << testDataDir + "/image.gif");
qDebug() << project->files().toSet() << expectedFiles.toSet();
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
delete project;
}
}
void tst_FileFormat::testMatchesFile()
{
QString error;