| 2102 | } |
| 2103 | |
| 2104 | void SpreadsheetTest::testSearchFindAll() { |
| 2105 | #ifdef __FreeBSD__ |
| 2106 | // ASSERT failure in QBoxLayout::insert: "index out of range" |
| 2107 | return; |
| 2108 | #endif |
| 2109 | Project project; |
| 2110 | auto* sheet = createSearchReplaceSpreadsheet(); |
| 2111 | project.addChild(sheet); |
| 2112 | |
| 2113 | // initialize the search&replace widget |
| 2114 | auto* searchReplaceWidget = new SearchReplaceWidget(sheet, nullptr); |
| 2115 | searchReplaceWidget->setReplaceEnabled(true); |
| 2116 | searchReplaceWidget->setDataType(SearchReplaceWidget::DataType::Text); |
| 2117 | searchReplaceWidget->setOrder(SearchReplaceWidget::Order::ColumnMajor); |
| 2118 | searchReplaceWidget->setTextOperator(SearchReplaceWidget::OperatorText::StartsWith); |
| 2119 | |
| 2120 | // search for cells starting with "B" and highlight them ("find") |
| 2121 | searchReplaceWidget->setInitialPattern(AbstractColumn::ColumnMode::Text, QLatin1String("B")); |
| 2122 | searchReplaceWidget->findAll(); |
| 2123 | |
| 2124 | // checks |
| 2125 | auto* view = static_cast<SpreadsheetView*>(sheet->view()); |
| 2126 | auto indexes = view->selectionModel()->selectedIndexes(); |
| 2127 | QCOMPARE(indexes.size(), 2); |
| 2128 | QCOMPARE(indexes.at(0).row(), 1); |
| 2129 | QCOMPARE(indexes.at(0).column(), 0); |
| 2130 | QCOMPARE(indexes.at(1).row(), 0); |
| 2131 | QCOMPARE(indexes.at(1).column(), 2); |
| 2132 | } |
| 2133 | |
| 2134 | /*! |
| 2135 | * replace a numeric value in int and double columns via "replace next" |
nothing calls this directly
no test coverage detected