Fix KTimeComboBox input mask for AM/PM times
ClosedPublic

Authored by glennw on Jul 28 2018, 7:45 AM.

Details

Summary

In some cases, the strings returned from amText() and
pmText() may differ in case to the provided format
in the timeFormatToInputMask method.

This results in an incorrect mask string being provided
to the line edit control.

Instead, detect if the format string uses upper or lower
case for the AM/PM specification, and use this to convert
the am/pm text strings to a consistent case.

BUG: 361764

Diff Detail

Repository
R236 KWidgetsAddons
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
glennw created this revision.Jul 28 2018, 7:45 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptJul 28 2018, 7:45 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
glennw requested review of this revision.Jul 28 2018, 7:45 AM
mlaurent requested changes to this revision.Jul 28 2018, 10:48 AM

could you provide an autotest for it please ?
(see autotest/ktimecomboboxtest.cpp)
Thanks

This revision now requires changes to proceed.Jul 28 2018, 10:48 AM
glennw updated this revision to Diff 38685.Jul 28 2018, 10:15 PM

Added an autotest to ensure that the line edit mask is updated correctly.

A couple of notes about the test results below:

  • I tried to set the current locale in the new test to ensure it reproduces. The setLocale() function is not reentrant, which should be fine unless tests are run in parallel?
  • There are other tests in this file that fail before my patch, and now pass afterwards. I guess they are probably passing in CI due to the CI locale setting?

Test results before this patch:

********* Start testing of KTimeComboBoxTest *********
Config: Using QtTest library 5.9.5, Qt 5.9.5 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 7.3.0)
PASS   : KTimeComboBoxTest::initTestCase()
PASS   : KTimeComboBoxTest::_q_showIfNotHidden()
FAIL!  : KTimeComboBoxTest::testDefaults() Compared values are not the same
   Actual   (m_combo->time())  : 12:00:00.000
   Expected (QTime(0, 0, 0, 0)): 00:00:00.000
   Loc: [kde/kwidgetsaddons/autotests/ktimecomboboxtest.cpp(33)]
PASS   : KTimeComboBoxTest::testValidNull()
FAIL!  : KTimeComboBoxTest::testTimeRange() Compared values are not the same
   Actual   (m_combo->isValid()): 1
   Expected (false)             : 0
   Loc: [kde/kwidgetsaddons/autotests/ktimecomboboxtest.cpp(69)]
PASS   : KTimeComboBoxTest::testTimeListInterval()
PASS   : KTimeComboBoxTest::testTimeList()
PASS   : KTimeComboBoxTest::testOptions()
PASS   : KTimeComboBoxTest::testDisplayFormat()
FAIL!  : KTimeComboBoxTest::testMask() Compared values are not the same
   Actual   (mask.contains(QLatin1String("aa"))): 0
   Expected (true)                              : 1
   Loc: [kde/kwidgetsaddons/autotests/ktimecomboboxtest.cpp(198)]
PASS   : KTimeComboBoxTest::cleanupTestCase()
Totals: 8 passed, 3 failed, 0 skipped, 0 blacklisted, 71ms
********* Finished testing of KTimeComboBoxTest *********

Test results after:

********* Start testing of KTimeComboBoxTest *********
Config: Using QtTest library 5.9.5, Qt 5.9.5 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 7.3.0)
PASS   : KTimeComboBoxTest::initTestCase()
PASS   : KTimeComboBoxTest::_q_showIfNotHidden()
PASS   : KTimeComboBoxTest::testDefaults()
PASS   : KTimeComboBoxTest::testValidNull()
PASS   : KTimeComboBoxTest::testTimeRange()
PASS   : KTimeComboBoxTest::testTimeListInterval()
PASS   : KTimeComboBoxTest::testTimeList()
PASS   : KTimeComboBoxTest::testOptions()
PASS   : KTimeComboBoxTest::testDisplayFormat()
PASS   : KTimeComboBoxTest::testMask()
PASS   : KTimeComboBoxTest::cleanupTestCase()
Totals: 11 passed, 0 failed, 0 skipped, 0 blacklisted, 69ms
********* Finished testing of KTimeComboBoxTest *********
mlaurent requested changes to this revision.Jul 30 2018, 6:06 AM
mlaurent added inline comments.
autotests/ktimecomboboxtest.cpp
198

Could you provide another case where mask will not contains "aa" so we can be sure that code works
Thanks.

This revision now requires changes to proceed.Jul 30 2018, 6:06 AM
glennw updated this revision to Diff 38748.Jul 30 2018, 7:15 AM

Updated to include test for 24hr locales.

mlaurent requested changes to this revision.Jul 31 2018, 11:55 AM

For me it's ok after using QVERIFY...

autotests/ktimecomboboxtest.cpp
198

QVERIFY(...)

205

QVERIFY(! ....)

This revision now requires changes to proceed.Jul 31 2018, 11:55 AM
glennw updated this revision to Diff 38890.Aug 1 2018, 7:03 AM

Switched test to use QVERIFY().

mlaurent accepted this revision.Aug 2 2018, 9:54 AM
This revision is now accepted and ready to land.Aug 2 2018, 9:54 AM
This revision was automatically updated to reflect the committed changes.
cfeck added a comment.Aug 2 2018, 12:35 PM

Thanks, committed. I hope I got the correct address from your bugzilla comment.

Offtopic: When I started understanding BOOPSI objects, I was a bit disappointed that Window and Screen objects in intuition.library where not BOOPSI objects. I re-sourced the complete intuition.library to C, just to be able to convert those to BOOPSI... That's why I turned then-famous "Intel inside!" into a "Intuition inside!" tag, which I appended to my comp.sys.amiga posts. Oh those times ...

glennw added a comment.Aug 3 2018, 9:52 AM

Yes, you got the address and the reference correct - that sounds like it would have been quite the project!