forked from qt-creator/qt-creator
QmlProject: Remove old test residuals
Change-Id: I800c3e9fe70725935aac5baf58763b7dabc6262a Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -8,6 +8,5 @@ add_subdirectory(qmldesigner)
|
||||
add_subdirectory(qmleditor)
|
||||
add_subdirectory(qmljssimplereader)
|
||||
add_subdirectory(qmljsutils)
|
||||
add_subdirectory(qmlprojectmanager)
|
||||
add_subdirectory(qrcparser)
|
||||
add_subdirectory(reformatter)
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
add_subdirectory(fileformat)
|
||||
@@ -1,20 +0,0 @@
|
||||
if (NOT TARGET QmlProjectManager)
|
||||
return()
|
||||
endif()
|
||||
|
||||
get_target_property(QmlProjectManagerSources QmlProjectManager SOURCES)
|
||||
foreach(source IN LISTS QmlProjectManagerSources)
|
||||
if (source MATCHES "fileformat")
|
||||
list(APPEND fileformat_sources "${PROJECT_SOURCE_DIR}/src/plugins/qmlprojectmanager/${source}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
#add_qtc_test(tst_qml_fileformat
|
||||
# DEPENDS QmlJS Utils
|
||||
# INCLUDES "${PROJECT_SOURCE_DIR}/src/plugins/qmlprojectmanager/fileformat"
|
||||
# DEFINES
|
||||
# QT_CREATOR
|
||||
# SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
# SOURCES tst_fileformat.cpp ${fileformat_sources}
|
||||
#)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
QmlFiles {
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
QmlFiles {
|
||||
recursive: false
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
QmlFiles {
|
||||
directory: "subdir"
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
QmlFiles {
|
||||
directory: "."
|
||||
recursive: false
|
||||
}
|
||||
QmlFiles {
|
||||
directory: "subdir"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
QmlFiles {
|
||||
paths: [ "file1.qml",
|
||||
"file2.qml" ]
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
ImageFiles {
|
||||
directory: "."
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
ImageFiles {
|
||||
filter: "?mage.[gf]if"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import QmlProject 1.1
|
||||
|
||||
Project {
|
||||
Files {
|
||||
filter: "image.gif"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
importPaths: [ "../otherLibrary", "library" ]
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import QmlProject 1.1
|
||||
|
||||
Project {
|
||||
mainFile: "file1.qml"
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import QmlProject 1.0
|
||||
|
||||
Project {
|
||||
QmlFiles {
|
||||
recursive: true
|
||||
}
|
||||
JavaScriptFiles {
|
||||
paths: ["script.js"]
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import qbs
|
||||
|
||||
QtcAutotest {
|
||||
name: "QmlProjectManager file format autotest"
|
||||
Depends { name: "QmlJS" }
|
||||
Depends { name: "Utils" }
|
||||
property path fileFormatDir: project.ide_source_tree + "/src/plugins/qmlprojectmanager/fileformat"
|
||||
files: "tst_fileformat.cpp"
|
||||
Group {
|
||||
name: "Files from QmlProjectManager"
|
||||
prefix: product.fileFormatDir + '/'
|
||||
files: [
|
||||
"filefilteritems.cpp",
|
||||
"filefilteritems.h",
|
||||
"qmlprojectfileformat.cpp",
|
||||
"qmlprojectfileformat.h",
|
||||
"qmlprojectitem.cpp",
|
||||
"qmlprojectitem.h",
|
||||
]
|
||||
}
|
||||
cpp.includePaths: base.concat([fileFormatDir])
|
||||
cpp.defines: base.concat([
|
||||
'QT_CREATOR',
|
||||
'SRCDIR="' + path + '"'
|
||||
])
|
||||
}
|
||||
@@ -1,227 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qmlprojectitem.h"
|
||||
#include "filefilteritems.h"
|
||||
#include "qmlprojectfileformat.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
//TESTED_COMPONENT=src/plugins/qmlprojectmanager/fileformat
|
||||
|
||||
using namespace QmlProjectManager;
|
||||
using namespace Utils;
|
||||
|
||||
#define COMPARE_AS_SETS(actual, expected) \
|
||||
do {\
|
||||
if (!QTest::qCompare(Utils::toSet(actual), Utils::toSet(expected), #actual, #expected, __FILE__, __LINE__)) {\
|
||||
qDebug() << actual << "\nvs." << expected; \
|
||||
return;\
|
||||
}\
|
||||
} while (false)
|
||||
|
||||
|
||||
class tst_FileFormat : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
tst_FileFormat();
|
||||
|
||||
private slots:
|
||||
void testFileFilter();
|
||||
void testMatchesFile();
|
||||
void testLibraryPaths();
|
||||
void testMainFile();
|
||||
};
|
||||
|
||||
tst_FileFormat::tst_FileFormat()
|
||||
{
|
||||
}
|
||||
|
||||
const QString testDataDir = QLatin1String(SRCDIR "/data");
|
||||
const FilePath testDataDirPath = FilePath::fromString(testDataDir);
|
||||
|
||||
static std::unique_ptr<QmlProjectItem> loadQmlProject(QString name, QString *error)
|
||||
{
|
||||
return QmlProjectFileFormat::parseProjectFile(
|
||||
Utils::FilePath::fromString(testDataDir).pathAppended(name + ".qmlproject"), error);
|
||||
}
|
||||
|
||||
void tst_FileFormat::testFileFilter()
|
||||
{
|
||||
QString error;
|
||||
|
||||
//
|
||||
// Search for qml files in directory + subdirectories
|
||||
//
|
||||
{
|
||||
auto project = loadQmlProject(QLatin1String("testFileFilter1"), &error);
|
||||
QVERIFY(project);
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
project->setSourceDirectory(testDataDirPath);
|
||||
|
||||
QStringList expectedFiles(QStringList() << testDataDir + "/file1.qml"
|
||||
<< testDataDir + "/file2.qml"
|
||||
<< testDataDir + "/subdir/file3.qml");
|
||||
COMPARE_AS_SETS(project->files(), expectedFiles);
|
||||
}
|
||||
|
||||
//
|
||||
// search for all qml files in directory
|
||||
//
|
||||
{
|
||||
auto project = loadQmlProject(QLatin1String("testFileFilter2"), &error);
|
||||
QVERIFY(project);
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
project->setSourceDirectory(testDataDirPath);
|
||||
|
||||
QStringList expectedFiles(QStringList() << testDataDir + "/file1.qml"
|
||||
<< testDataDir + "/file2.qml");
|
||||
COMPARE_AS_SETS(project->files(), expectedFiles);
|
||||
}
|
||||
|
||||
//
|
||||
// search for all qml files in subdirectory
|
||||
//
|
||||
{
|
||||
auto project = loadQmlProject(QLatin1String("testFileFilter3"), &error);
|
||||
QVERIFY(project);
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
project->setSourceDirectory(testDataDirPath);
|
||||
|
||||
QStringList expectedFiles(QStringList() << testDataDir + "/subdir/file3.qml");
|
||||
COMPARE_AS_SETS(project->files(), expectedFiles);
|
||||
}
|
||||
|
||||
//
|
||||
// multiple entries
|
||||
//
|
||||
{
|
||||
auto project = loadQmlProject(QLatin1String("testFileFilter4"), &error);
|
||||
QVERIFY(project);
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
project->setSourceDirectory(testDataDirPath);
|
||||
|
||||
QStringList expectedFiles(QStringList() << testDataDir + "/file1.qml"
|
||||
<< testDataDir + "/file2.qml"
|
||||
<< testDataDir + "/subdir/file3.qml");
|
||||
QCOMPARE(project->files().size(), 3);
|
||||
COMPARE_AS_SETS(project->files(), expectedFiles);
|
||||
}
|
||||
|
||||
//
|
||||
// include specific list
|
||||
//
|
||||
{
|
||||
auto project = loadQmlProject(QLatin1String("testFileFilter5"), &error);
|
||||
QVERIFY(project);
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
project->setSourceDirectory(testDataDirPath);
|
||||
|
||||
QStringList expectedFiles(QStringList() << testDataDir + "/file1.qml"
|
||||
<< testDataDir + "/file2.qml");
|
||||
COMPARE_AS_SETS(project->files(), expectedFiles);
|
||||
}
|
||||
|
||||
//
|
||||
// include specific list
|
||||
//
|
||||
{
|
||||
auto project = loadQmlProject(QLatin1String("testFileFilter6"), &error);
|
||||
QVERIFY(project);
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
project->setSourceDirectory(testDataDirPath);
|
||||
|
||||
QStringList expectedFiles(QStringList() << testDataDir + "/image.gif");
|
||||
COMPARE_AS_SETS(project->files(), expectedFiles);
|
||||
}
|
||||
|
||||
//
|
||||
// use wildcards
|
||||
//
|
||||
{
|
||||
auto project = loadQmlProject(QLatin1String("testFileFilter7"), &error);
|
||||
QVERIFY(project);
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
project->setSourceDirectory(testDataDirPath);
|
||||
|
||||
QStringList expectedFiles(QStringList() << testDataDir + "/image.gif");
|
||||
COMPARE_AS_SETS(project->files(), expectedFiles);
|
||||
}
|
||||
|
||||
//
|
||||
// use Files element (1.1)
|
||||
//
|
||||
{
|
||||
auto project = loadQmlProject(QLatin1String("testFileFilter8"), &error);
|
||||
QVERIFY(project);
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
project->setSourceDirectory(testDataDirPath);
|
||||
|
||||
QStringList expectedFiles(QStringList() << testDataDir + "/image.gif");
|
||||
COMPARE_AS_SETS(project->files(), expectedFiles);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_FileFormat::testMatchesFile()
|
||||
{
|
||||
QString error;
|
||||
//
|
||||
// search for qml files in local directory
|
||||
//
|
||||
auto project = loadQmlProject(QLatin1String("testMatchesFile"), &error);
|
||||
QVERIFY(project);
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
project->setSourceDirectory(testDataDirPath);
|
||||
|
||||
QVERIFY(project->matchesFile(testDataDir + "/file1.qml"));
|
||||
QVERIFY(project->matchesFile(testDataDir + "/notyetexistingfile.qml"));
|
||||
QVERIFY(project->matchesFile(testDataDir + "/subdir/notyetexistingfile.qml"));
|
||||
QVERIFY(project->matchesFile(testDataDir + "/script.js"));
|
||||
QVERIFY(!project->matchesFile(testDataDir + "/script.css"));
|
||||
}
|
||||
|
||||
void tst_FileFormat::testLibraryPaths()
|
||||
{
|
||||
QString error;
|
||||
//
|
||||
// search for qml files in local directory
|
||||
//
|
||||
auto project = loadQmlProject(QLatin1String("testLibraryPaths"), &error);
|
||||
QVERIFY(project);
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
project->setSourceDirectory(testDataDirPath);
|
||||
|
||||
const QDir base(testDataDir);
|
||||
const QStringList expectedPaths({base.relativeFilePath(SRCDIR "/otherLibrary"),
|
||||
base.relativeFilePath(SRCDIR "/data/library")});
|
||||
COMPARE_AS_SETS(project->importPaths(), expectedPaths);
|
||||
}
|
||||
|
||||
void tst_FileFormat::testMainFile()
|
||||
{
|
||||
QString error;
|
||||
//
|
||||
// search for qml files in local directory
|
||||
//
|
||||
auto project = loadQmlProject(QLatin1String("testMainFile"), &error);
|
||||
QVERIFY(project);
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
QCOMPARE(project->mainFile(), QString("file1.qml"));
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(tst_FileFormat);
|
||||
#include "tst_fileformat.moc"
|
||||
@@ -1,6 +0,0 @@
|
||||
import qbs
|
||||
|
||||
Project {
|
||||
name: "QmlProjectManager autotests"
|
||||
references: "fileformat/fileformat.qbs"
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
if(NOT TARGET QmlProjectManagerLib)
|
||||
return()
|
||||
endif()
|
||||
|
||||
project(QmlProjectManagerConverterDataCreator)
|
||||
|
||||
add_compile_definitions(QT_CREATOR)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
extend_qtc_test(unittest
|
||||
CONDITION
|
||||
TARGET QmlProjectManagerLib
|
||||
DEPENDS
|
||||
QmlProjectManagerLib
|
||||
SOURCES
|
||||
|
||||
@@ -519,7 +519,7 @@ TEST_F(QmlProjectItem, SetDesignStudioVersion)
|
||||
ASSERT_EQ(projectItemSetters->versionDesignStudio(), "6");
|
||||
}
|
||||
|
||||
// TODO: We should move this one into the integration tests
|
||||
// TODO: We should move these 2 tests into the integration tests
|
||||
TEST_F(QmlProjectItem, TestFileFilters)
|
||||
{
|
||||
// GIVEN
|
||||
@@ -536,4 +536,28 @@ TEST_F(QmlProjectItem, TestFileFilters)
|
||||
ASSERT_THAT(filePaths, UnorderedElementsAreArray(expectedAbsoluteFilePaths));
|
||||
}
|
||||
|
||||
TEST_F(QmlProjectItem, MatchesFile)
|
||||
{
|
||||
// GIVEN
|
||||
auto fileSearched = localTestDataDir + "/file-filters/content/MaterialNames.qml";
|
||||
|
||||
// WHEN
|
||||
auto fileFound = projectItemFileFilters->matchesFile(fileSearched);
|
||||
|
||||
// THEN
|
||||
ASSERT_TRUE(fileFound);
|
||||
}
|
||||
|
||||
TEST_F(QmlProjectItem, NotMatchesFile)
|
||||
{
|
||||
// GIVEN
|
||||
auto fileSearched = localTestDataDir + "/file-filters/content/non-existing-file.qwerty";
|
||||
|
||||
// WHEN
|
||||
auto fileFound = projectItemFileFilters->matchesFile(fileSearched);
|
||||
|
||||
// THEN
|
||||
ASSERT_FALSE(fileFound);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user