Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
PIM IncidenceEditor
Commits
5a1ab6d6
Commit
5a1ab6d6
authored
Mar 21, 2022
by
Glen Ditchfield
🐛
Browse files
Test more time zone special cases
parent
176c93a7
Pipeline
#153294
passed with stage
in 1 minute and 17 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
autotests/ktimezonecomboboxtest.cpp
View file @
5a1ab6d6
...
...
@@ -12,16 +12,19 @@
QTEST_MAIN
(
KTimeZoneComboBoxTest
)
const
auto
TEST_TZ
=
"Asia/Tokyo"
;
// Not UTC, not Paris.
void
KTimeZoneComboBoxTest
::
initTestCase
()
{
qputenv
(
"TZ"
,
TEST_TZ
);
}
void
KTimeZoneComboBoxTest
::
test_timeSpec
()
{
IncidenceEditorNG
::
KTimeZoneComboBox
combo
;
combo
.
selectLocalTimeZone
();
QVERIFY
(
!
combo
.
isFloating
());
if
(
combo
.
selectedTimeZone
().
id
()
!=
"UTC"
)
{
QCOMPARE
(
combo
.
selectedTimeZone
(),
QTimeZone
::
systemTimeZone
());
}
else
{
QCOMPARE
(
combo
.
selectedTimeZone
(),
QTimeZone
::
utc
());
}
QCOMPARE
(
combo
.
selectedTimeZone
(),
QTimeZone
::
systemTimeZone
());
combo
.
selectTimeZone
(
QTimeZone
());
QCOMPARE
(
combo
.
selectedTimeZone
(),
QTimeZone
::
systemTimeZone
());
...
...
@@ -31,7 +34,7 @@ void KTimeZoneComboBoxTest::test_timeSpec()
QCOMPARE
(
combo
.
selectedTimeZone
(),
QTimeZone
::
systemTimeZone
());
}
void
KTimeZoneComboBoxTest
::
test_
dateTime
()
void
KTimeZoneComboBoxTest
::
test_
selectTimeZoneFor
()
{
IncidenceEditorNG
::
KTimeZoneComboBox
combo
;
...
...
@@ -41,12 +44,46 @@ void KTimeZoneComboBoxTest::test_dateTime()
combo
.
selectTimeZoneFor
(
dt
);
QVERIFY
(
combo
.
isFloating
());
// Non-floating
// System time zone.
QDateTime
dtSys
(
QDate
(
2021
,
12
,
12
),
QTime
(
12
,
0
,
0
),
QTimeZone
::
systemTimeZone
());
combo
.
selectTimeZoneFor
(
dtSys
);
QVERIFY
(
!
combo
.
isFloating
());
QCOMPARE
(
combo
.
selectedTimeZone
(),
QTimeZone
::
systemTimeZone
());
// UTC.
QDateTime
dtUtc
=
QDateTime
::
currentDateTimeUtc
();
combo
.
selectTimeZoneFor
(
dtUtc
);
QVERIFY
(
!
combo
.
isFloating
());
QCOMPARE
(
combo
.
selectedTimeZone
(),
QTimeZone
::
utc
());
// General case.
const
QDateTime
dtParis
(
QDate
(
2021
,
12
,
12
),
QTime
(
12
,
0
,
0
),
QTimeZone
(
"Europe/Paris"
));
QCOMPARE
(
dtParis
.
timeSpec
(),
Qt
::
TimeZone
);
combo
.
selectTimeZoneFor
(
dtParis
);
QVERIFY
(
!
combo
.
isFloating
());
QCOMPARE
(
combo
.
selectedTimeZone
().
id
(),
"Europe/Paris"
);
}
void
KTimeZoneComboBoxTest
::
test_applyTimeZoneTo
()
{
IncidenceEditorNG
::
KTimeZoneComboBox
combo
;
QDateTime
dt
=
QDateTime
::
currentDateTime
();
combo
.
selectTimeZoneFor
(
QDateTime
(
QDate
(
2021
,
12
,
12
),
QTime
(
12
,
0
,
0
),
Qt
::
LocalTime
));
combo
.
applyTimeZoneTo
(
dt
);
QCOMPARE
(
dt
.
timeSpec
(),
Qt
::
LocalTime
);
combo
.
selectTimeZoneFor
(
QDateTime
(
QDate
(
2021
,
12
,
12
),
QTime
(
12
,
0
,
0
),
QTimeZone
::
systemTimeZone
()));
combo
.
applyTimeZoneTo
(
dt
);
QCOMPARE
(
dt
.
timeSpec
(),
Qt
::
TimeZone
);
QCOMPARE
(
dt
.
timeZone
(),
QTimeZone
::
systemTimeZone
());
combo
.
selectTimeZoneFor
(
QDateTime
::
currentDateTimeUtc
());
combo
.
applyTimeZoneTo
(
dt
);
QCOMPARE
(
dt
.
timeSpec
(),
Qt
::
TimeZone
);
QCOMPARE
(
dt
.
timeZone
(),
QTimeZone
::
utc
());
combo
.
selectTimeZoneFor
(
QDateTime
(
QDate
(
2021
,
12
,
12
),
QTime
(
12
,
0
,
0
),
QTimeZone
(
"Europe/Paris"
)));
combo
.
applyTimeZoneTo
(
dt
);
QCOMPARE
(
dt
.
timeSpec
(),
Qt
::
TimeZone
);
QCOMPARE
(
dt
.
timeZone
().
id
(),
"Europe/Paris"
);
...
...
autotests/ktimezonecomboboxtest.h
View file @
5a1ab6d6
...
...
@@ -11,7 +11,9 @@ class KTimeZoneComboBoxTest : public QObject
{
Q_OBJECT
private
Q_SLOTS
:
void
initTestCase
();
void
test_timeSpec
();
void
test_dateTime
();
void
test_selectTimeZoneFor
();
void
test_applyTimeZoneTo
();
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment