Commit 0af20138 authored by David Jarvie's avatar David Jarvie
Browse files

Bug 461713: Add unit tests for daily alarms before time shift

Add unit tests for daily alarms which trigger in the hour before a
daylight savings to standard time shift.
parent 725db99f
Pipeline #270113 passed with stage
in 1 minute and 52 seconds
KAlarm Change Log
=== Version 3.5.3 (KDE Gear 22.12) --- 4 October 2022 ===
=== Version 3.5.3 (KDE Gear 22.12) --- 18 November 2022 ===
* Provide build option to disable use of X11, even if it is available.
* Fix daily alarms continually triggering just before end of daylight savings time [KDE Bug 461713]
=== Version 3.5.2 (KDE Gear 22.08.2) --- 4 October 2022 ===
* Fix possible crash when alarm restored at login is deferred [KDE Bug 459901]
......
......@@ -1276,4 +1276,34 @@ void KAEventTest::toKCalEvent()
}
}
void KAEventTest::setNextOccurrence()
{
// Test setNextOccurrence() going from before to after a shift from daylight savings
// to standard time, for a daily recurrence at a clock time which occurs twice (once
// before the time shift, and once an hour later when the clock time repeats).
const KADateTime dt(QDate(2005, 10, 29), QTime(1, 30, 0), QTimeZone("Europe/London"));
KAEvent event(dt, QStringLiteral("name"), QStringLiteral("text"), Qt::black, Qt::white, QFont(), KAEvent::MESSAGE, 0, KAEvent::DEFAULT_FONT);
event.setRecurDaily(1, QBitArray(7, true), -1, QDate());
KAEvent::OccurType type = event.setNextOccurrence(dt);
const DateTime next1 = event.mainDateTime();
QCOMPARE(type, KAEvent::RECURRENCE_DATE_TIME);
QCOMPARE(next1.date(), QDate(2005, 10, 30));
QCOMPARE(next1.effectiveTime(), QTime(1, 30, 0));
KAEvent eventUTC = event;
const KADateTime dt1(QDate(2005, 10, 30), QTime(1, 30, 0), QTimeZone("Europe/London"));
type = event.setNextOccurrence(next1.kDateTime());
const DateTime next2 = event.mainDateTime();
QCOMPARE(type, KAEvent::RECURRENCE_DATE_TIME);
QCOMPARE(next2.date(), QDate(2005, 10, 31));
QCOMPARE(next2.effectiveTime(), QTime(1, 30, 0));
const KADateTime dt2(QDate(2005, 10, 30), QTime(1, 30, 0), KADateTime::UTC);
type = eventUTC.setNextOccurrence(dt2);
const DateTime next3 = eventUTC.mainDateTime();
QCOMPARE(type, KAEvent::RECURRENCE_DATE_TIME);
QCOMPARE(next3.date(), QDate(2005, 10, 31));
QVERIFY(!next3.isSecondOccurrence());
}
// vim: et sw=4:
......@@ -2,7 +2,7 @@
This file is part of kalarmcal library, which provides access to KAlarm
calendar data.
SPDX-FileCopyrightText: 2018 David Jarvie <djarvie@kde.org>
SPDX-FileCopyrightText: 2018-2022 David Jarvie <djarvie@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
......@@ -19,5 +19,6 @@ private Q_SLOTS:
void flags();
void fromKCalEvent();
void toKCalEvent();
void setNextOccurrence();
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment