| 2831 | } |
| 2832 | |
| 2833 | void SpreadsheetTest::testLinkSpreadsheetAddRow() { |
| 2834 | #ifdef __FreeBSD__ |
| 2835 | return; |
| 2836 | #endif |
| 2837 | Project project; |
| 2838 | auto* sheetData = new Spreadsheet(QStringLiteral("data"), false); |
| 2839 | project.addChild(sheetData); |
| 2840 | sheetData->setColumnCount(3); |
| 2841 | sheetData->setRowCount(10); |
| 2842 | |
| 2843 | auto* sheetCalculations = new Spreadsheet(QStringLiteral("calculations"), false); |
| 2844 | project.addChild(sheetCalculations); |
| 2845 | sheetCalculations->setColumnCount(3); |
| 2846 | sheetCalculations->setRowCount(2); |
| 2847 | |
| 2848 | SpreadsheetDock dock(nullptr); |
| 2849 | dock.setSpreadsheets({sheetCalculations}); |
| 2850 | |
| 2851 | QCOMPARE(dock.ui.cbLinkingEnabled->isChecked(), false); |
| 2852 | QCOMPARE(dock.ui.cbLinkedSpreadsheet->isVisible(), false); |
| 2853 | QCOMPARE(dock.ui.sbRowCount->isEnabled(), true); |
| 2854 | QCOMPARE(sheetCalculations->linking(), false); |
| 2855 | |
| 2856 | Q_EMIT dock.ui.cbLinkingEnabled->toggled(true); |
| 2857 | |
| 2858 | sheetCalculations->setLinkedSpreadsheet(sheetData); |
| 2859 | |
| 2860 | QCOMPARE(sheetCalculations->linking(), true); |
| 2861 | QCOMPARE(sheetCalculations->linkedSpreadsheet(), sheetData); |
| 2862 | QCOMPARE(sheetCalculations->linkedSpreadsheetPath(), sheetData->path()); |
| 2863 | QCOMPARE(sheetCalculations->rowCount(), 10); |
| 2864 | |
| 2865 | new SpreadsheetModel(sheetData); // otherwise emitRowCountChanged will not be called |
| 2866 | sheetData->setRowCount(13); |
| 2867 | |
| 2868 | QCOMPARE(sheetCalculations->linking(), true); |
| 2869 | QCOMPARE(sheetCalculations->linkedSpreadsheet(), sheetData); |
| 2870 | QCOMPARE(sheetCalculations->linkedSpreadsheetPath(), sheetData->path()); |
| 2871 | QCOMPARE(sheetCalculations->rowCount(), 13); |
| 2872 | } |
| 2873 | |
| 2874 | void SpreadsheetTest::testLinkSpreadsheetRemoveRow() { |
| 2875 | #ifdef __FreeBSD__ |
nothing calls this directly
no test coverage detected