| 
									
										
										
										
											2015-06-01 18:51:55 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2016-01-15 14:55:33 +01:00
										 |  |  | ** Copyright (C) 2016 The Qt Company Ltd. | 
					
						
							|  |  |  | ** Contact: https://www.qt.io/licensing/
 | 
					
						
							| 
									
										
										
										
											2015-06-01 18:51:55 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | ** 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 | 
					
						
							| 
									
										
										
										
											2016-01-15 14:55:33 +01:00
										 |  |  | ** 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.
 | 
					
						
							| 
									
										
										
										
											2015-06-01 18:51:55 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2016-01-15 14:55:33 +01:00
										 |  |  | ** 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.
 | 
					
						
							| 
									
										
										
										
											2015-06-01 18:51:55 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | ****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-30 11:27:06 +01:00
										 |  |  | #include "googletest.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-27 23:48:03 +02:00
										 |  |  | #include <sqlitedatabase.h>
 | 
					
						
							| 
									
										
										
										
											2021-05-07 09:19:39 +02:00
										 |  |  | #include <sqlitelibraryinitializer.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-16 12:38:04 +02:00
										 |  |  | #include <sqliteglobal.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-31 10:14:22 +02:00
										 |  |  | #include <utils/launcherinterface.h>
 | 
					
						
							| 
									
										
										
										
											2021-09-17 16:32:50 +02:00
										 |  |  | #include <utils/singleton.h>
 | 
					
						
							| 
									
										
										
										
											2017-01-30 10:05:42 +01:00
										 |  |  | #include <utils/temporarydirectory.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-13 13:23:46 +01:00
										 |  |  | #include <QGuiApplication>
 | 
					
						
							| 
									
										
										
										
											2015-09-30 14:21:34 +02:00
										 |  |  | #include <QLoggingCategory>
 | 
					
						
							| 
									
										
										
										
											2021-08-31 10:14:22 +02:00
										 |  |  | #include <QScopeGuard>
 | 
					
						
							| 
									
										
										
										
											2015-06-01 18:51:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-16 16:04:54 +01:00
										 |  |  | #ifdef WITH_BENCHMARKS
 | 
					
						
							| 
									
										
										
										
											2017-10-24 19:38:47 +02:00
										 |  |  | #include <benchmark/benchmark.h>
 | 
					
						
							| 
									
										
										
										
											2016-02-16 16:04:54 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-10 12:12:15 +01:00
										 |  |  | class Environment : public testing::Environment | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     void SetUp() override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const QString temporayDirectoryPath = QDir::tempPath() + "/QtCreator-UnitTests-XXXXXX"; | 
					
						
							|  |  |  |         Utils::TemporaryDirectory::setMasterTemporaryDirectory(temporayDirectoryPath); | 
					
						
							|  |  |  |         qputenv("TMPDIR", Utils::TemporaryDirectory::masterDirectoryPath().toUtf8()); | 
					
						
							|  |  |  |         qputenv("TEMP", Utils::TemporaryDirectory::masterDirectoryPath().toUtf8()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void TearDown() override {} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-01 18:51:55 +02:00
										 |  |  | int main(int argc, char *argv[]) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2021-05-07 09:19:39 +02:00
										 |  |  |     Sqlite::LibraryInitializer::initialize(); | 
					
						
							| 
									
										
										
										
											2020-05-27 23:48:03 +02:00
										 |  |  |     Sqlite::Database::activateLogging(); | 
					
						
							| 
									
										
										
										
											2017-02-20 17:14:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-13 13:23:46 +01:00
										 |  |  |     QGuiApplication application(argc, argv); | 
					
						
							| 
									
										
										
										
											2021-09-17 16:32:50 +02:00
										 |  |  |     Utils::LauncherInterface::setPathToLauncher(qApp->applicationDirPath() + '/' | 
					
						
							|  |  |  |                                                 + QLatin1String(TEST_RELATIVE_LIBEXEC_PATH)); | 
					
						
							| 
									
										
										
										
											2016-02-16 16:04:54 +01:00
										 |  |  |     testing::InitGoogleTest(&argc, argv); | 
					
						
							|  |  |  | #ifdef WITH_BENCHMARKS
 | 
					
						
							|  |  |  |     benchmark::Initialize(&argc, argv); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-10 15:39:36 +01:00
										 |  |  |     auto environment = std::make_unique<Environment>(); | 
					
						
							|  |  |  |     testing::AddGlobalTestEnvironment(environment.release()); | 
					
						
							| 
									
										
										
										
											2020-11-10 12:12:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-16 16:04:54 +01:00
										 |  |  |     int testsHaveErrors = RUN_ALL_TESTS(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-17 16:32:50 +02:00
										 |  |  |     Utils::Singleton::deleteAll(); | 
					
						
							| 
									
										
										
										
											2016-02-16 16:04:54 +01:00
										 |  |  | #ifdef WITH_BENCHMARKS
 | 
					
						
							|  |  |  |     if (testsHaveErrors == 0  && application.arguments().contains(QStringLiteral("--with-benchmarks"))) | 
					
						
							|  |  |  |         benchmark::RunSpecifiedBenchmarks(); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return testsHaveErrors; | 
					
						
							| 
									
										
										
										
											2015-06-01 18:51:55 +02:00
										 |  |  | } |