! * simple search ignoring data types, column-major order */
| 1670 | * simple search ignoring data types, column-major order |
| 1671 | */ |
| 1672 | void SpreadsheetTest::testSearchSimple00() { |
| 1673 | Project project; |
| 1674 | auto* sheet = createSearchReplaceSpreadsheet(); |
| 1675 | project.addChild(sheet); |
| 1676 | |
| 1677 | // navigate to the (0,0) cell having the text value "A" |
| 1678 | auto* view = static_cast<SpreadsheetView*>(sheet->view()); |
| 1679 | view->goToCell(0, 0); |
| 1680 | |
| 1681 | // check the initial selection |
| 1682 | auto indexes = view->selectionModel()->selectedIndexes(); |
| 1683 | QCOMPARE(indexes.count(), 1); |
| 1684 | auto curIndex = indexes.constFirst(); |
| 1685 | QCOMPARE(curIndex.row(), 0); |
| 1686 | QCOMPARE(curIndex.column(), 0); |
| 1687 | |
| 1688 | // initialize the search&replace widget |
| 1689 | auto* searchReplaceWidget = new SearchReplaceWidget(sheet, view); |
| 1690 | searchReplaceWidget->setReplaceEnabled(false); |
| 1691 | const auto& firstIndex = indexes.constFirst(); |
| 1692 | const auto* column = sheet->column(firstIndex.column()); |
| 1693 | const int row = firstIndex.row(); |
| 1694 | searchReplaceWidget->setInitialPattern(column->columnMode(), column->asStringColumn()->textAt(row)); |
| 1695 | |
| 1696 | // checks: the initial cell text is "A", we navigate with 'next' |
| 1697 | // and then back with 'prev' in the column-major order looking for "A" |
| 1698 | |
| 1699 | // next |
| 1700 | searchReplaceWidget->findNextSimple(true); |
| 1701 | indexes = view->selectionModel()->selectedIndexes(); |
| 1702 | QCOMPARE(indexes.count(), 1); |
| 1703 | curIndex = indexes.constFirst(); |
| 1704 | QCOMPARE(curIndex.row(), 2); |
| 1705 | QCOMPARE(curIndex.column(), 0); |
| 1706 | |
| 1707 | // next |
| 1708 | searchReplaceWidget->findNextSimple(true); |
| 1709 | indexes = view->selectionModel()->selectedIndexes(); |
| 1710 | QCOMPARE(indexes.count(), 1); |
| 1711 | curIndex = indexes.constFirst(); |
| 1712 | QCOMPARE(curIndex.row(), 1); |
| 1713 | QCOMPARE(curIndex.column(), 2); |
| 1714 | |
| 1715 | // next |
| 1716 | searchReplaceWidget->findNextSimple(true); |
| 1717 | indexes = view->selectionModel()->selectedIndexes(); |
| 1718 | QCOMPARE(indexes.count(), 1); |
| 1719 | curIndex = indexes.constFirst(); |
| 1720 | QCOMPARE(curIndex.row(), 3); |
| 1721 | QCOMPARE(curIndex.column(), 2); |
| 1722 | |
| 1723 | // next, last matching cell reached |
| 1724 | searchReplaceWidget->findNextSimple(true); |
| 1725 | indexes = view->selectionModel()->selectedIndexes(); |
| 1726 | QCOMPARE(indexes.count(), 1); |
| 1727 | curIndex = indexes.constFirst(); |
| 1728 | QCOMPARE(curIndex.row(), 3); |
| 1729 | QCOMPARE(curIndex.column(), 2); |
nothing calls this directly
no test coverage detected