Merge remote-tracking branch 'upstream/master' into pr983-rebase-check

# Conflicts:
#	sources/dataBase/projectdatabase.cpp
#	tests/qttest/CMakeLists.txt
This commit is contained in:
ispyisail
2026-09-23 13:10:06 +12:00
59 changed files with 9070 additions and 641 deletions
-4
View File
@@ -25,10 +25,6 @@ message(". PROJECT_SOURCE_DIR :" ${PROJECT_SOURCE_DIR})
# Add sub directories
message(". Add sub directory catch")
add_subdirectory(catch)
message(". Add sub directory googletest")
add_subdirectory(googletest)
message(". Add sub directory googlemock")
add_subdirectory(googlemock)
message(". Add sub directory modal-quit-regression")
add_subdirectory(modal-quit-regression)
message(". Add sub directory qttest")
-67
View File
@@ -1,67 +0,0 @@
---
BasedOnStyle: LLVM
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveMacros: 'true'
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AlignEscapedNewlines: Right
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllArgumentsOnNextLine: 'false'
AllowAllConstructorInitializersOnNextLine: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'true'
AllowShortCaseLabelsOnASingleLine: 'true'
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: 'true'
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'true'
AlwaysBreakTemplateDeclarations: 'Yes'
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakAfterJavaFieldAnnotations: 'true'
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: 'false'
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
BreakStringLiterals: 'true'
ColumnLimit: '80'
CompactNamespaces: 'false'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
Cpp11BracedListStyle: 'true'
FixNamespaceComments: 'true'
IncludeBlocks: Regroup
IndentCaseLabels: 'false'
IndentPPDirectives: AfterHash
IndentWidth: '4'
JavaScriptWrapImports: 'true'
Language: Cpp
MaxEmptyLinesToKeep: '1'
NamespaceIndentation: All
PointerAlignment: Left
ReflowComments: 'true'
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'true'
SpaceAfterLogicalNot: 'true'
SpaceAfterTemplateKeyword: 'true'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCpp11BracedList: 'true'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'true'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: Cpp11
TabWidth: '4'
UseTab: Always
...
-73
View File
@@ -1,73 +0,0 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
-78
View File
@@ -1,78 +0,0 @@
# Copyright 2006 The QElectroTech Team
# This file is part of QElectroTech.
#
# QElectroTech is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# QElectroTech is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.5)
message("..___________________________________________________________________")
project(G_unitmocktests LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
SET(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
message(".. PROJECT_NAME :" ${PROJECT_NAME})
message(".. PROJECT_SOURCE_DIR :" ${PROJECT_SOURCE_DIR})
if(NOT DEFINED QET_DIR)
set(QET_DIR "../..")
message(".. QET_DIR is not set, assuming QET is ../..")
endif()
message(".. QET_DIR :" ${QET_DIR})
if(NOT DEFINED QET_COMPONENTS)
message(".. QET_COMPONENTS is not set !!! I set them up !!!")
include(../../cmake/qet_compilation_vars.cmake)
endif()
find_package(
Qt6
COMPONENTS
${QET_COMPONENTS}
REQUIRED)
Include(FetchContent)
FetchContent_Declare(
GTest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0)
set(INSTALL_GTEST OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(GTest)
include(../../cmake/fetch_kdeaddons.cmake)
include(../../cmake/fetch_singleapplication.cmake)
include(../../cmake/fetch_pugixml.cmake)
enable_testing()
add_executable(
${PROJECT_NAME}
tst_My_test.cpp
main.cpp
)
target_link_libraries(
${PROJECT_NAME}
PUBLIC
gmock gmock_main
PRIVATE
${KF_PRIVATE_LIBRARIES}
${QET_PRIVATE_LIBRARIES})
-15
View File
@@ -1,15 +0,0 @@
#include <QtGui/QGuiApplication>
#include <gmock/gmock.h>
int main(int argc, char** argv)
{
QGuiApplication app(argc, argv);
// disable the whole debug output (we want only the output from gtest)
// Debug::instance()->setDebugLevelLogFile(Debug::DebugLevel_t::Nothing);
// Debug::instance()->setDebugLevelStderr(Debug::DebugLevel_t::Nothing);
// init gtest and run all tests
::testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
}
-5
View File
@@ -1,5 +0,0 @@
#include "../../sources/borderproperties.h"
#include <gmock/gmock.h>
TEST(googlemocktest, sample_mock) { EXPECT_EQ(1, 1); }
-67
View File
@@ -1,67 +0,0 @@
---
BasedOnStyle: LLVM
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveMacros: 'true'
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AlignEscapedNewlines: Right
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllArgumentsOnNextLine: 'false'
AllowAllConstructorInitializersOnNextLine: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'true'
AllowShortCaseLabelsOnASingleLine: 'true'
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: 'true'
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'true'
AlwaysBreakTemplateDeclarations: 'Yes'
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakAfterJavaFieldAnnotations: 'true'
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: 'false'
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
BreakStringLiterals: 'true'
ColumnLimit: '80'
CompactNamespaces: 'false'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
Cpp11BracedListStyle: 'true'
FixNamespaceComments: 'true'
IncludeBlocks: Regroup
IndentCaseLabels: 'false'
IndentPPDirectives: AfterHash
IndentWidth: '4'
JavaScriptWrapImports: 'true'
Language: Cpp
MaxEmptyLinesToKeep: '1'
NamespaceIndentation: All
PointerAlignment: Left
ReflowComments: 'true'
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'true'
SpaceAfterLogicalNot: 'true'
SpaceAfterTemplateKeyword: 'true'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCpp11BracedList: 'true'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'true'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: Cpp11
TabWidth: '4'
UseTab: Always
...
-73
View File
@@ -1,73 +0,0 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
-77
View File
@@ -1,77 +0,0 @@
# Copyright 2006 The QElectroTech Team
# This file is part of QElectroTech.
#
# QElectroTech is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# QElectroTech is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.5)
message("..___________________________________________________________________")
project(G_unittests LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
SET(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
message(".. PROJECT_NAME :" ${PROJECT_NAME})
message(".. PROJECT_SOURCE_DIR :" ${PROJECT_SOURCE_DIR})
if(NOT DEFINED QET_DIR)
set(QET_DIR "../..")
message(".. QET_DIR is not set, assuming QET is ../..")
endif()
message(".. QET_DIR :" ${QET_DIR})
if(NOT DEFINED QET_COMPONENTS)
message(".. QET_COMPONENTS is not set !!! I set them up !!!")
include(../../cmake/qet_compilation_vars.cmake)
endif()
find_package(
Qt6
COMPONENTS
${QET_COMPONENTS}
REQUIRED)
Include(FetchContent)
FetchContent_Declare(
GTest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.17.0)
set(INSTALL_GTEST OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(GTest)
include(../../cmake/fetch_kdeaddons.cmake)
include(../../cmake/fetch_singleapplication.cmake)
include(../../cmake/fetch_pugixml.cmake)
enable_testing()
add_executable(
${PROJECT_NAME}
tst_My_test.cpp
main.cpp
)
target_link_libraries(
${PROJECT_NAME}
PUBLIC
gtest gtest_main
PRIVATE
${KF_PRIVATE_LIBRARIES}
${QET_PRIVATE_LIBRARIES})
-15
View File
@@ -1,15 +0,0 @@
#include <QtGui/QGuiApplication>
#include <gtest/gtest.h>
int main(int argc, char** argv)
{
QGuiApplication app(argc, argv);
// disable the whole debug output (we want only the output from gtest)
// Debug::instance()->setDebugLevelLogFile(Debug::DebugLevel_t::Nothing);
// Debug::instance()->setDebugLevelStderr(Debug::DebugLevel_t::Nothing);
// init gtest and run all tests
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
-5
View File
@@ -1,5 +0,0 @@
#include "../../sources/borderproperties.h"
#include <gtest/gtest.h>
TEST(googletest, sample_test) { EXPECT_EQ(1, 1); }
+14 -4
View File
@@ -159,6 +159,17 @@ add_test(NAME tst_sqlreadonly COMMAND tst_sqlreadonly)
target_include_directories(tst_sqlreadonly PRIVATE ${QET_DIR}/sources)
target_link_libraries(tst_sqlreadonly PRIVATE Qt::Test SQLite3::SQLite3)
# QetSettings::scriptingEnabled() -- whether QElectroTech may run a script.
# Compiles qetsettings.cpp alone: the setting is deliberately a plain
# QSettings read, so the test needs nothing else of QElectroTech.
add_executable(
tst_scriptingsetting
tst_scriptingsetting.cpp
${QET_DIR}/sources/utils/qetsettings.cpp)
add_test(NAME tst_scriptingsetting COMMAND tst_scriptingsetting)
target_include_directories(tst_scriptingsetting PRIVATE ${QET_DIR}/sources)
target_link_libraries(tst_scriptingsetting PRIVATE Qt::Test Qt::Gui)
# CrashHandler::formatInt() -- the async-signal-safe decimal formatter the
# signal handler uses for the "Signal: N" line of a crash dump. Compiles
# crashhandler.cpp and logring.cpp alongside; the handler deliberately
@@ -196,11 +207,10 @@ target_include_directories(tst_crashdumps PRIVATE
${QET_DIR}
${QET_DIR}/sources
${QET_DIR}/sources/NameList)
target_link_libraries(tst_crashdumps PRIVATE
Qt::Test Qt::Widgets Qt::Xml pugixml::pugixml)
if(Backtrace_FOUND)
target_link_libraries(tst_crashdumps PRIVATE
Qt::Test Qt::Widgets Qt::Xml pugixml::pugixml ${Backtrace_LIBRARIES})
else()
target_link_libraries(tst_crashdumps PRIVATE Qt::Test Qt::Widgets Qt::Xml)
target_link_libraries(tst_crashdumps PRIVATE ${Backtrace_LIBRARIES})
endif()
add_executable(
+146
View File
@@ -0,0 +1,146 @@
/*
Copyright 2006-2026 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
/*
QetSettings::scriptingEnabled() -- the switch that decides whether
QElectroTech will run JavaScript at all.
Its default is the whole point: a setting nobody has touched must read
as off, because that is the state every existing installation is in
after an upgrade. The other case worth pinning is the environment
override, which exists so a headless run has a way in without a dialog
-- and which must beat a stored "false", or a CI machine that once had
the box unticked can never script again.
This test owns its own QSettings scope (organization + application
name), so it cannot read or write the real configuration of whoever
runs it.
*/
#include "utils/qetsettings.h"
#include <QtTest>
#include <QSettings>
class TstScriptingSetting : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void init();
void defaultsToOff();
void storedValueIsHonoured();
void environmentOverridesAStoredFalse();
void environmentIsReportedSeparately();
void writingDoesNotDependOnReading();
private:
void clearStoredValue();
};
void TstScriptingSetting::initTestCase()
{
// A scope of this test's own: whatever this writes must not land in
// the configuration of the account running the suite.
QCoreApplication::setOrganizationName(
QStringLiteral("QElectroTech-tst_scriptingsetting"));
QCoreApplication::setApplicationName(
QStringLiteral("tst_scriptingsetting"));
QSettings settings;
settings.clear();
}
void TstScriptingSetting::clearStoredValue()
{
QSettings settings;
settings.remove(QStringLiteral("scripting/enabled"));
settings.sync();
}
void TstScriptingSetting::init()
{
clearStoredValue();
qunsetenv("QET_ENABLE_SCRIPTING");
}
void TstScriptingSetting::defaultsToOff()
{
QVERIFY2(!QetSettings::scriptingEnabled(),
"an untouched installation must not run scripts");
}
void TstScriptingSetting::storedValueIsHonoured()
{
QetSettings::setScriptingEnabled(true);
QVERIFY(QetSettings::scriptingEnabled());
QetSettings::setScriptingEnabled(false);
QVERIFY(!QetSettings::scriptingEnabled());
}
void TstScriptingSetting::environmentOverridesAStoredFalse()
{
// The headless case: no dialog to tick, and a stored false that must
// not be able to lock a CI job out of --run forever.
QetSettings::setScriptingEnabled(false);
qputenv("QET_ENABLE_SCRIPTING", "1");
QVERIFY(QetSettings::scriptingEnabled());
// Only "1" counts. An empty or accidental value is not consent.
for (const QByteArray &value : {QByteArray(""), QByteArray("0"),
QByteArray("true"), QByteArray("yes")}) {
qputenv("QET_ENABLE_SCRIPTING", value);
QVERIFY2(!QetSettings::scriptingEnabled(),
qPrintable(QStringLiteral("accepted QET_ENABLE_SCRIPTING=%1")
.arg(QString::fromUtf8(value))));
}
}
void TstScriptingSetting::environmentIsReportedSeparately()
{
// The configuration dialog asks this to explain why its checkbox is
// disabled, so it must answer about the environment alone and not be
// confused by the stored value.
QetSettings::setScriptingEnabled(true);
QVERIFY(!QetSettings::scriptingForcedByEnvironment());
qputenv("QET_ENABLE_SCRIPTING", "1");
QVERIFY(QetSettings::scriptingForcedByEnvironment());
}
void TstScriptingSetting::writingDoesNotDependOnReading()
{
// While the environment forces scripting on, scriptingEnabled() says
// true whatever is stored -- so read the stored value directly to be
// sure a write still lands. The configuration dialog relies on this:
// it skips the write in that state on purpose, and would be silently
// wrong if setScriptingEnabled() were a no-op instead.
qputenv("QET_ENABLE_SCRIPTING", "1");
QetSettings::setScriptingEnabled(false);
QSettings settings;
QCOMPARE(settings.value(QStringLiteral("scripting/enabled")).toBool(), false);
QetSettings::setScriptingEnabled(true);
QSettings other;
QCOMPARE(other.value(QStringLiteral("scripting/enabled")).toBool(), true);
}
QTEST_MAIN(TstScriptingSetting)
#include "tst_scriptingsetting.moc"