| 714 | } |
| 715 | |
| 716 | void templateTableModelTest() |
| 717 | { |
| 718 | Map map; |
| 719 | MapView view{ &map }; |
| 720 | QVERIFY(map.loadFrom(QStringLiteral("testdata:templates/world-file.xmap"), &view)); |
| 721 | QCOMPARE(map.getNumTemplates(), 1); |
| 722 | |
| 723 | TemplateTableModel model(map, view); |
| 724 | QCOMPARE(model.rowCount(), 2); |
| 725 | |
| 726 | // Single template, in background |
| 727 | QCOMPARE(map.getFirstFrontTemplate(), 1); |
| 728 | QCOMPARE(model.mapRow(map.getFirstFrontTemplate()), 0); |
| 729 | QCOMPARE(model.posFromRow(0), -1); |
| 730 | QCOMPARE(model.rowFromPos(0), 1); |
| 731 | QCOMPARE(model.posFromRow(1), 0); |
| 732 | // Three possible calls in onTemplateAboutToBeAdded |
| 733 | QCOMPARE(model.insertionRowFromPos(0, true), 2); |
| 734 | QCOMPARE(model.insertionRowFromPos(1, true), 1); |
| 735 | QCOMPARE(model.insertionRowFromPos(1, false), 0); |
| 736 | |
| 737 | // Single template, in foreground |
| 738 | map.setFirstFrontTemplate(0); |
| 739 | QCOMPARE(model.mapRow(map.getFirstFrontTemplate()), 1); |
| 740 | QCOMPARE(model.posFromRow(1), -1); |
| 741 | QCOMPARE(model.rowFromPos(0), 0); |
| 742 | QCOMPARE(model.posFromRow(0), 0); |
| 743 | // Three possible calls in onTemplateAboutToBeAdded |
| 744 | QCOMPARE(model.insertionRowFromPos(0, true), 2); |
| 745 | QCOMPARE(model.insertionRowFromPos(0, false), 1); |
| 746 | QCOMPARE(model.insertionRowFromPos(1, false), 0); |
| 747 | } |
| 748 | |
| 749 | }; |
| 750 |
nothing calls this directly
no test coverage detected