Changeset View
Changeset View
Standalone View
Standalone View
tests/units/widgets/editorviewtest.cpp
Show All 21 Lines | |||||
22 | */ | 22 | */ | ||
23 | 23 | | |||
24 | #include <testlib/qtest_gui_zanshin.h> | 24 | #include <testlib/qtest_gui_zanshin.h> | ||
25 | 25 | | |||
26 | #include <QAbstractButton> | 26 | #include <QAbstractButton> | ||
27 | #include <QLabel> | 27 | #include <QLabel> | ||
28 | #include <QPlainTextEdit> | 28 | #include <QPlainTextEdit> | ||
29 | 29 | | |||
30 | #include <KLocalizedString> | ||||
31 | | ||||
30 | #include "domain/note.h" | 32 | #include "domain/note.h" | ||
31 | #include "domain/task.h" | 33 | #include "domain/task.h" | ||
32 | 34 | | |||
33 | #include "widgets/editorview.h" | 35 | #include "widgets/editorview.h" | ||
34 | 36 | | |||
35 | #include "addressline/addresseelineedit.h" | 37 | #include "addressline/addresseelineedit.h" | ||
36 | #include "kdateedit.h" | 38 | #include "kdateedit.h" | ||
37 | 39 | | |||
▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Line(s) | 225 | { | |||
229 | 231 | | |||
230 | auto delegateLabel = editor.findChild<QLabel*>(QStringLiteral("delegateLabel")); | 232 | auto delegateLabel = editor.findChild<QLabel*>(QStringLiteral("delegateLabel")); | ||
231 | QVERIFY(!delegateLabel->isVisibleTo(&editor)); | 233 | QVERIFY(!delegateLabel->isVisibleTo(&editor)); | ||
232 | 234 | | |||
233 | // WHEN | 235 | // WHEN | ||
234 | editor.setModel(&model); | 236 | editor.setModel(&model); | ||
235 | 237 | | |||
236 | // THEN | 238 | // THEN | ||
237 | auto expectedText = tr("Delegated to: <b>%1</b>").arg(model.property("delegateText").toString()); | 239 | auto expectedText = i18n("Delegated to: <b>%1</b>", model.property("delegateText").toString()); | ||
238 | QVERIFY(delegateLabel->isVisibleTo(&editor)); | 240 | QVERIFY(delegateLabel->isVisibleTo(&editor)); | ||
239 | QCOMPARE(delegateLabel->text(), expectedText); | 241 | QCOMPARE(delegateLabel->text(), expectedText); | ||
240 | } | 242 | } | ||
241 | 243 | | |||
242 | void shouldBeEnabledOnlyWhenAnArtifactIsAvailable() | 244 | void shouldBeEnabledOnlyWhenAnArtifactIsAvailable() | ||
243 | { | 245 | { | ||
244 | // GIVEN | 246 | // GIVEN | ||
245 | Widgets::EditorView editor; | 247 | Widgets::EditorView editor; | ||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Line(s) | 340 | { | |||
372 | delegateEdit->setFocus(); | 374 | delegateEdit->setFocus(); | ||
373 | model.setDelegateText(QStringLiteral("John Smith")); | 375 | model.setDelegateText(QStringLiteral("John Smith")); | ||
374 | 376 | | |||
375 | // THEN (nothing changed) | 377 | // THEN (nothing changed) | ||
376 | QCOMPARE(textEdit->toPlainText(), QStringLiteral("My title\n\nMy text")); | 378 | QCOMPARE(textEdit->toPlainText(), QStringLiteral("My title\n\nMy text")); | ||
377 | QCOMPARE(startDateEdit->date(), QDate::currentDate()); | 379 | QCOMPARE(startDateEdit->date(), QDate::currentDate()); | ||
378 | QCOMPARE(dueDateEdit->date(), QDate::currentDate().addDays(2)); | 380 | QCOMPARE(dueDateEdit->date(), QDate::currentDate().addDays(2)); | ||
379 | QVERIFY(doneButton->isChecked()); | 381 | QVERIFY(doneButton->isChecked()); | ||
380 | auto expectedText = tr("Delegated to: <b>%1</b>").arg(QStringLiteral("John Doe")); | 382 | auto expectedText = i18n("Delegated to: <b>%1</b>", QStringLiteral("John Doe")); | ||
381 | QCOMPARE(delegateLabel->text(), expectedText); | 383 | QCOMPARE(delegateLabel->text(), expectedText); | ||
382 | 384 | | |||
383 | } | 385 | } | ||
384 | 386 | | |||
385 | void shouldReactToTitleChanges() | 387 | void shouldReactToTitleChanges() | ||
386 | { | 388 | { | ||
387 | // GIVEN | 389 | // GIVEN | ||
388 | Widgets::EditorView editor; | 390 | Widgets::EditorView editor; | ||
▲ Show 20 Lines • Show All 228 Lines • ▼ Show 20 Line(s) | 613 | { | |||
617 | editor.setModel(&model); | 619 | editor.setModel(&model); | ||
618 | 620 | | |||
619 | auto delegateLabel = editor.findChild<QLabel*>(QStringLiteral("delegateLabel")); | 621 | auto delegateLabel = editor.findChild<QLabel*>(QStringLiteral("delegateLabel")); | ||
620 | 622 | | |||
621 | // WHEN | 623 | // WHEN | ||
622 | model.setDelegateText(QStringLiteral("John Smith")); | 624 | model.setDelegateText(QStringLiteral("John Smith")); | ||
623 | 625 | | |||
624 | // THEN | 626 | // THEN | ||
625 | auto expectedText = tr("Delegated to: <b>%1</b>").arg(model.property("delegateText").toString()); | 627 | auto expectedText = i18n("Delegated to: <b>%1</b>", model.property("delegateText").toString()); | ||
626 | QCOMPARE(delegateLabel->text(), expectedText); | 628 | QCOMPARE(delegateLabel->text(), expectedText); | ||
627 | } | 629 | } | ||
628 | 630 | | |||
629 | void shouldClearDelegateEditOnArtifactChanges() | 631 | void shouldClearDelegateEditOnArtifactChanges() | ||
630 | { | 632 | { | ||
631 | // GIVEN | 633 | // GIVEN | ||
632 | Widgets::EditorView editor; | 634 | Widgets::EditorView editor; | ||
633 | EditorModelStub model; | 635 | EditorModelStub model; | ||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |