| 2780 | } |
| 2781 | |
| 2782 | void SpreadsheetTest::testLinkSpreadsheetDeleteAdd() { |
| 2783 | #ifdef __FreeBSD__ |
| 2784 | return; |
| 2785 | #endif |
| 2786 | Project project; |
| 2787 | auto* sheetData = new Spreadsheet(QStringLiteral("data"), false); |
| 2788 | project.addChild(sheetData); |
| 2789 | sheetData->setColumnCount(3); |
| 2790 | sheetData->setRowCount(10); |
| 2791 | |
| 2792 | auto* sheetCalculations = new Spreadsheet(QStringLiteral("calculations"), false); |
| 2793 | project.addChild(sheetCalculations); |
| 2794 | sheetCalculations->setColumnCount(3); |
| 2795 | sheetCalculations->setRowCount(2); |
| 2796 | |
| 2797 | SpreadsheetDock dock(nullptr); |
| 2798 | dock.setSpreadsheets({sheetCalculations}); |
| 2799 | |
| 2800 | QCOMPARE(dock.ui.cbLinkingEnabled->isChecked(), false); |
| 2801 | QCOMPARE(dock.ui.cbLinkedSpreadsheet->isVisible(), false); |
| 2802 | QCOMPARE(dock.ui.sbRowCount->isEnabled(), true); |
| 2803 | QCOMPARE(sheetCalculations->linking(), false); |
| 2804 | |
| 2805 | Q_EMIT dock.ui.cbLinkingEnabled->toggled(true); |
| 2806 | |
| 2807 | sheetCalculations->setLinkedSpreadsheet(sheetData); |
| 2808 | |
| 2809 | QCOMPARE(sheetCalculations->linking(), true); |
| 2810 | QCOMPARE(sheetCalculations->linkedSpreadsheet(), sheetData); |
| 2811 | QCOMPARE(sheetCalculations->linkedSpreadsheetPath(), sheetData->path()); |
| 2812 | QCOMPARE(sheetCalculations->rowCount(), 10); |
| 2813 | |
| 2814 | sheetData->remove(); |
| 2815 | sheetData->setRowCount(100); |
| 2816 | |
| 2817 | QCOMPARE(sheetCalculations->linking(), true); |
| 2818 | QCOMPARE(sheetCalculations->linkedSpreadsheet(), nullptr); |
| 2819 | QCOMPARE(sheetCalculations->linkedSpreadsheetPath(), i18n("Project") + QStringLiteral("/data")); |
| 2820 | QCOMPARE(sheetCalculations->rowCount(), 10); // does not change |
| 2821 | |
| 2822 | auto* sheetDataNew = new Spreadsheet(QStringLiteral("data"), false); |
| 2823 | sheetDataNew->setColumnCount(3); |
| 2824 | sheetDataNew->setRowCount(12); |
| 2825 | project.addChild(sheetDataNew); |
| 2826 | |
| 2827 | QCOMPARE(sheetCalculations->linking(), true); |
| 2828 | QCOMPARE(sheetCalculations->linkedSpreadsheet(), sheetDataNew); |
| 2829 | QCOMPARE(sheetCalculations->linkedSpreadsheetPath(), sheetDataNew->path()); |
| 2830 | QCOMPARE(sheetCalculations->rowCount(), 12); |
| 2831 | } |
| 2832 | |
| 2833 | void SpreadsheetTest::testLinkSpreadsheetAddRow() { |
| 2834 | #ifdef __FreeBSD__ |
nothing calls this directly
no test coverage detected