! * search for Numeric, row major */
| 2020 | * search for Numeric, row major |
| 2021 | */ |
| 2022 | void SpreadsheetTest::testSearchExtended03() { |
| 2023 | #ifdef __FreeBSD__ |
| 2024 | // ASSERT failure in QBoxLayout::insert: "index out of range" |
| 2025 | return; |
| 2026 | #endif |
| 2027 | Project project; |
| 2028 | auto* sheet = createSearchReplaceSpreadsheet(); |
| 2029 | project.addChild(sheet); |
| 2030 | |
| 2031 | // navigate to the (1,1) cell having the numeric value "2" |
| 2032 | auto* view = static_cast<SpreadsheetView*>(sheet->view()); |
| 2033 | view->goToCell(1, 1); |
| 2034 | |
| 2035 | // check the initial selection |
| 2036 | auto indexes = view->selectionModel()->selectedIndexes(); |
| 2037 | QCOMPARE(indexes.count(), 1); |
| 2038 | auto curIndex = indexes.constFirst(); |
| 2039 | QCOMPARE(curIndex.row(), 1); |
| 2040 | QCOMPARE(curIndex.column(), 1); |
| 2041 | |
| 2042 | // initialize the search&replace widget |
| 2043 | auto* searchReplaceWidget = new SearchReplaceWidget(sheet, view); |
| 2044 | searchReplaceWidget->setReplaceEnabled(true); |
| 2045 | searchReplaceWidget->setDataType(SearchReplaceWidget::DataType::Numeric); |
| 2046 | searchReplaceWidget->setOrder(SearchReplaceWidget::Order::RowMajor); |
| 2047 | const auto& firstIndex = indexes.constFirst(); |
| 2048 | const auto* column = sheet->column(firstIndex.column()); |
| 2049 | const int row = firstIndex.row(); |
| 2050 | searchReplaceWidget->setInitialPattern(column->columnMode(), column->asStringColumn()->textAt(row)); |
| 2051 | |
| 2052 | // checks: the initial cell text is "2", we navigate with 'next' |
| 2053 | // and then back with 'prev' in the column-major order looking for "2" |
| 2054 | |
| 2055 | // next |
| 2056 | searchReplaceWidget->findNext(true); |
| 2057 | indexes = view->selectionModel()->selectedIndexes(); |
| 2058 | QCOMPARE(indexes.count(), 1); |
| 2059 | curIndex = indexes.constFirst(); |
| 2060 | QCOMPARE(curIndex.row(), 2); |
| 2061 | QCOMPARE(curIndex.column(), 3); |
| 2062 | |
| 2063 | // next |
| 2064 | searchReplaceWidget->findNext(true); |
| 2065 | indexes = view->selectionModel()->selectedIndexes(); |
| 2066 | QCOMPARE(indexes.count(), 1); |
| 2067 | curIndex = indexes.constFirst(); |
| 2068 | QCOMPARE(curIndex.row(), 3); |
| 2069 | QCOMPARE(curIndex.column(), 1); |
| 2070 | |
| 2071 | // next, last matching cell reached |
| 2072 | searchReplaceWidget->findNext(true); |
| 2073 | indexes = view->selectionModel()->selectedIndexes(); |
| 2074 | QCOMPARE(indexes.count(), 1); |
| 2075 | curIndex = indexes.constFirst(); |
| 2076 | QCOMPARE(curIndex.row(), 3); |
| 2077 | QCOMPARE(curIndex.column(), 1); |
| 2078 | |
| 2079 | // previous |
nothing calls this directly
no test coverage detected