forked from qt-creator/qt-creator
New qml based .qmproject file format
This commit is contained in:
21
tests/auto/qml/qmlprojectmanager/fileformat/fileformat.pro
Normal file
21
tests/auto/qml/qmlprojectmanager/fileformat/fileformat.pro
Normal file
@@ -0,0 +1,21 @@
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += qt warn_on console depend_includepath
|
||||
CONFIG -= app_bundle
|
||||
|
||||
QT += testlib \
|
||||
script \
|
||||
declarative
|
||||
|
||||
PLUGIN_DIR=../../../../../src/plugins/qmlprojectmanager
|
||||
|
||||
include($$PLUGIN_DIR/fileformat/fileformat.pri)
|
||||
|
||||
INCLUDEPATH += $$PLUGIN_DIR/fileformat
|
||||
|
||||
TARGET=tst_$$TARGET
|
||||
|
||||
DEFINES += SRCDIR=\\\"$$PWD\\\"
|
||||
|
||||
TEMPLATE = app
|
||||
SOURCES += tst_fileformat.cpp
|
||||
141
tests/auto/qml/qmlprojectmanager/fileformat/tst_fileformat.cpp
Normal file
141
tests/auto/qml/qmlprojectmanager/fileformat/tst_fileformat.cpp
Normal file
@@ -0,0 +1,141 @@
|
||||
#include "qmlprojectitem.h"
|
||||
#include "filefilteritems.h"
|
||||
#include <QmlComponent>
|
||||
#include <QmlContext>
|
||||
#include <QmlEngine>
|
||||
#include <QtTest>
|
||||
|
||||
using namespace QmlProjectManager;
|
||||
|
||||
class TestProject : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestProject();
|
||||
|
||||
private slots:
|
||||
void testQmlFileFilter();
|
||||
};
|
||||
|
||||
TestProject::TestProject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString testDataDir = QLatin1String(SRCDIR "/data");
|
||||
|
||||
void TestProject::testQmlFileFilter()
|
||||
{
|
||||
//
|
||||
// search for qml files in local directory
|
||||
//
|
||||
QString projectFile = QLatin1String(
|
||||
"import QmlProject 1.0\n"
|
||||
"Project {\n"
|
||||
" QmlFiles {"
|
||||
" }"
|
||||
"}\n");
|
||||
|
||||
{
|
||||
QmlEngine engine;
|
||||
QmlComponent component(&engine);
|
||||
component.setData(projectFile.toUtf8(), QUrl());
|
||||
if (!component.isReady())
|
||||
qDebug() << component.errorsString();
|
||||
QVERIFY(component.isReady());
|
||||
|
||||
QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
|
||||
QVERIFY(project);
|
||||
|
||||
project->setSourceDirectory(testDataDir);
|
||||
|
||||
QStringList expectedFiles(QStringList() << "file1.qml" << "file2.qml");
|
||||
QCOMPARE(project->qmlFiles().toSet(), expectedFiles.toSet());
|
||||
}
|
||||
|
||||
//
|
||||
// search for all qml files in all subdirectories
|
||||
//
|
||||
projectFile = QLatin1String(
|
||||
"import QmlProject 1.0\n"
|
||||
"Project {\n"
|
||||
" QmlFiles {\n"
|
||||
" recursive: true\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
|
||||
{
|
||||
QmlEngine engine;
|
||||
QmlComponent component(&engine);
|
||||
component.setData(projectFile.toUtf8(), QUrl());
|
||||
QVERIFY(component.isReady());
|
||||
|
||||
QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
|
||||
QVERIFY(project);
|
||||
|
||||
project->setSourceDirectory(testDataDir);
|
||||
|
||||
QStringList expectedFiles(QStringList() << "file1.qml" << "file2.qml" << "subdir/file3.qml");
|
||||
QCOMPARE(project->qmlFiles().toSet(), expectedFiles.toSet());
|
||||
}
|
||||
|
||||
//
|
||||
// search for all qml files in subdirectory
|
||||
//
|
||||
projectFile = QLatin1String(
|
||||
"import QmlProject 1.0\n"
|
||||
"Project {\n"
|
||||
" QmlFiles {\n"
|
||||
" directory: \"subdir\"\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
|
||||
{
|
||||
QmlEngine engine;
|
||||
QmlComponent component(&engine);
|
||||
component.setData(projectFile.toUtf8(), QUrl());
|
||||
QVERIFY(component.isReady());
|
||||
|
||||
QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
|
||||
QVERIFY(project);
|
||||
|
||||
project->setSourceDirectory(testDataDir);
|
||||
|
||||
QStringList expectedFiles(QStringList() << "subdir/file3.qml");
|
||||
QCOMPARE(project->qmlFiles().toSet(), expectedFiles.toSet());
|
||||
}
|
||||
|
||||
//
|
||||
// combination
|
||||
//
|
||||
projectFile = QLatin1String(
|
||||
"import QmlProject 1.0\n"
|
||||
"Project {\n"
|
||||
" QmlFiles {\n"
|
||||
" }"
|
||||
" QmlFiles {\n"
|
||||
" directory: \"subdir\"\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
|
||||
{
|
||||
QmlEngine engine;
|
||||
QmlComponent component(&engine);
|
||||
component.setData(projectFile.toUtf8(), QUrl());
|
||||
qDebug() << component.errorsString();
|
||||
QVERIFY(component.isReady());
|
||||
|
||||
QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
|
||||
QVERIFY(project);
|
||||
|
||||
project->setSourceDirectory(testDataDir);
|
||||
|
||||
QStringList expectedFiles(QStringList() << "file1.qml" << "file2.qml" << "subdir/file3.qml");
|
||||
QCOMPARE(project->qmlFiles().size(), 3);
|
||||
QCOMPARE(project->qmlFiles().toSet(), expectedFiles.toSet());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(TestProject);
|
||||
#include "tst_fileformat.moc"
|
||||
3
tests/auto/qml/qmlprojectmanager/qmlprojectmanager.pro
Normal file
3
tests/auto/qml/qmlprojectmanager/qmlprojectmanager.pro
Normal file
@@ -0,0 +1,3 @@
|
||||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += fileformat
|
||||
Reference in New Issue
Block a user