forked from qt-creator/qt-creator
Tests: Re-enable qml auto tests
Change-Id: I424caba6b79423d1bf680fab3bd0ec089c564ace Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
+9
-3
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
Item { // 324 1 4
|
||||
x: {
|
||||
switch (a) {
|
||||
case 1:
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
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([
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
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 += \
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
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()
|
||||
{
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
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"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,18 +1,10 @@
|
||||
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"
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
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"])
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
QmlFiles {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
QmlFiles {
|
||||
recursive: false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
QmlFiles {
|
||||
directory: "subdir"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
QmlFiles {
|
||||
directory: "."
|
||||
recursive: false
|
||||
}
|
||||
QmlFiles {
|
||||
directory: "subdir"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
QmlFiles {
|
||||
paths: [ "file1.qml",
|
||||
"file2.qml" ]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
ImageFiles {
|
||||
directory: "."
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
ImageFiles {
|
||||
filter: "?mage.[gf]if"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import QmlProject 1.1
|
||||
|
||||
Project {
|
||||
Files {
|
||||
filter: "image.gif"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
importPaths: [ "../otherLibrary", "library" ]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import QmlProject 1.1
|
||||
|
||||
Project {
|
||||
mainFile: "file1.qml"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
QmlFiles {
|
||||
recursive: true
|
||||
}
|
||||
JavaScriptFiles {
|
||||
paths: ["script.js"]
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,17 @@
|
||||
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;
|
||||
//
|
||||
// search for qml files in local directory
|
||||
//
|
||||
QString projectFile = QLatin1String(
|
||||
"import QmlProject 1.0\n"
|
||||
"Project {\n"
|
||||
" QmlFiles {"
|
||||
" recursive: true"
|
||||
" }"
|
||||
" JavaScriptFiles {"
|
||||
" paths: [\"script.js\"]"
|
||||
" }"
|
||||
"}\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("testMatchesFile"), &error);
|
||||
QVERIFY(project);
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
project->setSourceDirectory(testDataDir);
|
||||
|
||||
@@ -331,63 +214,40 @@ void tst_FileFormat::testMatchesFile()
|
||||
QVERIFY(project->matchesFile(testDataDir + "/subdir/notyetexistingfile.qml"));
|
||||
QVERIFY(project->matchesFile(testDataDir + "/script.js"));
|
||||
QVERIFY(!project->matchesFile(testDataDir + "/script.css"));
|
||||
delete project;
|
||||
}
|
||||
|
||||
void tst_FileFormat::testLibraryPaths()
|
||||
{
|
||||
QString error;
|
||||
//
|
||||
// search for qml files in local directory
|
||||
//
|
||||
QString projectFile = QLatin1String(
|
||||
"import QmlProject 1.0\n"
|
||||
"Project {\n"
|
||||
" importPaths: [ \"../otherLibrary\", \"library\" ]\n"
|
||||
"}\n");
|
||||
QmlProjectItem *project = loadQmlProject(QLatin1String("testLibraryPaths"), &error);
|
||||
QVERIFY(project);
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
{
|
||||
QDeclarativeEngine engine;
|
||||
QDeclarativeComponent component(&engine);
|
||||
component.setData(projectFile.toUtf8(), QUrl());
|
||||
if (!component.isReady())
|
||||
qDebug() << component.errorString();
|
||||
QVERIFY(component.isReady());
|
||||
project->setSourceDirectory(testDataDir);
|
||||
|
||||
QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
|
||||
QVERIFY(project);
|
||||
|
||||
project->setSourceDirectory(testDataDir);
|
||||
|
||||
QStringList expectedPaths(QStringList() << SRCDIR "/otherLibrary"
|
||||
<< SRCDIR "/data/library");
|
||||
qDebug() << expectedPaths << project->importPaths();
|
||||
QCOMPARE(project->importPaths().toSet(), expectedPaths.toSet());
|
||||
}
|
||||
QStringList expectedPaths(QStringList() << SRCDIR "/otherLibrary"
|
||||
<< SRCDIR "/data/library");
|
||||
qDebug() << expectedPaths << project->importPaths();
|
||||
QCOMPARE(project->importPaths().toSet(), expectedPaths.toSet());
|
||||
delete project;
|
||||
}
|
||||
|
||||
void tst_FileFormat::testMainFile()
|
||||
{
|
||||
QString error;
|
||||
//
|
||||
// search for qml files in local directory
|
||||
//
|
||||
QString projectFile = QLatin1String(
|
||||
"import QmlProject 1.1\n"
|
||||
"Project {\n"
|
||||
" mainFile: \"file1.qml\"\n"
|
||||
"}\n");
|
||||
QmlProjectItem *project = loadQmlProject(QLatin1String("testMainFile"), &error);
|
||||
QVERIFY(project);
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
{
|
||||
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());
|
||||
QVERIFY(project);
|
||||
|
||||
QCOMPARE(project->mainFile(), QString("file1.qml"));
|
||||
}
|
||||
QCOMPARE(project->mainFile(), QString("file1.qml"));
|
||||
delete project;
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_FileFormat);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import qbs
|
||||
|
||||
Project {
|
||||
condition: false // Known to be broken, nobody cares.
|
||||
name: "QmlProjectManager autotests"
|
||||
references: "fileformat/fileformat.qbs"
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
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/qmljs/qmljs-lib.pri)
|
||||
DEFINES+=TESTSRCDIR=\\\"$$_PRO_FILE_PWD_\\\"
|
||||
|
||||
TARGET = tst_reformatter
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import "../../autotest.qbs" as Autotest
|
||||
Autotest {
|
||||
name: "QML reformatter autotest"
|
||||
Depends { name: "QmlJS" }
|
||||
Depends { name: "Utils" }
|
||||
Depends { name: "Qt.widgets" } // TODO: Remove when qbs bug is fixed
|
||||
files: "tst_reformatter.cpp"
|
||||
cpp.defines: base.concat([
|
||||
|
||||
Reference in New Issue
Block a user