File indexing completed on 2024-05-12 05:15:00

0001 /*
0002   SPDX-FileCopyrightText: 2020 Glen Ditchfield <GJDitchfield@acm.org>
0003 
0004   SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "testtodotooltip.h"
0008 
0009 #include "incidenceformatter.h"
0010 #include <KCalendarCore/Todo>
0011 
0012 #include <QRegularExpression>
0013 #include <QTest>
0014 
0015 // Standard values for to-dos.
0016 static const bool ALL_DAY = true;
0017 static const bool RECURS = true;
0018 static const QDateTime START_DT{QDate(2222, 6, 10), QTime(11, 0, 0)};
0019 static const QDateTime DUE_DT{QDate(2222, 6, 12), QTime(11, 30, 0)};
0020 static const QDate AS_OF_DATE{2222, 6, 12};
0021 static const QString SUMMARY{QStringLiteral("Do something")};
0022 static const QString CAL_NAME{QStringLiteral("A calendar")};
0023 
0024 // Field names in tool tips.
0025 static const QString CALENDAR{QStringLiteral("Calendar")};
0026 static const QString START{QStringLiteral("Start")};
0027 static const QString DUE{QStringLiteral("Due")};
0028 static const QString PERCENT{QStringLiteral("Percent Done")};
0029 static const QString COMPLETED{QStringLiteral("Completed")};
0030 static const QString DURATION{QStringLiteral("Duration")};
0031 static const QString RECURRENCE{QStringLiteral("Recurrence")};
0032 static const QString PRIORITY{QStringLiteral("Priority")};
0033 
0034 // Common expected field values in tool tips.
0035 static const QString EXPECTED_RECURRENCE{QStringLiteral("Recurs every 7 days until")};
0036 static const QString EXPECTED_DURATION_DAYS{QStringLiteral("3 days")};
0037 static const QString EXPECTED_DURATION_DT{QStringLiteral("2 days 30 minutes")};
0038 static const QString EXPECTED_PCT100{QStringLiteral("100%")};
0039 static const QString EXPECTED_PCT50{QStringLiteral("50%")};
0040 static const QString EXPECTED_PCT0{QStringLiteral("0%")};
0041 
0042 using namespace KCalUtils::IncidenceFormatter;
0043 
0044 // Create a to-do that may or may not be an all-day to-do, may or may nor recur,
0045 // and with the given start and due dates (which may be invalid).
0046 // Other to-do fields are fixed.
0047 static KCalendarCore::Todo::Ptr makeToDo(bool allday, bool recurs, const QDateTime &dtStart, const QDateTime &dtDue)
0048 {
0049     KCalendarCore::Todo::Ptr todo{new KCalendarCore::Todo};
0050     todo->setSummary(SUMMARY);
0051     todo->setDtStart(dtStart);
0052     todo->setDtDue(dtDue);
0053     todo->setAllDay(allday);
0054     if (recurs) {
0055         todo->recurrence()->setDaily(7);
0056         todo->recurrence()->setDuration(3);
0057         todo->setCompleted(dtStart);
0058     }
0059     todo->setPercentComplete(50);
0060     return todo;
0061 }
0062 
0063 // Convert a tool tip to a convenient form for testing.
0064 static QString plain(QString s)
0065 {
0066     return s.replace(QStringLiteral("&nbsp;"), QStringLiteral(" "))
0067         .replace(QStringLiteral("<hr>"), QStringLiteral("\n---\n"))
0068         .replace(QStringLiteral("<br>"), QStringLiteral("\n"))
0069         .remove(QRegularExpression(QStringLiteral("<[/a-z]+>")));
0070 }
0071 
0072 // Return a regular expression that matches a field name and value.
0073 static QRegularExpression field(const QString &name, const QString &value)
0074 {
0075     return QRegularExpression(QStringLiteral("\\b%1:\\s*%2").arg(name, value));
0076 }
0077 
0078 // Return a regular expression that matches just a field name.
0079 static QRegularExpression field(const QString &name)
0080 {
0081     return QRegularExpression(QStringLiteral("\\b%1:").arg(name));
0082 }
0083 
0084 void TestTodoToolTip::testNonrecurring_data()
0085 {
0086     QTest::addColumn<bool>("allDay");
0087     QTest::addColumn<QDateTime>("dtStart");
0088     QTest::addColumn<QDateTime>("dtDue");
0089     QTest::addColumn<QDate>("asOfDate");
0090 
0091     // Tests for the agenda and month views.
0092     QTest::newRow("all day,both") << ALL_DAY << START_DT << DUE_DT << AS_OF_DATE;
0093     QTest::newRow("all day,start") << ALL_DAY << START_DT << QDateTime() << AS_OF_DATE;
0094     QTest::newRow("all day,due") << ALL_DAY << QDateTime() << DUE_DT << AS_OF_DATE;
0095     QTest::newRow("all day,neither") << ALL_DAY << QDateTime() << QDateTime() << AS_OF_DATE;
0096     QTest::newRow("timed,both") << !ALL_DAY << START_DT << DUE_DT << AS_OF_DATE;
0097     QTest::newRow("timed,start") << !ALL_DAY << START_DT << QDateTime() << AS_OF_DATE;
0098     QTest::newRow("timed,due") << !ALL_DAY << QDateTime() << DUE_DT << AS_OF_DATE;
0099     QTest::newRow("timed,neither") << !ALL_DAY << QDateTime() << QDateTime() << AS_OF_DATE;
0100 
0101     // Tests for the to-do list view.
0102     QTest::newRow("all day,both,dateless") << ALL_DAY << START_DT << DUE_DT << QDate();
0103     QTest::newRow("all day,start,dateless") << ALL_DAY << START_DT << QDateTime() << QDate();
0104     QTest::newRow("all day,due,dateless") << ALL_DAY << QDateTime() << DUE_DT << QDate();
0105     QTest::newRow("all day,neither,dateless") << ALL_DAY << QDateTime() << QDateTime() << QDate();
0106     QTest::newRow("timed,both,dateless") << !ALL_DAY << START_DT << DUE_DT << QDate();
0107     QTest::newRow("timed,start,dateless") << !ALL_DAY << START_DT << QDateTime() << QDate();
0108     QTest::newRow("timed,due,dateless") << !ALL_DAY << QDateTime() << DUE_DT << QDate();
0109     QTest::newRow("timed,neither,dateless") << !ALL_DAY << QDateTime() << QDateTime() << QDate();
0110 }
0111 
0112 // Test for the values of tool tip fields, or their absence, in non-recurring to-dos.
0113 void TestTodoToolTip::testNonrecurring()
0114 {
0115     QFETCH(bool, allDay);
0116     QFETCH(QDateTime, dtStart);
0117     QFETCH(QDateTime, dtDue);
0118     QFETCH(QDate, asOfDate);
0119 
0120     auto todo = makeToDo(allDay, !RECURS, dtStart, dtDue);
0121     auto toolTip = plain(toolTipStr(CAL_NAME, todo, asOfDate, false));
0122 
0123     QVERIFY(toolTip.contains(QRegularExpression(SUMMARY)));
0124     QVERIFY(toolTip.contains(field(CALENDAR, CAL_NAME)));
0125     QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50)));
0126     QVERIFY(!toolTip.contains(field(COMPLETED)));
0127     QVERIFY(!toolTip.contains(field(RECURRENCE)));
0128     if (dtStart.isValid()) {
0129         QVERIFY(toolTip.contains(field(START, dateTimeToString(dtStart, allDay, false))));
0130     } else {
0131         QVERIFY(!toolTip.contains(field(START)));
0132     }
0133     if (dtDue.isValid()) {
0134         QVERIFY(toolTip.contains(field(DUE, dateTimeToString(dtDue, allDay, false))));
0135     } else {
0136         QVERIFY(!toolTip.contains(field(DUE)));
0137     }
0138     if (dtStart.isValid() && dtDue.isValid()) {
0139         if (allDay) {
0140             QVERIFY(toolTip.contains(field(DURATION, EXPECTED_DURATION_DAYS)));
0141         } else {
0142             QVERIFY(toolTip.contains(field(DURATION, EXPECTED_DURATION_DT)));
0143         }
0144     } else {
0145         QVERIFY(!toolTip.contains(field(DURATION)));
0146     }
0147 }
0148 
0149 // Tool tips for all-day non-recurring to-dos should contain a completion percentage
0150 // if they are incomplete, or a completion date otherwise.
0151 void TestTodoToolTip::testAlldayNonrecurringDone()
0152 {
0153     auto todo = makeToDo(ALL_DAY, !RECURS, START_DT, DUE_DT);
0154     todo->setCompleted(START_DT);
0155 
0156     auto toolTip = plain(toolTipStr(CAL_NAME, todo, AS_OF_DATE, false));
0157     QVERIFY(toolTip.contains(field(COMPLETED, dateTimeToString(START_DT, ALL_DAY, false))));
0158     QVERIFY(!toolTip.contains(field(PERCENT)));
0159 
0160     toolTip = plain(toolTipStr(CAL_NAME, todo, QDate(), false));
0161     QVERIFY(toolTip.contains(field(COMPLETED, dateTimeToString(START_DT, ALL_DAY, false))));
0162     QVERIFY(!toolTip.contains(field(PERCENT)));
0163 }
0164 
0165 // Tool tips for non-all-day non-recurring to-dos should contain a completion percentage
0166 // if they are incomplete, or a completion date otherwise.
0167 void TestTodoToolTip::testTimedNonrecurringDone()
0168 {
0169     auto todo = makeToDo(!ALL_DAY, !RECURS, START_DT, DUE_DT);
0170     todo->setCompleted(START_DT);
0171 
0172     auto toolTip = plain(toolTipStr(CAL_NAME, todo, AS_OF_DATE, false));
0173     QVERIFY(toolTip.contains(field(COMPLETED, dateTimeToString(START_DT, !ALL_DAY, false))));
0174     QVERIFY(!toolTip.contains(field(PERCENT)));
0175 
0176     toolTip = plain(toolTipStr(CAL_NAME, todo, QDate(), false));
0177     QVERIFY(toolTip.contains(field(COMPLETED, dateTimeToString(START_DT, !ALL_DAY, false))));
0178     QVERIFY(!toolTip.contains(field(PERCENT)));
0179 }
0180 
0181 void TestTodoToolTip::testRecurringOnDate_data()
0182 {
0183     QTest::addColumn<bool>("allDay");
0184     QTest::addColumn<QDateTime>("dtStart");
0185     QTest::addColumn<QDateTime>("dtDue");
0186     QTest::addColumn<QDate>("asOfDate");
0187     QTest::addColumn<QString>("pct");
0188     QTest::addColumn<int>("daysOffset");
0189     QTest::addColumn<QString>("dur");
0190 
0191     // Test the tool tip for each day of each occurrence of all-day to-dos.
0192     QTest::newRow("All day, 1st occurrence, day 1") << ALL_DAY << START_DT << DUE_DT << START_DT.date() << EXPECTED_PCT100 << 0 << EXPECTED_DURATION_DAYS;
0193     QTest::newRow("All day, 1st occurrence, day 2") << ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(1) << EXPECTED_PCT100 << 0
0194                                                     << EXPECTED_DURATION_DAYS;
0195     QTest::newRow("All day, 1st occurrence, day 3") << ALL_DAY << START_DT << DUE_DT << DUE_DT.date() << EXPECTED_PCT100 << 0 << EXPECTED_DURATION_DAYS;
0196     QTest::newRow("All day, 1st occurrence, only day") << ALL_DAY << DUE_DT << DUE_DT << DUE_DT.date() << EXPECTED_PCT100 << 0 << QStringLiteral("1 day");
0197 
0198     QTest::newRow("All day, 2nd occurrence, day 1") << ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(7) << EXPECTED_PCT50 << 7
0199                                                     << EXPECTED_DURATION_DAYS;
0200     QTest::newRow("All day, 2nd occurrence, day 2") << ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(8) << EXPECTED_PCT50 << 7
0201                                                     << EXPECTED_DURATION_DAYS;
0202     QTest::newRow("All day, 2nd occurrence, day 3") << ALL_DAY << START_DT << DUE_DT << DUE_DT.date().addDays(7) << EXPECTED_PCT50 << 7
0203                                                     << EXPECTED_DURATION_DAYS;
0204     QTest::newRow("All day, 2nd occurrence, only day")
0205         << ALL_DAY << DUE_DT << DUE_DT << DUE_DT.date().addDays(7) << EXPECTED_PCT50 << 7 << QStringLiteral("1 day");
0206 
0207     QTest::newRow("All day, 3rd occurrence, day 1") << ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(14) << EXPECTED_PCT0 << 14
0208                                                     << EXPECTED_DURATION_DAYS;
0209     QTest::newRow("All day, 3rd occurrence, day 2") << ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(15) << EXPECTED_PCT0 << 14
0210                                                     << EXPECTED_DURATION_DAYS;
0211     QTest::newRow("All day, 3rd occurrence, day 3") << ALL_DAY << START_DT << DUE_DT << DUE_DT.date().addDays(14) << EXPECTED_PCT0 << 14
0212                                                     << EXPECTED_DURATION_DAYS;
0213     QTest::newRow("All day, 3rd occurrence, only day")
0214         << ALL_DAY << DUE_DT << DUE_DT << DUE_DT.date().addDays(14) << EXPECTED_PCT0 << 14 << QStringLiteral("1 day");
0215 
0216     // Test the tool tip for each day of each occurrence of time-of-day to-dos.
0217     QTest::newRow("Timed, 1st occurrence, day 1") << !ALL_DAY << START_DT << DUE_DT << START_DT.date() << EXPECTED_PCT100 << 0 << EXPECTED_DURATION_DT;
0218     QTest::newRow("Timed, 1st occurrence, day 2") << !ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(1) << EXPECTED_PCT100 << 0
0219                                                   << EXPECTED_DURATION_DT;
0220     QTest::newRow("Timed, 1st occurrence, day 3") << !ALL_DAY << START_DT << DUE_DT << DUE_DT.date() << EXPECTED_PCT100 << 0 << EXPECTED_DURATION_DT;
0221     QTest::newRow("Timed, 1st occurrence, only day") << !ALL_DAY << START_DT.addDays(2) << DUE_DT << DUE_DT.date() << EXPECTED_PCT100 << 0
0222                                                      << QStringLiteral("30 minutes");
0223 
0224     QTest::newRow("Timed, 2nd occurrence, day 1") << !ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(7) << EXPECTED_PCT50 << 7
0225                                                   << EXPECTED_DURATION_DT;
0226     QTest::newRow("Timed, 2nd occurrence, day 2") << !ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(8) << EXPECTED_PCT50 << 7
0227                                                   << EXPECTED_DURATION_DT;
0228     QTest::newRow("Timed, 2nd occurrence, day 3") << !ALL_DAY << START_DT << DUE_DT << DUE_DT.date().addDays(7) << EXPECTED_PCT50 << 7 << EXPECTED_DURATION_DT;
0229     QTest::newRow("Timed, 2nd occurrence, only day") << !ALL_DAY << START_DT.addDays(2) << DUE_DT << DUE_DT.date().addDays(7) << EXPECTED_PCT50 << 7
0230                                                      << QStringLiteral("30 minutes");
0231 
0232     QTest::newRow("Timed, 3rd occurrence, day 1") << !ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(14) << EXPECTED_PCT0 << 14
0233                                                   << EXPECTED_DURATION_DT;
0234     QTest::newRow("Timed, 3rd occurrence, day 2") << !ALL_DAY << START_DT << DUE_DT << START_DT.date().addDays(15) << EXPECTED_PCT0 << 14
0235                                                   << EXPECTED_DURATION_DT;
0236     QTest::newRow("Timed, 3rd occurrence, day 3") << !ALL_DAY << START_DT << DUE_DT << DUE_DT.date().addDays(14) << EXPECTED_PCT0 << 14 << EXPECTED_DURATION_DT;
0237     QTest::newRow("Timed, 3rd occurrence, only day") << !ALL_DAY << START_DT.addDays(2) << DUE_DT << DUE_DT.date().addDays(14) << EXPECTED_PCT0 << 14
0238                                                      << QStringLiteral("30 minutes");
0239 }
0240 
0241 // Test for the values of tool tip fields, or their absence, for specific dates
0242 // in occurrences of recurring to-dos.
0243 void TestTodoToolTip::testRecurringOnDate()
0244 {
0245     QFETCH(bool, allDay);
0246     QFETCH(QDateTime, dtStart);
0247     QFETCH(QDateTime, dtDue);
0248     QFETCH(QDate, asOfDate);
0249     QFETCH(QString, pct);
0250     QFETCH(int, daysOffset);
0251     QFETCH(QString, dur);
0252 
0253     auto todo = makeToDo(allDay, RECURS, dtStart, dtDue);
0254     auto toolTip = plain(toolTipStr(CAL_NAME, todo, asOfDate, false));
0255     QVERIFY(toolTip.contains(QRegularExpression(SUMMARY)));
0256     QVERIFY(toolTip.contains(field(CALENDAR, CAL_NAME)));
0257     QVERIFY(toolTip.contains(field(PERCENT, pct)));
0258     QVERIFY(!toolTip.contains(field(COMPLETED)));
0259     QVERIFY(toolTip.contains(field(START, dateTimeToString(dtStart.addDays(daysOffset), allDay, false))));
0260     QVERIFY(toolTip.contains(field(DUE, dateTimeToString(dtDue.addDays(daysOffset), allDay, false))));
0261     QVERIFY(toolTip.contains(field(DURATION, dur)));
0262     QVERIFY(toolTip.contains(field(RECURRENCE, EXPECTED_RECURRENCE)));
0263 }
0264 
0265 // Tool tips for no particular date show the properties of the first uncompleted occurrence.
0266 void TestTodoToolTip::testAlldayRecurringNoDate()
0267 {
0268     auto todo = makeToDo(ALL_DAY, RECURS, START_DT, DUE_DT);
0269     auto toolTip = plain(toolTipStr(CAL_NAME, todo, QDate(), false));
0270 
0271     QVERIFY(toolTip.contains(QRegularExpression(SUMMARY)));
0272     QVERIFY(toolTip.contains(field(CALENDAR, CAL_NAME)));
0273     QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50)));
0274     QVERIFY(!toolTip.contains(field(COMPLETED)));
0275     QVERIFY(toolTip.contains(field(START, dateTimeToString(START_DT.addDays(7), ALL_DAY, false))));
0276     QVERIFY(toolTip.contains(field(DUE, dateTimeToString(DUE_DT.addDays(7), ALL_DAY, false))));
0277     QVERIFY(toolTip.contains(field(DURATION, EXPECTED_DURATION_DAYS)));
0278     QVERIFY(toolTip.contains(field(RECURRENCE, EXPECTED_RECURRENCE)));
0279 }
0280 
0281 // Tool tips for no particular date show the properties of the first uncompleted occurrence.
0282 void TestTodoToolTip::testTimedRecurringNoDate()
0283 {
0284     auto todo = makeToDo(!ALL_DAY, RECURS, START_DT, DUE_DT);
0285     auto toolTip = plain(toolTipStr(CAL_NAME, todo, QDate(), false));
0286 
0287     QVERIFY(toolTip.contains(QRegularExpression(SUMMARY)));
0288     QVERIFY(toolTip.contains(field(CALENDAR, CAL_NAME)));
0289     QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50)));
0290     QVERIFY(!toolTip.contains(field(COMPLETED)));
0291     QVERIFY(toolTip.contains(field(START, dateTimeToString(START_DT.addDays(7), !ALL_DAY, false))));
0292     QVERIFY(toolTip.contains(field(DUE, dateTimeToString(DUE_DT.addDays(7), !ALL_DAY, false))));
0293     QVERIFY(toolTip.contains(field(DURATION, EXPECTED_DURATION_DT)));
0294     QVERIFY(toolTip.contains(field(RECURRENCE, EXPECTED_RECURRENCE)));
0295 }
0296 
0297 // Tool tips for recurring to-dos with no due dates do not have "duration"
0298 // or "due" fields.
0299 void TestTodoToolTip::testAlldayRecurringNeverDue()
0300 {
0301     auto todo = makeToDo(ALL_DAY, RECURS, START_DT, QDateTime());
0302     auto toolTip = plain(toolTipStr(CAL_NAME, todo, QDate(), false));
0303 
0304     QVERIFY(toolTip.contains(QRegularExpression(SUMMARY)));
0305     QVERIFY(toolTip.contains(field(CALENDAR, CAL_NAME)));
0306     QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50)));
0307     QVERIFY(!toolTip.contains(field(COMPLETED)));
0308     QVERIFY(toolTip.contains(field(START, dateTimeToString(START_DT.addDays(7), ALL_DAY, false))));
0309     QVERIFY(!toolTip.contains(field(DUE)));
0310     QVERIFY(!toolTip.contains(field(DURATION)));
0311     QVERIFY(toolTip.contains(field(RECURRENCE, EXPECTED_RECURRENCE)));
0312 }
0313 
0314 // Tool tips for recurring to-dos with no due dates do not have "duration"
0315 // or "due" fields.
0316 void TestTodoToolTip::testTimedRecurringNeverDue()
0317 {
0318     auto todo = makeToDo(!ALL_DAY, RECURS, START_DT, QDateTime());
0319     auto toolTip = plain(toolTipStr(CAL_NAME, todo, QDate(), false));
0320 
0321     QVERIFY(toolTip.contains(QRegularExpression(SUMMARY)));
0322     QVERIFY(toolTip.contains(field(CALENDAR, CAL_NAME)));
0323     QVERIFY(toolTip.contains(field(PERCENT, EXPECTED_PCT50)));
0324     QVERIFY(toolTip.contains(field(START, dateTimeToString(START_DT.addDays(7), !ALL_DAY, false))));
0325     QVERIFY(!toolTip.contains(field(DUE)));
0326     QVERIFY(!toolTip.contains(field(DURATION)));
0327     QVERIFY(toolTip.contains(field(RECURRENCE, EXPECTED_RECURRENCE)));
0328 }
0329 
0330 // Tool tips for recurring to-dos should contain a "completed" field instead of
0331 // a percentage field after the last occurrence has been marked as complete.
0332 void TestTodoToolTip::testAlldayRecurringDone()
0333 {
0334     auto todo = makeToDo(ALL_DAY, RECURS, START_DT, DUE_DT);
0335     todo->setCompleted(START_DT.addDays(14)); // Complete the second occurrence.
0336     todo->setCompleted(START_DT.addMonths(1)); // Complete the third occurrence.
0337 
0338     auto toolTip = plain(toolTipStr(CAL_NAME, todo, AS_OF_DATE, false));
0339     QVERIFY(toolTip.contains(field(COMPLETED, dateTimeToString(START_DT.addMonths(1), ALL_DAY, false))));
0340     QVERIFY(!toolTip.contains(field(PERCENT)));
0341 
0342     toolTip = plain(toolTipStr(CAL_NAME, todo, QDate(), false));
0343     QVERIFY(toolTip.contains(field(COMPLETED, dateTimeToString(START_DT.addMonths(1), ALL_DAY, false))));
0344     QVERIFY(!toolTip.contains(field(PERCENT)));
0345 }
0346 
0347 // Tool tips for recurring to-dos should contain a "completed" field instead of
0348 // a percentage field after the last occurrence has been marked as complete.
0349 void TestTodoToolTip::testTimedRecurringDone()
0350 {
0351     auto todo = makeToDo(!ALL_DAY, RECURS, START_DT, DUE_DT);
0352     todo->setCompleted(START_DT.addDays(14)); // Complete the second occurrence.
0353     todo->setCompleted(START_DT.addMonths(1)); // Complete the third occurrence.
0354 
0355     auto toolTip = plain(toolTipStr(CAL_NAME, todo, AS_OF_DATE, false));
0356     QVERIFY(toolTip.contains(field(COMPLETED, dateTimeToString(START_DT.addMonths(1), !ALL_DAY, false))));
0357     QVERIFY(!toolTip.contains(field(PERCENT)));
0358 
0359     toolTip = plain(toolTipStr(CAL_NAME, todo, QDate(), false));
0360     QVERIFY(toolTip.contains(field(COMPLETED, dateTimeToString(START_DT.addMonths(1), !ALL_DAY, false))));
0361     QVERIFY(!toolTip.contains(field(PERCENT)));
0362 }
0363 
0364 // Tool tips should only contain a "priority" field if the priority is not zero.
0365 void TestTodoToolTip::testPriority()
0366 {
0367     auto todo = makeToDo(!ALL_DAY, RECURS, START_DT, DUE_DT);
0368 
0369     auto toolTip = plain(toolTipStr(CAL_NAME, todo, AS_OF_DATE, false));
0370     QVERIFY(!toolTip.contains(field(PRIORITY)));
0371 
0372     todo->setPriority(5);
0373     toolTip = plain(toolTipStr(CAL_NAME, todo, AS_OF_DATE, false));
0374     QVERIFY(toolTip.contains(field(PRIORITY, QStringLiteral("5"))));
0375 }
0376 
0377 QTEST_MAIN(TestTodoToolTip)
0378 
0379 #include "moc_testtodotooltip.cpp"