diff --git a/src/plugins/qmldesigner/designercore/projectstorage/filestatus.h b/src/plugins/qmldesigner/designercore/projectstorage/filestatus.h index 34a0b648390..9a2b4036ef5 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/filestatus.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/filestatus.h @@ -34,6 +34,7 @@ namespace QmlDesigner { class FileStatus { public: + explicit FileStatus() = default; explicit FileStatus(SourceId sourceId, long long size, long long lastModified) : sourceId{sourceId} , size{size} @@ -49,7 +50,8 @@ public: friend bool operator==(const FileStatus &first, const FileStatus &second) { return first.sourceId == second.sourceId && first.size == second.size - && first.lastModified == second.lastModified; + && first.lastModified == second.lastModified && first.size >= 0 + && first.lastModified >= 0; } friend bool operator!=(const FileStatus &first, const FileStatus &second) @@ -72,10 +74,14 @@ public: return first.sourceId < second; } + bool isValid() const { return sourceId && size >= 0 && lastModified >= 0; } + + explicit operator bool() const { return isValid(); } + public: SourceId sourceId; - long long size; - long long lastModified; + long long size = -1; + long long lastModified = -1; }; using FileStatuses = std::vector; diff --git a/src/plugins/qmldesigner/designercore/projectstorage/filesysteminterface.h b/src/plugins/qmldesigner/designercore/projectstorage/filesysteminterface.h index 01ea60bacaa..9e3fc1e7a97 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/filesysteminterface.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/filesysteminterface.h @@ -40,6 +40,7 @@ public: virtual long long lastModified(SourceId sourceId) const = 0; virtual FileStatus fileStatus(SourceId sourceId) const = 0; virtual void remove(const SourceIds &sourceIds) = 0; + virtual QString contentAsQString(const QString &filePath) const = 0; protected: ~FileSystemInterface() = default; diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectmanagerinterface.h b/src/plugins/qmldesigner/designercore/projectstorage/projectmanagerinterface.h new file mode 100644 index 00000000000..9167e858ff7 --- /dev/null +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectmanagerinterface.h @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +namespace QmlDesigner { + +class ProjectManagerInterface +{ +public: + virtual QStringList qtQmlDirs() const = 0; + +protected: + ~ProjectManagerInterface() = default; +}; + +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h index 71d9f139e8f..e0f0b2cef9f 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h @@ -25,10 +25,8 @@ #pragma once -#include "filestatus.h" #include "projectstorageexceptions.h" -#include "projectstorageids.h" -#include "projectstoragetypes.h" +#include "projectstorageinterface.h" #include "sourcepathcachetypes.h" #include @@ -43,7 +41,7 @@ namespace QmlDesigner { template -class ProjectStorage +class ProjectStorage final : public ProjectStorageInterface { public: template @@ -61,7 +59,7 @@ public: Storage::Documents documents, Storage::Types types, SourceIds sourceIds, - FileStatuses fileStatuses) + FileStatuses fileStatuses) override { Sqlite::ImmediateTransaction transaction{database}; @@ -299,6 +297,14 @@ public: return selectAllFileStatusesStatement.template rangeWithTransaction(); } + FileStatus fetchFileStatus(SourceId sourceId) const override + { + return selectFileStatusesForSourceIdStatement.template valueWithTransaction( + &sourceId); + } + + SourceIds fetchSourceDependencieIds(SourceId sourceId) const override { return {}; } + private: class AliasPropertyDeclaration { @@ -1240,6 +1246,11 @@ private: TypeId declareType(Storage::Type &type) { + if (type.import.name.isEmpty() && type.typeName.isEmpty()) { + type.typeId = selectTypeIdBySourceIdStatement.template value(&type.sourceId); + return type.typeId; + } + ImportId importId = fetchImportId(type.import); if (!importId) @@ -2186,11 +2197,16 @@ public: "SELECT sourceId, size, lastModified FROM fileStatuses WHERE sourceId IN carray(?1) ORDER " "BY sourceId", database}; + mutable ReadStatement<3> selectFileStatusesForSourceIdStatement{ + "SELECT sourceId, size, lastModified FROM fileStatuses WHERE sourceId=?1 ORDER BY sourceId", + database}; WriteStatement insertFileStatusStatement{ "INSERT INTO fileStatuses(sourceId, size, lastModified) VALUES(?1, ?2, ?3)", database}; WriteStatement deleteFileStatusStatement{"DELETE FROM fileStatuses WHERE sourceId=?1", database}; WriteStatement updateFileStatusStatement{ "UPDATE fileStatuses SET size=?2, lastModified=?3 WHERE sourceId=?1", database}; + ReadStatement<1> selectTypeIdBySourceIdStatement{"SELECT typeId FROM types WHERE sourceId=?", + database}; }; } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h new file mode 100644 index 00000000000..fc43d104ea5 --- /dev/null +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "filestatus.h" +#include "projectstoragetypes.h" + +namespace QmlDesigner { + +class ProjectStorageInterface +{ +public: + virtual void synchronize(Storage::ImportDependencies importDependencies, + Storage::Documents documents, + Storage::Types types, + SourceIds sourceIds, + FileStatuses fileStatuses) + = 0; + + virtual FileStatus fetchFileStatus(SourceId sourceId) const = 0; + virtual SourceIds fetchSourceDependencieIds(SourceId sourceId) const = 0; + +protected: + ~ProjectStorageInterface() = default; +}; + +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h index b5e8a14a31d..1247820494c 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h @@ -145,6 +145,11 @@ public: : name{name} {} + friend bool operator==(const ExportedType &first, const ExportedType &second) + { + return first.name == second.name; + } + public: Utils::SmallString name; }; @@ -158,6 +163,11 @@ public: , import{std::move(import)} {} + friend bool operator==(const ExplicitExportedType &first, const ExplicitExportedType &second) + { + return first.name == second.name && first.import == second.import; + } + public: Utils::SmallString name; Import import; @@ -173,6 +183,11 @@ public: : name{name} {} + friend bool operator==(const NativeType &first, const NativeType &second) + { + return first.name == second.name; + } + public: Utils::SmallString name; }; @@ -422,6 +437,13 @@ public: , kind{PropertyKind::Alias} {} + friend bool operator==(const PropertyDeclaration &first, const PropertyDeclaration &second) + { + return first.name == second.name && first.typeName == second.typeName + && first.aliasPropertyName == second.aliasPropertyName + && first.traits == second.traits && first.kind == second.kind; + } + public: Utils::SmallString name; TypeName typeName; @@ -516,10 +538,20 @@ public: , typeId{typeId} {} + friend bool operator==(const Type &first, const Type &second) noexcept + { + return first.typeName == second.typeName && first.prototype == second.prototype + && first.exportedTypes == second.exportedTypes + && first.propertyDeclarations == second.propertyDeclarations + && first.functionDeclarations == second.functionDeclarations + && first.signalDeclarations == second.signalDeclarations + && first.import == second.import && first.sourceId == second.sourceId + && first.sourceId == second.sourceId; + } + public: Utils::SmallString typeName; TypeName prototype; - Utils::SmallString attachedType; ExportedTypes exportedTypes; PropertyDeclarations propertyDeclarations; FunctionDeclarations functionDeclarations; @@ -529,7 +561,6 @@ public: TypeAccessSemantics accessSemantics = TypeAccessSemantics::Invalid; SourceId sourceId; TypeId typeId; - bool isCreatable = false; }; using Types = std::vector; @@ -591,8 +622,8 @@ public: friend bool operator==(const ImportView &first, const ImportView &second) { - return first.name == second.name - && first.version == second.version && first.sourceId == second.sourceId; + return first.name == second.name && first.version == second.version + && first.sourceId == second.sourceId; } public: diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageupdater.cpp b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageupdater.cpp new file mode 100644 index 00000000000..9eb05a0cbb4 --- /dev/null +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageupdater.cpp @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "projectstorageupdater.h" + +#include "filestatuscache.h" +#include "filesysteminterface.h" +#include "projectmanagerinterface.h" +#include "projectstorage.h" +#include "qmldocumentparserinterface.h" +#include "qmltypesparserinterface.h" +#include "sourcepathcache.h" + +#include + +#include + +namespace QmlDesigner { + +ComponentReferences createComponentReferences(const QMultiHash &components) +{ + ComponentReferences componentReferences; + componentReferences.reserve(static_cast(components.size())); + + for (const QmlDirParser::Component &component : components) + componentReferences.push_back(std::cref(component)); + + return componentReferences; +} + +void ProjectUpdater::update() +{ + Storage::ImportDependencies importDependencies; + Storage::Documents documents; + Storage::Types types; + SourceIds sourceIds; + FileStatuses fileStatuses; + + for (const QString &qmldirPath : m_projectManager.qtQmlDirs()) { + SourcePath qmldirSourcePath{qmldirPath}; + SourceId qmlDirSourceId = m_pathCache.sourceId(qmldirSourcePath); + + switch (fileState(qmlDirSourceId)) { + case FileState::Changed: { + QmlDirParser parser; + parser.parse(m_fileSystem.contentAsQString(qmldirPath)); + + sourceIds.push_back(qmlDirSourceId); + + Utils::SmallString moduleName{parser.typeNamespace()}; + SourceContextId directoryId = m_pathCache.sourceContextId(qmlDirSourceId); + + parseTypeInfos(parser.typeInfos(), directoryId, importDependencies, types, sourceIds); + parseQmlComponents(createComponentReferences(parser.components()), + directoryId, + moduleName, + importDependencies, + types, + sourceIds); + break; + } + case FileState::NotChanged: { + SourceIds qmltypesSourceIds = m_projectStorage.fetchSourceDependencieIds(qmlDirSourceId); + parseTypeInfos(qmltypesSourceIds, importDependencies, types, sourceIds); + break; + } + case FileState::NotExists: { + // sourceIds.push_back(qmlDirSourceId); + break; + } + } + } + + m_projectStorage.synchronize(std::move(importDependencies), + std::move(documents), + std::move(types), + std::move(sourceIds), + std::move(fileStatuses)); +} + +void ProjectUpdater::parseTypeInfos(const QStringList &typeInfos, + SourceContextId directoryId, + Storage::ImportDependencies &importDependencies, + Storage::Types &types, + SourceIds &sourceIds) +{ + QString directory{m_pathCache.sourceContextPath(directoryId)}; + + for (const QString &typeInfo : typeInfos) { + SourceId sourceId = m_pathCache.sourceId(directoryId, Utils::SmallString{typeInfo}); + QString qmltypesPath = directory + "/" + typeInfo; + + parseTypeInfo(sourceId, qmltypesPath, importDependencies, types, sourceIds); + } +} + +void ProjectUpdater::parseTypeInfos(const SourceIds &qmltypesSourceIds, + Storage::ImportDependencies &importDependencies, + Storage::Types &types, + SourceIds &sourceIds) +{ + for (SourceId sourceId : qmltypesSourceIds) { + QString qmltypesPath = m_pathCache.sourcePath(sourceId).toQString(); + + parseTypeInfo(sourceId, qmltypesPath, importDependencies, types, sourceIds); + } +} + +void ProjectUpdater::parseTypeInfo(SourceId sourceId, + const QString &qmltypesPath, + Storage::ImportDependencies &importDependencies, + Storage::Types &types, + SourceIds &sourceIds) +{ + if (fileState(sourceId) == FileState::Changed) { + sourceIds.push_back(sourceId); + const auto content = m_fileSystem.contentAsQString(qmltypesPath); + m_qmlTypesParser.parse(content, importDependencies, types, sourceIds); + } +} + +void ProjectUpdater::parseQmlComponents(ComponentReferences components, + SourceContextId directoryId, + Utils::SmallStringView moduleName, + Storage::ImportDependencies &importDependencies, + Storage::Types &types, + SourceIds &sourceIds) +{ + std::sort(components.begin(), components.end(), [](auto &&first, auto &&second) { + return std::tie(first.get().typeName, first.get().majorVersion, first.get().minorVersion) + > std::tie(second.get().typeName, second.get().majorVersion, second.get().minorVersion); + }); + + auto newEnd = std::unique(components.begin(), components.end(), [](auto &&first, auto &&second) { + return first.get().typeName == second.get().typeName + && first.get().majorVersion == second.get().majorVersion; + }); + + components.erase(newEnd, components.end()); + + QString directory{m_pathCache.sourceContextPath(directoryId)}; + + for (const QmlDirParser::Component &component : components) { + Utils::SmallString fileName{component.fileName}; + SourceId sourceId = m_pathCache.sourceId(directoryId, fileName); + + sourceIds.push_back(sourceId); + + const auto content = m_fileSystem.contentAsQString(directory + "/" + component.fileName); + auto type = m_qmlDocumentParser.parse(content); + + type.typeName = fileName; + type.import.name = moduleName; + type.import.version.version = component.majorVersion; + type.accessSemantics = Storage::TypeAccessSemantics::Reference; + type.sourceId = sourceId; + type.exportedTypes.push_back(Storage::ExportedType{Utils::SmallString{component.typeName}}); + + types.push_back(std::move(type)); + } +} + +ProjectUpdater::FileState ProjectUpdater::fileState(SourceId sourceId) const +{ + auto currentFileStatus = m_fileStatusCache.find(sourceId); + + if (!currentFileStatus.isValid()) + return FileState::NotExists; + + auto projectStorageFileStatus = m_projectStorage.fetchFileStatus(sourceId); + + if (!projectStorageFileStatus.isValid() || projectStorageFileStatus != currentFileStatus) + return FileState::Changed; + + return FileState::NotChanged; +} + +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageupdater.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageupdater.h new file mode 100644 index 00000000000..ff8275377c7 --- /dev/null +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageupdater.h @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "nonlockingmutex.h" +#include "projectstorageids.h" +#include "projectstoragetypes.h" + +#include + +#include + +#include + +namespace Sqlite { +class Database; +} + +namespace QmlDesigner { +class ProjectManagerInterface; +class FileSystemInterface; +class ProjectStorageInterface; +template +class SourcePathCache; +class FileStatusCache; +template +class ProjectStorage; +class QmlDocumentParserInterface; +class QmlTypesParserInterface; + +using ComponentReferences = std::vector>; + +class ProjectUpdater +{ +public: + using PathCache = SourcePathCache, NonLockingMutex>; + + ProjectUpdater(ProjectManagerInterface &projectManager, + FileSystemInterface &fileSystem, + ProjectStorageInterface &projectStorage, + FileStatusCache &fileStatusCache, + PathCache &pathCache, + QmlDocumentParserInterface &qmlDocumentParser, + QmlTypesParserInterface &qmlTypesParser) + : m_projectManager{projectManager} + , m_fileSystem{fileSystem} + , m_projectStorage{projectStorage} + , m_fileStatusCache{fileStatusCache} + , m_pathCache{pathCache} + , m_qmlDocumentParser{qmlDocumentParser} + , m_qmlTypesParser{qmlTypesParser} + {} + + void update(); + +private: + enum class FileState { + NotChanged, + Changed, + NotExists, + }; + + void parseTypeInfos(const QStringList &typeInfos, + SourceContextId directoryId, + Storage::ImportDependencies &importDependencies, + Storage::Types &types, + SourceIds &sourceIds); + void parseTypeInfos(const SourceIds &qmltypesSourceIds, + Storage::ImportDependencies &importDependencies, + Storage::Types &types, + SourceIds &sourceIds); + void parseTypeInfo(SourceId sourceId, + const QString &qmltypesPath, + Storage::ImportDependencies &importDependencies, + Storage::Types &types, + SourceIds &sourceIds); + void parseQmlComponents(ComponentReferences components, + SourceContextId directoryId, + Utils::SmallStringView moduleName, + Storage::ImportDependencies &importDependencies, + Storage::Types &types, + SourceIds &sourceIds); + + FileState fileState(SourceId sourceId) const; + +private: + ProjectManagerInterface &m_projectManager; + FileSystemInterface &m_fileSystem; + ProjectStorageInterface &m_projectStorage; + FileStatusCache &m_fileStatusCache; + PathCache &m_pathCache; + QmlDocumentParserInterface &m_qmlDocumentParser; + QmlTypesParserInterface &m_qmlTypesParser; +}; + +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/projectstorage/qmldocumentparserinterface.h b/src/plugins/qmldesigner/designercore/projectstorage/qmldocumentparserinterface.h new file mode 100644 index 00000000000..1d2ce1ee589 --- /dev/null +++ b/src/plugins/qmldesigner/designercore/projectstorage/qmldocumentparserinterface.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "projectstoragetypes.h" + +#include + +namespace QmlDesigner { + +class QmlDocumentParserInterface +{ +public: + virtual Storage::Type parse(const QString &sourceContent) = 0; + +protected: + ~QmlDocumentParserInterface() = default; +}; +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/projectstorage/qmltypesparserinterface.h b/src/plugins/qmldesigner/designercore/projectstorage/qmltypesparserinterface.h new file mode 100644 index 00000000000..7f6239872ae --- /dev/null +++ b/src/plugins/qmldesigner/designercore/projectstorage/qmltypesparserinterface.h @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "projectstoragetypes.h" + +#include + +namespace QmlDesigner { + +class QmlTypesParserInterface +{ +public: + virtual void parse(const QString &sourceContent, + Storage::ImportDependencies &importDependencies, + Storage::Types &types, + SourceIds &sourceIds) + = 0; + +protected: + ~QmlTypesParserInterface() = default; +}; +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/projectstorage/sourcepathcache.h b/src/plugins/qmldesigner/designercore/projectstorage/sourcepathcache.h index 3226ab0a7d9..0858aedd536 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/sourcepathcache.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/sourcepathcache.h @@ -78,6 +78,11 @@ public: return m_sourcePathCache.id({sourceName, sourceContextId}); } + SourceId sourceId(SourceContextId sourceContextId, Utils::SmallStringView sourceName) const + { + return m_sourcePathCache.id({sourceName, sourceContextId}); + } + SourceContextId sourceContextId(Utils::SmallStringView sourceContextPath) const { Utils::SmallStringView path = sourceContextPath.back() == '/' diff --git a/tests/unit/unittest/CMakeLists.txt b/tests/unit/unittest/CMakeLists.txt index 6b74776a28e..f9f4f73e26e 100644 --- a/tests/unit/unittest/CMakeLists.txt +++ b/tests/unit/unittest/CMakeLists.txt @@ -33,7 +33,7 @@ add_qtc_test(unittest GTEST DEPENDS Qt5::Core Qt5::Network Qt5::Widgets Qt5::Xml Qt5::Concurrent Qt5::Qml Qt5::Gui - Qt6Core5Compat + Qt6Core5Compat QmlJS Googletest DEFINES QT_NO_CAST_TO_ASCII @@ -342,6 +342,8 @@ extend_qtc_test(unittest projectstorage/filestatus.h projectstorage/filestatuscache.cpp projectstorage/filestatuscache.h projectstorage/nonlockingmutex.h + projectstorage/projectmanagerinterface.h + projectstorage/projectstorageinterface.h projectstorage/projectstorage.h projectstorage/projectstoragepathwatcher.h projectstorage/projectstoragepathwatcherinterface.h @@ -351,6 +353,7 @@ extend_qtc_test(unittest projectstorage/projectstoragepathwatcher.h projectstorage/projectstoragepathwatchertypes.h projectstorage/projectstoragetypes.h + projectstorage/projectstorageupdater.cpp projectstorage/projectstorageupdater.h projectstorage/sourcepath.h projectstorage/sourcepathcache.h projectstorage/sourcepathcache.h @@ -359,6 +362,8 @@ extend_qtc_test(unittest projectstorage/storagecache.h projectstorage/storagecacheentry.h projectstorage/storagecachefwd.h + projectstorage/qmldocumentparserinterface.h + projectstorage/qmltypesparserinterface.h rewritertransaction.cpp rewritertransaction.h EXPLICIT_MOC @@ -373,7 +378,9 @@ extend_qtc_test(unittest filesystemmock.h filestatuscache-test.cpp listmodeleditor-test.cpp + projectmanagermock.h projectstorage-test.cpp + projectstorageupdater-test.cpp projectstoragesqlitefunctionregistry-test.cpp projectstoragepathwatchermock.h projectstoragepathwatchernotifiermock.h @@ -383,7 +390,8 @@ extend_qtc_test(unittest sourcepathcachemock.h sourcepathview-test.cpp storagecache-test.cpp - + qmldocumentparsermock.h + qmltypesparsermock.h ) # QmlDesigner tests END diff --git a/tests/unit/unittest/filesystemmock.h b/tests/unit/unittest/filesystemmock.h index 972f6af142c..1dd66c7fbdd 100644 --- a/tests/unit/unittest/filesystemmock.h +++ b/tests/unit/unittest/filesystemmock.h @@ -40,4 +40,5 @@ public: MOCK_METHOD(long long, lastModified, (QmlDesigner::SourceId sourceId), (const, override)); MOCK_METHOD(QmlDesigner::FileStatus, fileStatus, (QmlDesigner::SourceId sourceId), (const, override)); MOCK_METHOD(void, remove, (const QmlDesigner::SourceIds &sourceIds), (override)); + MOCK_METHOD(QString, contentAsQString, (const QString &filePath), (const, override)); }; diff --git a/tests/unit/unittest/projectmanagermock.h b/tests/unit/unittest/projectmanagermock.h new file mode 100644 index 00000000000..59e83590951 --- /dev/null +++ b/tests/unit/unittest/projectmanagermock.h @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "googletest.h" + +#include + +class ProjectManagerMock : public QmlDesigner::ProjectManagerInterface +{ +public: + MOCK_METHOD(QStringList, qtQmlDirs, (), (const)); +}; diff --git a/tests/unit/unittest/projectstorage-test.cpp b/tests/unit/unittest/projectstorage-test.cpp index cacf69ff489..2026e9d0e20 100644 --- a/tests/unit/unittest/projectstorage-test.cpp +++ b/tests/unit/unittest/projectstorage-test.cpp @@ -84,7 +84,7 @@ MATCHER_P5(IsStorageType, return type.import == import && type.typeName == typeName && type.accessSemantics == accessSemantics && type.sourceId == sourceId - && Utils::visit([&](auto &&v) -> bool { return v.name == prototype.name; }, type.prototype); + && Storage::TypeName{prototype} == type.prototype; } MATCHER_P4(IsStorageTypeWithInvalidSourceId, @@ -120,8 +120,7 @@ MATCHER_P3(IsPropertyDeclaration, const Storage::PropertyDeclaration &propertyDeclaration = arg; return propertyDeclaration.name == name - && Utils::visit([&](auto &&v) -> bool { return v.name == typeName.name; }, - propertyDeclaration.typeName) + && Storage::TypeName{typeName} == propertyDeclaration.typeName && propertyDeclaration.traits == traits; } @@ -166,292 +165,6 @@ MATCHER_P3(IsImportDependency, class ProjectStorage : public testing::Test { -public: - ProjectStorage() - { - ON_CALL(selectSourceContextIdFromSourceContextsBySourceContextPathStatement, - valueReturnsSourceContextId(A())) - .WillByDefault(Return(SourceContextId())); - ON_CALL(selectSourceContextIdFromSourceContextsBySourceContextPathStatement, - valueReturnsSourceContextId(Utils::SmallStringView(""))) - .WillByDefault(Return(SourceContextId(0))); - ON_CALL(selectSourceContextIdFromSourceContextsBySourceContextPathStatement, - valueReturnsSourceContextId(Utils::SmallStringView("/path/to"))) - .WillByDefault(Return(SourceContextId(5))); - ON_CALL(databaseMock, lastInsertedRowId()).WillByDefault(Return(12)); - ON_CALL(selectSourceIdFromSourcesBySourceContextIdAndSourceNameStatment, - valueReturnInt32(_, _)) - .WillByDefault(Return(Utils::optional())); - ON_CALL(selectSourceIdFromSourcesBySourceContextIdAndSourceNameStatment, - valueReturnInt32(0, Utils::SmallStringView(""))) - .WillByDefault(Return(Utils::optional(0))); - ON_CALL(selectSourceIdFromSourcesBySourceContextIdAndSourceNameStatment, - valueReturnInt32(5, Utils::SmallStringView("file.h"))) - .WillByDefault(Return(Utils::optional(42))); - ON_CALL(selectAllSourcesStatement, valuesReturnCacheSources(_)) - .WillByDefault(Return(std::vector{{"file.h", SourceContextId{1}, SourceId{1}}, - {"file.cpp", SourceContextId{2}, SourceId{4}}})); - ON_CALL(selectSourceContextPathFromSourceContextsBySourceContextIdStatement, - valueReturnPathString(5)) - .WillByDefault(Return(Utils::optional("/path/to"))); - ON_CALL(selectSourceNameAndSourceContextIdFromSourcesBySourceIdStatement, - valueReturnCacheSourceNameAndSourceContextId(42)) - .WillByDefault(Return(QmlDesigner::Cache::SourceNameAndSourceContextId{"file.cpp", 5})); - ON_CALL(selectSourceContextIdFromSourcesBySourceIdStatement, - valueReturnInt32(TypedEq(42))) - .WillByDefault(Return(Utils::optional(5))); - } - -protected: - using ProjectStorageMock = QmlDesigner::ProjectStorage; - template - using ReadStatement = ProjectStorageMock::ReadStatement; - using WriteStatement = ProjectStorageMock::WriteStatement; - template - using ReadWriteStatement = ProjectStorageMock::ReadWriteStatement; - - NiceMock databaseMock; - ProjectStorageMock storage{databaseMock, true}; - ReadWriteStatement<1> &upsertTypeStatement = storage.upsertTypeStatement; - ReadStatement<1> &selectTypeIdByExportedNameStatement = storage.selectTypeIdByExportedNameStatement; - ReadStatement<1> &selectSourceContextIdFromSourceContextsBySourceContextPathStatement - = storage.selectSourceContextIdFromSourceContextsBySourceContextPathStatement; - ReadStatement<1> &selectSourceIdFromSourcesBySourceContextIdAndSourceNameStatment - = storage.selectSourceIdFromSourcesBySourceContextIdAndSourceNameStatement; - ReadStatement<1> &selectSourceContextPathFromSourceContextsBySourceContextIdStatement - = storage.selectSourceContextPathFromSourceContextsBySourceContextIdStatement; - ReadStatement<2> &selectSourceNameAndSourceContextIdFromSourcesBySourceIdStatement - = storage.selectSourceNameAndSourceContextIdFromSourcesBySourceIdStatement; - ReadStatement<2> &selectAllSourceContextsStatement = storage.selectAllSourceContextsStatement; - WriteStatement &insertIntoSourceContexts = storage.insertIntoSourceContextsStatement; - WriteStatement &insertIntoSourcesStatement = storage.insertIntoSourcesStatement; - ReadStatement<3> &selectAllSourcesStatement = storage.selectAllSourcesStatement; - ReadStatement<1> &selectSourceContextIdFromSourcesBySourceIdStatement = storage.selectSourceContextIdFromSourcesBySourceIdStatement; - ReadStatement<5> &selectTypeByTypeIdStatement = storage.selectTypeByTypeIdStatement; - ReadStatement<1> &selectExportedTypesByTypeIdStatement = storage.selectExportedTypesByTypeIdStatement; - ReadStatement<7> &selectTypesStatement = storage.selectTypesStatement; -}; - -TEST_F(ProjectStorage, SelectForFetchingSourceContextIdForKnownPathCalls) -{ - InSequence s; - - EXPECT_CALL(databaseMock, deferredBegin()); - EXPECT_CALL(selectSourceContextIdFromSourceContextsBySourceContextPathStatement, - valueReturnsSourceContextId(TypedEq("/path/to"))); - EXPECT_CALL(databaseMock, commit()); - - storage.fetchSourceContextId("/path/to"); -} - -TEST_F(ProjectStorage, SelectForFetchingSourceIdForKnownPathCalls) -{ - InSequence s; - - EXPECT_CALL(databaseMock, deferredBegin()); - EXPECT_CALL(selectSourceIdFromSourcesBySourceContextIdAndSourceNameStatment, - valueReturnsSourceId(5, Eq("file.h"))); - EXPECT_CALL(databaseMock, commit()); - - storage.fetchSourceId(SourceContextId{5}, "file.h"); -} - -TEST_F(ProjectStorage, NotWriteForFetchingSourceContextIdForKnownPathCalls) -{ - EXPECT_CALL(insertIntoSourceContexts, write(An())).Times(0); - - storage.fetchSourceContextId("/path/to"); -} - -TEST_F(ProjectStorage, NotWriteForFetchingSoureIdForKnownEntryCalls) -{ - EXPECT_CALL(insertIntoSourcesStatement, write(An(), An())).Times(0); - - storage.fetchSourceId(SourceContextId{5}, "file.h"); -} - -TEST_F(ProjectStorage, SelectAndWriteForFetchingSourceContextIdForUnknownPathCalls) -{ - InSequence s; - - EXPECT_CALL(databaseMock, deferredBegin()); - EXPECT_CALL(selectSourceContextIdFromSourceContextsBySourceContextPathStatement, - valueReturnsSourceContextId( - TypedEq("/some/not/known/path"))); - EXPECT_CALL(insertIntoSourceContexts, - write(TypedEq("/some/not/known/path"))); - EXPECT_CALL(databaseMock, commit()); - - storage.fetchSourceContextId("/some/not/known/path"); -} - -TEST_F(ProjectStorage, SelectAndWriteForFetchingSourceIdForUnknownEntryCalls) -{ - InSequence s; - - EXPECT_CALL(databaseMock, deferredBegin()); - EXPECT_CALL(selectSourceIdFromSourcesBySourceContextIdAndSourceNameStatment, - valueReturnsSourceId(5, Eq("unknownfile.h"))); - EXPECT_CALL(insertIntoSourcesStatement, - write(TypedEq(5), TypedEq("unknownfile.h"))); - EXPECT_CALL(databaseMock, commit()); - - storage.fetchSourceId(SourceContextId{5}, "unknownfile.h"); -} - -TEST_F(ProjectStorage, ValueForFetchSourceContextForIdCalls) -{ - EXPECT_CALL(databaseMock, deferredBegin()); - EXPECT_CALL(selectSourceContextPathFromSourceContextsBySourceContextIdStatement, - valueReturnPathString(5)); - EXPECT_CALL(databaseMock, commit()); - - storage.fetchSourceContextPath(SourceContextId{5}); -} - -TEST_F(ProjectStorage, FetchSourceContextForId) -{ - auto path = storage.fetchSourceContextPath(SourceContextId{5}); - - ASSERT_THAT(path, Eq("/path/to")); -} - -TEST_F(ProjectStorage, ThrowAsFetchingSourceContextPathForNonExistingId) -{ - ASSERT_THROW(storage.fetchSourceContextPath(SourceContextId{12}), - QmlDesigner::SourceContextIdDoesNotExists); -} - -TEST_F(ProjectStorage, FetchSourceContextIdForUnknownSourceId) -{ - ASSERT_THROW(storage.fetchSourceContextId(SourceId{1111}), QmlDesigner::SourceIdDoesNotExists); -} - -TEST_F(ProjectStorage, FetchSourceContextIdThrows) -{ - ASSERT_THROW(storage.fetchSourceContextId(SourceId{41}), QmlDesigner::SourceIdDoesNotExists); -} - -TEST_F(ProjectStorage, GetTheSourceContextIdBackAfterFetchingANewEntryFromSourceContextsUnguarded) -{ - auto sourceContextId = storage.fetchSourceContextIdUnguarded("/some/not/known/path"); - - ASSERT_THAT(sourceContextId, SourceContextId{12}); -} - -TEST_F(ProjectStorage, GetTheSourceIdBackAfterFetchingANewEntryFromSourcesUnguarded) -{ - auto sourceId = storage.fetchSourceIdUnguarded(SourceContextId{5}, "unknownfile.h"); - - ASSERT_THAT(sourceId, SourceId{12}); -} - -TEST_F(ProjectStorage, SelectForFetchingSourceContextIdForKnownPathUnguardedCalls) -{ - InSequence s; - - EXPECT_CALL(selectSourceContextIdFromSourceContextsBySourceContextPathStatement, - valueReturnsSourceContextId(TypedEq("/path/to"))); - - storage.fetchSourceContextIdUnguarded("/path/to"); -} - -TEST_F(ProjectStorage, SelectForFetchingSourceIdForKnownPathUnguardedCalls) -{ - EXPECT_CALL(selectSourceIdFromSourcesBySourceContextIdAndSourceNameStatment, - valueReturnsSourceId(5, Eq("file.h"))); - - storage.fetchSourceIdUnguarded(SourceContextId{5}, "file.h"); -} - -TEST_F(ProjectStorage, NotWriteForFetchingSourceContextIdForKnownPathUnguardedCalls) -{ - EXPECT_CALL(insertIntoSourceContexts, write(An())).Times(0); - - storage.fetchSourceContextIdUnguarded("/path/to"); -} - -TEST_F(ProjectStorage, NotWriteForFetchingSoureIdForKnownEntryUnguardedCalls) -{ - EXPECT_CALL(insertIntoSourcesStatement, write(An(), An())).Times(0); - - storage.fetchSourceIdUnguarded(SourceContextId{5}, "file.h"); -} - -TEST_F(ProjectStorage, SelectAndWriteForFetchingSourceContextIdForUnknownPathUnguardedCalls) -{ - InSequence s; - - EXPECT_CALL(selectSourceContextIdFromSourceContextsBySourceContextPathStatement, - valueReturnsSourceContextId( - TypedEq("/some/not/known/path"))); - EXPECT_CALL(insertIntoSourceContexts, - write(TypedEq("/some/not/known/path"))); - - storage.fetchSourceContextIdUnguarded("/some/not/known/path"); -} - -TEST_F(ProjectStorage, SelectAndWriteForFetchingSourceIdForUnknownEntryUnguardedCalls) -{ - InSequence s; - - EXPECT_CALL(selectSourceIdFromSourcesBySourceContextIdAndSourceNameStatment, - valueReturnsSourceId(5, Eq("unknownfile.h"))); - EXPECT_CALL(insertIntoSourcesStatement, - write(TypedEq(5), TypedEq("unknownfile.h"))); - - storage.fetchSourceIdUnguarded(SourceContextId{5}, "unknownfile.h"); -} - -TEST_F(ProjectStorage, - SelectAndWriteForFetchingSourceContextIdTwoTimesIfTheIndexIsConstraintBecauseTheEntryExistsAlreadyCalls) -{ - InSequence s; - - EXPECT_CALL(databaseMock, deferredBegin()); - EXPECT_CALL(selectSourceContextIdFromSourceContextsBySourceContextPathStatement, - valueReturnsSourceContextId(TypedEq("/other/unknow/path"))); - EXPECT_CALL(insertIntoSourceContexts, write(TypedEq("/other/unknow/path"))) - .WillOnce(Throw(Sqlite::ConstraintPreventsModification("busy"))); - EXPECT_CALL(databaseMock, rollback()); - EXPECT_CALL(databaseMock, deferredBegin()); - EXPECT_CALL(selectSourceContextIdFromSourceContextsBySourceContextPathStatement, - valueReturnsSourceContextId(TypedEq("/other/unknow/path"))); - EXPECT_CALL(insertIntoSourceContexts, - write(TypedEq("/other/unknow/path"))); - EXPECT_CALL(databaseMock, commit()); - - storage.fetchSourceContextId("/other/unknow/path"); -} - -TEST_F(ProjectStorage, FetchTypeByTypeIdCalls) -{ - InSequence s; - - EXPECT_CALL(databaseMock, deferredBegin()); - EXPECT_CALL(selectTypeByTypeIdStatement, valueReturnsStorageType(Eq(21))); - EXPECT_CALL(selectExportedTypesByTypeIdStatement, valuesReturnsStorageExportedTypes(_, Eq(21))); - EXPECT_CALL(databaseMock, commit()); - - storage.fetchTypeByTypeId(TypeId{21}); -} - -TEST_F(ProjectStorage, FetchTypesCalls) -{ - InSequence s; - Storage::Type type{Storage::Import{}, {}, {}, {}, SourceId{}, {}, {}, {}, {}, {}, TypeId{55}}; - Storage::Types types{type}; - - EXPECT_CALL(databaseMock, deferredBegin()); - EXPECT_CALL(selectTypesStatement, valuesReturnsStorageTypes(_)).WillOnce(Return(types)); - EXPECT_CALL(selectExportedTypesByTypeIdStatement, valuesReturnsStorageExportedTypes(_, Eq(55))); - EXPECT_CALL(databaseMock, commit()); - - storage.fetchTypes(); -} - -class ProjectStorageSlowTest : public testing::Test -{ protected: template static auto toValues(Range &&range) @@ -688,11 +401,10 @@ protected: } protected: - using ProjectStorage = QmlDesigner::ProjectStorage; Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory}; - //Sqlite::Database database{TESTDATA_DIR "/alias7.db", Sqlite::JournalMode::Memory}; - ProjectStorage storage{database, database.isInitialized()}; - QmlDesigner::SourcePathCache sourcePathCache{storage}; + QmlDesigner::ProjectStorage storage{database, database.isInitialized()}; + QmlDesigner::SourcePathCache> sourcePathCache{ + storage}; QmlDesigner::SourcePathView path1{"/path1/to"}; QmlDesigner::SourcePathView path2{"/path2/to"}; QmlDesigner::SourcePathView path3{"/path3/to"}; @@ -721,7 +433,7 @@ protected: QmlDesigner::ImportIds importIds; }; -TEST_F(ProjectStorageSlowTest, FetchSourceContextIdReturnsAlwaysTheSameIdForTheSamePath) +TEST_F(ProjectStorage, FetchSourceContextIdReturnsAlwaysTheSameIdForTheSamePath) { auto sourceContextId = storage.fetchSourceContextId("/path/to"); @@ -730,7 +442,7 @@ TEST_F(ProjectStorageSlowTest, FetchSourceContextIdReturnsAlwaysTheSameIdForTheS ASSERT_THAT(newSourceContextId, Eq(sourceContextId)); } -TEST_F(ProjectStorageSlowTest, FetchSourceContextIdReturnsNotTheSameIdForDifferentPath) +TEST_F(ProjectStorage, FetchSourceContextIdReturnsNotTheSameIdForDifferentPath) { auto sourceContextId = storage.fetchSourceContextId("/path/to"); @@ -739,7 +451,7 @@ TEST_F(ProjectStorageSlowTest, FetchSourceContextIdReturnsNotTheSameIdForDiffere ASSERT_THAT(newSourceContextId, Ne(sourceContextId)); } -TEST_F(ProjectStorageSlowTest, FetchSourceContextPath) +TEST_F(ProjectStorage, FetchSourceContextPath) { auto sourceContextId = storage.fetchSourceContextId("/path/to"); @@ -748,20 +460,20 @@ TEST_F(ProjectStorageSlowTest, FetchSourceContextPath) ASSERT_THAT(path, Eq("/path/to")); } -TEST_F(ProjectStorageSlowTest, FetchUnknownSourceContextPathThrows) +TEST_F(ProjectStorage, FetchUnknownSourceContextPathThrows) { ASSERT_THROW(storage.fetchSourceContextPath(SourceContextId{323}), QmlDesigner::SourceContextIdDoesNotExists); } -TEST_F(ProjectStorageSlowTest, FetchAllSourceContextsAreEmptyIfNoSourceContextsExists) +TEST_F(ProjectStorage, FetchAllSourceContextsAreEmptyIfNoSourceContextsExists) { auto sourceContexts = storage.fetchAllSourceContexts(); ASSERT_THAT(toValues(sourceContexts), IsEmpty()); } -TEST_F(ProjectStorageSlowTest, FetchAllSourceContexts) +TEST_F(ProjectStorage, FetchAllSourceContexts) { auto sourceContextId = storage.fetchSourceContextId("/path/to"); auto sourceContextId2 = storage.fetchSourceContextId("/path/to2"); @@ -773,7 +485,7 @@ TEST_F(ProjectStorageSlowTest, FetchAllSourceContexts) IsSourceContext(sourceContextId2, "/path/to2"))); } -TEST_F(ProjectStorageSlowTest, FetchSourceIdFirstTime) +TEST_F(ProjectStorage, FetchSourceIdFirstTime) { addSomeDummyData(); auto sourceContextId = storage.fetchSourceContextId("/path/to"); @@ -783,7 +495,7 @@ TEST_F(ProjectStorageSlowTest, FetchSourceIdFirstTime) ASSERT_TRUE(sourceId.isValid()); } -TEST_F(ProjectStorageSlowTest, FetchExistingSourceId) +TEST_F(ProjectStorage, FetchExistingSourceId) { addSomeDummyData(); auto sourceContextId = storage.fetchSourceContextId("/path/to"); @@ -794,7 +506,7 @@ TEST_F(ProjectStorageSlowTest, FetchExistingSourceId) ASSERT_THAT(sourceId, createdSourceId); } -TEST_F(ProjectStorageSlowTest, FetchSourceIdWithDifferentContextIdAreNotEqual) +TEST_F(ProjectStorage, FetchSourceIdWithDifferentContextIdAreNotEqual) { addSomeDummyData(); auto sourceContextId = storage.fetchSourceContextId("/path/to"); @@ -806,7 +518,7 @@ TEST_F(ProjectStorageSlowTest, FetchSourceIdWithDifferentContextIdAreNotEqual) ASSERT_THAT(sourceId, Ne(sourceId2)); } -TEST_F(ProjectStorageSlowTest, FetchSourceIdWithDifferentNameAreNotEqual) +TEST_F(ProjectStorage, FetchSourceIdWithDifferentNameAreNotEqual) { addSomeDummyData(); auto sourceContextId = storage.fetchSourceContextId("/path/to"); @@ -817,19 +529,19 @@ TEST_F(ProjectStorageSlowTest, FetchSourceIdWithDifferentNameAreNotEqual) ASSERT_THAT(sourceId, Ne(sourceId2)); } -TEST_F(ProjectStorageSlowTest, FetchSourceIdWithNonExistingSourceContextIdThrows) +TEST_F(ProjectStorage, FetchSourceIdWithNonExistingSourceContextIdThrows) { ASSERT_THROW(storage.fetchSourceId(SourceContextId{42}, "foo"), Sqlite::ConstraintPreventsModification); } -TEST_F(ProjectStorageSlowTest, FetchSourceNameAndSourceContextIdForNonExistingSourceId) +TEST_F(ProjectStorage, FetchSourceNameAndSourceContextIdForNonExistingSourceId) { ASSERT_THROW(storage.fetchSourceNameAndSourceContextId(SourceId{212}), QmlDesigner::SourceIdDoesNotExists); } -TEST_F(ProjectStorageSlowTest, FetchSourceNameAndSourceContextIdForNonExistingEntry) +TEST_F(ProjectStorage, FetchSourceNameAndSourceContextIdForNonExistingEntry) { addSomeDummyData(); auto sourceContextId = storage.fetchSourceContextId("/path/to"); @@ -840,12 +552,12 @@ TEST_F(ProjectStorageSlowTest, FetchSourceNameAndSourceContextIdForNonExistingEn ASSERT_THAT(sourceNameAndSourceContextId, IsSourceNameAndSourceContextId("foo", sourceContextId)); } -TEST_F(ProjectStorageSlowTest, FetchSourceContextIdForNonExistingSourceId) +TEST_F(ProjectStorage, FetchSourceContextIdForNonExistingSourceId) { ASSERT_THROW(storage.fetchSourceContextId(SourceId{212}), QmlDesigner::SourceIdDoesNotExists); } -TEST_F(ProjectStorageSlowTest, FetchSourceContextIdForExistingSourceId) +TEST_F(ProjectStorage, FetchSourceContextIdForExistingSourceId) { addSomeDummyData(); auto originalSourceContextId = storage.fetchSourceContextId("/path/to3"); @@ -856,14 +568,14 @@ TEST_F(ProjectStorageSlowTest, FetchSourceContextIdForExistingSourceId) ASSERT_THAT(sourceContextId, Eq(originalSourceContextId)); } -TEST_F(ProjectStorageSlowTest, FetchAllSources) +TEST_F(ProjectStorage, FetchAllSources) { auto sources = storage.fetchAllSources(); ASSERT_THAT(toValues(sources), IsEmpty()); } -TEST_F(ProjectStorageSlowTest, FetchSourceIdUnguardedFirstTime) +TEST_F(ProjectStorage, FetchSourceIdUnguardedFirstTime) { addSomeDummyData(); auto sourceContextId = storage.fetchSourceContextId("/path/to"); @@ -874,7 +586,7 @@ TEST_F(ProjectStorageSlowTest, FetchSourceIdUnguardedFirstTime) ASSERT_TRUE(sourceId.isValid()); } -TEST_F(ProjectStorageSlowTest, FetchExistingSourceIdUnguarded) +TEST_F(ProjectStorage, FetchExistingSourceIdUnguarded) { addSomeDummyData(); auto sourceContextId = storage.fetchSourceContextId("/path/to"); @@ -886,7 +598,7 @@ TEST_F(ProjectStorageSlowTest, FetchExistingSourceIdUnguarded) ASSERT_THAT(sourceId, createdSourceId); } -TEST_F(ProjectStorageSlowTest, FetchSourceIdUnguardedWithDifferentContextIdAreNotEqual) +TEST_F(ProjectStorage, FetchSourceIdUnguardedWithDifferentContextIdAreNotEqual) { addSomeDummyData(); auto sourceContextId = storage.fetchSourceContextId("/path/to"); @@ -899,7 +611,7 @@ TEST_F(ProjectStorageSlowTest, FetchSourceIdUnguardedWithDifferentContextIdAreNo ASSERT_THAT(sourceId, Ne(sourceId2)); } -TEST_F(ProjectStorageSlowTest, FetchSourceIdUnguardedWithDifferentNameAreNotEqual) +TEST_F(ProjectStorage, FetchSourceIdUnguardedWithDifferentNameAreNotEqual) { addSomeDummyData(); auto sourceContextId = storage.fetchSourceContextId("/path/to"); @@ -911,7 +623,7 @@ TEST_F(ProjectStorageSlowTest, FetchSourceIdUnguardedWithDifferentNameAreNotEqua ASSERT_THAT(sourceId, Ne(sourceId2)); } -TEST_F(ProjectStorageSlowTest, FetchSourceIdUnguardedWithNonExistingSourceContextIdThrows) +TEST_F(ProjectStorage, FetchSourceIdUnguardedWithNonExistingSourceContextIdThrows) { std::lock_guard lock{database}; @@ -919,7 +631,7 @@ TEST_F(ProjectStorageSlowTest, FetchSourceIdUnguardedWithNonExistingSourceContex Sqlite::ConstraintPreventsModification); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypes) +TEST_F(ProjectStorage, SynchronizeTypesAddsNewTypes) { Storage::Types types{createTypes()}; @@ -943,7 +655,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypes) UnorderedElementsAre(IsExportedType("Item")))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypesWithExportedPrototypeName) +TEST_F(ProjectStorage, SynchronizeTypesAddsNewTypesWithExportedPrototypeName) { Storage::Types types{createTypes()}; types[0].prototype = Storage::ExportedType{"Object"}; @@ -968,7 +680,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypesWithExportedPrototype UnorderedElementsAre(IsExportedType("Item")))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypesThrowsWithWrongExportedPrototypeName) +TEST_F(ProjectStorage, SynchronizeTypesAddsNewTypesThrowsWithWrongExportedPrototypeName) { Storage::Types types{createTypes()}; types[0].prototype = Storage::ExportedType{"Objec"}; @@ -977,7 +689,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypesThrowsWithWrongExport QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypesWithMissingImportAndExportedPrototypeName) +TEST_F(ProjectStorage, SynchronizeTypesAddsNewTypesWithMissingImportAndExportedPrototypeName) { Storage::Types types{createTypes()}; types.push_back(Storage::Type{Storage::Import{"/path/to"}, @@ -993,7 +705,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypesWithMissingImportAndE QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypesWithMissingImport) +TEST_F(ProjectStorage, SynchronizeTypesAddsNewTypesWithMissingImport) { Storage::Types types{createTypes()}; storage.synchronize({}, {Storage::Document{sourceId1, {imports[0]}}}, {}, {sourceId1}, {}); @@ -1002,7 +714,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypesWithMissingImport) QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypesReverseOrder) +TEST_F(ProjectStorage, SynchronizeTypesAddsNewTypesReverseOrder) { Storage::Types types{createTypes()}; std::reverse(types.begin(), types.end()); @@ -1027,7 +739,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypesReverseOrder) UnorderedElementsAre(IsExportedType("Item")))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesOverwritesTypeAccessSemantics) +TEST_F(ProjectStorage, SynchronizeTypesOverwritesTypeAccessSemantics) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -1054,7 +766,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesOverwritesTypeAccessSemantics) UnorderedElementsAre(IsExportedType("Item")))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesOverwritesSources) +TEST_F(ProjectStorage, SynchronizeTypesOverwritesSources) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -1081,7 +793,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesOverwritesSources) UnorderedElementsAre(IsExportedType("Item")))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesInsertTypeIntoPrototypeChain) +TEST_F(ProjectStorage, SynchronizeTypesInsertTypeIntoPrototypeChain) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -1120,7 +832,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesInsertTypeIntoPrototypeChain) UnorderedElementsAre(IsExportedType("Item")))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddExplicitPrototype) +TEST_F(ProjectStorage, SynchronizeTypesAddExplicitPrototype) { Storage::Types types{createTypes()}; types[0].prototype = Storage::ExplicitExportedType{"Object", Storage::Import{"QtQuick"}}; @@ -1158,7 +870,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddExplicitPrototype) UnorderedElementsAre(IsExportedType("Item")))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesThrowsForMissingPrototype) +TEST_F(ProjectStorage, SynchronizeTypesThrowsForMissingPrototype) { setUpImportDependenciesAndDocuments(); sourceId1 = sourcePathCache.sourceId(path1); @@ -1173,7 +885,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesThrowsForMissingPrototype) QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesThrowsForMissingImport) +TEST_F(ProjectStorage, SynchronizeTypesThrowsForMissingImport) { sourceId1 = sourcePathCache.sourceId(path1); Storage::Types types{Storage::Type{Storage::Import{"QtQuick"}, @@ -1187,7 +899,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesThrowsForMissingImport) QmlDesigner::ImportDoesNotExists); } -TEST_F(ProjectStorageSlowTest, TypeWithInvalidSourceIdThrows) +TEST_F(ProjectStorage, TypeWithInvalidSourceIdThrows) { Storage::Types types{Storage::Type{Storage::Import{"QtQuick"}, "QQuickItem", @@ -1199,7 +911,7 @@ TEST_F(ProjectStorageSlowTest, TypeWithInvalidSourceIdThrows) ASSERT_THROW(storage.synchronize({}, {}, types, {}, {}), QmlDesigner::TypeHasInvalidSourceId); } -TEST_F(ProjectStorageSlowTest, DeleteTypeIfSourceIdIsSynchronized) +TEST_F(ProjectStorage, DeleteTypeIfSourceIdIsSynchronized) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -1218,7 +930,7 @@ TEST_F(ProjectStorageSlowTest, DeleteTypeIfSourceIdIsSynchronized) IsExportedType("Obj")))))); } -TEST_F(ProjectStorageSlowTest, DontDeleteTypeIfSourceIdIsNotSynchronized) +TEST_F(ProjectStorage, DontDeleteTypeIfSourceIdIsNotSynchronized) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -1244,7 +956,7 @@ TEST_F(ProjectStorageSlowTest, DontDeleteTypeIfSourceIdIsNotSynchronized) UnorderedElementsAre(IsExportedType("Item")))))); } -TEST_F(ProjectStorageSlowTest, UpdateExportedTypesIfTypeNameChanges) +TEST_F(ProjectStorage, UpdateExportedTypesIfTypeNameChanges) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -1270,7 +982,7 @@ TEST_F(ProjectStorageSlowTest, UpdateExportedTypesIfTypeNameChanges) UnorderedElementsAre(IsExportedType("Item")))))); } -TEST_F(ProjectStorageSlowTest, BreakingPrototypeChainByDeletingBaseComponentThrows) +TEST_F(ProjectStorage, BreakingPrototypeChainByDeletingBaseComponentThrows) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -1280,7 +992,7 @@ TEST_F(ProjectStorageSlowTest, BreakingPrototypeChainByDeletingBaseComponentThro QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddPropertyDeclarations) +TEST_F(ProjectStorage, SynchronizeTypesAddPropertyDeclarations) { Storage::Types types{createTypes()}; @@ -1305,8 +1017,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddPropertyDeclarations) | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } -TEST_F(ProjectStorageSlowTest, - SynchronizeTypesAddPropertyDeclarationsWithMissingImportIdsForNativeTypes) +TEST_F(ProjectStorage, SynchronizeTypesAddPropertyDeclarationsWithMissingImportIdsForNativeTypes) { Storage::Types types{createTypes()}; storage.synchronize({}, {Storage::Document{sourceId1, {}}}, {}, {sourceId1}, {}); @@ -1315,8 +1026,7 @@ TEST_F(ProjectStorageSlowTest, ASSERT_THROW(storage.synchronize({}, {}, types, {}, {}), QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, - SynchronizeTypesAddPropertyDeclarationsWithMissingImportIdsForExportedTypes) +TEST_F(ProjectStorage, SynchronizeTypesAddPropertyDeclarationsWithMissingImportIdsForExportedTypes) { Storage::Types types{createTypes()}; storage.synchronize({}, {Storage::Document{sourceId1, {imports[0]}}}, {}, {sourceId1}, {}); @@ -1325,7 +1035,7 @@ TEST_F(ProjectStorageSlowTest, ASSERT_THROW(storage.synchronize({}, {}, types, {}, {}), QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddPropertyDeclarationExplicitType) +TEST_F(ProjectStorage, SynchronizeTypesAddPropertyDeclarationExplicitType) { Storage::Types types{createTypes()}; types[0].propertyDeclarations[0].typeName = Storage::ExplicitExportedType{"Object", @@ -1359,7 +1069,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddPropertyDeclarationExplicitTyp | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesPropertyDeclarationType) +TEST_F(ProjectStorage, SynchronizeTypesChangesPropertyDeclarationType) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1386,7 +1096,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesPropertyDeclarationType) | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesDeclarationTraits) +TEST_F(ProjectStorage, SynchronizeTypesChangesDeclarationTraits) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1413,7 +1123,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesDeclarationTraits) | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesDeclarationTraitsAndType) +TEST_F(ProjectStorage, SynchronizeTypesChangesDeclarationTraitsAndType) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1441,7 +1151,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesDeclarationTraitsAndType) | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemovesAPropertyDeclaration) +TEST_F(ProjectStorage, SynchronizeTypesRemovesAPropertyDeclaration) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1462,7 +1172,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemovesAPropertyDeclaration) Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsAPropertyDeclaration) +TEST_F(ProjectStorage, SynchronizeTypesAddsAPropertyDeclaration) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1495,7 +1205,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsAPropertyDeclaration) | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesRenameAPropertyDeclaration) +TEST_F(ProjectStorage, SynchronizeTypesRenameAPropertyDeclaration) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1522,7 +1232,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesRenameAPropertyDeclaration) | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } -TEST_F(ProjectStorageSlowTest, UsingNonExistingNativePropertyTypeThrows) +TEST_F(ProjectStorage, UsingNonExistingNativePropertyTypeThrows) { Storage::Types types{createTypes()}; types[0].propertyDeclarations[0].typeName = Storage::NativeType{"QObject2"}; @@ -1532,7 +1242,7 @@ TEST_F(ProjectStorageSlowTest, UsingNonExistingNativePropertyTypeThrows) QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, UsingNonExistingExportedPropertyTypeThrows) +TEST_F(ProjectStorage, UsingNonExistingExportedPropertyTypeThrows) { Storage::Types types{createTypes()}; types[0].propertyDeclarations[0].typeName = Storage::ExportedType{"QObject2"}; @@ -1542,7 +1252,7 @@ TEST_F(ProjectStorageSlowTest, UsingNonExistingExportedPropertyTypeThrows) QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, UsingNonExistingExplicitExportedPropertyTypeWithWrongNameThrows) +TEST_F(ProjectStorage, UsingNonExistingExplicitExportedPropertyTypeWithWrongNameThrows) { Storage::Types types{createTypes()}; types[0].propertyDeclarations[0].typeName = Storage::ExplicitExportedType{"QObject2", @@ -1554,7 +1264,7 @@ TEST_F(ProjectStorageSlowTest, UsingNonExistingExplicitExportedPropertyTypeWithW QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, UsingNonExistingExplicitExportedPropertyTypeWithWrongImportThrows) +TEST_F(ProjectStorage, UsingNonExistingExplicitExportedPropertyTypeWithWrongImportThrows) { Storage::Types types{createTypes()}; types[0].propertyDeclarations[0].typeName = Storage::ExplicitExportedType{"QObject", @@ -1566,7 +1276,7 @@ TEST_F(ProjectStorageSlowTest, UsingNonExistingExplicitExportedPropertyTypeWithW QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, BreakingPropertyDeclarationTypeDependencyByDeletingTypeThrows) +TEST_F(ProjectStorage, BreakingPropertyDeclarationTypeDependencyByDeletingTypeThrows) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -1577,7 +1287,7 @@ TEST_F(ProjectStorageSlowTest, BreakingPropertyDeclarationTypeDependencyByDeleti QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddFunctionDeclarations) +TEST_F(ProjectStorage, SynchronizeTypesAddFunctionDeclarations) { Storage::Types types{createTypes()}; @@ -1594,7 +1304,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddFunctionDeclarations) Eq(types[0].functionDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesFunctionDeclarationReturnType) +TEST_F(ProjectStorage, SynchronizeTypesChangesFunctionDeclarationReturnType) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1613,7 +1323,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesFunctionDeclarationReturnT Eq(types[0].functionDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesFunctionDeclarationName) +TEST_F(ProjectStorage, SynchronizeTypesChangesFunctionDeclarationName) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1632,7 +1342,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesFunctionDeclarationName) Eq(types[0].functionDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesFunctionDeclarationPopParameters) +TEST_F(ProjectStorage, SynchronizeTypesChangesFunctionDeclarationPopParameters) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1651,7 +1361,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesFunctionDeclarationPopPara Eq(types[0].functionDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesFunctionDeclarationAppendParameters) +TEST_F(ProjectStorage, SynchronizeTypesChangesFunctionDeclarationAppendParameters) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1670,7 +1380,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesFunctionDeclarationAppendP Eq(types[0].functionDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesFunctionDeclarationChangeParameterName) +TEST_F(ProjectStorage, SynchronizeTypesChangesFunctionDeclarationChangeParameterName) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1689,7 +1399,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesFunctionDeclarationChangeP Eq(types[0].functionDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesFunctionDeclarationChangeParameterTypeName) +TEST_F(ProjectStorage, SynchronizeTypesChangesFunctionDeclarationChangeParameterTypeName) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1708,7 +1418,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesFunctionDeclarationChangeP Eq(types[0].functionDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesFunctionDeclarationChangeParameterTraits) +TEST_F(ProjectStorage, SynchronizeTypesChangesFunctionDeclarationChangeParameterTraits) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1727,7 +1437,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesFunctionDeclarationChangeP Eq(types[0].functionDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemovesFunctionDeclaration) +TEST_F(ProjectStorage, SynchronizeTypesRemovesFunctionDeclaration) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1745,7 +1455,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemovesFunctionDeclaration) UnorderedElementsAre(Eq(types[0].functionDeclarations[0])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddFunctionDeclaration) +TEST_F(ProjectStorage, SynchronizeTypesAddFunctionDeclaration) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1766,7 +1476,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddFunctionDeclaration) Eq(types[0].functionDeclarations[2])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddSignalDeclarations) +TEST_F(ProjectStorage, SynchronizeTypesAddSignalDeclarations) { Storage::Types types{createTypes()}; @@ -1783,7 +1493,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddSignalDeclarations) Eq(types[0].signalDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesSignalDeclarationName) +TEST_F(ProjectStorage, SynchronizeTypesChangesSignalDeclarationName) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1802,7 +1512,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesSignalDeclarationName) Eq(types[0].signalDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesSignalDeclarationPopParameters) +TEST_F(ProjectStorage, SynchronizeTypesChangesSignalDeclarationPopParameters) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1821,7 +1531,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesSignalDeclarationPopParame Eq(types[0].signalDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesSignalDeclarationAppendParameters) +TEST_F(ProjectStorage, SynchronizeTypesChangesSignalDeclarationAppendParameters) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1840,7 +1550,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesSignalDeclarationAppendPar Eq(types[0].signalDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesSignalDeclarationChangeParameterName) +TEST_F(ProjectStorage, SynchronizeTypesChangesSignalDeclarationChangeParameterName) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1859,7 +1569,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesSignalDeclarationChangePar Eq(types[0].signalDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesSignalDeclarationChangeParameterTypeName) +TEST_F(ProjectStorage, SynchronizeTypesChangesSignalDeclarationChangeParameterTypeName) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1878,7 +1588,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesSignalDeclarationChangePar Eq(types[0].signalDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesSignalDeclarationChangeParameterTraits) +TEST_F(ProjectStorage, SynchronizeTypesChangesSignalDeclarationChangeParameterTraits) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1897,7 +1607,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesSignalDeclarationChangePar Eq(types[0].signalDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemovesSignalDeclaration) +TEST_F(ProjectStorage, SynchronizeTypesRemovesSignalDeclaration) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1915,7 +1625,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemovesSignalDeclaration) UnorderedElementsAre(Eq(types[0].signalDeclarations[0])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddSignalDeclaration) +TEST_F(ProjectStorage, SynchronizeTypesAddSignalDeclaration) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1936,7 +1646,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddSignalDeclaration) Eq(types[0].signalDeclarations[2])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddEnumerationDeclarations) +TEST_F(ProjectStorage, SynchronizeTypesAddEnumerationDeclarations) { Storage::Types types{createTypes()}; @@ -1953,7 +1663,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddEnumerationDeclarations) Eq(types[0].enumerationDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesEnumerationDeclarationName) +TEST_F(ProjectStorage, SynchronizeTypesChangesEnumerationDeclarationName) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1972,7 +1682,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesEnumerationDeclarationName Eq(types[0].enumerationDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesEnumerationDeclarationPopEnumeratorDeclaration) +TEST_F(ProjectStorage, SynchronizeTypesChangesEnumerationDeclarationPopEnumeratorDeclaration) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -1991,7 +1701,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesEnumerationDeclarationPopE Eq(types[0].enumerationDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesEnumerationDeclarationAppendEnumeratorDeclaration) +TEST_F(ProjectStorage, SynchronizeTypesChangesEnumerationDeclarationAppendEnumeratorDeclaration) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -2011,8 +1721,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangesEnumerationDeclarationAppe Eq(types[0].enumerationDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, - SynchronizeTypesChangesEnumerationDeclarationChangeEnumeratorDeclarationName) +TEST_F(ProjectStorage, SynchronizeTypesChangesEnumerationDeclarationChangeEnumeratorDeclarationName) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -2031,8 +1740,7 @@ TEST_F(ProjectStorageSlowTest, Eq(types[0].enumerationDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, - SynchronizeTypesChangesEnumerationDeclarationChangeEnumeratorDeclarationValue) +TEST_F(ProjectStorage, SynchronizeTypesChangesEnumerationDeclarationChangeEnumeratorDeclarationValue) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -2051,7 +1759,7 @@ TEST_F(ProjectStorageSlowTest, Eq(types[0].enumerationDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, +TEST_F(ProjectStorage, SynchronizeTypesChangesEnumerationDeclarationAddThatEnumeratorDeclarationHasValue) { Storage::Types types{createTypes()}; @@ -2072,7 +1780,7 @@ TEST_F(ProjectStorageSlowTest, Eq(types[0].enumerationDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, +TEST_F(ProjectStorage, SynchronizeTypesChangesEnumerationDeclarationRemoveThatEnumeratorDeclarationHasValue) { Storage::Types types{createTypes()}; @@ -2092,7 +1800,7 @@ TEST_F(ProjectStorageSlowTest, Eq(types[0].enumerationDeclarations[1])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemovesEnumerationDeclaration) +TEST_F(ProjectStorage, SynchronizeTypesRemovesEnumerationDeclaration) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -2110,7 +1818,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemovesEnumerationDeclaration) UnorderedElementsAre(Eq(types[0].enumerationDeclarations[0])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddEnumerationDeclaration) +TEST_F(ProjectStorage, SynchronizeTypesAddEnumerationDeclaration) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {}, {}); @@ -2131,7 +1839,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddEnumerationDeclaration) Eq(types[0].enumerationDeclarations[2])))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddImports) +TEST_F(ProjectStorage, SynchronizeImportsAddImports) { Storage::ImportDependencies importDependencies{createImportDependencies()}; @@ -2148,7 +1856,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddImports) IsImportDependency("/path/to", Storage::VersionNumber{}, importSourceId5))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddImportsAgain) +TEST_F(ProjectStorage, SynchronizeImportsAddImportsAgain) { Storage::ImportDependencies importDependencies{createImportDependencies()}; storage.synchronize(importDependencies, @@ -2170,7 +1878,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddImportsAgain) IsImportDependency("/path/to", Storage::VersionNumber{}, importSourceId5))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsUpdateToMoreImports) +TEST_F(ProjectStorage, SynchronizeImportsUpdateToMoreImports) { Storage::ImportDependencies importDependencies{createImportDependencies()}; storage.synchronize(importDependencies, @@ -2195,7 +1903,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsUpdateToMoreImports) IsImportDependency("QtQuick.Foo", Storage::VersionNumber{1}, importSourceId3))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddOneMoreImports) +TEST_F(ProjectStorage, SynchronizeImportsAddOneMoreImports) { Storage::ImportDependencies importDependencies{createImportDependencies()}; storage.synchronize(importDependencies, @@ -2217,7 +1925,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddOneMoreImports) IsImportDependency("QtQuick.Foo", Storage::VersionNumber{1}, importSourceId3))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddSameImportNameButDifferentVersion) +TEST_F(ProjectStorage, SynchronizeImportsAddSameImportNameButDifferentVersion) { auto importSourceIdQml4 = sourcePathCache.sourceId("/path/Qml.4"); auto importSourceIdQml3 = sourcePathCache.sourceId("/path/Qml.3"); @@ -2243,7 +1951,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddSameImportNameButDifferentVe IsImportDependency("/path/to", Storage::VersionNumber{}, importSourceId5))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsRemoveImport) +TEST_F(ProjectStorage, SynchronizeImportsRemoveImport) { Storage::ImportDependencies importDependencies{createImportDependencies()}; storage.synchronize(importDependencies, @@ -2260,7 +1968,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsRemoveImport) IsImportDependency("QtQuick", Storage::VersionNumber{}, importSourceId2))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsChangeSourceId) +TEST_F(ProjectStorage, SynchronizeImportsChangeSourceId) { Storage::ImportDependencies importDependencies{createImportDependencies()}; storage.synchronize(importDependencies, @@ -2279,7 +1987,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsChangeSourceId) IsImportDependency("/path/to", Storage::VersionNumber{}, importSourceId5))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsChangeName) +TEST_F(ProjectStorage, SynchronizeImportsChangeName) { Storage::ImportDependencies importDependencies{createImportDependencies()}; storage.synchronize(importDependencies, @@ -2304,7 +2012,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsChangeName) IsImportDependency("/path/to", Storage::VersionNumber{}, importSourceId5))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsChangeVersion) +TEST_F(ProjectStorage, SynchronizeImportsChangeVersion) { Storage::ImportDependencies importDependencies{createImportDependencies()}; storage.synchronize(importDependencies, @@ -2329,7 +2037,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsChangeVersion) IsImportDependency("/path/to", Storage::VersionNumber{}, importSourceId5))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddImportDependecies) +TEST_F(ProjectStorage, SynchronizeImportsAddImportDependecies) { Storage::ImportDependencies importDependencies{createImportDependencies()}; @@ -2352,7 +2060,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddImportDependecies) IsImport("QtQuick", Storage::VersionNumber{})))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddImportDependeciesWhichDoesNotExitsThrows) +TEST_F(ProjectStorage, SynchronizeImportsAddImportDependeciesWhichDoesNotExitsThrows) { Storage::ImportDependencies importDependencies{createImportDependencies()}; importDependencies[1].dependencies.push_back(Storage::Import{"QmlBase", Storage::VersionNumber{2}}); @@ -2365,7 +2073,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddImportDependeciesWhichDoesNo QmlDesigner::ImportDoesNotExists); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsRemovesDependeciesForRemovedImports) +TEST_F(ProjectStorage, SynchronizeImportsRemovesDependeciesForRemovedImports) { Storage::ImportDependencies importDependencies{createImportDependencies()}; storage.synchronize(importDependencies, @@ -2393,7 +2101,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsRemovesDependeciesForRemovedImp UnorderedElementsAre(IsImport("QtQuick", Storage::VersionNumber{})))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddMoreImportDependecies) +TEST_F(ProjectStorage, SynchronizeImportsAddMoreImportDependecies) { Storage::ImportDependencies importDependencies{createImportDependencies()}; storage.synchronize(importDependencies, @@ -2429,7 +2137,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddMoreImportDependecies) IsImport("QtQuick", Storage::VersionNumber{})))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddMoreImportDependeciesWithDifferentVersionNumber) +TEST_F(ProjectStorage, SynchronizeImportsAddMoreImportDependeciesWithDifferentVersionNumber) { Storage::ImportDependencies importDependencies{createImportDependencies()}; storage.synchronize(importDependencies, @@ -2464,7 +2172,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsAddMoreImportDependeciesWithDif IsImport("QtQuick", Storage::VersionNumber{})))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsDependencyGetsHighestVersionIfNoVersionIsSupplied) +TEST_F(ProjectStorage, SynchronizeImportsDependencyGetsHighestVersionIfNoVersionIsSupplied) { Storage::ImportDependencies importDependencies{createImportDependencies()}; storage.synchronize(importDependencies, @@ -2499,7 +2207,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsDependencyGetsHighestVersionIfN IsImport("QtQuick", Storage::VersionNumber{})))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsDependencyGetsOnlyTheHighestDependency) +TEST_F(ProjectStorage, SynchronizeImportsDependencyGetsOnlyTheHighestDependency) { Storage::ImportDependencies importDependencies{createImportDependencies()}; storage.synchronize(importDependencies, @@ -2533,7 +2241,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsDependencyGetsOnlyTheHighestDep IsImport("QtQuick", Storage::VersionNumber{})))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeImportsDependencyRemoveDuplicateDependencies) +TEST_F(ProjectStorage, SynchronizeImportsDependencyRemoveDuplicateDependencies) { Storage::ImportDependencies importDependencies{createImportDependencies()}; storage.synchronize(importDependencies, @@ -2571,7 +2279,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeImportsDependencyRemoveDuplicateDepend IsImport("QtQuick", Storage::VersionNumber{})))))); } -TEST_F(ProjectStorageSlowTest, RemovingImportRemovesDependentTypesToo) +TEST_F(ProjectStorage, RemovingImportRemovesDependentTypesToo) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -2591,7 +2299,7 @@ TEST_F(ProjectStorageSlowTest, RemovingImportRemovesDependentTypesToo) IsExportedType("Obj")))))); } -TEST_F(ProjectStorageSlowTest, FetchTypeIdByImportIdAndName) +TEST_F(ProjectStorage, FetchTypeIdByImportIdAndName) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -2601,7 +2309,7 @@ TEST_F(ProjectStorageSlowTest, FetchTypeIdByImportIdAndName) ASSERT_THAT(storage.fetchTypeIdByExportedName("Object"), Eq(typeId)); } -TEST_F(ProjectStorageSlowTest, FetchTypeIdByExportedName) +TEST_F(ProjectStorage, FetchTypeIdByExportedName) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -2611,7 +2319,7 @@ TEST_F(ProjectStorageSlowTest, FetchTypeIdByExportedName) ASSERT_THAT(storage.fetchTypeIdByName(importId1, "QObject"), Eq(typeId)); } -TEST_F(ProjectStorageSlowTest, FetchTypeIdByImporIdsAndExportedName) +TEST_F(ProjectStorage, FetchTypeIdByImporIdsAndExportedName) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -2621,7 +2329,7 @@ TEST_F(ProjectStorageSlowTest, FetchTypeIdByImporIdsAndExportedName) ASSERT_THAT(storage.fetchTypeIdByName(importId1, "QObject"), Eq(typeId)); } -TEST_F(ProjectStorageSlowTest, FetchInvalidTypeIdByImporIdsAndExportedNameIfImportIdsAreEmpty) +TEST_F(ProjectStorage, FetchInvalidTypeIdByImporIdsAndExportedNameIfImportIdsAreEmpty) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -2631,7 +2339,7 @@ TEST_F(ProjectStorageSlowTest, FetchInvalidTypeIdByImporIdsAndExportedNameIfImpo ASSERT_FALSE(typeId.isValid()); } -TEST_F(ProjectStorageSlowTest, FetchInvalidTypeIdByImporIdsAndExportedNameIfImportIdsAreInvalid) +TEST_F(ProjectStorage, FetchInvalidTypeIdByImporIdsAndExportedNameIfImportIdsAreInvalid) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -2641,7 +2349,7 @@ TEST_F(ProjectStorageSlowTest, FetchInvalidTypeIdByImporIdsAndExportedNameIfImpo ASSERT_FALSE(typeId.isValid()); } -TEST_F(ProjectStorageSlowTest, FetchInvalidTypeIdByImporIdsAndExportedNameIfNotInImport) +TEST_F(ProjectStorage, FetchInvalidTypeIdByImporIdsAndExportedNameIfNotInImport) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -2651,7 +2359,7 @@ TEST_F(ProjectStorageSlowTest, FetchInvalidTypeIdByImporIdsAndExportedNameIfNotI ASSERT_FALSE(typeId.isValid()); } -TEST_F(ProjectStorageSlowTest, FetchImportDepencencyIds) +TEST_F(ProjectStorage, FetchImportDepencencyIds) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -2661,7 +2369,7 @@ TEST_F(ProjectStorageSlowTest, FetchImportDepencencyIds) ASSERT_THAT(importIds, UnorderedElementsAre(importId1, importId2, importId3)); } -TEST_F(ProjectStorageSlowTest, FetchImportDepencencyIdsForRootDepencency) +TEST_F(ProjectStorage, FetchImportDepencencyIdsForRootDepencency) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -2671,7 +2379,7 @@ TEST_F(ProjectStorageSlowTest, FetchImportDepencencyIdsForRootDepencency) ASSERT_THAT(importIds, ElementsAre(importId1)); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddAliasDeclarations) +TEST_F(ProjectStorage, SynchronizeTypesAddAliasDeclarations) { Storage::Types types{createTypesWithAliases()}; @@ -2698,7 +2406,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddAliasDeclarations) Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddAliasDeclarationsAgain) +TEST_F(ProjectStorage, SynchronizeTypesAddAliasDeclarationsAgain) { Storage::Types types{createTypesWithAliases()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4}, {}); @@ -2726,7 +2434,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddAliasDeclarationsAgain) Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemoveAliasDeclarations) +TEST_F(ProjectStorage, SynchronizeTypesRemoveAliasDeclarations) { Storage::Types types{createTypesWithAliases()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4}, {}); @@ -2752,7 +2460,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemoveAliasDeclarations) Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddAliasDeclarationsThrowsForWrongTypeName) +TEST_F(ProjectStorage, SynchronizeTypesAddAliasDeclarationsThrowsForWrongTypeName) { Storage::Types types{createTypesWithAliases()}; types[2].propertyDeclarations[1].typeName = Storage::NativeType{"QQuickItemWrong"}; @@ -2760,7 +2468,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddAliasDeclarationsThrowsForWron ASSERT_THROW(storage.synchronize({}, {}, {types[2]}, {sourceId4}, {}), QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddAliasDeclarationsThrowsForWrongPropertyName) +TEST_F(ProjectStorage, SynchronizeTypesAddAliasDeclarationsThrowsForWrongPropertyName) { Storage::Types types{createTypesWithAliases()}; types[2].propertyDeclarations[1].aliasPropertyName = "childrenWrong"; @@ -2769,7 +2477,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddAliasDeclarationsThrowsForWron QmlDesigner::PropertyNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangeAliasDeclarationsTypeName) +TEST_F(ProjectStorage, SynchronizeTypesChangeAliasDeclarationsTypeName) { Storage::Types types{createTypesWithAliases()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4}, {}); @@ -2798,7 +2506,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangeAliasDeclarationsTypeName) Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangeAliasDeclarationsPropertyName) +TEST_F(ProjectStorage, SynchronizeTypesChangeAliasDeclarationsPropertyName) { Storage::Types types{createTypesWithAliases()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4}, {}); @@ -2829,7 +2537,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangeAliasDeclarationsPropertyNa Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangeAliasDeclarationsToPropertyDeclaration) +TEST_F(ProjectStorage, SynchronizeTypesChangeAliasDeclarationsToPropertyDeclaration) { Storage::Types types{createTypesWithAliases()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4}, {}); @@ -2865,7 +2573,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangeAliasDeclarationsToProperty Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangePropertyDeclarationsToAliasDeclaration) +TEST_F(ProjectStorage, SynchronizeTypesChangePropertyDeclarationsToAliasDeclaration) { Storage::Types types{createTypesWithAliases()}; auto typesChanged = types; @@ -2900,7 +2608,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangePropertyDeclarationsToAlias Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangeAliasTargetPropertyDeclarationTraits) +TEST_F(ProjectStorage, SynchronizeTypesChangeAliasTargetPropertyDeclarationTraits) { Storage::Types types{createTypesWithAliases()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4}, {}); @@ -2932,7 +2640,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangeAliasTargetPropertyDeclarat Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangeAliasTargetPropertyDeclarationTypeName) +TEST_F(ProjectStorage, SynchronizeTypesChangeAliasTargetPropertyDeclarationTypeName) { Storage::Types types{createTypesWithAliases()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4}, {}); @@ -2961,7 +2669,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesChangeAliasTargetPropertyDeclarat Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemovePropertyDeclarationWithAnAliasThrows) +TEST_F(ProjectStorage, SynchronizeTypesRemovePropertyDeclarationWithAnAliasThrows) { Storage::Types types{createTypesWithAliases()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4}, {}); @@ -2971,7 +2679,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemovePropertyDeclarationWithAnAl Sqlite::ConstraintPreventsModification); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemovePropertyDeclarationAndAlias) +TEST_F(ProjectStorage, SynchronizeTypesRemovePropertyDeclarationAndAlias) { Storage::Types types{createTypesWithAliases()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4}, {}); @@ -2998,7 +2706,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemovePropertyDeclarationAndAlias Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemoveTypeWithAliasTargetPropertyDeclarationThrows) +TEST_F(ProjectStorage, SynchronizeTypesRemoveTypeWithAliasTargetPropertyDeclarationThrows) { Storage::Types types{createTypesWithAliases()}; types[2].propertyDeclarations[2].typeName = Storage::ExportedType{"Object2"}; @@ -3007,7 +2715,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemoveTypeWithAliasTargetProperty ASSERT_THROW(storage.synchronize({}, {}, {}, {sourceId4}, {}), QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemoveTypeAndAliasPropertyDeclaration) +TEST_F(ProjectStorage, SynchronizeTypesRemoveTypeAndAliasPropertyDeclaration) { Storage::Types types{createTypesWithAliases()}; types[2].propertyDeclarations[2].typeName = Storage::ExportedType{"Object2"}; @@ -3034,7 +2742,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesRemoveTypeAndAliasPropertyDeclara Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, UpdateAliasPropertyIfPropertyIsOverloaded) +TEST_F(ProjectStorage, UpdateAliasPropertyIfPropertyIsOverloaded) { Storage::Types types{createTypesWithAliases()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4}, {}); @@ -3069,7 +2777,7 @@ TEST_F(ProjectStorageSlowTest, UpdateAliasPropertyIfPropertyIsOverloaded) Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, AliasPropertyIsOverloaded) +TEST_F(ProjectStorage, AliasPropertyIsOverloaded) { Storage::Types types{createTypesWithAliases()}; types[0].propertyDeclarations.push_back( @@ -3103,7 +2811,7 @@ TEST_F(ProjectStorageSlowTest, AliasPropertyIsOverloaded) Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, UpdateAliasPropertyIfOverloadedPropertyIsRemoved) +TEST_F(ProjectStorage, UpdateAliasPropertyIfOverloadedPropertyIsRemoved) { Storage::Types types{createTypesWithAliases()}; types[0].propertyDeclarations.push_back( @@ -3137,7 +2845,7 @@ TEST_F(ProjectStorageSlowTest, UpdateAliasPropertyIfOverloadedPropertyIsRemoved) Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, RelinkAliasProperty) +TEST_F(ProjectStorage, RelinkAliasProperty) { Storage::Types types{createTypesWithAliases()}; types[1].propertyDeclarations[0].typeName = Storage::NativeType{"QObject2"}; @@ -3167,7 +2875,7 @@ TEST_F(ProjectStorageSlowTest, RelinkAliasProperty) Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, DoNotRelinkAliasPropertyForExplicitExportedTypeName) +TEST_F(ProjectStorage, DoNotRelinkAliasPropertyForExplicitExportedTypeName) { Storage::Types types{createTypesWithAliases()}; types[1].propertyDeclarations[0].typeName = Storage::ExplicitExportedType{"Object2", @@ -3180,7 +2888,7 @@ TEST_F(ProjectStorageSlowTest, DoNotRelinkAliasPropertyForExplicitExportedTypeNa QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, +TEST_F(ProjectStorage, DoRelinkAliasPropertyForExplicitExportedTypeNameEvenIfAnOtherSimilarTimeNameExists) { Storage::Types types{createTypesWithAliases()}; @@ -3217,7 +2925,7 @@ TEST_F(ProjectStorageSlowTest, Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, RelinkAliasPropertyReactToTypeNameChange) +TEST_F(ProjectStorage, RelinkAliasPropertyReactToTypeNameChange) { Storage::Types types{createTypesWithAliases2()}; types[2].propertyDeclarations.push_back( @@ -3248,7 +2956,7 @@ TEST_F(ProjectStorageSlowTest, RelinkAliasPropertyReactToTypeNameChange) Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, DoNotRelinkAliasPropertyForDeletedType) +TEST_F(ProjectStorage, DoNotRelinkAliasPropertyForDeletedType) { Storage::Types types{createTypesWithAliases()}; types[1].propertyDeclarations[0].typeName = Storage::NativeType{"QObject2"}; @@ -3266,7 +2974,7 @@ TEST_F(ProjectStorageSlowTest, DoNotRelinkAliasPropertyForDeletedType) sourceId3))))); } -TEST_F(ProjectStorageSlowTest, DoNotRelinkAliasPropertyForDeletedTypeAndPropertyType) +TEST_F(ProjectStorage, DoNotRelinkAliasPropertyForDeletedTypeAndPropertyType) { Storage::Types types{createTypesWithAliases()}; types[1].propertyDeclarations[0].typeName = Storage::NativeType{"QObject2"}; @@ -3280,7 +2988,7 @@ TEST_F(ProjectStorageSlowTest, DoNotRelinkAliasPropertyForDeletedTypeAndProperty ASSERT_THAT(storage.fetchTypes(), SizeIs(2)); } -TEST_F(ProjectStorageSlowTest, DoNotRelinkAliasPropertyForDeletedTypeAndPropertyTypeNameChange) +TEST_F(ProjectStorage, DoNotRelinkAliasPropertyForDeletedTypeAndPropertyTypeNameChange) { Storage::Types types{createTypesWithAliases()}; types[1].propertyDeclarations[0].typeName = Storage::NativeType{"QObject2"}; @@ -3299,7 +3007,7 @@ TEST_F(ProjectStorageSlowTest, DoNotRelinkAliasPropertyForDeletedTypeAndProperty sourceId3))))); } -TEST_F(ProjectStorageSlowTest, DoNotRelinkPropertyTypeDoesNotExists) +TEST_F(ProjectStorage, DoNotRelinkPropertyTypeDoesNotExists) { Storage::Types types{createTypesWithAliases()}; types[1].propertyDeclarations[0].typeName = Storage::NativeType{"QObject2"}; @@ -3309,7 +3017,7 @@ TEST_F(ProjectStorageSlowTest, DoNotRelinkPropertyTypeDoesNotExists) ASSERT_THROW(storage.synchronize({}, {}, {}, {sourceId4}, {}), QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, DoNotRelinkAliasPropertyTypeDoesNotExists) +TEST_F(ProjectStorage, DoNotRelinkAliasPropertyTypeDoesNotExists) { Storage::Types types{createTypesWithAliases2()}; types[1].propertyDeclarations[0].typeName = Storage::NativeType{"QObject2"}; @@ -3319,7 +3027,7 @@ TEST_F(ProjectStorageSlowTest, DoNotRelinkAliasPropertyTypeDoesNotExists) ASSERT_THROW(storage.synchronize({}, {}, {}, {sourceId1}, {}), QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, ChangePrototypeTypeName) +TEST_F(ProjectStorage, ChangePrototypeTypeName) { Storage::Types types{createTypesWithExportedTypeNamesOnly()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -3335,7 +3043,7 @@ TEST_F(ProjectStorageSlowTest, ChangePrototypeTypeName) sourceId1))); } -TEST_F(ProjectStorageSlowTest, ChangePrototypeTypeImportId) +TEST_F(ProjectStorage, ChangePrototypeTypeImportId) { Storage::Types types{createTypes()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -3351,7 +3059,7 @@ TEST_F(ProjectStorageSlowTest, ChangePrototypeTypeImportId) sourceId1))); } -TEST_F(ProjectStorageSlowTest, ChangeExplicitPrototypeTypeImportIdThows) +TEST_F(ProjectStorage, ChangeExplicitPrototypeTypeImportIdThows) { Storage::Types types{createTypes()}; types[0].prototype = Storage::ExplicitExportedType{"Object", Storage::Import{"Qml"}}; @@ -3362,7 +3070,7 @@ TEST_F(ProjectStorageSlowTest, ChangeExplicitPrototypeTypeImportIdThows) QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, ChangeExplicitPrototypeTypeImportId) +TEST_F(ProjectStorage, ChangeExplicitPrototypeTypeImportId) { Storage::Types types{createTypes()}; types[0].prototype = Storage::ExplicitExportedType{"Object", Storage::Import{"Qml"}}; @@ -3380,7 +3088,7 @@ TEST_F(ProjectStorageSlowTest, ChangeExplicitPrototypeTypeImportId) sourceId1))); } -TEST_F(ProjectStorageSlowTest, ChangePrototypeTypeNameAndImportId) +TEST_F(ProjectStorage, ChangePrototypeTypeNameAndImportId) { Storage::Types types{createTypesWithExportedTypeNamesOnly()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -3397,7 +3105,7 @@ TEST_F(ProjectStorageSlowTest, ChangePrototypeTypeNameAndImportId) sourceId1))); } -TEST_F(ProjectStorageSlowTest, ChangePrototypeTypeNameThrowsForWrongNativePrototupeTypeName) +TEST_F(ProjectStorage, ChangePrototypeTypeNameThrowsForWrongNativePrototupeTypeName) { Storage::Types types{createTypes()}; types[0].propertyDeclarations[0].typeName = Storage::ExportedType{"Object"}; @@ -3408,7 +3116,7 @@ TEST_F(ProjectStorageSlowTest, ChangePrototypeTypeNameThrowsForWrongNativeProtot QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, ThrowForPrototypeChainCycles) +TEST_F(ProjectStorage, ThrowForPrototypeChainCycles) { Storage::Types types{createTypes()}; types[1].prototype = Storage::ExportedType{"Object2"}; @@ -3423,7 +3131,7 @@ TEST_F(ProjectStorageSlowTest, ThrowForPrototypeChainCycles) QmlDesigner::PrototypeChainCycle); } -TEST_F(ProjectStorageSlowTest, ThrowForTypeIdAndPrototypeIdAreTheSame) +TEST_F(ProjectStorage, ThrowForTypeIdAndPrototypeIdAreTheSame) { Storage::Types types{createTypes()}; types[1].prototype = Storage::ExportedType{"Object"}; @@ -3432,7 +3140,7 @@ TEST_F(ProjectStorageSlowTest, ThrowForTypeIdAndPrototypeIdAreTheSame) QmlDesigner::PrototypeChainCycle); } -TEST_F(ProjectStorageSlowTest, ThrowForTypeIdAndPrototypeIdAreTheSameForRelinking) +TEST_F(ProjectStorage, ThrowForTypeIdAndPrototypeIdAreTheSameForRelinking) { Storage::Types types{createTypesWithExportedTypeNamesOnly()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2}, {}); @@ -3443,7 +3151,7 @@ TEST_F(ProjectStorageSlowTest, ThrowForTypeIdAndPrototypeIdAreTheSameForRelinkin QmlDesigner::PrototypeChainCycle); } -TEST_F(ProjectStorageSlowTest, RecursiveAliases) +TEST_F(ProjectStorage, RecursiveAliases) { Storage::Types types{createTypesWithRecursiveAliases()}; @@ -3462,7 +3170,7 @@ TEST_F(ProjectStorageSlowTest, RecursiveAliases) Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, RecursiveAliasesChangePropertyType) +TEST_F(ProjectStorage, RecursiveAliasesChangePropertyType) { Storage::Types types{createTypesWithRecursiveAliases()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4, sourceId5}, {}); @@ -3483,7 +3191,7 @@ TEST_F(ProjectStorageSlowTest, RecursiveAliasesChangePropertyType) Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, UpdateAliasesAfterInjectingProperty) +TEST_F(ProjectStorage, UpdateAliasesAfterInjectingProperty) { Storage::Types types{createTypesWithRecursiveAliases()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4, sourceId5}, {}); @@ -3509,7 +3217,7 @@ TEST_F(ProjectStorageSlowTest, UpdateAliasesAfterInjectingProperty) | Storage::PropertyDeclarationTraits::IsReadOnly)))))); } -TEST_F(ProjectStorageSlowTest, UpdateAliasesAfterChangeAliasToProperty) +TEST_F(ProjectStorage, UpdateAliasesAfterChangeAliasToProperty) { Storage::Types types{createTypesWithRecursiveAliases()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4, sourceId5}, {}); @@ -3549,7 +3257,7 @@ TEST_F(ProjectStorageSlowTest, UpdateAliasesAfterChangeAliasToProperty) ""))))))); } -TEST_F(ProjectStorageSlowTest, UpdateAliasesAfterChangePropertyToAlias) +TEST_F(ProjectStorage, UpdateAliasesAfterChangePropertyToAlias) { Storage::Types types{createTypesWithRecursiveAliases()}; types[3].propertyDeclarations[0].traits = Storage::PropertyDeclarationTraits::IsList @@ -3576,7 +3284,7 @@ TEST_F(ProjectStorageSlowTest, UpdateAliasesAfterChangePropertyToAlias) "objects")))))); } -TEST_F(ProjectStorageSlowTest, CheckForProtoTypeCycleThrows) +TEST_F(ProjectStorage, CheckForProtoTypeCycleThrows) { Storage::Types types{createTypesWithRecursiveAliases()}; types[1].propertyDeclarations.clear(); @@ -3588,7 +3296,7 @@ TEST_F(ProjectStorageSlowTest, CheckForProtoTypeCycleThrows) QmlDesigner::AliasChainCycle); } -TEST_F(ProjectStorageSlowTest, CheckForProtoTypeCycleAfterUpdateThrows) +TEST_F(ProjectStorage, CheckForProtoTypeCycleAfterUpdateThrows) { Storage::Types types{createTypesWithRecursiveAliases()}; storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4, sourceId5}, {}); @@ -3600,7 +3308,7 @@ TEST_F(ProjectStorageSlowTest, CheckForProtoTypeCycleAfterUpdateThrows) QmlDesigner::AliasChainCycle); } -TEST_F(ProjectStorageSlowTest, ExplicitPrototype) +TEST_F(ProjectStorage, ExplicitPrototype) { Storage::Types types{createTypes()}; types[0].prototype = Storage::ExplicitExportedType{"Object", Storage::Import{"Qml"}}; @@ -3621,7 +3329,7 @@ TEST_F(ProjectStorageSlowTest, ExplicitPrototype) sourceId1))); } -TEST_F(ProjectStorageSlowTest, ExplicitPrototypeUpperDownTheImportChainThrows) +TEST_F(ProjectStorage, ExplicitPrototypeUpperDownTheImportChainThrows) { Storage::Types types{createTypes()}; types[0].prototype = Storage::ExplicitExportedType{"Object", Storage::Import{"QtQuick"}}; @@ -3630,7 +3338,7 @@ TEST_F(ProjectStorageSlowTest, ExplicitPrototypeUpperDownTheImportChainThrows) QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, ExplicitPrototypeUpperInTheImportChain) +TEST_F(ProjectStorage, ExplicitPrototypeUpperInTheImportChain) { Storage::Types types{createTypes()}; types[0].prototype = Storage::ExplicitExportedType{"Object", Storage::Import{"QtQuick"}}; @@ -3651,7 +3359,7 @@ TEST_F(ProjectStorageSlowTest, ExplicitPrototypeUpperInTheImportChain) sourceId1))); } -TEST_F(ProjectStorageSlowTest, ExplicitPrototypeWithWrongVersionThrows) +TEST_F(ProjectStorage, ExplicitPrototypeWithWrongVersionThrows) { Storage::Types types{createTypes()}; types[0].prototype = Storage::ExplicitExportedType{"Object", Storage::Import{"Qml", 4}}; @@ -3666,7 +3374,7 @@ TEST_F(ProjectStorageSlowTest, ExplicitPrototypeWithWrongVersionThrows) QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, ExplicitPrototypeWithVersion) +TEST_F(ProjectStorage, ExplicitPrototypeWithVersion) { Storage::Types types{createTypes()}; types[0].prototype = Storage::ExplicitExportedType{"Object", Storage::Import{"Qml", 2}}; @@ -3687,7 +3395,7 @@ TEST_F(ProjectStorageSlowTest, ExplicitPrototypeWithVersion) sourceId1))); } -TEST_F(ProjectStorageSlowTest, ExplicitPrototypeWithVersionInTheProtoTypeChain) +TEST_F(ProjectStorage, ExplicitPrototypeWithVersionInTheProtoTypeChain) { Storage::Types types{createTypes()}; auto importDependencyQtQuick2 = Storage::ImportDependency{ @@ -3717,7 +3425,7 @@ TEST_F(ProjectStorageSlowTest, ExplicitPrototypeWithVersionInTheProtoTypeChain) sourceId1))); } -TEST_F(ProjectStorageSlowTest, ExplicitPrototypeWithVersionDownTheProtoTypeChainThrows) +TEST_F(ProjectStorage, ExplicitPrototypeWithVersionDownTheProtoTypeChainThrows) { Storage::Types types{createTypes()}; auto importDependencyQtQuick2 = Storage::ImportDependency{ @@ -3735,7 +3443,7 @@ TEST_F(ProjectStorageSlowTest, ExplicitPrototypeWithVersionDownTheProtoTypeChain QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, ExplicitPropertyDeclarationTypeName) +TEST_F(ProjectStorage, ExplicitPropertyDeclarationTypeName) { Storage::Types types{createTypes()}; types[0].propertyDeclarations[0].typeName = Storage::ExplicitExportedType{"Object", @@ -3758,7 +3466,7 @@ TEST_F(ProjectStorageSlowTest, ExplicitPropertyDeclarationTypeName) Storage::PropertyDeclarationTraits::IsList))))); } -TEST_F(ProjectStorageSlowTest, ExplicitPropertyDeclarationTypeNameDownTheImportChainThrows) +TEST_F(ProjectStorage, ExplicitPropertyDeclarationTypeNameDownTheImportChainThrows) { Storage::Types types{createTypes()}; types[0].propertyDeclarations[0].typeName = Storage::ExplicitExportedType{"Object", @@ -3769,7 +3477,7 @@ TEST_F(ProjectStorageSlowTest, ExplicitPropertyDeclarationTypeNameDownTheImportC QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, ExplicitPropertyDeclarationTypeNameInTheImportChain) +TEST_F(ProjectStorage, ExplicitPropertyDeclarationTypeNameInTheImportChain) { Storage::Types types{createTypes()}; types[0].propertyDeclarations[0].typeName = Storage::ExplicitExportedType{"Object", @@ -3792,7 +3500,7 @@ TEST_F(ProjectStorageSlowTest, ExplicitPropertyDeclarationTypeNameInTheImportCha Storage::PropertyDeclarationTraits::IsList))))); } -TEST_F(ProjectStorageSlowTest, ExplicitPropertyDeclarationTypeNameWithVersion) +TEST_F(ProjectStorage, ExplicitPropertyDeclarationTypeNameWithVersion) { Storage::Types types{createTypes()}; types[0].propertyDeclarations[0].typeName = Storage::ExplicitExportedType{"Object", @@ -3809,7 +3517,7 @@ TEST_F(ProjectStorageSlowTest, ExplicitPropertyDeclarationTypeNameWithVersion) Storage::PropertyDeclarationTraits::IsList))))); } -TEST_F(ProjectStorageSlowTest, PrototypeWithVersionDownTheProtoTypeChainThrows) +TEST_F(ProjectStorage, PrototypeWithVersionDownTheProtoTypeChainThrows) { Storage::Types types{createTypes()}; auto importDependencyQtQuick2 = Storage::ImportDependency{ @@ -3828,7 +3536,7 @@ TEST_F(ProjectStorageSlowTest, PrototypeWithVersionDownTheProtoTypeChainThrows) QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, ChangePropertyTypeImportIdWithExplicitTypeThrows) +TEST_F(ProjectStorage, ChangePropertyTypeImportIdWithExplicitTypeThrows) { Storage::Types types{createTypes()}; types[0].propertyDeclarations[0].typeName = Storage::ExplicitExportedType{"Object", @@ -3841,7 +3549,7 @@ TEST_F(ProjectStorageSlowTest, ChangePropertyTypeImportIdWithExplicitTypeThrows) QmlDesigner::TypeNameDoesNotExists); } -TEST_F(ProjectStorageSlowTest, ChangePropertyTypeImportIdWithExplicitType) +TEST_F(ProjectStorage, ChangePropertyTypeImportIdWithExplicitType) { Storage::Types types{createTypes()}; types[0].propertyDeclarations[0].typeName = Storage::ExplicitExportedType{"Object", @@ -3868,7 +3576,7 @@ TEST_F(ProjectStorageSlowTest, ChangePropertyTypeImportIdWithExplicitType) Storage::PropertyDeclarationTraits::IsList)))))); } -TEST_F(ProjectStorageSlowTest, AddFileStatuses) +TEST_F(ProjectStorage, AddFileStatuses) { setUpSourceIds(); FileStatus fileStatus1{sourceId1, 100, 100}; @@ -3880,7 +3588,7 @@ TEST_F(ProjectStorageSlowTest, AddFileStatuses) UnorderedElementsAre(fileStatus1, fileStatus2)); } -TEST_F(ProjectStorageSlowTest, RemoveFileStatus) +TEST_F(ProjectStorage, RemoveFileStatus) { setUpSourceIds(); FileStatus fileStatus1{sourceId1, 100, 100}; @@ -3892,7 +3600,7 @@ TEST_F(ProjectStorageSlowTest, RemoveFileStatus) ASSERT_THAT(convert(storage.fetchAllFileStatuses()), UnorderedElementsAre(fileStatus1)); } -TEST_F(ProjectStorageSlowTest, UpdateFileStatus) +TEST_F(ProjectStorage, UpdateFileStatus) { setUpSourceIds(); FileStatus fileStatus1{sourceId1, 100, 100}; @@ -3906,7 +3614,7 @@ TEST_F(ProjectStorageSlowTest, UpdateFileStatus) UnorderedElementsAre(fileStatus1, fileStatus2b)); } -TEST_F(ProjectStorageSlowTest, ThrowForInvalidSourceId) +TEST_F(ProjectStorage, ThrowForInvalidSourceId) { setUpSourceIds(); FileStatus fileStatus1{SourceId{}, 100, 100}; @@ -3915,7 +3623,7 @@ TEST_F(ProjectStorageSlowTest, ThrowForInvalidSourceId) Sqlite::ConstraintPreventsModification); } -TEST_F(ProjectStorageSlowTest, FetchAllFileStatuses) +TEST_F(ProjectStorage, FetchAllFileStatuses) { setUpSourceIds(); FileStatus fileStatus1{sourceId1, 100, 100}; @@ -3927,7 +3635,7 @@ TEST_F(ProjectStorageSlowTest, FetchAllFileStatuses) ASSERT_THAT(fileStatuses, ElementsAre(fileStatus1, fileStatus2)); } -TEST_F(ProjectStorageSlowTest, FetchAllFileStatusesReverse) +TEST_F(ProjectStorage, FetchAllFileStatusesReverse) { setUpSourceIds(); FileStatus fileStatus1{sourceId1, 100, 100}; @@ -3939,4 +3647,37 @@ TEST_F(ProjectStorageSlowTest, FetchAllFileStatusesReverse) ASSERT_THAT(fileStatuses, ElementsAre(fileStatus1, fileStatus2)); } +TEST_F(ProjectStorage, FetchFileStatus) +{ + setUpSourceIds(); + FileStatus fileStatus1{sourceId1, 100, 100}; + FileStatus fileStatus2{sourceId2, 101, 101}; + storage.synchronize({}, {}, {}, {sourceId1, sourceId2}, {fileStatus1, fileStatus2}); + + auto fileStatus = storage.fetchFileStatus(sourceId1); + + ASSERT_THAT(fileStatus, Eq(fileStatus1)); +} + +TEST_F(ProjectStorage, SynchronizeTypesWithoutTypeName) +{ + Storage::Types types{createTypesWithAliases()}; + storage.synchronize({}, {}, types, {sourceId1, sourceId2, sourceId3, sourceId4}, {}); + types[3].typeName.clear(); + types[3].import.name.clear(); + types[3].prototype = Storage::ExportedType{"Object"}; + + storage.synchronize({}, {}, {types[3]}, {sourceId4}, {}); + + ASSERT_THAT(storage.fetchTypes(), + Contains(AllOf(IsStorageType(Storage::Import{"/path/to"}, + "QObject2", + Storage::NativeType{"QObject"}, + TypeAccessSemantics::Reference, + sourceId4), + Field(&Storage::Type::exportedTypes, + UnorderedElementsAre(IsExportedType("Object2"), + IsExportedType("Obj2")))))); +} + } // namespace diff --git a/tests/unit/unittest/projectstoragemock.h b/tests/unit/unittest/projectstoragemock.h index 10d749b077c..e3eb0e35de1 100644 --- a/tests/unit/unittest/projectstoragemock.h +++ b/tests/unit/unittest/projectstoragemock.h @@ -29,36 +29,55 @@ #include "sqlitedatabasemock.h" -#include +#include +#include #include -#include -class ProjectStorageMock +class ProjectStorageMock : public QmlDesigner::ProjectStorageInterface { public: - ProjectStorageMock(SqliteDatabaseMock &databaseMock) - : databaseMock{databaseMock} - {} + MOCK_METHOD(void, + synchronize, + (QmlDesigner::Storage::ImportDependencies importDependencies, + QmlDesigner::Storage::Documents documents, + QmlDesigner::Storage::Types types, + QmlDesigner::SourceIds sourceIds, + QmlDesigner::FileStatuses fileStatuses), + (override)); - MOCK_METHOD1(fetchSourceContextId, - QmlDesigner::SourceContextId(Utils::SmallStringView SourceContextPath)); - MOCK_METHOD2(fetchSourceId, - QmlDesigner::SourceId(QmlDesigner::SourceContextId SourceContextId, - Utils::SmallStringView sourceName)); - MOCK_METHOD1(fetchSourceContextIdUnguarded, - QmlDesigner::SourceContextId(Utils::SmallStringView SourceContextPath)); - MOCK_METHOD2(fetchSourceIdUnguarded, - QmlDesigner::SourceId(QmlDesigner::SourceContextId SourceContextId, - Utils::SmallStringView sourceName)); - MOCK_METHOD1(fetchSourceContextPath, - Utils::PathString(QmlDesigner::SourceContextId sourceContextId)); - MOCK_METHOD1(fetchSourceNameAndSourceContextId, - QmlDesigner::Cache::SourceNameAndSourceContextId(QmlDesigner::SourceId sourceId)); - MOCK_METHOD0(fetchAllSourceContexts, std::vector()); - MOCK_METHOD0(fetchAllSources, std::vector()); + MOCK_METHOD(QmlDesigner::FileStatus, + fetchFileStatus, + (QmlDesigner::SourceId sourceId), + (const, override)); - SqliteDatabaseMock &database() { return databaseMock; } + MOCK_METHOD(QmlDesigner::SourceIds, + fetchSourceDependencieIds, + (QmlDesigner::SourceId sourceId), + (const, override)); - SqliteDatabaseMock &databaseMock; + MOCK_METHOD(QmlDesigner::SourceContextId, + fetchSourceContextId, + (Utils::SmallStringView SourceContextPath), + ()); + MOCK_METHOD(QmlDesigner::SourceId, + fetchSourceId, + (QmlDesigner::SourceContextId SourceContextId, Utils::SmallStringView sourceName), + ()); + MOCK_METHOD(QmlDesigner::SourceContextId, + fetchSourceContextIdUnguarded, + (Utils::SmallStringView SourceContextPath), + ()); + MOCK_METHOD(QmlDesigner::SourceId, + fetchSourceIdUnguarded, + (QmlDesigner::SourceContextId SourceContextId, Utils::SmallStringView sourceName), + ()); + MOCK_METHOD(Utils::PathString, + fetchSourceContextPath, + (QmlDesigner::SourceContextId sourceContextId)); + MOCK_METHOD(QmlDesigner::Cache::SourceNameAndSourceContextId, + fetchSourceNameAndSourceContextId, + (QmlDesigner::SourceId sourceId)); + MOCK_METHOD(std::vector, fetchAllSourceContexts, (), ()); + MOCK_METHOD(std::vector, fetchAllSources, (), ()); }; diff --git a/tests/unit/unittest/projectstoragepathwatcher-test.cpp b/tests/unit/unittest/projectstoragepathwatcher-test.cpp index 5bbcddfd496..f4843017b78 100644 --- a/tests/unit/unittest/projectstoragepathwatcher-test.cpp +++ b/tests/unit/unittest/projectstoragepathwatcher-test.cpp @@ -41,6 +41,7 @@ namespace { using Watcher = QmlDesigner::ProjectStoragePathWatcher, NiceMock, NiceMock>; +using QmlDesigner::FileStatus; using QmlDesigner::IdPaths; using QmlDesigner::ProjectChunkId; using QmlDesigner::ProjectChunkIds; @@ -81,7 +82,9 @@ protected: .WillByDefault(Return(sourceContextIds[1])); ON_CALL(sourcePathCacheMock, sourceContextId(TypedEq(pathIds[4]))) .WillByDefault(Return(sourceContextIds[2])); - ON_CALL(mockFileSystem, lastModified(_)).WillByDefault(Return(1)); + ON_CALL(mockFileSystem, fileStatus(_)).WillByDefault([](auto sourceId) { + return FileStatus{sourceId, 1, 1}; + }); ON_CALL(sourcePathCacheMock, sourceContextId(TypedEq(sourceContextPathString))) .WillByDefault(Return(sourceContextIds[0])); @@ -359,9 +362,12 @@ TEST_F(ProjectStoragePathWatcher, TwoNotifyFileChanges) watcher.updateIdPaths({{id1, {pathIds[0], pathIds[1], pathIds[2]}}, {id2, {pathIds[0], pathIds[1], pathIds[2], pathIds[3], pathIds[4]}}, {id3, {pathIds[4]}}}); - ON_CALL(mockFileSystem, lastModified(Eq(pathIds[0]))).WillByDefault(Return(2)); - ON_CALL(mockFileSystem, lastModified(Eq(pathIds[1]))).WillByDefault(Return(2)); - ON_CALL(mockFileSystem, lastModified(Eq(pathIds[3]))).WillByDefault(Return(2)); + ON_CALL(mockFileSystem, fileStatus(Eq(pathIds[0]))) + .WillByDefault(Return(FileStatus{pathIds[0], 1, 2})); + ON_CALL(mockFileSystem, fileStatus(Eq(pathIds[1]))) + .WillByDefault(Return(FileStatus{pathIds[1], 1, 2})); + ON_CALL(mockFileSystem, fileStatus(Eq(pathIds[3]))) + .WillByDefault(Return(FileStatus{pathIds[3], 1, 2})); EXPECT_CALL(notifier, pathsWithIdsChanged( @@ -376,8 +382,11 @@ TEST_F(ProjectStoragePathWatcher, NotifyForPathChanges) { watcher.updateIdPaths( {{id1, {pathIds[0], pathIds[1], pathIds[2]}}, {id2, {pathIds[0], pathIds[1], pathIds[3]}}}); - ON_CALL(mockFileSystem, lastModified(Eq(pathIds[0]))).WillByDefault(Return(2)); - ON_CALL(mockFileSystem, lastModified(Eq(pathIds[3]))).WillByDefault(Return(2)); + ON_CALL(mockFileSystem, fileStatus(Eq(pathIds[0]))) + .WillByDefault(Return(FileStatus{pathIds[0], 1, 2})); + + ON_CALL(mockFileSystem, fileStatus(Eq(pathIds[3]))) + .WillByDefault(Return(FileStatus{pathIds[3], 1, 2})); EXPECT_CALL(notifier, pathsChanged(ElementsAre(pathIds[0]))); @@ -397,7 +406,8 @@ TEST_F(ProjectStoragePathWatcher, NoDuplicatePathChanges) { watcher.updateIdPaths( {{id1, {pathIds[0], pathIds[1], pathIds[2]}}, {id2, {pathIds[0], pathIds[1], pathIds[3]}}}); - ON_CALL(mockFileSystem, lastModified(Eq(pathIds[0]))).WillByDefault(Return(2)); + ON_CALL(mockFileSystem, fileStatus(Eq(pathIds[0]))) + .WillByDefault(Return(FileStatus{pathIds[0], 1, 2})); EXPECT_CALL(notifier, pathsChanged(ElementsAre(pathIds[0]))); diff --git a/tests/unit/unittest/projectstorageupdater-test.cpp b/tests/unit/unittest/projectstorageupdater-test.cpp new file mode 100644 index 00000000000..3b16f2e636e --- /dev/null +++ b/tests/unit/unittest/projectstorageupdater-test.cpp @@ -0,0 +1,368 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "googletest.h" + +#include "filesystemmock.h" +#include "projectmanagermock.h" +#include "projectstoragemock.h" +#include "qmldocumentparsermock.h" +#include "qmltypesparsermock.h" + +#include +#include +#include +#include +#include + +namespace { + +namespace Storage = QmlDesigner::Storage; + +using QmlDesigner::FileStatus; +using QmlDesigner::SourceId; +using QmlDesigner::Storage::TypeAccessSemantics; + +MATCHER_P5(IsStorageType, + import, + typeName, + prototype, + accessSemantics, + sourceId, + std::string(negation ? "isn't " : "is ") + + PrintToString(Storage::Type{import, typeName, prototype, accessSemantics, sourceId})) +{ + const Storage::Type &type = arg; + + return type.import == import && type.typeName == typeName + && type.accessSemantics == accessSemantics && type.sourceId == sourceId + && Storage::TypeName{prototype} == type.prototype; +} + +MATCHER_P3(IsPropertyDeclaration, + name, + typeName, + traits, + std::string(negation ? "isn't " : "is ") + + PrintToString(Storage::PropertyDeclaration{name, typeName, traits})) +{ + const Storage::PropertyDeclaration &propertyDeclaration = arg; + + return propertyDeclaration.name == name + && Storage::TypeName{typeName} == propertyDeclaration.typeName + && propertyDeclaration.traits == traits; +} + +MATCHER_P(IsExportedType, + name, + std::string(negation ? "isn't " : "is ") + PrintToString(Storage::ExportedType{name})) +{ + const Storage::ExportedType &type = arg; + + return type.name == name; +} + +class ProjectStorageUpdater : public testing::Test +{ +public: + ProjectStorageUpdater() + { + ON_CALL(fileSystemMock, fileStatus(Eq(qmltypesPathSourceId))) + .WillByDefault(Return(FileStatus{qmltypesPathSourceId, 21, 421})); + ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmltypesPathSourceId))) + .WillByDefault(Return(FileStatus{qmltypesPathSourceId, 2, 421})); + + ON_CALL(fileSystemMock, fileStatus(Eq(qmltypes2PathSourceId))) + .WillByDefault(Return(FileStatus{qmltypes2PathSourceId, 21, 421})); + ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmltypes2PathSourceId))) + .WillByDefault(Return(FileStatus{qmltypes2PathSourceId, 2, 421})); + + ON_CALL(fileSystemMock, fileStatus(Eq(qmlDirPathSourceId))) + .WillByDefault(Return(FileStatus{qmlDirPathSourceId, 21, 421})); + ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmlDirPathSourceId))) + .WillByDefault(Return(FileStatus{qmlDirPathSourceId, 2, 421})); + + ON_CALL(projectStorageMock, fetchSourceDependencieIds(Eq(qmlDirPathSourceId))) + .WillByDefault(Return(QmlDesigner::SourceIds{qmltypesPathSourceId, qmltypes2PathSourceId})); + + QString qmldir{"module Example\ntypeinfo example.qmltypes\n"}; + ON_CALL(projectManagerMock, qtQmlDirs()).WillByDefault(Return(QStringList{"/path/qmldir"})); + ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))) + .WillByDefault(Return(qmldir)); + } + +protected: + NiceMock projectManagerMock; + NiceMock fileSystemMock; + NiceMock projectStorageMock; + NiceMock qmlTypesParserMock; + NiceMock qmlDocumentParserMock; + QmlDesigner::FileStatusCache fileStatusCache{fileSystemMock}; + Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory}; + QmlDesigner::ProjectStorage storage{database, database.isInitialized()}; + QmlDesigner::SourcePathCache> sourcePathCache{ + storage}; + QmlDesigner::ProjectUpdater updater{projectManagerMock, + fileSystemMock, + projectStorageMock, + fileStatusCache, + sourcePathCache, + qmlDocumentParserMock, + qmlTypesParserMock}; + SourceId objectTypeSourceId{sourcePathCache.sourceId("/path/Object")}; + Storage::Type objectType{Storage::Import{"Qml", 2}, + "QObject", + Storage::NativeType{}, + Storage::TypeAccessSemantics::Reference, + objectTypeSourceId, + {Storage::ExportedType{"Object"}, Storage::ExportedType{"Obj"}}}; + SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/path/example.qmltypes"); + SourceId qmltypes2PathSourceId = sourcePathCache.sourceId("/path/example2.qmltypes"); + SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/path/qmldir"); +}; + +TEST_F(ProjectStorageUpdater, GetContentForQmlDirPathsIfFileStatusIsDifferent) +{ + SourceId qmlDir1PathSourceId = sourcePathCache.sourceId("/path/one/qmldir"); + SourceId qmlDir2PathSourceId = sourcePathCache.sourceId("/path/two/qmldir"); + SourceId qmlDir3PathSourceId = sourcePathCache.sourceId("/path/three/qmldir"); + ON_CALL(projectManagerMock, qtQmlDirs()) + .WillByDefault( + Return(QStringList{"/path/one/qmldir", "/path/two/qmldir", "/path/three/qmldir"})); + ON_CALL(fileSystemMock, fileStatus(_)).WillByDefault([](auto sourceId) { + return FileStatus{sourceId, 21, 421}; + }); + ON_CALL(projectStorageMock, fetchFileStatus(_)).WillByDefault([](auto sourceId) { + return FileStatus{sourceId, 2, 421}; + }); + ON_CALL(fileSystemMock, fileStatus(Eq(qmlDir3PathSourceId))) + .WillByDefault(Return(FileStatus{qmlDir3PathSourceId, 21, 421})); + ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmlDir3PathSourceId))) + .WillByDefault(Return(FileStatus{qmlDir3PathSourceId, 21, 421})); + + EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/one/qmldir")))); + EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/two/qmldir")))); + + updater.update(); +} + +TEST_F(ProjectStorageUpdater, RequestFileStatusFromFileSystem) +{ + EXPECT_CALL(fileSystemMock, fileStatus(Ne(qmlDirPathSourceId))).Times(AnyNumber()); + + EXPECT_CALL(fileSystemMock, fileStatus(Eq(qmlDirPathSourceId))); + + updater.update(); +} + +TEST_F(ProjectStorageUpdater, GetContentForQmlTypes) +{ + QString qmldir{"module Example\ntypeinfo example.qmltypes\n"}; + EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))) + .WillRepeatedly(Return(qmldir)); + + EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes")))); + + updater.update(); +} + +TEST_F(ProjectStorageUpdater, GetContentForQmlTypesIfProjectStorageFileStatusIsInvalid) +{ + QString qmldir{"module Example\ntypeinfo example.qmltypes\n"}; + EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))) + .WillRepeatedly(Return(qmldir)); + ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmltypesPathSourceId))) + .WillByDefault(Return(FileStatus{})); + + EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes")))); + + updater.update(); +} + +TEST_F(ProjectStorageUpdater, DontGetContentForQmlTypesIfFileSystemFileStatusIsInvalid) +{ + QString qmldir{"module Example\ntypeinfo example.qmltypes\n"}; + EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))) + .WillRepeatedly(Return(qmldir)); + ON_CALL(fileSystemMock, fileStatus(Eq(qmltypesPathSourceId))).WillByDefault(Return(FileStatus{})); + + EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes")))).Times(0); + + updater.update(); +} + +TEST_F(ProjectStorageUpdater, ParseQmlTypes) +{ + QString qmldir{"module Example\ntypeinfo example.qmltypes\ntypeinfo example2.qmltypes\n"}; + ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir)); + QString qmltypes{"Module {\ndependencies: []}"}; + QString qmltypes2{"Module {\ndependencies: [foo]}"}; + ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes")))) + .WillByDefault(Return(qmltypes)); + ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example2.qmltypes")))) + .WillByDefault(Return(qmltypes2)); + + EXPECT_CALL(qmlTypesParserMock, parse(qmltypes, _, _, _)); + EXPECT_CALL(qmlTypesParserMock, parse(qmltypes2, _, _, _)); + + updater.update(); +} + +TEST_F(ProjectStorageUpdater, DISABLED_SynchronizeIsEmptyForNoChange) +{ + EXPECT_CALL(projectStorageMock, + synchronize(IsEmpty(), IsEmpty(), IsEmpty(), IsEmpty(), IsEmpty())); + + updater.update(); +} + +TEST_F(ProjectStorageUpdater, SynchronizeQmlTypes) +{ + auto qmlDirPathSourceId = sourcePathCache.sourceId("/path/qmldir"); + auto qmltypesPathSourceId = sourcePathCache.sourceId("/path/example.qmltypes"); + QString qmltypes{"Module {\ndependencies: []}"}; + ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes")))) + .WillByDefault(Return(qmltypes)); + ON_CALL(qmlTypesParserMock, parse(qmltypes, _, _, _)) + .WillByDefault([&](auto, auto &importDependencies, auto &types, auto &sourceIds) { + types.push_back(objectType); + }); + + EXPECT_CALL(projectStorageMock, + synchronize(_, + _, + ElementsAre(Eq(objectType)), + UnorderedElementsAre(qmlDirPathSourceId, qmltypesPathSourceId), + _)); + + updater.update(); +} + +TEST_F(ProjectStorageUpdater, SynchronizeQmlTypesAreEmptyIfFileDoesNotChanged) +{ + QString qmltypes{"Module {\ndependencies: []}"}; + ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes")))) + .WillByDefault(Return(qmltypes)); + ON_CALL(qmlTypesParserMock, parse(qmltypes, _, _, _)) + .WillByDefault([&](auto, auto &importDependencies, auto &types, auto &sourceIds) { + types.push_back(objectType); + }); + ON_CALL(fileSystemMock, fileStatus(Eq(qmltypesPathSourceId))) + .WillByDefault(Return(FileStatus{qmltypesPathSourceId, 2, 421})); + ON_CALL(fileSystemMock, fileStatus(Eq(qmltypes2PathSourceId))) + .WillByDefault(Return(FileStatus{qmltypes2PathSourceId, 2, 421})); + ON_CALL(fileSystemMock, fileStatus(Eq(qmlDirPathSourceId))) + .WillByDefault(Return(FileStatus{qmlDirPathSourceId, 2, 421})); + + EXPECT_CALL(projectStorageMock, + synchronize(IsEmpty(), IsEmpty(), IsEmpty(), IsEmpty(), IsEmpty())); + + updater.update(); +} + +TEST_F(ProjectStorageUpdater, GetContentForQmlDocuments) +{ + QString qmldir{"module Example\nFirstType 1.0 First.qml\nFirstTypeV2 2.2 " + "First.2.qml\nSecondType 2.1 OldSecond.qml\nSecondType 2.2 Second.qml\n"}; + EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))) + .WillRepeatedly(Return(qmldir)); + + EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.qml")))); + EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.2.qml")))); + EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/Second.qml")))); + + updater.update(); +} + +TEST_F(ProjectStorageUpdater, ParseQmlDocuments) +{ + QString qmldir{"module Example\nFirstType 1.0 First.qml\nFirstTypeV2 2.2 " + "First.2.qml\nSecondType 2.1 OldSecond.qml\nSecondType 2.2 Second.qml\n"}; + QString qmlDocument1{"First{}"}; + QString qmlDocument2{"Second{}"}; + QString qmlDocument3{"Third{}"}; + ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir)); + ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.qml")))) + .WillByDefault(Return(qmlDocument1)); + ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.2.qml")))) + .WillByDefault(Return(qmlDocument2)); + ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/Second.qml")))) + .WillByDefault(Return(qmlDocument3)); + + EXPECT_CALL(qmlDocumentParserMock, parse(qmlDocument1)); + EXPECT_CALL(qmlDocumentParserMock, parse(qmlDocument2)); + EXPECT_CALL(qmlDocumentParserMock, parse(qmlDocument3)); + + updater.update(); +} + +TEST_F(ProjectStorageUpdater, SynchronizeQmlDocuments) +{ + QString qmldir{"module Example\nFirstType 1.0 First.qml\nFirstTypeV2 2.2 " + "First.2.qml\nSecondType 2.1 OldSecond.qml\nSecondType 2.2 Second.qml\n"}; + QString qmlDocument1{"First{}"}; + QString qmlDocument2{"Second{}"}; + QString qmlDocument3{"Third{}"}; + auto qmlDocumentSourceId1 = sourcePathCache.sourceId("/path/First.qml"); + auto qmlDocumentSourceId2 = sourcePathCache.sourceId("/path/First.2.qml"); + auto qmlDocumentSourceId3 = sourcePathCache.sourceId("/path/Second.qml"); + Storage::Type firstType; + firstType.prototype = Storage::ExportedType{"Object"}; + Storage::Type secondType; + secondType.prototype = Storage::ExportedType{"Object2"}; + Storage::Type thirdType; + thirdType.prototype = Storage::ExportedType{"Object3"}; + auto firstQmlDocumentSourceId = sourcePathCache.sourceId("/path/First.qml"); + ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir)); + ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.qml")))) + .WillByDefault(Return(qmlDocument1)); + ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.2.qml")))) + .WillByDefault(Return(qmlDocument2)); + ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/Second.qml")))) + .WillByDefault(Return(qmlDocument3)); + ON_CALL(qmlDocumentParserMock, parse(qmlDocument1)).WillByDefault(Return(firstType)); + ON_CALL(qmlDocumentParserMock, parse(qmlDocument2)).WillByDefault(Return(secondType)); + ON_CALL(qmlDocumentParserMock, parse(qmlDocument3)).WillByDefault(Return(thirdType)); + + EXPECT_CALL(projectStorageMock, + synchronize(_, + _, + Contains(AllOf(IsStorageType(Storage::Import{"Example", 1}, + "First.qml", + Storage::ExportedType{"Object"}, + TypeAccessSemantics::Reference, + firstQmlDocumentSourceId), + Field(&Storage::Type::exportedTypes, + ElementsAre(IsExportedType("FirstType"))))), + UnorderedElementsAre(qmlDirPathSourceId, + qmlDocumentSourceId1, + qmlDocumentSourceId2, + qmlDocumentSourceId3), + _)); + + updater.update(); +} + +} // namespace diff --git a/tests/unit/unittest/qmldocumentparsermock.h b/tests/unit/unittest/qmldocumentparsermock.h new file mode 100644 index 00000000000..20e633e9047 --- /dev/null +++ b/tests/unit/unittest/qmldocumentparsermock.h @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "googletest.h" + +#include + +class QmlDocumentParserMock : public QmlDesigner::QmlDocumentParserInterface +{ +public: + MOCK_METHOD(QmlDesigner::Storage::Type, parse, (const QString &), (override)); +}; diff --git a/tests/unit/unittest/qmltypesparsermock.h b/tests/unit/unittest/qmltypesparsermock.h new file mode 100644 index 00000000000..e88e0db8fd7 --- /dev/null +++ b/tests/unit/unittest/qmltypesparsermock.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "googletest.h" + +#include + +class QmlTypesParserMock : public QmlDesigner::QmlTypesParserInterface +{ +public: + MOCK_METHOD(void, + parse, + (const QString &sourceContent, + QmlDesigner::Storage::ImportDependencies &importDependencies, + QmlDesigner::Storage::Types &types, + QmlDesigner::SourceIds &sourceIds), + (override)); +}; diff --git a/tests/unit/unittest/sourcepathcache-test.cpp b/tests/unit/unittest/sourcepathcache-test.cpp index 8755f694986..abb3bf29d1c 100644 --- a/tests/unit/unittest/sourcepathcache-test.cpp +++ b/tests/unit/unittest/sourcepathcache-test.cpp @@ -76,10 +76,9 @@ protected: } protected: - NiceMock databaseMock; - NiceMock storageMock{databaseMock}; + NiceMock storageMock; Cache cache{storageMock}; - NiceMock storageMockFilled{databaseMock}; + NiceMock storageMockFilled; Cache cacheNotFilled{storageMockFilled}; }; @@ -104,6 +103,15 @@ TEST_F(SourcePathCache, SourceIdOfSourceIdWithOutAnyEntry) ASSERT_THAT(sourceId, SourceId{42}); } +TEST_F(SourcePathCache, SourceIdWithSourceContextIdAndSourceName) +{ + auto sourceContextId = cache.sourceContextId("/path/to"_sv); + + auto sourceId = cache.sourceId(sourceContextId, "file.cpp"_sv); + + ASSERT_THAT(sourceId, SourceId{42}); +} + TEST_F(SourcePathCache, IfEntryExistsDontCallInStrorage) { cache.sourceId(SourcePathView("/path/to/file.cpp")); diff --git a/tests/unit/unittest/sqlitereadstatementmock.h b/tests/unit/unittest/sqlitereadstatementmock.h index 78f02b31d03..9bde954ac91 100644 --- a/tests/unit/unittest/sqlitereadstatementmock.h +++ b/tests/unit/unittest/sqlitereadstatementmock.h @@ -27,7 +27,7 @@ #include "googletest.h" -#include +#include #include #include #include @@ -60,10 +60,6 @@ public: (Utils::SmallStringView, long long), ()); - MOCK_METHOD(CppEditor::Usages, valuesReturnSourceUsages, (std::size_t, int, int, int), ()); - - MOCK_METHOD(CppEditor::Usages, valuesReturnSourceUsages, (std::size_t, int, int, int, int), ()); - MOCK_METHOD(Utils::optional, valueReturnInt32, (Utils::SmallStringView), ()); MOCK_METHOD(Utils::optional, valueReturnInt32, (int, Utils::SmallStringView), ()); @@ -78,7 +74,7 @@ public: MOCK_METHOD(Utils::optional, valueReturnSmallString, (int), ()); - MOCK_METHOD(QmlDesigner::TypeId, valueReturnsTypeId, (Utils::SmallStringView name), ()); + MOCK_METHOD(QmlDesigner::TypeId, valueReturnsTypeId, (long long, Utils::SmallStringView name), ()); MOCK_METHOD(QmlDesigner::TypeId, valueWithTransactionReturnsTypeId, (long long, long long), ()); MOCK_METHOD(QmlDesigner::PropertyDeclarationId, valueWithTransactionReturnsPropertyDeclarationId, @@ -151,6 +147,8 @@ public: (std::size_t, long long), ()); + MOCK_METHOD(QmlDesigner::FileStatuses, rangesReturnsFileStatuses, (Utils::span), ()); + template auto optionalValue(const QueryTypes &...queryValues) { @@ -221,8 +219,6 @@ public: return valuesReturnStringVector(reserveSize); else if constexpr (std::is_same_v) return valuesReturnRowIds(reserveSize); - else if constexpr (std::is_same_v) - return valuesReturnSourceUsages(reserveSize, queryValues...); else if constexpr (std::is_same_v) return valuesReturnCacheSourceContexts(reserveSize); else if constexpr (std::is_same_v) @@ -255,6 +251,8 @@ public: return rangeReturnStorageSignalDeclarationViews(queryValues...); else if constexpr (std::is_same_v) return rangeReturnStorageEnumerationDeclarationViews(queryValues...); + else if constexpr (std::is_same_v) + return rangesReturnsFileStatuses(queryValues...); else static_assert(!std::is_same_v, "SqliteReadStatementMock::values does not handle result type!"); diff --git a/tests/unit/unittest/sqlitewritestatementmock.h b/tests/unit/unittest/sqlitewritestatementmock.h index 92e82e86bbe..9031da67bbe 100644 --- a/tests/unit/unittest/sqlitewritestatementmock.h +++ b/tests/unit/unittest/sqlitewritestatementmock.h @@ -44,6 +44,7 @@ public: MOCK_METHOD(void, write, (long long), ()); MOCK_METHOD(void, write, (long long, long long), ()); MOCK_METHOD(void, write, (long long, long long, int), ()); + MOCK_METHOD(void, write, (long long, long long, long long), ()); MOCK_METHOD(void, write, (long long, unsigned int), ()); MOCK_METHOD(void, write, (Utils::SmallStringView, long long), ()); MOCK_METHOD(void, write, (Utils::SmallStringView, Utils::SmallStringView), ()); @@ -95,6 +96,7 @@ public: MOCK_METHOD(void, write, (void *, long long), ()); MOCK_METHOD(void, write, (int), ()); MOCK_METHOD(void, write, (int, long long), ()); + MOCK_METHOD(void, write, (int, long long, long long), ()); MOCK_METHOD(void, write, (int, int), ()); MOCK_METHOD(void, write, (uint, uint, uint), ()); MOCK_METHOD(void, write, (int, off_t, time_t), ()); @@ -109,6 +111,7 @@ public: MOCK_METHOD(void, write, (uint, Utils::SmallStringView), ()); MOCK_METHOD(void, write, (int, Utils::SmallStringView), ()); MOCK_METHOD(void, write, (int, Utils::SmallStringView, long long), ()); + MOCK_METHOD(void, write, (long long, Sqlite::NullValue, Sqlite::NullValue), ()); MOCK_METHOD(void, write, (Utils::span, Utils::span), ()); MOCK_METHOD(void, write, (Utils::span), ()); diff --git a/tests/unit/unittest/storagecache-test.cpp b/tests/unit/unittest/storagecache-test.cpp index 1b515a7412a..6fca4afb14e 100644 --- a/tests/unit/unittest/storagecache-test.cpp +++ b/tests/unit/unittest/storagecache-test.cpp @@ -101,8 +101,7 @@ protected: } protected: - NiceMock databaseMock; - NiceMock mockStorage{databaseMock}; + NiceMock mockStorage; StorageAdapter storageAdapter{mockStorage}; Cache cache{storageAdapter}; typename Cache::MutexType &mockMutex = cache.mutex();