| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | /****************************************************************************
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Copyright (C) 2016 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"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-08 14:47:33 +02:00
										 |  |  | #include "mockfilepathcaching.h"
 | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | #include "mockpchmanagerclient.h"
 | 
					
						
							|  |  |  | #include "mockpchmanagernotifier.h"
 | 
					
						
							|  |  |  | #include "mockpchmanagerserver.h"
 | 
					
						
							| 
									
										
										
										
											2018-02-20 12:43:05 +01:00
										 |  |  | #include "mockprecompiledheaderstorage.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-27 17:52:44 +02:00
										 |  |  | #include "mockprogressmanager.h"
 | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  | #include "mockprojectpartsstorage.h"
 | 
					
						
							|  |  |  | #include "mocksqlitetransactionbackend.h"
 | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-17 12:44:52 +02:00
										 |  |  | #include <pchmanagerprojectupdater.h>
 | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 16:51:22 +02:00
										 |  |  | #include <clangindexingprojectsettings.h>
 | 
					
						
							|  |  |  | #include <clangindexingsettingsmanager.h>
 | 
					
						
							| 
									
										
										
										
											2018-01-22 14:21:01 +01:00
										 |  |  | #include <filepathcaching.h>
 | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | #include <pchmanagerclient.h>
 | 
					
						
							| 
									
										
										
										
											2018-02-20 12:43:05 +01:00
										 |  |  | #include <precompiledheaderstorage.h>
 | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | #include <precompiledheadersupdatedmessage.h>
 | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  | #include <projectpartsstorage.h>
 | 
					
						
							| 
									
										
										
										
											2018-01-22 14:21:01 +01:00
										 |  |  | #include <refactoringdatabaseinitializer.h>
 | 
					
						
							| 
									
										
										
										
											2018-08-06 19:14:00 +02:00
										 |  |  | #include <removegeneratedfilesmessage.h>
 | 
					
						
							| 
									
										
										
										
											2018-02-20 12:43:05 +01:00
										 |  |  | #include <removeprojectpartsmessage.h>
 | 
					
						
							| 
									
										
										
										
											2018-08-06 19:14:00 +02:00
										 |  |  | #include <updategeneratedfilesmessage.h>
 | 
					
						
							| 
									
										
										
										
											2018-02-20 12:43:05 +01:00
										 |  |  | #include <updateprojectpartsmessage.h>
 | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-27 10:32:52 +02:00
										 |  |  | #include <cpptools/compileroptionsbuilder.h>
 | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | #include <cpptools/projectpart.h>
 | 
					
						
							| 
									
										
										
										
											2019-04-07 20:46:06 +02:00
										 |  |  | #include <projectexplorer/project.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/projectexplorerconstants.h>
 | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-22 14:21:01 +01:00
										 |  |  | #include <utils/algorithm.h>
 | 
					
						
							| 
									
										
										
										
											2019-05-07 16:51:22 +02:00
										 |  |  | #include <utils/namevalueitem.h>
 | 
					
						
							| 
									
										
										
										
											2018-01-22 14:21:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | namespace { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using testing::_; | 
					
						
							| 
									
										
										
										
											2017-02-01 13:43:28 +01:00
										 |  |  | using testing::ElementsAre; | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | using testing::SizeIs; | 
					
						
							|  |  |  | using testing::NiceMock; | 
					
						
							|  |  |  | using testing::AnyNumber; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-08 12:48:46 +01:00
										 |  |  | using ClangBackEnd::CompilerMacro; | 
					
						
							| 
									
										
										
										
											2019-08-20 14:45:01 +02:00
										 |  |  | using ClangBackEnd::FilePath; | 
					
						
							| 
									
										
										
										
											2018-12-17 12:06:57 +01:00
										 |  |  | using ClangBackEnd::IncludeSearchPath; | 
					
						
							|  |  |  | using ClangBackEnd::IncludeSearchPathType; | 
					
						
							|  |  |  | using ClangBackEnd::ProjectPartContainer; | 
					
						
							| 
									
										
										
										
											2019-08-20 14:45:01 +02:00
										 |  |  | using ClangBackEnd::V2::FileContainer; | 
					
						
							| 
									
										
										
										
											2017-09-27 10:32:52 +02:00
										 |  |  | using CppTools::CompilerOptionsBuilder; | 
					
						
							| 
									
										
										
										
											2018-09-03 16:10:43 +02:00
										 |  |  | using ProjectExplorer::HeaderPath; | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | class ProjectUpdater : public testing::Test | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | protected: | 
					
						
							| 
									
										
										
										
											2018-01-22 14:21:01 +01:00
										 |  |  |     ClangBackEnd::FilePathId filePathId(Utils::SmallStringView path) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return filePathCache.filePathId(ClangBackEnd::FilePathView{path}); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ClangBackEnd::FilePathIds filePathIds(const Utils::PathStringVector &paths) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return filePathCache.filePathIds(Utils::transform(paths, [] (const Utils::PathString &path) { | 
					
						
							|  |  |  |             return ClangBackEnd::FilePathView(path); | 
					
						
							|  |  |  |         })); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void SetUp() override | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-06-17 14:34:37 +02:00
										 |  |  |         project.rootProjectDirectoryPath = Utils::FilePath::fromString("project"); | 
					
						
							| 
									
										
										
										
											2019-04-07 20:46:06 +02:00
										 |  |  |         projectPart.project = &project; | 
					
						
							| 
									
										
										
										
											2018-01-22 14:21:01 +01:00
										 |  |  |         projectPart.files.push_back(header1ProjectFile); | 
					
						
							|  |  |  |         projectPart.files.push_back(header2ProjectFile); | 
					
						
							|  |  |  |         projectPart.files.push_back(source1ProjectFile); | 
					
						
							|  |  |  |         projectPart.files.push_back(source2ProjectFile); | 
					
						
							| 
									
										
										
										
											2019-02-15 16:15:01 +01:00
										 |  |  |         projectPart.files.push_back(nonActiveProjectFile); | 
					
						
							| 
									
										
										
										
											2018-09-11 17:02:45 +02:00
										 |  |  |         projectPart.displayName = "projectb"; | 
					
						
							| 
									
										
										
										
											2019-05-07 16:51:22 +02:00
										 |  |  |         projectPart.projectMacros = {{"FOO", "2"}, {"BAR", "1"}, {"POO", "3"}}; | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  |         projectPartId = projectPartsStorage.fetchProjectPartId(Utils::SmallString{projectPart.id()}); | 
					
						
							| 
									
										
										
										
											2018-01-22 14:21:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-07 20:46:06 +02:00
										 |  |  |         projectPart2.project = &project; | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  |         projectPart2.files.push_back(header2ProjectFile); | 
					
						
							|  |  |  |         projectPart2.files.push_back(header1ProjectFile); | 
					
						
							|  |  |  |         projectPart2.files.push_back(source2ProjectFile); | 
					
						
							|  |  |  |         projectPart2.files.push_back(source1ProjectFile); | 
					
						
							| 
									
										
										
										
											2019-02-15 16:15:01 +01:00
										 |  |  |         projectPart2.files.push_back(nonActiveProjectFile); | 
					
						
							| 
									
										
										
										
											2018-09-11 17:02:45 +02:00
										 |  |  |         projectPart2.displayName = "projectaa"; | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  |         projectPart2.projectMacros = {{"BAR", "1"}, {"FOO", "2"}}; | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  |         projectPartId2 = projectPartsStorage.fetchProjectPartId(Utils::SmallString{projectPart2.id()}); | 
					
						
							| 
									
										
										
										
											2018-09-10 17:47:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-15 16:15:01 +01:00
										 |  |  |         nonBuildingProjectPart.files.push_back(cannotBuildSourceProjectFile); | 
					
						
							|  |  |  |         nonBuildingProjectPart.displayName = "nonbuilding"; | 
					
						
							|  |  |  |         nonBuildingProjectPart.selectedForBuilding = false; | 
					
						
							| 
									
										
										
										
											2018-02-08 12:48:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-15 16:15:01 +01:00
										 |  |  |         Utils::SmallStringVector arguments{ | 
					
						
							|  |  |  |             ClangPchManager::ProjectUpdater::toolChainArguments(&projectPart)}; | 
					
						
							|  |  |  |         Utils::SmallStringVector arguments2{ | 
					
						
							|  |  |  |             ClangPchManager::ProjectUpdater::toolChainArguments(&projectPart2)}; | 
					
						
							| 
									
										
										
										
											2018-01-22 14:21:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  |         expectedContainer = {projectPartId, | 
					
						
							| 
									
										
										
										
											2018-01-22 14:21:01 +01:00
										 |  |  |                              arguments.clone(), | 
					
						
							| 
									
										
										
										
											2018-02-06 19:03:14 +01:00
										 |  |  |                              Utils::clone(compilerMacros), | 
					
						
							| 
									
										
										
										
											2019-04-07 20:46:06 +02:00
										 |  |  |                              {{"project/.pre_includes", 1, ClangBackEnd::IncludeSearchPathType::System}, | 
					
						
							| 
									
										
										
										
											2020-08-24 10:46:58 +02:00
										 |  |  |                               {CLANG_INCLUDE_DIR, 2, ClangBackEnd::IncludeSearchPathType::BuiltIn}}, | 
					
						
							| 
									
										
										
										
											2018-02-08 12:48:46 +01:00
										 |  |  |                              {}, | 
					
						
							| 
									
										
										
										
											2018-01-22 14:21:01 +01:00
										 |  |  |                              {filePathId(headerPaths[1])}, | 
					
						
							| 
									
										
										
										
											2018-12-17 12:06:57 +01:00
										 |  |  |                              {filePathIds(sourcePaths)}, | 
					
						
							|  |  |  |                              Utils::Language::Cxx, | 
					
						
							|  |  |  |                              Utils::LanguageVersion::LatestCxx, | 
					
						
							|  |  |  |                              Utils::LanguageExtension::None}; | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  |         expectedContainer2 = {projectPartId2, | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  |                               arguments2.clone(), | 
					
						
							|  |  |  |                               Utils::clone(compilerMacros), | 
					
						
							| 
									
										
										
										
											2019-04-07 20:46:06 +02:00
										 |  |  |                               {{"project/.pre_includes", 1, ClangBackEnd::IncludeSearchPathType::System}, | 
					
						
							| 
									
										
										
										
											2020-08-24 10:46:58 +02:00
										 |  |  |                                {CLANG_INCLUDE_DIR, 2, ClangBackEnd::IncludeSearchPathType::BuiltIn}}, | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  |                               {}, | 
					
						
							|  |  |  |                               {filePathId(headerPaths[1])}, | 
					
						
							| 
									
										
										
										
											2018-12-17 12:06:57 +01:00
										 |  |  |                               {filePathIds(sourcePaths)}, | 
					
						
							|  |  |  |                               Utils::Language::Cxx, | 
					
						
							|  |  |  |                               Utils::LanguageVersion::LatestCxx, | 
					
						
							|  |  |  |                               Utils::LanguageExtension::None}; | 
					
						
							| 
									
										
										
										
											2019-05-07 16:51:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         auto settings = settingsManager.settings(&project); | 
					
						
							|  |  |  |         settings->saveMacros({{"POO", "3", Utils::NameValueItem::Unset}}); | 
					
						
							| 
									
										
										
										
											2018-01-22 14:21:01 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							| 
									
										
										
										
											2018-01-22 14:21:01 +01:00
										 |  |  |     Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory}; | 
					
						
							|  |  |  |     ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> initializer{database}; | 
					
						
							|  |  |  |     ClangBackEnd::FilePathCaching filePathCache{database}; | 
					
						
							| 
									
										
										
										
											2019-02-19 20:46:08 +01:00
										 |  |  |     NiceMock<MockProgressManager> mockPchCreationProgressManager; | 
					
						
							|  |  |  |     NiceMock<MockProgressManager> mockDependencyCreationProgressManager; | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  |     ClangBackEnd::ProjectPartsStorage<Sqlite::Database> projectPartsStorage{database}; | 
					
						
							| 
									
										
										
										
											2019-02-19 20:46:08 +01:00
										 |  |  |     ClangPchManager::PchManagerClient pchManagerClient{mockPchCreationProgressManager, | 
					
						
							|  |  |  |                                                        mockDependencyCreationProgressManager}; | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  |     MockPchManagerNotifier mockPchManagerNotifier{pchManagerClient}; | 
					
						
							|  |  |  |     NiceMock<MockPchManagerServer> mockPchManagerServer; | 
					
						
							| 
									
										
										
										
											2019-05-07 16:51:22 +02:00
										 |  |  |     ClangPchManager::ClangIndexingSettingsManager settingsManager; | 
					
						
							|  |  |  |     ClangPchManager::ProjectUpdater updater{mockPchManagerServer, | 
					
						
							|  |  |  |                                             filePathCache, | 
					
						
							|  |  |  |                                             projectPartsStorage, | 
					
						
							|  |  |  |                                             settingsManager}; | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  |     ClangBackEnd::ProjectPartId projectPartId; | 
					
						
							|  |  |  |     ClangBackEnd::ProjectPartId projectPartId2; | 
					
						
							| 
									
										
										
										
											2017-02-01 13:43:28 +01:00
										 |  |  |     Utils::PathStringVector headerPaths = {"/path/to/header1.h", "/path/to/header2.h"}; | 
					
						
							|  |  |  |     Utils::PathStringVector sourcePaths = {"/path/to/source1.cpp", "/path/to/source2.cpp"}; | 
					
						
							| 
									
										
										
										
											2018-11-21 20:11:07 +01:00
										 |  |  |     ClangBackEnd::CompilerMacros compilerMacros = {{"BAR", "1", 1}, {"FOO", "2", 2}}; | 
					
						
							| 
									
										
										
										
											2017-08-29 12:54:10 +02:00
										 |  |  |     CppTools::ProjectFile header1ProjectFile{QString(headerPaths[0]), CppTools::ProjectFile::CXXHeader}; | 
					
						
							|  |  |  |     CppTools::ProjectFile header2ProjectFile{QString(headerPaths[1]), CppTools::ProjectFile::CXXHeader}; | 
					
						
							|  |  |  |     CppTools::ProjectFile source1ProjectFile{QString(sourcePaths[0]), CppTools::ProjectFile::CXXSource}; | 
					
						
							| 
									
										
										
										
											2019-02-15 16:15:01 +01:00
										 |  |  |     CppTools::ProjectFile source2ProjectFile{QString(sourcePaths[1]), | 
					
						
							|  |  |  |                                              CppTools::ProjectFile::CXXSource}; | 
					
						
							|  |  |  |     CppTools::ProjectFile cannotBuildSourceProjectFile{QString("/cannot/build"), | 
					
						
							|  |  |  |                                                        CppTools::ProjectFile::CXXSource}; | 
					
						
							|  |  |  |     CppTools::ProjectFile nonActiveProjectFile{QString("/foo"), CppTools::ProjectFile::CXXSource, false}; | 
					
						
							| 
									
										
										
										
											2019-04-07 20:46:06 +02:00
										 |  |  |     ProjectExplorer::Project project; | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  |     CppTools::ProjectPart projectPart; | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  |     CppTools::ProjectPart projectPart2; | 
					
						
							| 
									
										
										
										
											2019-02-15 16:15:01 +01:00
										 |  |  |     CppTools::ProjectPart nonBuildingProjectPart; | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  |     ProjectPartContainer expectedContainer; | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  |     ProjectPartContainer expectedContainer2; | 
					
						
							| 
									
										
										
										
											2019-08-20 14:45:01 +02:00
										 |  |  |     FileContainer generatedFile{{"/path/to", "header1.h"}, | 
					
						
							|  |  |  |                                 filePathCache.filePathId(FilePath{"/path/to", "header1.h"}), | 
					
						
							|  |  |  |                                 "content", | 
					
						
							|  |  |  |                                 {}}; | 
					
						
							|  |  |  |     FileContainer generatedFile2{{"/path/to2", "header1.h"}, | 
					
						
							|  |  |  |                                  filePathCache.filePathId(FilePath{"/path/to2", "header1.h"}), | 
					
						
							|  |  |  |                                  "content", | 
					
						
							|  |  |  |                                  {}}; | 
					
						
							|  |  |  |     FileContainer generatedFile3{{"/path/to", "header2.h"}, | 
					
						
							|  |  |  |                                  filePathCache.filePathId(FilePath{"/path/to", "header2.h"}), | 
					
						
							|  |  |  |                                  "content", | 
					
						
							|  |  |  |                                  {}}; | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-20 12:43:05 +01:00
										 |  |  | TEST_F(ProjectUpdater, CallUpdateProjectParts) | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  |     std::vector<CppTools::ProjectPart*> projectParts = {&projectPart2, &projectPart}; | 
					
						
							| 
									
										
										
										
											2018-12-17 12:06:57 +01:00
										 |  |  |     ClangBackEnd::UpdateProjectPartsMessage message{ | 
					
						
							|  |  |  |         {expectedContainer.clone(), expectedContainer2.clone()}, {"toolChainArgument"}}; | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  |     updater.updateGeneratedFiles({generatedFile}); | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-20 12:43:05 +01:00
										 |  |  |     EXPECT_CALL(mockPchManagerServer, updateProjectParts(message)); | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-17 12:06:57 +01:00
										 |  |  |     updater.updateProjectParts(projectParts, {"toolChainArgument"}); | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  | TEST_F(ProjectUpdater, CallUpdateGeneratedFilesWithSortedEntries) | 
					
						
							| 
									
										
										
										
											2018-08-06 19:14:00 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  |     ClangBackEnd::UpdateGeneratedFilesMessage message{{generatedFile, generatedFile3, generatedFile2}}; | 
					
						
							| 
									
										
										
										
											2018-08-06 19:14:00 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     EXPECT_CALL(mockPchManagerServer, updateGeneratedFiles(message)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  |     updater.updateGeneratedFiles({generatedFile2, generatedFile3, generatedFile}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ProjectUpdater, GeneratedFilesAddedAreSorted) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     updater.updateGeneratedFiles({generatedFile2, generatedFile3, generatedFile}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(updater.generatedFiles().fileContainers(), | 
					
						
							|  |  |  |                 ElementsAre(generatedFile, generatedFile3, generatedFile2)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ProjectUpdater, GeneratedFilesAddedToExcludePaths) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     updater.updateGeneratedFiles({generatedFile2, generatedFile3, generatedFile}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(updater.excludedPaths(), ElementsAre(generatedFile.filePath, | 
					
						
							|  |  |  |                                                      generatedFile3.filePath, | 
					
						
							|  |  |  |                                                      generatedFile2.filePath)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ProjectUpdater, CallRemoveGeneratedFiles) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ClangBackEnd::RemoveGeneratedFilesMessage message{{{"/path/to/header1.h"}}}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     EXPECT_CALL(mockPchManagerServer, removeGeneratedFiles(message)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     updater.removeGeneratedFiles({{"/path/to/header1.h"}}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ProjectUpdater, GeneratedFilesRemovedFromExcludePaths) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     updater.updateGeneratedFiles({generatedFile}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     updater.removeGeneratedFiles({generatedFile.filePath}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(updater.excludedPaths(), IsEmpty()); | 
					
						
							| 
									
										
										
										
											2018-08-06 19:14:00 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-20 12:43:05 +01:00
										 |  |  | TEST_F(ProjectUpdater, CallRemoveProjectParts) | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-20 12:43:05 +01:00
										 |  |  |     ClangBackEnd::RemoveProjectPartsMessage message{{projectPartId, projectPartId2}}; | 
					
						
							| 
									
										
										
										
											2017-08-17 12:44:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-20 12:43:05 +01:00
										 |  |  |     EXPECT_CALL(mockPchManagerServer, removeProjectParts(message)); | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  |     updater.removeProjectParts({projectPartId2, projectPartId}); | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-17 12:44:52 +02:00
										 |  |  | TEST_F(ProjectUpdater, CallPrecompiledHeaderRemovedInPchManagerProjectUpdater) | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-07 16:51:22 +02:00
										 |  |  |     ClangPchManager::ClangIndexingSettingsManager settingManager; | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  |     ClangPchManager::PchManagerProjectUpdater pchUpdater{mockPchManagerServer, | 
					
						
							|  |  |  |                                                          pchManagerClient, | 
					
						
							|  |  |  |                                                          filePathCache, | 
					
						
							| 
									
										
										
										
											2019-05-07 16:51:22 +02:00
										 |  |  |                                                          projectPartsStorage, | 
					
						
							|  |  |  |                                                          settingManager}; | 
					
						
							| 
									
										
										
										
											2018-02-20 12:43:05 +01:00
										 |  |  |     ClangBackEnd::RemoveProjectPartsMessage message{{projectPartId, projectPartId2}}; | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  |     EXPECT_CALL(mockPchManagerNotifier, precompiledHeaderRemoved(projectPartId)); | 
					
						
							|  |  |  |     EXPECT_CALL(mockPchManagerNotifier, precompiledHeaderRemoved(projectPartId2)); | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  |     pchUpdater.removeProjectParts({projectPartId, projectPartId2}); | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ProjectUpdater, ConvertProjectPartToProjectPartContainer) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-02-01 13:43:28 +01:00
										 |  |  |     updater.setExcludedPaths({"/path/to/header1.h"}); | 
					
						
							| 
									
										
										
										
											2019-08-20 14:45:01 +02:00
										 |  |  |     updater.fetchProjectPartIds({&projectPart}); | 
					
						
							| 
									
										
										
										
											2017-02-01 13:43:28 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  |     auto container = updater.toProjectPartContainer(&projectPart); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(container, expectedContainer); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ProjectUpdater, ConvertProjectPartToProjectPartContainersHaveSameSizeLikeProjectParts) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-08-20 14:45:01 +02:00
										 |  |  |     updater.fetchProjectPartIds({&projectPart, &nonBuildingProjectPart}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-15 16:15:01 +01:00
										 |  |  |     auto containers = updater.toProjectPartContainers( | 
					
						
							|  |  |  |         {&projectPart, &projectPart, &nonBuildingProjectPart}); | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(containers, SizeIs(2)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-20 14:45:01 +02:00
										 |  |  | TEST_F(ProjectUpdater, ProjectPartIdsPrefetchingInsideTransaction) | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     InSequence s; | 
					
						
							|  |  |  |     CppTools::ProjectPart projectPart; | 
					
						
							| 
									
										
										
										
											2019-04-07 20:46:06 +02:00
										 |  |  |     projectPart.project = &project; | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  |     projectPart.displayName = "project"; | 
					
						
							|  |  |  |     Utils::SmallString projectPartName = projectPart.id(); | 
					
						
							| 
									
										
										
										
											2019-08-20 14:45:01 +02:00
										 |  |  |     NiceMock<MockSqliteTransactionBackend> mockSqliteTransactionBackend; | 
					
						
							|  |  |  |     NiceMock<MockProjectPartsStorage> mockProjectPartsStorage; | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  |     ON_CALL(mockProjectPartsStorage, transactionBackend()) | 
					
						
							|  |  |  |         .WillByDefault(ReturnRef(mockSqliteTransactionBackend)); | 
					
						
							| 
									
										
										
										
											2019-05-07 16:51:22 +02:00
										 |  |  |     ClangPchManager::ClangIndexingSettingsManager settingsManager; | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  |     ClangPchManager::ProjectUpdater updater{mockPchManagerServer, | 
					
						
							|  |  |  |                                             filePathCache, | 
					
						
							| 
									
										
										
										
											2019-05-07 16:51:22 +02:00
										 |  |  |                                             mockProjectPartsStorage, | 
					
						
							|  |  |  |                                             settingsManager}; | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-20 14:45:01 +02:00
										 |  |  |     EXPECT_CALL(mockSqliteTransactionBackend, deferredBegin()); | 
					
						
							| 
									
										
										
										
											2019-08-26 16:33:26 +02:00
										 |  |  |     EXPECT_CALL(mockProjectPartsStorage, fetchProjectPartIdUnguarded(Eq(projectPartName))).WillOnce(Return(1)); | 
					
						
							| 
									
										
										
										
											2019-08-20 14:45:01 +02:00
										 |  |  |     EXPECT_CALL(mockSqliteTransactionBackend, commit()); | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-20 14:45:01 +02:00
										 |  |  |     updater.fetchProjectPartIds({&projectPart}); | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  | TEST_F(ProjectUpdater, CreateSortedExcludedPaths) | 
					
						
							| 
									
										
										
										
											2017-02-01 13:43:28 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  |     auto excludedPaths = updater.createExcludedPaths({generatedFile2, generatedFile3, generatedFile}); | 
					
						
							| 
									
										
										
										
											2017-02-01 13:43:28 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  |     ASSERT_THAT(excludedPaths, ElementsAre(ClangBackEnd::FilePath{"/path/to/header1.h"}, | 
					
						
							|  |  |  |                                            ClangBackEnd::FilePath{"/path/to/header2.h"}, | 
					
						
							|  |  |  |                                            ClangBackEnd::FilePath{"/path/to2/header1.h"})); | 
					
						
							| 
									
										
										
										
											2017-02-01 13:43:28 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  | TEST_F(ProjectUpdater, CreateSortedCompilerMacros) | 
					
						
							| 
									
										
										
										
											2018-02-08 12:48:46 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-07 16:51:22 +02:00
										 |  |  |     auto paths = updater.createCompilerMacros({{"DEFINE", "1"}, {"FOO", "2"}, {"BAR", "1"}}, {}); | 
					
						
							| 
									
										
										
										
											2018-02-08 12:48:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-21 20:11:07 +01:00
										 |  |  |     ASSERT_THAT(paths, ElementsAre(CompilerMacro{"BAR", "1", 1}, | 
					
						
							|  |  |  |                                    CompilerMacro{"FOO", "2", 2}, | 
					
						
							|  |  |  |                                    CompilerMacro{"DEFINE", "1", 3})); | 
					
						
							| 
									
										
										
										
											2018-02-08 12:48:46 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-06 15:58:39 +02:00
										 |  |  | TEST_F(ProjectUpdater, FilterCompilerMacros) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-07 16:51:22 +02:00
										 |  |  |     auto paths = updater.createCompilerMacros({{"DEFINE", "1"}, | 
					
						
							|  |  |  |                                                {"QT_TESTCASE_BUILDDIR", "2"}, | 
					
						
							|  |  |  |                                                {"BAR", "1"}}, | 
					
						
							|  |  |  |                                               {}); | 
					
						
							| 
									
										
										
										
											2019-05-06 15:58:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(paths, ElementsAre(CompilerMacro{"BAR", "1", 1}, CompilerMacro{"DEFINE", "1", 3})); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 16:51:22 +02:00
										 |  |  | TEST_F(ProjectUpdater, FilterSettingsMacros) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto paths = updater.createCompilerMacros({{"YI", "1"}, {"SAN", "3"}, {"SE", "4"}, {"WU", "5"}}, | 
					
						
							|  |  |  |                                               {{"SE", "44", Utils::NameValueItem::Unset}, | 
					
						
							| 
									
										
										
										
											2019-07-24 11:14:37 +02:00
										 |  |  |                                                {"ER", "2", Utils::NameValueItem::SetEnabled}, | 
					
						
							| 
									
										
										
										
											2019-05-07 16:51:22 +02:00
										 |  |  |                                                {"WU", "5", Utils::NameValueItem::Unset}}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(paths, | 
					
						
							|  |  |  |                 ElementsAre(CompilerMacro{"ER", "2", 3}, | 
					
						
							|  |  |  |                             CompilerMacro{"SE", "4", 3}, | 
					
						
							|  |  |  |                             CompilerMacro{"YI", "1", 1}, | 
					
						
							|  |  |  |                             CompilerMacro{"SAN", "3", 2})); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 19:01:01 +02:00
										 |  |  | TEST_F(ProjectUpdater, CreateSortedIncludeSearchPaths) | 
					
						
							| 
									
										
										
										
											2018-02-08 12:48:46 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-12-17 12:06:57 +01:00
										 |  |  |     CppTools::ProjectPart projectPart; | 
					
						
							| 
									
										
										
										
											2019-04-07 20:46:06 +02:00
										 |  |  |     projectPart.project = &project; | 
					
						
							| 
									
										
										
										
											2018-09-13 11:44:43 +02:00
										 |  |  |     ProjectExplorer::HeaderPath includePath{"/to/path1", ProjectExplorer::HeaderPathType::User}; | 
					
						
							|  |  |  |     ProjectExplorer::HeaderPath includePath2{"/to/path2", ProjectExplorer::HeaderPathType::User}; | 
					
						
							| 
									
										
										
										
											2018-09-03 16:10:43 +02:00
										 |  |  |     ProjectExplorer::HeaderPath invalidPath; | 
					
						
							| 
									
										
										
										
											2018-12-17 12:06:57 +01:00
										 |  |  |     ProjectExplorer::HeaderPath frameworkPath{"/framework/path", | 
					
						
							|  |  |  |                                               ProjectExplorer::HeaderPathType::Framework}; | 
					
						
							|  |  |  |     ProjectExplorer::HeaderPath builtInPath{"/builtin/path", ProjectExplorer::HeaderPathType::BuiltIn}; | 
					
						
							|  |  |  |     ProjectExplorer::HeaderPath systemPath{"/system/path", ProjectExplorer::HeaderPathType::System}; | 
					
						
							|  |  |  |     projectPart.headerPaths = { | 
					
						
							|  |  |  |         systemPath, builtInPath, frameworkPath, includePath2, includePath, invalidPath}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto paths = updater.createIncludeSearchPaths(projectPart); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-07 20:46:06 +02:00
										 |  |  |     ASSERT_THAT( | 
					
						
							|  |  |  |         paths.system, | 
					
						
							|  |  |  |         ElementsAre(Eq(IncludeSearchPath{systemPath.path, 2, IncludeSearchPathType::System}), | 
					
						
							|  |  |  |                     Eq(IncludeSearchPath{builtInPath.path, 5, IncludeSearchPathType::BuiltIn}), | 
					
						
							|  |  |  |                     Eq(IncludeSearchPath{frameworkPath.path, 3, IncludeSearchPathType::Framework}), | 
					
						
							|  |  |  |                     Eq(IncludeSearchPath{"project/.pre_includes", 1, IncludeSearchPathType::System}), | 
					
						
							| 
									
										
										
										
											2020-08-24 10:46:58 +02:00
										 |  |  |                     Eq(IncludeSearchPath{CLANG_INCLUDE_DIR, | 
					
						
							| 
									
										
										
										
											2019-04-07 20:46:06 +02:00
										 |  |  |                                          4, | 
					
						
							|  |  |  |                                          ClangBackEnd::IncludeSearchPathType::BuiltIn}))); | 
					
						
							| 
									
										
										
										
											2018-12-17 12:06:57 +01:00
										 |  |  |     ASSERT_THAT(paths.project, | 
					
						
							|  |  |  |                 ElementsAre(Eq(IncludeSearchPath{includePath.path, 2, IncludeSearchPathType::User}), | 
					
						
							|  |  |  |                             Eq(IncludeSearchPath{includePath2.path, 1, IncludeSearchPathType::User}))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ProjectUpdater, ToolChainArguments) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     projectPart.toolChainTargetTriple = "target"; | 
					
						
							|  |  |  |     projectPart.extraCodeModelFlags.push_back("extraflags"); | 
					
						
							|  |  |  |     projectPart.compilerFlags.push_back("-fPIC"); | 
					
						
							|  |  |  |     projectPart.projectConfigFile = "config.h"; | 
					
						
							| 
									
										
										
										
											2018-02-08 12:48:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-17 12:06:57 +01:00
										 |  |  |     auto arguments = updater.toolChainArguments(&projectPart); | 
					
						
							| 
									
										
										
										
											2018-02-08 12:48:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-17 12:06:57 +01:00
										 |  |  |     ASSERT_THAT(arguments, | 
					
						
							| 
									
										
										
										
											2019-04-04 15:50:11 +02:00
										 |  |  |                 ElementsAre(QString{"-m32"}, | 
					
						
							|  |  |  |                             QString{"extraflags"}, | 
					
						
							|  |  |  |                             QString{"-include"}, | 
					
						
							|  |  |  |                             QString{"config.h"})); | 
					
						
							| 
									
										
										
										
											2018-12-17 12:06:57 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ProjectUpdater, ToolChainArgumentsMSVC) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     projectPart.toolChainTargetTriple = "target"; | 
					
						
							|  |  |  |     projectPart.extraCodeModelFlags.push_back("extraflags"); | 
					
						
							|  |  |  |     projectPart.toolchainType = ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID; | 
					
						
							|  |  |  |     projectPart.isMsvc2015Toolchain = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto arguments = updater.toolChainArguments(&projectPart); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(arguments, | 
					
						
							| 
									
										
										
										
											2019-04-04 15:50:11 +02:00
										 |  |  |                 ElementsAre(QString{"-m32"}, | 
					
						
							|  |  |  |                             QString{"extraflags"}, | 
					
						
							|  |  |  |                             QString{"-U__clang__"}, | 
					
						
							|  |  |  |                             QString{"-U__clang_major__"}, | 
					
						
							|  |  |  |                             QString{"-U__clang_minor__"}, | 
					
						
							|  |  |  |                             QString{"-U__clang_patchlevel__"}, | 
					
						
							|  |  |  |                             QString{"-U__clang_version__"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_aggregate_bases"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_aggregate_nsdmi"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_alias_templates"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_aligned_new"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_attributes"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_binary_literals"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_capture_star_this"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_constexpr"}, | 
					
						
							| 
									
										
										
										
											2020-11-17 22:53:59 +01:00
										 |  |  |                             QString{"-U__cpp_constexpr_in_decltype"}, | 
					
						
							| 
									
										
										
										
											2019-04-04 15:50:11 +02:00
										 |  |  |                             QString{"-U__cpp_decltype"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_decltype_auto"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_deduction_guides"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_delegating_constructors"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_digit_separators"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_enumerator_attributes"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_exceptions"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_fold_expressions"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_generic_lambdas"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_guaranteed_copy_elision"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_hex_float"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_if_constexpr"}, | 
					
						
							| 
									
										
										
										
											2019-04-04 14:50:10 +02:00
										 |  |  |                             QString{"-U__cpp_impl_destroying_delete"}, | 
					
						
							| 
									
										
										
										
											2019-04-04 15:50:11 +02:00
										 |  |  |                             QString{"-U__cpp_inheriting_constructors"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_init_captures"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_initializer_lists"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_inline_variables"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_lambdas"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_namespace_attributes"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_nested_namespace_definitions"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_noexcept_function_type"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_nontype_template_args"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_nontype_template_parameter_auto"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_nsdmi"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_range_based_for"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_raw_strings"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_ref_qualifiers"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_return_type_deduction"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_rtti"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_rvalue_references"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_static_assert"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_structured_bindings"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_template_auto"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_threadsafe_static_init"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_unicode_characters"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_unicode_literals"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_user_defined_literals"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_variable_templates"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_variadic_templates"}, | 
					
						
							|  |  |  |                             QString{"-U__cpp_variadic_using"})); | 
					
						
							| 
									
										
										
										
											2018-02-08 12:48:46 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-01-22 14:21:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  | TEST_F(ProjectUpdater, FetchProjectPartName) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     updater.updateProjectParts({&projectPart}, {}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto projectPartName = updater.fetchProjectPartName(1); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-04 15:50:11 +02:00
										 |  |  |     ASSERT_THAT(projectPartName, Eq(QString{" projectb"})); | 
					
						
							| 
									
										
										
										
											2017-01-30 11:24:46 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-08 14:47:33 +02:00
										 |  |  | TEST_F(ProjectUpdater, AddProjectFilesToFilePathCache) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     NiceMock<MockFilePathCaching> mockFilePathCaching; | 
					
						
							|  |  |  |     ClangPchManager::ProjectUpdater updater{mockPchManagerServer, | 
					
						
							|  |  |  |                                             mockFilePathCaching, | 
					
						
							| 
									
										
										
										
											2019-08-20 14:45:01 +02:00
										 |  |  |                                             projectPartsStorage, | 
					
						
							|  |  |  |                                             settingsManager}; | 
					
						
							| 
									
										
										
										
											2019-08-08 14:47:33 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     EXPECT_CALL(mockFilePathCaching, | 
					
						
							|  |  |  |                 addFilePaths(UnorderedElementsAre(Eq(headerPaths[0]), | 
					
						
							|  |  |  |                                                   Eq(headerPaths[1]), | 
					
						
							|  |  |  |                                                   Eq(sourcePaths[0]), | 
					
						
							|  |  |  |                                                   Eq(sourcePaths[1])))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     updater.updateProjectParts({&projectPart}, {}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-20 14:45:01 +02:00
										 |  |  | TEST_F(ProjectUpdater, FillProjectPartIdCacheAtCreation) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     NiceMock<MockProjectPartsStorage> mockProjectPartsStorage; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     EXPECT_CALL(mockProjectPartsStorage, fetchAllProjectPartNamesAndIds()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ClangPchManager::ProjectUpdater updater{mockPchManagerServer, | 
					
						
							|  |  |  |                                             filePathCache, | 
					
						
							|  |  |  |                                             mockProjectPartsStorage, | 
					
						
							|  |  |  |                                             settingsManager}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ProjectUpdater, DontFetchProjectPartIdFromDatabaseIfItIsInCache) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     projectPart.files.clear(); | 
					
						
							|  |  |  |     NiceMock<MockSqliteTransactionBackend> mockSqliteTransactionBackend; | 
					
						
							|  |  |  |     NiceMock<MockProjectPartsStorage> mockProjectPartsStorage; | 
					
						
							|  |  |  |     ON_CALL(mockProjectPartsStorage, transactionBackend()) | 
					
						
							|  |  |  |         .WillByDefault(ReturnRef(mockSqliteTransactionBackend)); | 
					
						
							|  |  |  |     ON_CALL(mockProjectPartsStorage, fetchAllProjectPartNamesAndIds()) | 
					
						
							|  |  |  |         .WillByDefault(Return( | 
					
						
							|  |  |  |             ClangBackEnd::Internal::ProjectPartNameIds{{Utils::PathString(projectPart.id()), 55}})); | 
					
						
							|  |  |  |     ClangPchManager::ProjectUpdater updater{mockPchManagerServer, | 
					
						
							|  |  |  |                                             filePathCache, | 
					
						
							|  |  |  |                                             mockProjectPartsStorage, | 
					
						
							|  |  |  |                                             settingsManager}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     EXPECT_CALL(mockSqliteTransactionBackend, deferredBegin()).Times(0); | 
					
						
							|  |  |  |     EXPECT_CALL(mockProjectPartsStorage, fetchProjectPartId(_)).Times(0); | 
					
						
							|  |  |  |     EXPECT_CALL(mockProjectPartsStorage, fetchProjectPartIdUnguarded(_)).Times(0); | 
					
						
							|  |  |  |     EXPECT_CALL(mockSqliteTransactionBackend, commit()).Times(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     updater.updateProjectParts({&projectPart}, {}); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-03-13 15:09:30 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // namespace
 |