This repository was archived by the owner on Oct 20, 2026. It is now read-only.
Repository navigation
fix: preferences changed utc #85
Merged
august-alt
merged 3 commits into
august-alt:master
from
nailatik:fix/preferences-changed-utc
Aug 24, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| add_subdirectory(common/basemodelbuilder) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,2 @@ | ||
| find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets Test REQUIRED) | ||
|
|
||
| find_package(XercesC REQUIRED) | ||
|
|
||
| set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
|
|
||
| set(SOURCES | ||
| preferencesdialogtest.cpp | ||
| ../../../../../src/plugins/preferences/shortcuts/shortcutswidget.cpp | ||
| ../../../../../src/plugins/preferences/shortcuts/shortcutsschema.cpp | ||
| ../../../../../src/plugins/preferences/shortcuts/modelbuilder.cpp | ||
| ) | ||
|
|
||
| set(UI_FORMS | ||
| ../../../../../src/plugins/preferences/common/preferencesdialog.ui | ||
| ../../../../../src/plugins/preferences/shortcuts/shortcutswidget.ui | ||
| ) | ||
|
|
||
| set(MOC_HEADERS | ||
| preferencesdialogtest.h | ||
| ../../../../../src/plugins/preferences/common/preferencesdialog.h | ||
| ../../../../../src/plugins/preferences/shortcuts/shortcutswidget.h | ||
| ) | ||
|
|
||
| qt_wrap_ui(UI_SOURCES ${UI_FORMS}) | ||
| qt_wrap_cpp(MOC_SOURCES ${MOC_HEADERS}) | ||
|
|
||
| add_executable(preferencesdialogtest ${SOURCES} ${MOC_SOURCES} ${UI_SOURCES}) | ||
| target_link_libraries(preferencesdialogtest ${GPUI_LIBRARIES} preferences-common Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Test XercesC::XercesC) | ||
| add_gpui_test(plugins.preferencesdialogtest preferencesdialogtest) | ||
| add_subdirectory(basemodelbuilder) | ||
| add_subdirectory(preferencesdialog) |
8 changes: 8 additions & 0 deletions
8
tests/auto/plugins/preferences/common/basemodelbuilder/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Test REQUIRED) | ||
|
|
||
| qt_wrap_cpp(MOC_SOURCES basemodelbuildertest.h) | ||
|
|
||
| add_executable(basemodelbuildertest basemodelbuildertest.cpp ${MOC_SOURCES}) | ||
| target_include_directories(basemodelbuildertest PRIVATE ${CMAKE_SOURCE_DIR}/src/plugins/preferences/common) | ||
| target_link_libraries(basemodelbuildertest preferences_static Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Test) | ||
| add_gpui_test(plugins.basemodelbuildertest basemodelbuildertest) |
129 changes: 129 additions & 0 deletions
129
tests/auto/plugins/preferences/common/basemodelbuilder/basemodelbuildertest.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| /*********************************************************************************************************************** | ||
| ** | ||
| ** Copyright (C) 2026 BaseALT Ltd. <org@basealt.ru> | ||
| ** | ||
| ** This program 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. | ||
| ** | ||
| ** This program 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 this program; if not, write to the Free Software | ||
| ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| ** | ||
| ***********************************************************************************************************************/ | ||
|
|
||
| #include "basemodelbuildertest.h" | ||
|
|
||
| #include "basemodelbuilder.h" | ||
|
|
||
| #include <string> | ||
|
|
||
| #include <QtGlobal> | ||
| #include <QtTest> | ||
| #include <QTimeZone> | ||
|
|
||
| #ifdef Q_OS_UNIX | ||
| # include <time.h> | ||
| #endif | ||
|
|
||
| namespace { | ||
| const QString timestampFormat = "yyyy-MM-dd hh:mm:ss"; | ||
|
|
||
| class TestModelBuilder : public preferences::BaseModelBuilder | ||
| { | ||
| public: | ||
| using BaseModelBuilder::createDateOfChange; | ||
| using BaseModelBuilder::createRootElement; | ||
| }; | ||
|
|
||
| struct TestRootElement | ||
| { | ||
| TestRootElement(const std::string &guidValue, const std::string &changedValue, | ||
| const std::string &descriptionValue) | ||
| : guid(guidValue), changed(changedValue), description(descriptionValue) | ||
| { | ||
| } | ||
|
|
||
| std::string guid; | ||
| std::string changed; | ||
| std::string description; | ||
| }; | ||
|
|
||
| void updateSystemTimeZone() | ||
| { | ||
| #ifdef Q_OS_UNIX | ||
| tzset(); | ||
| #endif | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| namespace tests { | ||
| void BaseModelBuilderTest::initTestCase() | ||
| { | ||
| originalTimeZone = qgetenv("TZ"); | ||
| hadOriginalTimeZone = qEnvironmentVariableIsSet("TZ"); | ||
|
|
||
| QVERIFY(qputenv("TZ", "Europe/Saratov")); | ||
| updateSystemTimeZone(); | ||
|
|
||
| QVERIFY(QDateTime::currentDateTime().offsetFromUtc() != 0); | ||
| } | ||
|
|
||
| void BaseModelBuilderTest::cleanupTestCase() | ||
| { | ||
| if (hadOriginalTimeZone) { | ||
| qputenv("TZ", originalTimeZone); | ||
| } else { | ||
| qunsetenv("TZ"); | ||
| } | ||
| updateSystemTimeZone(); | ||
| } | ||
|
|
||
| void BaseModelBuilderTest::createDateOfChangeUsesUtc() | ||
| { | ||
| TestModelBuilder builder; | ||
|
|
||
| const QDateTime before = QDateTime::currentDateTimeUtc(); | ||
| const QString timestamp = QString::fromStdString(builder.createDateOfChange()); | ||
| const QDateTime after = QDateTime::currentDateTimeUtc(); | ||
|
|
||
| verifyUtcTimestamp(timestamp, before, after); | ||
| } | ||
|
|
||
| void BaseModelBuilderTest::createRootElementUsesUtc() | ||
| { | ||
| TestModelBuilder builder; | ||
|
|
||
| const QDateTime before = QDateTime::currentDateTimeUtc(); | ||
| const TestRootElement root = builder.createRootElement<TestRootElement>("test-guid"); | ||
| const QDateTime after = QDateTime::currentDateTimeUtc(); | ||
|
|
||
| QCOMPARE(QString::fromStdString(root.guid), QString("test-guid")); | ||
| QCOMPARE(QString::fromStdString(root.description), QString()); | ||
| verifyUtcTimestamp(QString::fromStdString(root.changed), before, after); | ||
| } | ||
|
|
||
| void BaseModelBuilderTest::verifyUtcTimestamp(const QString ×tamp, const QDateTime &before, | ||
| const QDateTime &after) | ||
| { | ||
| QVERIFY(timestamp.size() == 19); | ||
|
|
||
| QDateTime parsedTimestamp = QDateTime::fromString(timestamp, timestampFormat); | ||
| QVERIFY(parsedTimestamp.isValid()); | ||
| QCOMPARE(parsedTimestamp.toString(timestampFormat), timestamp); | ||
|
|
||
| parsedTimestamp.setTimeZone(QTimeZone::utc()); | ||
| QVERIFY(parsedTimestamp >= before.addSecs(-1)); | ||
| QVERIFY(parsedTimestamp <= after); | ||
| } | ||
|
|
||
| } // namespace tests | ||
|
|
||
| QTEST_APPLESS_MAIN(tests::BaseModelBuilderTest) |
50 changes: 50 additions & 0 deletions
50
tests/auto/plugins/preferences/common/basemodelbuilder/basemodelbuildertest.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /*********************************************************************************************************************** | ||
| ** | ||
| ** Copyright (C) 2026 BaseALT Ltd. <org@basealt.ru> | ||
| ** | ||
| ** This program 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. | ||
| ** | ||
| ** This program 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 this program; if not, write to the Free Software | ||
| ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| ** | ||
| ***********************************************************************************************************************/ | ||
|
|
||
| #ifndef GPUI_BASE_MODEL_BUILDER_TEST_H | ||
| #define GPUI_BASE_MODEL_BUILDER_TEST_H | ||
|
|
||
| #include <QByteArray> | ||
| #include <QDateTime> | ||
| #include <QObject> | ||
|
|
||
| namespace tests { | ||
| class BaseModelBuilderTest : public QObject | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| private slots: | ||
| void initTestCase(); | ||
| void cleanupTestCase(); | ||
|
|
||
| void createDateOfChangeUsesUtc(); | ||
| void createRootElementUsesUtc(); | ||
|
|
||
| private: | ||
| void verifyUtcTimestamp(const QString ×tamp, const QDateTime &before, | ||
| const QDateTime &after); | ||
|
|
||
| QByteArray originalTimeZone; | ||
| bool hadOriginalTimeZone = false; | ||
| }; | ||
|
|
||
| } // namespace tests | ||
|
|
||
| #endif // GPUI_BASE_MODEL_BUILDER_TEST_H |
30 changes: 30 additions & 0 deletions
30
tests/auto/plugins/preferences/common/preferencesdialog/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets Test REQUIRED) | ||
|
|
||
| find_package(XercesC REQUIRED) | ||
|
|
||
| set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
|
|
||
| set(SOURCES | ||
| preferencesdialogtest.cpp | ||
| ../../../../../../src/plugins/preferences/shortcuts/shortcutswidget.cpp | ||
| ../../../../../../src/plugins/preferences/shortcuts/shortcutsschema.cpp | ||
| ../../../../../../src/plugins/preferences/shortcuts/modelbuilder.cpp | ||
| ) | ||
|
|
||
| set(UI_FORMS | ||
| ../../../../../../src/plugins/preferences/common/preferencesdialog.ui | ||
| ../../../../../../src/plugins/preferences/shortcuts/shortcutswidget.ui | ||
| ) | ||
|
|
||
| set(MOC_HEADERS | ||
| preferencesdialogtest.h | ||
| ../../../../../../src/plugins/preferences/common/preferencesdialog.h | ||
| ../../../../../../src/plugins/preferences/shortcuts/shortcutswidget.h | ||
| ) | ||
|
|
||
| qt_wrap_ui(UI_SOURCES ${UI_FORMS}) | ||
| qt_wrap_cpp(MOC_SOURCES ${MOC_HEADERS}) | ||
|
|
||
| add_executable(preferencesdialogtest ${SOURCES} ${MOC_SOURCES} ${UI_SOURCES}) | ||
| target_link_libraries(preferencesdialogtest ${GPUI_LIBRARIES} preferences-common Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Test XercesC::XercesC) | ||
| add_gpui_test(plugins.preferencesdialogtest preferencesdialogtest) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.