! * check the position of the statistics spreadsheet in the list of children of the parent * spreadsheet, it should always be put at the last position. */
| 3210 | * spreadsheet, it should always be put at the last position. |
| 3211 | */ |
| 3212 | void SpreadsheetTest::testStatisticsSpreadsheetChildIndex() { |
| 3213 | Project project; |
| 3214 | auto* sheet = new Spreadsheet(QStringLiteral("test"), false); |
| 3215 | project.addChild(sheet); |
| 3216 | |
| 3217 | // toggle on the statistics spreadsheet and count the available columns |
| 3218 | sheet->toggleStatisticsSpreadsheet(true); |
| 3219 | auto* statisticsSpreadsheet = sheet->children<StatisticsSpreadsheet>().constFirst(); |
| 3220 | |
| 3221 | // set the column count and check the position of the statistics spreadsheet |
| 3222 | sheet->setColumnCount(2); |
| 3223 | QCOMPARE(sheet->indexOfChild<AbstractAspect>(statisticsSpreadsheet), 2); |
| 3224 | |
| 3225 | // change the column count and check the position again |
| 3226 | sheet->setColumnCount(3); |
| 3227 | QCOMPARE(sheet->indexOfChild<AbstractAspect>(statisticsSpreadsheet), 3); |
| 3228 | |
| 3229 | // append one more column and check the position again |
| 3230 | sheet->appendColumn(); |
| 3231 | QCOMPARE(sheet->indexOfChild<AbstractAspect>(statisticsSpreadsheet), 4); |
| 3232 | |
| 3233 | // check also the position when adding new columns via the actions in the view that also |
| 3234 | // take the current selected column into account and have more logic for "append left to" |
| 3235 | // and "append right to" - ensure no columns are added after the statistics spreadhseet |
| 3236 | auto* view = static_cast<SpreadsheetView*>(sheet->view()); |
| 3237 | |
| 3238 | // insert a new column right to the last selected column, it should be placed in front of the statistics spreadsheet |
| 3239 | view->selectColumn(3); // select the last 4th column |
| 3240 | view->insertColumnsRight(1); |
| 3241 | QCOMPARE(sheet->indexOfChild<AbstractAspect>(statisticsSpreadsheet), 5); |
| 3242 | } |
| 3243 | |
| 3244 | /*! |
| 3245 | * check the position of the statistics spreadsheet in the list of children of the parent |
nothing calls this directly
no test coverage detected