Changeset View
Changeset View
Standalone View
Standalone View
tests/units/widgets/pageviewtest.cpp
Show First 20 Lines • Show All 269 Lines • ▼ Show 20 Line(s) | 269 | { | |||
---|---|---|---|---|---|
270 | // GIVEN | 270 | // GIVEN | ||
271 | Widgets::PageView page; | 271 | Widgets::PageView page; | ||
272 | auto centralView = page.findChild<QTreeView*>(QStringLiteral("centralView")); | 272 | auto centralView = page.findChild<QTreeView*>(QStringLiteral("centralView")); | ||
273 | auto quickAddEdit = page.findChild<QLineEdit*>(QStringLiteral("quickAddEdit")); | 273 | auto quickAddEdit = page.findChild<QLineEdit*>(QStringLiteral("quickAddEdit")); | ||
274 | auto filter = page.findChild<Widgets::FilterWidget*>(QStringLiteral("filterWidget")); | 274 | auto filter = page.findChild<Widgets::FilterWidget*>(QStringLiteral("filterWidget")); | ||
275 | auto filterEdit = filter->findChild<QLineEdit*>(); | 275 | auto filterEdit = filter->findChild<QLineEdit*>(); | ||
276 | QVERIFY(filterEdit); | 276 | QVERIFY(filterEdit); | ||
277 | page.show(); | 277 | page.show(); | ||
278 | QVERIFY(QTest::qWaitForWindowShown(&page)); | 278 | QVERIFY(QTest::qWaitForWindowExposed(&page)); | ||
279 | 279 | | |||
280 | centralView->setFocus(); | 280 | centralView->setFocus(); | ||
281 | QVERIFY(centralView->hasFocus()); | 281 | QVERIFY(centralView->hasFocus()); | ||
282 | QVERIFY(!quickAddEdit->hasFocus()); | 282 | QVERIFY(!quickAddEdit->hasFocus()); | ||
283 | QVERIFY(!filter->isVisibleTo(&page)); | 283 | QVERIFY(!filter->isVisibleTo(&page)); | ||
284 | QVERIFY(!filterEdit->hasFocus()); | 284 | QVERIFY(!filterEdit->hasFocus()); | ||
285 | 285 | | |||
286 | auto addAction = page.findChild<QAction*>(QStringLiteral("addItemAction")); | 286 | auto addAction = page.findChild<QAction*>(QStringLiteral("addItemAction")); | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
328 | { | 328 | { | ||
329 | // GIVEN | 329 | // GIVEN | ||
330 | Widgets::PageView page; | 330 | Widgets::PageView page; | ||
331 | auto centralView = page.findChild<QTreeView*>(QStringLiteral("centralView")); | 331 | auto centralView = page.findChild<QTreeView*>(QStringLiteral("centralView")); | ||
332 | auto filter = page.findChild<Widgets::FilterWidget*>(QStringLiteral("filterWidget")); | 332 | auto filter = page.findChild<Widgets::FilterWidget*>(QStringLiteral("filterWidget")); | ||
333 | auto filterEdit = filter->findChild<QLineEdit*>(); | 333 | auto filterEdit = filter->findChild<QLineEdit*>(); | ||
334 | QVERIFY(filterEdit); | 334 | QVERIFY(filterEdit); | ||
335 | page.show(); | 335 | page.show(); | ||
336 | QVERIFY(QTest::qWaitForWindowShown(&page)); | 336 | QVERIFY(QTest::qWaitForWindowExposed(&page)); | ||
337 | 337 | | |||
338 | centralView->setFocus(); | 338 | centralView->setFocus(); | ||
339 | QVERIFY(centralView->hasFocus()); | 339 | QVERIFY(centralView->hasFocus()); | ||
340 | QVERIFY(!filter->isVisibleTo(&page)); | 340 | QVERIFY(!filter->isVisibleTo(&page)); | ||
341 | QVERIFY(!filterEdit->hasFocus()); | 341 | QVERIFY(!filterEdit->hasFocus()); | ||
342 | 342 | | |||
343 | auto filterAction = page.findChild<QAction*>(QStringLiteral("filterViewAction")); | 343 | auto filterAction = page.findChild<QAction*>(QStringLiteral("filterViewAction")); | ||
344 | 344 | | |||
▲ Show 20 Lines • Show All 205 Lines • ▼ Show 20 Line(s) | 542 | { | |||
550 | page.setModel(&stubPageModel); | 550 | page.setModel(&stubPageModel); | ||
551 | 551 | | |||
552 | QTreeView *centralView = page.findChild<QTreeView*>(QStringLiteral("centralView")); | 552 | QTreeView *centralView = page.findChild<QTreeView*>(QStringLiteral("centralView")); | ||
553 | centralView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); | 553 | centralView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); | ||
554 | centralView->setFocus(); | 554 | centralView->setFocus(); | ||
555 | 555 | | |||
556 | // Needed for shortcuts to work | 556 | // Needed for shortcuts to work | ||
557 | page.show(); | 557 | page.show(); | ||
558 | QVERIFY(QTest::qWaitForWindowShown(&page)); | 558 | QVERIFY(QTest::qWaitForWindowExposed(&page)); | ||
559 | QTest::qWait(100); | 559 | QTest::qWait(100); | ||
560 | 560 | | |||
561 | // WHEN | 561 | // WHEN | ||
562 | QTest::keyPress(centralView, Qt::Key_Delete); | 562 | QTest::keyPress(centralView, Qt::Key_Delete); | ||
563 | 563 | | |||
564 | // THEN | 564 | // THEN | ||
565 | QCOMPARE(stubPageModel.removedIndices.size(), 1); | 565 | QCOMPARE(stubPageModel.removedIndices.size(), 1); | ||
566 | QCOMPARE(stubPageModel.removedIndices.first(), index); | 566 | QCOMPARE(stubPageModel.removedIndices.first(), index); | ||
Show All 10 Lines | 570 | { | |||
577 | page.setModel(&stubPageModel); | 577 | page.setModel(&stubPageModel); | ||
578 | 578 | | |||
579 | QTreeView *centralView = page.findChild<QTreeView*>(QStringLiteral("centralView")); | 579 | QTreeView *centralView = page.findChild<QTreeView*>(QStringLiteral("centralView")); | ||
580 | centralView->clearSelection(); | 580 | centralView->clearSelection(); | ||
581 | page.findChild<QLineEdit*>(QStringLiteral("quickAddEdit"))->setFocus(); | 581 | page.findChild<QLineEdit*>(QStringLiteral("quickAddEdit"))->setFocus(); | ||
582 | 582 | | |||
583 | // Needed for shortcuts to work | 583 | // Needed for shortcuts to work | ||
584 | page.show(); | 584 | page.show(); | ||
585 | QVERIFY(QTest::qWaitForWindowShown(&page)); | 585 | QVERIFY(QTest::qWaitForWindowExposed(&page)); | ||
586 | QTest::qWait(100); | 586 | QTest::qWait(100); | ||
587 | 587 | | |||
588 | // WHEN | 588 | // WHEN | ||
589 | QTest::keyPress(centralView, Qt::Key_Delete); | 589 | QTest::keyPress(centralView, Qt::Key_Delete); | ||
590 | 590 | | |||
591 | // THEN | 591 | // THEN | ||
592 | QVERIFY(stubPageModel.removedIndices.isEmpty()); | 592 | QVERIFY(stubPageModel.removedIndices.isEmpty()); | ||
593 | } | 593 | } | ||
Show All 15 Lines | 596 | { | |||
609 | 609 | | |||
610 | QTreeView *centralView = page.findChild<QTreeView*>(QStringLiteral("centralView")); | 610 | QTreeView *centralView = page.findChild<QTreeView*>(QStringLiteral("centralView")); | ||
611 | centralView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); | 611 | centralView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); | ||
612 | QVERIFY(centralView->selectionModel()->currentIndex().isValid()); | 612 | QVERIFY(centralView->selectionModel()->currentIndex().isValid()); | ||
613 | centralView->setFocus(); | 613 | centralView->setFocus(); | ||
614 | 614 | | |||
615 | // Needed for shortcuts to work | 615 | // Needed for shortcuts to work | ||
616 | page.show(); | 616 | page.show(); | ||
617 | QVERIFY(QTest::qWaitForWindowShown(&page)); | 617 | QVERIFY(QTest::qWaitForWindowExposed(&page)); | ||
618 | QTest::qWait(100); | 618 | QTest::qWait(100); | ||
619 | 619 | | |||
620 | // WHEN | 620 | // WHEN | ||
621 | QTest::keyPress(centralView, Qt::Key_Delete); | 621 | QTest::keyPress(centralView, Qt::Key_Delete); | ||
622 | 622 | | |||
623 | // THEN | 623 | // THEN | ||
624 | QVERIFY(msgbox->called()); | 624 | QVERIFY(msgbox->called()); | ||
625 | QCOMPARE(stubPageModel.removedIndices.size(), 1); | 625 | QCOMPARE(stubPageModel.removedIndices.size(), 1); | ||
Show All 22 Lines | 630 | { | |||
648 | 648 | | |||
649 | QTreeView *centralView = page.findChild<QTreeView*>(QStringLiteral("centralView")); | 649 | QTreeView *centralView = page.findChild<QTreeView*>(QStringLiteral("centralView")); | ||
650 | centralView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); | 650 | centralView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); | ||
651 | QVERIFY(centralView->selectionModel()->currentIndex().isValid()); | 651 | QVERIFY(centralView->selectionModel()->currentIndex().isValid()); | ||
652 | centralView->setFocus(); | 652 | centralView->setFocus(); | ||
653 | 653 | | |||
654 | // Needed for shortcuts to work | 654 | // Needed for shortcuts to work | ||
655 | page.show(); | 655 | page.show(); | ||
656 | QVERIFY(QTest::qWaitForWindowShown(&page)); | 656 | QVERIFY(QTest::qWaitForWindowExposed(&page)); | ||
657 | QTest::qWait(100); | 657 | QTest::qWait(100); | ||
658 | 658 | | |||
659 | // WHEN | 659 | // WHEN | ||
660 | QTest::keyPress(centralView, Qt::Key_Delete); | 660 | QTest::keyPress(centralView, Qt::Key_Delete); | ||
661 | 661 | | |||
662 | // THEN | 662 | // THEN | ||
663 | QVERIFY(msgbox->called()); | 663 | QVERIFY(msgbox->called()); | ||
664 | QCOMPARE(stubPageModel.removedIndices.size(), 1); | 664 | QCOMPARE(stubPageModel.removedIndices.size(), 1); | ||
Show All 16 Lines | 669 | { | |||
681 | 681 | | |||
682 | QTreeView *centralView = page.findChild<QTreeView*>(QStringLiteral("centralView")); | 682 | QTreeView *centralView = page.findChild<QTreeView*>(QStringLiteral("centralView")); | ||
683 | centralView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); | 683 | centralView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); | ||
684 | centralView->selectionModel()->setCurrentIndex(index2, QItemSelectionModel::Select); | 684 | centralView->selectionModel()->setCurrentIndex(index2, QItemSelectionModel::Select); | ||
685 | centralView->setFocus(); | 685 | centralView->setFocus(); | ||
686 | 686 | | |||
687 | // Needed for shortcuts to work | 687 | // Needed for shortcuts to work | ||
688 | page.show(); | 688 | page.show(); | ||
689 | QVERIFY(QTest::qWaitForWindowShown(&page)); | 689 | QVERIFY(QTest::qWaitForWindowExposed(&page)); | ||
690 | QTest::qWait(100); | 690 | QTest::qWait(100); | ||
691 | 691 | | |||
692 | // WHEN | 692 | // WHEN | ||
693 | QTest::keyPress(centralView, Qt::Key_Delete); | 693 | QTest::keyPress(centralView, Qt::Key_Delete); | ||
694 | 694 | | |||
695 | // THEN | 695 | // THEN | ||
696 | QVERIFY(msgbox->called()); | 696 | QVERIFY(msgbox->called()); | ||
697 | QCOMPARE(stubPageModel.removedIndices.size(), 2); | 697 | QCOMPARE(stubPageModel.removedIndices.size(), 2); | ||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Line(s) | 775 | { | |||
805 | QCOMPARE(selectedIndexes.at(1).model(), index2.model()); | 805 | QCOMPARE(selectedIndexes.at(1).model(), index2.model()); | ||
806 | } | 806 | } | ||
807 | 807 | | |||
808 | void shouldDisplayMessageOnError() | 808 | void shouldDisplayMessageOnError() | ||
809 | { | 809 | { | ||
810 | // GIVEN | 810 | // GIVEN | ||
811 | Widgets::PageView page; | 811 | Widgets::PageView page; | ||
812 | page.show(); | 812 | page.show(); | ||
813 | QVERIFY(QTest::qWaitForWindowShown(&page)); | 813 | QVERIFY(QTest::qWaitForWindowExposed(&page)); | ||
814 | QTest::qWait(100); | 814 | QTest::qWait(100); | ||
815 | 815 | | |||
816 | auto messageWidget = page.findChild<KMessageWidget*>(QStringLiteral("messageWidget")); | 816 | auto messageWidget = page.findChild<KMessageWidget*>(QStringLiteral("messageWidget")); | ||
817 | QVERIFY(messageWidget); | 817 | QVERIFY(messageWidget); | ||
818 | QVERIFY(!messageWidget->isVisibleTo(&page)); | 818 | QVERIFY(!messageWidget->isVisibleTo(&page)); | ||
819 | 819 | | |||
820 | QCOMPARE(messageWidget->findChildren<QToolButton*>().size(), 1); | 820 | QCOMPARE(messageWidget->findChildren<QToolButton*>().size(), 1); | ||
821 | auto closeButton = messageWidget->findChildren<QToolButton*>().first(); | 821 | auto closeButton = messageWidget->findChildren<QToolButton*>().first(); | ||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |