Changeset View
Changeset View
Standalone View
Standalone View
autotests/filemetadatadatedisplaytest.cpp
Show All 35 Lines | |||||
36 | #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) | 36 | #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) | ||
37 | #include <time.h> | 37 | #include <time.h> | ||
38 | #include <utime.h> | 38 | #include <utime.h> | ||
39 | #include <sys/stat.h> | 39 | #include <sys/stat.h> | ||
40 | #endif | 40 | #endif | ||
41 | 41 | | |||
42 | void initLocale() | 42 | void initLocale() | ||
43 | { | 43 | { | ||
44 | QLocale::setDefault(QLocale("en_US")); | 44 | QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); | ||
bruns: use the `QLocale(Language, Country)` constructor here, dito below.
https://doc.qt.io/qt… | |||||
45 | } | 45 | } | ||
46 | Q_CONSTRUCTOR_FUNCTION(initLocale) | 46 | Q_CONSTRUCTOR_FUNCTION(initLocale) | ||
47 | 47 | | |||
48 | QTEST_MAIN(FileMetadataDateDisplayTest) | 48 | QTEST_MAIN(FileMetadataDateDisplayTest) | ||
49 | 49 | | |||
50 | bool FileMetadataDateDisplayTest::setFileTime(const QString& filePath, const QDateTime& fileTime) | 50 | bool FileMetadataDateDisplayTest::setFileTime(const QString& filePath, const QDateTime& fileTime) | ||
51 | { | 51 | { | ||
52 | bool ret; | 52 | bool ret; | ||
Show All 36 Lines | |||||
89 | { | 89 | { | ||
90 | QTest::addColumn<Baloo::DateFormats>("format"); | 90 | QTest::addColumn<Baloo::DateFormats>("format"); | ||
91 | QTest::addColumn<QUrl>("file"); | 91 | QTest::addColumn<QUrl>("file"); | ||
92 | QTest::addColumn<QRegularExpression>("regex"); | 92 | QTest::addColumn<QRegularExpression>("regex"); | ||
93 | 93 | | |||
94 | QTest::addRow("Short date, long ago") | 94 | QTest::addRow("Short date, long ago") | ||
95 | << Baloo::DateFormats::ShortFormat | 95 | << Baloo::DateFormats::ShortFormat | ||
96 | << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.mp3")) | 96 | << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.mp3")) | ||
97 | << QRegularExpression("(?:[1-3][0-9]|[1-9]) (?:[1-2][0-9]|[1-9]):[0-5][0-9] [AP]M") | 97 | << QRegularExpression(QStringLiteral("(?:[1-3][0-9]|[1-9]) (?:[1-2][0-9]|[1-9]):[0-5][0-9] [AP]M")) | ||
98 | ; | 98 | ; | ||
99 | 99 | | |||
100 | QTest::addRow("Short date, yesterday") | 100 | QTest::addRow("Short date, yesterday") | ||
101 | << Baloo::DateFormats::ShortFormat | 101 | << Baloo::DateFormats::ShortFormat | ||
102 | << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.m4a")) | 102 | << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.m4a")) | ||
103 | << QRegularExpression("Yesterday, (?:[1-2][0-9]|[1-9]):[0-5][0-9] [AP]M") | 103 | << QRegularExpression(QStringLiteral("Yesterday, (?:[1-2][0-9]|[1-9]):[0-5][0-9] [AP]M")) | ||
104 | ; | 104 | ; | ||
105 | 105 | | |||
106 | QTest::addRow("Long date, long ago") | 106 | QTest::addRow("Long date, long ago") | ||
107 | << Baloo::DateFormats::LongFormat | 107 | << Baloo::DateFormats::LongFormat | ||
108 | << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.mp3")) | 108 | << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.mp3")) | ||
109 | << QRegularExpression("[A-Z][a-z]+, [A-Z][a-z]+ (?:[1-3][0-9]|[1-9]), 20[0-9]{2} (?:1[0-2]|[1-9]):[0-5][0-9]:[0-5][0-9] [AP]M [A-Z]{3,4}") | 109 | << QRegularExpression(QStringLiteral("[A-Z][a-z]+, [A-Z][a-z]+ (?:[1-3][0-9]|[1-9]), 20[0-9]{2} (?:1[0-2]|[1-9]):[0-5][0-9]:[0-5][0-9] [AP]M [A-Z]{3,4}")) | ||
110 | ; | 110 | ; | ||
111 | 111 | | |||
112 | QTest::addRow("Long date, yesterday") | 112 | QTest::addRow("Long date, yesterday") | ||
113 | << Baloo::DateFormats::LongFormat | 113 | << Baloo::DateFormats::LongFormat | ||
114 | << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.m4a")) | 114 | << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.m4a")) | ||
115 | << QRegularExpression("Yesterday, (?:1[0-2]|[1-9]):[0-5][0-9]:[0-5][0-9] [AP]M [A-Z]{3,4}") | 115 | << QRegularExpression(QStringLiteral("Yesterday, (?:1[0-2]|[1-9]):[0-5][0-9]:[0-5][0-9] [AP]M [A-Z]{3,4}")) | ||
116 | ; | 116 | ; | ||
117 | 117 | | |||
118 | } | 118 | } | ||
119 | 119 | | |||
120 | void FileMetadataDateDisplayTest::shouldDisplayLongAndShortDates() | 120 | void FileMetadataDateDisplayTest::shouldDisplayLongAndShortDates() | ||
121 | { | 121 | { | ||
122 | QFETCH(Baloo::DateFormats, format); | 122 | QFETCH(Baloo::DateFormats, format); | ||
123 | QFETCH(QUrl, file); | 123 | QFETCH(QUrl, file); | ||
Show All 14 Lines |
use the QLocale(Language, Country) constructor here, dito below.
https://doc.qt.io/qt-5/qlocale.html#QLocale-2