diff options
author | Tobias Markmann <tm@ayena.de> | 2017-04-07 09:17:07 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2017-04-07 10:42:24 (GMT) |
commit | ed2226782ac15345aeb8e615b41d30e5aab67b51 (patch) | |
tree | a519ef4b314570fb134b969bb5fcff0e1f2be6e9 /Swift/QtUI/UnitTest | |
parent | 7d2e5e200d8449a4492c6fafa4811197e6fbe40b (diff) | |
download | swift-ed2226782ac15345aeb8e615b41d30e5aab67b51.zip swift-ed2226782ac15345aeb8e615b41d30e5aab67b51.tar.bz2 |
Make day change chat system message DST aware
Moved the code for day change message handling from
Swift/Controllers to Swift/QtUI. Use QDateTime in local
time time spec, which allows DST aware calculation of the
duration to the next midnight.
Added Swift Qt UI unit tests, which are build when Qt has
been successfully detected.
Test-Information:
Added unit tests for duration to next midnight calculation.
Set clock shortly before midnight and verified that a single
day change message is added to the chat log at midnight.
Tested on macOS 10.12.4 with Qt 5.4.2.
Change-Id: I34d69eaa3272981fd220a7963a0417f73ff78e68
Diffstat (limited to 'Swift/QtUI/UnitTest')
-rw-r--r-- | Swift/QtUI/UnitTest/QtUtilitiesTest.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Swift/QtUI/UnitTest/QtUtilitiesTest.cpp b/Swift/QtUI/UnitTest/QtUtilitiesTest.cpp new file mode 100644 index 0000000..45d2239 --- /dev/null +++ b/Swift/QtUI/UnitTest/QtUtilitiesTest.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include <gtest/gtest.h> + +#include <QDateTime> +#include <QLocale> + +#include <Swift/QtUI/QtUtilities.h> +#include <Swift/QtUI/QtUtilities.cpp> + +TEST(QtUtilitiesTest, testDSTawareness) { + QLocale::setDefault(QLocale(QLocale::English, QLocale::Germany)); + + auto beforeDSTpoint = QDateTime(QDate(2017, 3, 26), QTime(0, 0)); + + ASSERT_EQ(23 * 60 * 60, QtUtilities::secondsToNextMidnight(beforeDSTpoint)); +} + + +TEST(QtUtilitiesTest, testNoDSTChange) { + QLocale::setDefault(QLocale(QLocale::English, QLocale::Germany)); + + auto beforeDSTpoint = QDateTime(QDate(2017, 3, 23), QTime(0, 0)); + + ASSERT_EQ(24 * 60 * 60, QtUtilities::secondsToNextMidnight(beforeDSTpoint)); +} |