! * search for Numeric, column-major order */
| 1935 | * search for Numeric, column-major order |
| 1936 | */ |
| 1937 | void SpreadsheetTest::testSearchExtended02() { |
| 1938 | #ifdef __FreeBSD__ |
| 1939 | // ASSERT failure in QBoxLayout::insert: "index out of range" |
| 1940 | return; |
| 1941 | #endif |
| 1942 | Project project; |
| 1943 | auto* sheet = createSearchReplaceSpreadsheet(); |
| 1944 | project.addChild(sheet); |
| 1945 | |
| 1946 | // navigate to the (1,1) cell having the numeric value "2" |
| 1947 | auto* view = static_cast<SpreadsheetView*>(sheet->view()); |
| 1948 | view->goToCell(1, 1); |
| 1949 | |
| 1950 | // check the initial selection |
| 1951 | auto indexes = view->selectionModel()->selectedIndexes(); |
| 1952 | QCOMPARE(indexes.count(), 1); |
| 1953 | auto curIndex = indexes.constFirst(); |
| 1954 | QCOMPARE(curIndex.row(), 1); |
| 1955 | QCOMPARE(curIndex.column(), 1); |
| 1956 | |
| 1957 | // initialize the search&replace widget |
| 1958 | auto* searchReplaceWidget = new SearchReplaceWidget(sheet, view); |
| 1959 | searchReplaceWidget->setReplaceEnabled(true); |
| 1960 | searchReplaceWidget->setDataType(SearchReplaceWidget::DataType::Numeric); |
| 1961 | searchReplaceWidget->setOrder(SearchReplaceWidget::Order::ColumnMajor); |
| 1962 | const auto& firstIndex = indexes.constFirst(); |
| 1963 | const auto* column = sheet->column(firstIndex.column()); |
| 1964 | const int row = firstIndex.row(); |
| 1965 | searchReplaceWidget->setInitialPattern(column->columnMode(), column->asStringColumn()->textAt(row)); |
| 1966 | |
| 1967 | // checks: the initial cell text is "2", we navigate with 'next' |
| 1968 | // and then back with 'prev' in the column-major order looking for "2" |
| 1969 | |
| 1970 | // next |
| 1971 | searchReplaceWidget->findNext(true); |
| 1972 | indexes = view->selectionModel()->selectedIndexes(); |
| 1973 | QCOMPARE(indexes.count(), 1); |
| 1974 | curIndex = indexes.constFirst(); |
| 1975 | QCOMPARE(curIndex.row(), 3); |
| 1976 | QCOMPARE(curIndex.column(), 1); |
| 1977 | |
| 1978 | // next |
| 1979 | searchReplaceWidget->findNext(true); |
| 1980 | indexes = view->selectionModel()->selectedIndexes(); |
| 1981 | QCOMPARE(indexes.count(), 1); |
| 1982 | curIndex = indexes.constFirst(); |
| 1983 | QCOMPARE(curIndex.row(), 2); |
| 1984 | QCOMPARE(curIndex.column(), 3); |
| 1985 | |
| 1986 | // next, last matching cell reached |
| 1987 | searchReplaceWidget->findNext(true); |
| 1988 | indexes = view->selectionModel()->selectedIndexes(); |
| 1989 | QCOMPARE(indexes.count(), 1); |
| 1990 | curIndex = indexes.constFirst(); |
| 1991 | QCOMPARE(curIndex.row(), 2); |
| 1992 | QCOMPARE(curIndex.column(), 3); |
| 1993 | |
| 1994 | // previous |
nothing calls this directly
no test coverage detected