| 1339 | } |
| 1340 | |
| 1341 | void ColumnTest::testRemoveRow() { |
| 1342 | Project project; |
| 1343 | auto* c = new Column(QStringLiteral("Test"), Column::ColumnMode::Double); |
| 1344 | project.addChild(c); |
| 1345 | c->resizeTo(100); |
| 1346 | QCOMPARE(c->rowCount(), 100); |
| 1347 | |
| 1348 | int rowsAboutToBeInsertedCounter = 0; |
| 1349 | connect(c, &Column::rowsAboutToBeInserted, [&rowsAboutToBeInsertedCounter, c](const AbstractColumn* source, int before, int count) { |
| 1350 | QCOMPARE(source, c); |
| 1351 | QCOMPARE(before, 96); |
| 1352 | QCOMPARE(count, 3); |
| 1353 | rowsAboutToBeInsertedCounter++; |
| 1354 | }); |
| 1355 | |
| 1356 | int rowsAboutToBeRemovedCounter = 0; |
| 1357 | connect(c, &Column::rowsAboutToBeRemoved, [&rowsAboutToBeRemovedCounter, c](const AbstractColumn* source, int first, int count) { |
| 1358 | QCOMPARE(source, c); |
| 1359 | switch (rowsAboutToBeRemovedCounter) { |
| 1360 | case 0: |
| 1361 | QCOMPARE(first, 99); |
| 1362 | QCOMPARE(count, 1); |
| 1363 | break; |
| 1364 | case 1: |
| 1365 | QCOMPARE(first, 96); |
| 1366 | QCOMPARE(count, 3); |
| 1367 | break; |
| 1368 | case 2: // redo() |
| 1369 | QCOMPARE(first, 96); |
| 1370 | QCOMPARE(count, 3); |
| 1371 | break; |
| 1372 | } |
| 1373 | rowsAboutToBeRemovedCounter++; |
| 1374 | }); |
| 1375 | |
| 1376 | int rowsInsertedCounter = 0; |
| 1377 | connect(c, &Column::rowsInserted, [&rowsInsertedCounter, c](const AbstractColumn* source, int before, int count) { |
| 1378 | QCOMPARE(source, c); |
| 1379 | |
| 1380 | QCOMPARE(before, 96); |
| 1381 | QCOMPARE(count, 3); |
| 1382 | |
| 1383 | rowsInsertedCounter++; |
| 1384 | }); |
| 1385 | |
| 1386 | int rowsRemovedCounter = 0; |
| 1387 | connect(c, &Column::rowsRemoved, [&rowsRemovedCounter, c](const AbstractColumn* source, int first, int count) { |
| 1388 | QCOMPARE(source, c); |
| 1389 | |
| 1390 | switch (rowsRemovedCounter) { |
| 1391 | case 0: |
| 1392 | QCOMPARE(first, 99); |
| 1393 | QCOMPARE(count, 1); |
| 1394 | break; |
| 1395 | case 1: |
| 1396 | QCOMPARE(first, 96); |
| 1397 | QCOMPARE(count, 3); |
| 1398 | break; |