Changeset View
Changeset View
Standalone View
Standalone View
autotests/searchtest.cpp
Show All 40 Lines | 39 | private slots: | |||
---|---|---|---|---|---|
41 | void testNextAndPrevious(); | 41 | void testNextAndPrevious(); | ||
42 | void test311232(); | 42 | void test311232(); | ||
43 | void test323262(); | 43 | void test323262(); | ||
44 | void test323263(); | 44 | void test323263(); | ||
45 | void testDottedI(); | 45 | void testDottedI(); | ||
46 | void testHyphenAtEndOfLineWithoutYOverlap(); | 46 | void testHyphenAtEndOfLineWithoutYOverlap(); | ||
47 | void testHyphenWithYOverlap(); | 47 | void testHyphenWithYOverlap(); | ||
48 | void testHyphenAtEndOfPage(); | 48 | void testHyphenAtEndOfPage(); | ||
49 | void testWholeWords_data(); | ||||
50 | void testWholeWords(); | ||||
49 | void testOneColumn(); | 51 | void testOneColumn(); | ||
50 | void testTwoColumns(); | 52 | void testTwoColumns(); | ||
51 | }; | 53 | }; | ||
52 | 54 | | |||
53 | void SearchTest::initTestCase() | 55 | void SearchTest::initTestCase() | ||
54 | { | 56 | { | ||
55 | qRegisterMetaType<Okular::Document::SearchStatus>(); | 57 | qRegisterMetaType<Okular::Document::SearchStatus>(); | ||
56 | Okular::SettingsCore::instance( QStringLiteral("searchtest") ); | 58 | Okular::SettingsCore::instance( QStringLiteral("searchtest") ); | ||
Show All 16 Lines | |||||
73 | } | 75 | } | ||
74 | 76 | | |||
75 | #define CREATE_PAGE \ | 77 | #define CREATE_PAGE \ | ||
76 | QCOMPARE(text.size(), rect.size()); \ | 78 | QCOMPARE(text.size(), rect.size()); \ | ||
77 | Okular::Page* page; \ | 79 | Okular::Page* page; \ | ||
78 | Okular::TextPage* tp; \ | 80 | Okular::TextPage* tp; \ | ||
79 | createTextPage(text, rect, tp, page); | 81 | createTextPage(text, rect, tp, page); | ||
80 | 82 | | |||
81 | #define TEST_NEXT_PREV(searchType, expectedStatus) \ | 83 | #define TEST_NEXT_PREV(searchType, expectedStatus, wholeWords) \ | ||
82 | { \ | 84 | { \ | ||
83 | Okular::RegularAreaRect* result = tp->findText(0, searchString, searchType, Qt::CaseSensitive, NULL); \ | 85 | Okular::RegularAreaRect* result = tp->findText(0, searchString, searchType, Qt::CaseSensitive, NULL, wholeWords); \ | ||
84 | QCOMPARE(!!result, expectedStatus); \ | 86 | QCOMPARE(!!result, expectedStatus); \ | ||
85 | delete result; \ | 87 | delete result; \ | ||
86 | } | 88 | } | ||
87 | 89 | | |||
88 | //The test testNextAndPrevious checks that | 90 | //The test testNextAndPrevious checks that | ||
89 | //a) if one starts a new search, then the first or last match is found, depending on the search direction | 91 | //a) if one starts a new search, then the first or last match is found, depending on the search direction | ||
90 | // (2 cases: FromTop/FromBottom) | 92 | // (2 cases: FromTop/FromBottom) | ||
91 | //b) if the last search has found a match, | 93 | //b) if the last search has found a match, | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 139 | for (int i = 0; i < TEST_NEXT_PREV_SITUATION_COUNT; i++) { | |||
143 | for (int i = 0; i < text.size(); i++) { | 145 | for (int i = 0; i < text.size(); i++) { | ||
144 | rect << Okular::NormalizedRect(0.1*i, 0.0, 0.1*(i+1), 0.1); \ | 146 | rect << Okular::NormalizedRect(0.1*i, 0.0, 0.1*(i+1), 0.1); \ | ||
145 | } | 147 | } | ||
146 | 148 | | |||
147 | CREATE_PAGE; | 149 | CREATE_PAGE; | ||
148 | 150 | | |||
149 | //Test 3 of the 8 cases listed above: | 151 | //Test 3 of the 8 cases listed above: | ||
150 | //FromTop, Next-Next (match) and Next-Next (no match) | 152 | //FromTop, Next-Next (match) and Next-Next (no match) | ||
151 | TEST_NEXT_PREV(Okular::FromTop, true); | 153 | TEST_NEXT_PREV(Okular::FromTop, true, false); | ||
152 | TEST_NEXT_PREV(Okular::NextResult, true); | 154 | TEST_NEXT_PREV(Okular::NextResult, true, false); | ||
153 | TEST_NEXT_PREV(Okular::NextResult, false); | 155 | TEST_NEXT_PREV(Okular::NextResult, false, false); | ||
154 | 156 | | |||
155 | //Test 5 cases: FromBottom, Previous-Previous (match), Previous-Next, | 157 | //Test 5 cases: FromBottom, Previous-Previous (match), Previous-Next, | ||
156 | //Next-Previous, Previous-Previous (no match) | 158 | //Next-Previous, Previous-Previous (no match) | ||
157 | TEST_NEXT_PREV(Okular::FromBottom, true); | 159 | TEST_NEXT_PREV(Okular::FromBottom, true, false); | ||
158 | TEST_NEXT_PREV(Okular::PreviousResult, true); | 160 | TEST_NEXT_PREV(Okular::PreviousResult, true, false); | ||
159 | TEST_NEXT_PREV(Okular::NextResult, true); | 161 | TEST_NEXT_PREV(Okular::NextResult, true, false); | ||
160 | TEST_NEXT_PREV(Okular::PreviousResult, true); | 162 | TEST_NEXT_PREV(Okular::PreviousResult, true, false); | ||
161 | TEST_NEXT_PREV(Okular::PreviousResult, false); | 163 | TEST_NEXT_PREV(Okular::PreviousResult, false, false); | ||
162 | 164 | | |||
163 | delete page; | 165 | delete page; | ||
164 | } | 166 | } | ||
165 | } | 167 | } | ||
166 | 168 | | |||
167 | void SearchTest::test311232() | 169 | void SearchTest::test311232() | ||
168 | { | 170 | { | ||
169 | Okular::Document d(nullptr); | 171 | Okular::Document d(nullptr); | ||
170 | SearchFinishedReceiver receiver; | 172 | SearchFinishedReceiver receiver; | ||
171 | QSignalSpy spy(&d, SIGNAL(searchFinished(int,Okular::Document::SearchStatus))); | 173 | QSignalSpy spy(&d, SIGNAL(searchFinished(int,Okular::Document::SearchStatus))); | ||
172 | 174 | | |||
173 | QObject::connect(&d, SIGNAL(searchFinished(int,Okular::Document::SearchStatus)), &receiver, SLOT(searchFinished(int,Okular::Document::SearchStatus))); | 175 | QObject::connect(&d, SIGNAL(searchFinished(int,Okular::Document::SearchStatus)), &receiver, SLOT(searchFinished(int,Okular::Document::SearchStatus))); | ||
174 | 176 | | |||
175 | const QString testFile = QStringLiteral(KDESRCDIR "data/file1.pdf"); | 177 | const QString testFile = QStringLiteral(KDESRCDIR "data/file1.pdf"); | ||
176 | QMimeDatabase db; | 178 | QMimeDatabase db; | ||
177 | const QMimeType mime = db.mimeTypeForFile( testFile ); | 179 | const QMimeType mime = db.mimeTypeForFile( testFile ); | ||
178 | d.openDocument(testFile, QUrl(), mime); | 180 | d.openDocument(testFile, QUrl(), mime); | ||
179 | 181 | | |||
180 | const int searchId = 0; | 182 | const int searchId = 0; | ||
181 | d.searchText(searchId, QStringLiteral(" i "), true, Qt::CaseSensitive, Okular::Document::NextMatch, false, QColor()); | 183 | d.searchText(searchId, QStringLiteral(" i "), true, Qt::CaseSensitive, Okular::Document::NextMatch, false, QColor(), false); | ||
182 | QTRY_COMPARE(spy.count(), 1); | 184 | QTRY_COMPARE(spy.count(), 1); | ||
183 | QCOMPARE(receiver.m_id, searchId); | 185 | QCOMPARE(receiver.m_id, searchId); | ||
184 | QCOMPARE(receiver.m_status, Okular::Document::MatchFound); | 186 | QCOMPARE(receiver.m_status, Okular::Document::MatchFound); | ||
185 | 187 | | |||
186 | 188 | | |||
187 | d.continueSearch( searchId, Okular::Document::PreviousMatch ); | 189 | d.continueSearch( searchId, Okular::Document::PreviousMatch ); | ||
188 | QTRY_COMPARE(spy.count(), 2); | 190 | QTRY_COMPARE(spy.count(), 2); | ||
189 | QCOMPARE(receiver.m_id, searchId); | 191 | QCOMPARE(receiver.m_id, searchId); | ||
190 | QCOMPARE(receiver.m_status, Okular::Document::NoMatchFound); | 192 | QCOMPARE(receiver.m_status, Okular::Document::NoMatchFound); | ||
191 | } | 193 | } | ||
192 | 194 | | |||
193 | void SearchTest::test323262() | 195 | void SearchTest::test323262() | ||
194 | { | 196 | { | ||
195 | QVector<QString> text; | 197 | QVector<QString> text; | ||
196 | text << QStringLiteral("a\n"); | 198 | text << QStringLiteral("a\n"); | ||
197 | 199 | | |||
198 | QVector<Okular::NormalizedRect> rect; | 200 | QVector<Okular::NormalizedRect> rect; | ||
199 | rect << Okular::NormalizedRect(1, 2, 3, 4); | 201 | rect << Okular::NormalizedRect(1, 2, 3, 4); | ||
200 | 202 | | |||
201 | CREATE_PAGE; | 203 | CREATE_PAGE; | ||
202 | 204 | | |||
203 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("a"), Okular::FromBottom, Qt::CaseSensitive, nullptr); | 205 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("a"), Okular::FromBottom, Qt::CaseSensitive, nullptr, false); | ||
204 | QVERIFY(result); | 206 | QVERIFY(result); | ||
205 | delete result; | 207 | delete result; | ||
206 | 208 | | |||
207 | delete page; | 209 | delete page; | ||
208 | } | 210 | } | ||
209 | 211 | | |||
210 | void SearchTest::test323263() | 212 | void SearchTest::test323263() | ||
211 | { | 213 | { | ||
212 | QVector<QString> text; | 214 | QVector<QString> text; | ||
213 | text << QStringLiteral("a") << QStringLiteral("a") << QStringLiteral("b"); | 215 | text << QStringLiteral("a") << QStringLiteral("a") << QStringLiteral("b"); | ||
214 | 216 | | |||
215 | QVector<Okular::NormalizedRect> rect; | 217 | QVector<Okular::NormalizedRect> rect; | ||
216 | rect << Okular::NormalizedRect(0, 0, 1, 1) | 218 | rect << Okular::NormalizedRect(0, 0, 1, 1) | ||
217 | << Okular::NormalizedRect(1, 0, 2, 1) | 219 | << Okular::NormalizedRect(1, 0, 2, 1) | ||
218 | << Okular::NormalizedRect(2, 0, 3, 1); | 220 | << Okular::NormalizedRect(2, 0, 3, 1); | ||
219 | 221 | | |||
220 | CREATE_PAGE; | 222 | CREATE_PAGE; | ||
221 | 223 | | |||
222 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("ab"), Okular::FromTop, Qt::CaseSensitive, nullptr); | 224 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("ab"), Okular::FromTop, Qt::CaseSensitive, nullptr, false); | ||
223 | QVERIFY(result); | 225 | QVERIFY(result); | ||
224 | Okular::RegularAreaRect expected; | 226 | Okular::RegularAreaRect expected; | ||
225 | expected.append(rect[1]); | 227 | expected.append(rect[1]); | ||
226 | expected.append(rect[2]); | 228 | expected.append(rect[2]); | ||
227 | expected.simplify(); | 229 | expected.simplify(); | ||
228 | QCOMPARE(*result, expected); | 230 | QCOMPARE(*result, expected); | ||
229 | delete result; | 231 | delete result; | ||
230 | 232 | | |||
Show All 14 Lines | 237 | { | |||
245 | QVector<QString> text; | 247 | QVector<QString> text; | ||
246 | text << QString::fromUtf8("İ"); | 248 | text << QString::fromUtf8("İ"); | ||
247 | 249 | | |||
248 | QVector<Okular::NormalizedRect> rect; | 250 | QVector<Okular::NormalizedRect> rect; | ||
249 | rect << Okular::NormalizedRect(1, 2, 3, 4); | 251 | rect << Okular::NormalizedRect(1, 2, 3, 4); | ||
250 | 252 | | |||
251 | CREATE_PAGE; | 253 | CREATE_PAGE; | ||
252 | 254 | | |||
253 | Okular::RegularAreaRect* result = tp->findText(0, QString::fromUtf8("İ"), Okular::FromTop, Qt::CaseInsensitive, nullptr); | 255 | Okular::RegularAreaRect* result = tp->findText(0, QString::fromUtf8("İ"), Okular::FromTop, Qt::CaseInsensitive, nullptr, false); | ||
254 | QVERIFY(result); | 256 | QVERIFY(result); | ||
255 | delete result; | 257 | delete result; | ||
256 | 258 | | |||
257 | delete page; | 259 | delete page; | ||
258 | } | 260 | } | ||
259 | 261 | | |||
260 | void SearchTest::testHyphenAtEndOfLineWithoutYOverlap() | 262 | void SearchTest::testHyphenAtEndOfLineWithoutYOverlap() | ||
261 | { | 263 | { | ||
Show All 9 Lines | 272 | rect << Okular::NormalizedRect(0.4, 0.0, 0.9, 0.1) | |||
271 | << Okular::NormalizedRect(0.0, 0.1, 0.6, 0.2) | 273 | << Okular::NormalizedRect(0.0, 0.1, 0.6, 0.2) | ||
272 | << Okular::NormalizedRect(0.0, 0.2, 0.8, 0.3) << Okular::NormalizedRect(0.8, 0.2, 0.9, 0.3) | 274 | << Okular::NormalizedRect(0.0, 0.2, 0.8, 0.3) << Okular::NormalizedRect(0.8, 0.2, 0.9, 0.3) | ||
273 | << Okular::NormalizedRect(0.0, 0.3, 0.8, 0.4) << Okular::NormalizedRect(0.8, 0.3, 0.9, 0.4) | 275 | << Okular::NormalizedRect(0.0, 0.3, 0.8, 0.4) << Okular::NormalizedRect(0.8, 0.3, 0.9, 0.4) | ||
274 | << Okular::NormalizedRect(0.0, 0.4, 0.7, 0.5); | 276 | << Okular::NormalizedRect(0.0, 0.4, 0.7, 0.5); | ||
275 | 277 | | |||
276 | CREATE_PAGE; | 278 | CREATE_PAGE; | ||
277 | 279 | | |||
278 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("supercalifragilisticexpialidocious"), | 280 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("supercalifragilisticexpialidocious"), | ||
279 | Okular::FromTop, Qt::CaseSensitive, nullptr); | 281 | Okular::FromTop, Qt::CaseSensitive, nullptr, false); | ||
280 | QVERIFY(result); | 282 | QVERIFY(result); | ||
281 | Okular::RegularAreaRect expected; | 283 | Okular::RegularAreaRect expected; | ||
282 | for (int i = 0; i < text.size(); i++) { | 284 | for (int i = 0; i < text.size(); i++) { | ||
283 | expected.append(rect[i]); | 285 | expected.append(rect[i]); | ||
284 | } | 286 | } | ||
285 | expected.simplify(); | 287 | expected.simplify(); | ||
286 | QCOMPARE(*result, expected); | 288 | QCOMPARE(*result, expected); | ||
287 | delete result; | 289 | delete result; | ||
288 | 290 | | |||
289 | delete page; | 291 | delete page; | ||
290 | } | 292 | } | ||
291 | 293 | | |||
292 | #define CREATE_PAGE_AND_TEST_SEARCH(searchString, matchExpected) \ | 294 | #define CREATE_PAGE_AND_TEST_SEARCH(searchString, matchExpected) \ | ||
293 | { \ | 295 | // { \ | ||
294 | CREATE_PAGE; \ | 296 | CREATE_PAGE; \ | ||
295 | \ | 297 | \ | ||
296 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral(searchString), \ | 298 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral(searchString), \ | ||
297 | Okular::FromTop, Qt::CaseSensitive, NULL); \ | 299 | Okular::FromTop, Qt::CaseSensitive, NULL, false); \ | ||
298 | \ | 300 | \ | ||
299 | QCOMPARE(!!result, matchExpected); \ | 301 | QCOMPARE(!!result, matchExpected); \ | ||
300 | \ | 302 | \ | ||
301 | delete result; \ | 303 | delete result; \ | ||
302 | delete page; \ | 304 | delete page; \ | ||
303 | } | 305 | } | ||
304 | 306 | | |||
305 | void SearchTest::testHyphenWithYOverlap() | 307 | void SearchTest::testHyphenWithYOverlap() | ||
Show All 38 Lines | 339 | { | |||
344 | 346 | | |||
345 | QVector<Okular::NormalizedRect> rect; | 347 | QVector<Okular::NormalizedRect> rect; | ||
346 | rect << Okular::NormalizedRect(0, 0, 1, 1); | 348 | rect << Okular::NormalizedRect(0, 0, 1, 1); | ||
347 | 349 | | |||
348 | CREATE_PAGE; | 350 | CREATE_PAGE; | ||
349 | 351 | | |||
350 | { | 352 | { | ||
351 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("a"), | 353 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("a"), | ||
352 | Okular::FromTop, Qt::CaseSensitive, nullptr); | 354 | Okular::FromTop, Qt::CaseSensitive, nullptr, false); | ||
353 | QVERIFY(result); | 355 | QVERIFY(result); | ||
354 | delete result; | 356 | delete result; | ||
355 | } | 357 | } | ||
356 | 358 | | |||
357 | { | 359 | { | ||
358 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("a"), | 360 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("a"), | ||
359 | Okular::FromBottom, Qt::CaseSensitive, nullptr); | 361 | Okular::FromBottom, Qt::CaseSensitive, nullptr, false); | ||
360 | QVERIFY(result); | 362 | QVERIFY(result); | ||
361 | delete result; | 363 | delete result; | ||
362 | } | 364 | } | ||
363 | 365 | | |||
364 | delete page; | 366 | delete page; | ||
365 | } | 367 | } | ||
366 | 368 | | |||
369 | void SearchTest::testWholeWords_data() | ||||
aacid: Seems like using a _data function here so that "test data" and "test code" are separated may be… | |||||
370 | { | ||||
371 | //Tests if we are encountering whole words. | ||||
372 | //The first test searchs for b, should encounter only one ocurrence. | ||||
373 | //The second test searchs for ab, and should encounter the first two results | ||||
374 | //The third test is looking for ab, it will find one result. | ||||
375 | //The fourth test is looking for a and it finds one ocurrence | ||||
376 | #define TEST_NEXT_AND_PREV 0 | ||||
377 | #define TEST_NEXT_PREV_NEXT 1 | ||||
378 | QTest::addColumn<QVector<QString>>("text"); | ||||
379 | QTest::addColumn<QString>("searchString"); | ||||
380 | QTest::addColumn<int>("testNumber"); | ||||
381 | | ||||
382 | QTest::newRow("b find one normally") << (QVector<QString>() << QStringLiteral("b") << QStringLiteral("a") << QStringLiteral(" ") << QStringLiteral("b") << QStringLiteral("c") << QStringLiteral(" ") << QStringLiteral("b")) << QStringLiteral("b") << TEST_NEXT_AND_PREV; | ||||
383 | QTest::newRow("ab find two with dots") << (QVector<QString>() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral(".") << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral(".") << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c")) << QStringLiteral("ab") << TEST_NEXT_PREV_NEXT; | ||||
384 | QTest::newRow("ab find with hyphen at end of page") << (QVector<QString>() << QStringLiteral("a") << QStringLiteral("-\n") << QStringLiteral("b") << QStringLiteral(" ") << QStringLiteral("a") << QStringLiteral("-") << QStringLiteral("b")) << QStringLiteral("ab") << TEST_NEXT_AND_PREV; | ||||
385 | QTest::newRow("a find at end of page") << (QVector<QString>() << QStringLiteral("a\n") << QStringLiteral("a") << QStringLiteral("b\n")) << QStringLiteral("a") << TEST_NEXT_AND_PREV; | ||||
386 | QTest::newRow("find same TinyTextEntity") << (QVector<QString>() << QStringLiteral("it") << QStringLiteral(" should find this ")) << QStringLiteral("find") << TEST_NEXT_AND_PREV; | ||||
387 | QTest::newRow("find two TinyTextEntity") << (QVector<QString>() << QStringLiteral("find one then fi") << QStringLiteral("nd another")) << QStringLiteral("find") << TEST_NEXT_PREV_NEXT; | ||||
388 | QTest::newRow("find on last TinyTextEntity") << (QVector<QString>() << QStringLiteral("ab ab\n")) << QStringLiteral("ab") << TEST_NEXT_PREV_NEXT; | ||||
389 | QTest::newRow("find with \\n") << (QVector<QString>() << QStringLiteral("ab-\nab\n")) << QStringLiteral("ab") << TEST_NEXT_PREV_NEXT; | ||||
390 | | ||||
391 | } | ||||
392 | | ||||
393 | void SearchTest::testWholeWords() | ||||
394 | { | ||||
395 | QFETCH(QVector<QString>, text); | ||||
396 | QFETCH(QString, searchString); | ||||
397 | QFETCH(int, testNumber); | ||||
398 | | ||||
399 | QVector<Okular::NormalizedRect> rect; \ | ||||
400 | | ||||
401 | for (int i = 0; i < text.size(); i++) { | ||||
402 | rect << Okular::NormalizedRect(0.1*i, 0.0, 0.1*(i+1), 0.1); \ | ||||
403 | } | ||||
404 | | ||||
405 | CREATE_PAGE; | ||||
406 | switch(testNumber) | ||||
407 | { | ||||
408 | case 0: | ||||
409 | TEST_NEXT_PREV(Okular::FromTop, true, true); | ||||
410 | TEST_NEXT_PREV(Okular::NextResult, false, true); | ||||
411 | TEST_NEXT_PREV(Okular::FromBottom, true, true); | ||||
412 | TEST_NEXT_PREV(Okular::PreviousResult, false, true); | ||||
413 | break; | ||||
414 | case 1: | ||||
415 | TEST_NEXT_PREV(Okular::FromTop, true, true); | ||||
416 | TEST_NEXT_PREV(Okular::NextResult, true, true); | ||||
417 | TEST_NEXT_PREV(Okular::PreviousResult, true, true); | ||||
418 | TEST_NEXT_PREV(Okular::NextResult, true, true); | ||||
419 | TEST_NEXT_PREV(Okular::NextResult, false, true); | ||||
420 | break; | ||||
421 | default: | ||||
422 | break; | ||||
423 | } | ||||
424 | delete page; | ||||
425 | | ||||
426 | } | ||||
427 | | ||||
367 | void SearchTest::testOneColumn() | 428 | void SearchTest::testOneColumn() | ||
368 | { | 429 | { | ||
369 | //Tests that the layout analysis algorithm does not create too many columns. | 430 | //Tests that the layout analysis algorithm does not create too many columns. | ||
370 | //Bug 326207 was caused by the fact that if all the horizontal breaks in a line | 431 | //Bug 326207 was caused by the fact that if all the horizontal breaks in a line | ||
371 | //had the same length and were smaller than vertical breaks between lines then | 432 | //had the same length and were smaller than vertical breaks between lines then | ||
372 | //the horizontal breaks were treated as column separators. | 433 | //the horizontal breaks were treated as column separators. | ||
373 | //(Note that "same length" means "same length after rounding rectangles to integer pixels". | 434 | //(Note that "same length" means "same length after rounding rectangles to integer pixels". | ||
374 | //The resolution used by the XY Cut algorithm with a square page is 1000 x 1000, | 435 | //The resolution used by the XY Cut algorithm with a square page is 1000 x 1000, | ||
375 | //and the horizontal spaces in the example are 0.1, so they are indeed both exactly 100 pixels.) | 436 | //and the horizontal spaces in the example are 0.1, so they are indeed both exactly 100 pixels.) | ||
376 | 437 | | |||
377 | QVector<QString> text; | 438 | QVector<QString> text; | ||
378 | text << QStringLiteral("Only") << QStringLiteral("one") << QStringLiteral("column") | 439 | text << QStringLiteral("Only") << QStringLiteral("one") << QStringLiteral("column") | ||
379 | << QStringLiteral("here"); | 440 | << QStringLiteral("here"); | ||
380 | 441 | | |||
381 | //characters and line breaks have length 0.05, word breaks 0.1 | 442 | //characters and line breaks have length 0.05, word breaks 0.1 | ||
382 | QVector<Okular::NormalizedRect> rect; | 443 | QVector<Okular::NormalizedRect> rect; | ||
383 | rect << Okular::NormalizedRect(0.0, 0.0, 0.2, 0.1) | 444 | rect << Okular::NormalizedRect(0.0, 0.0, 0.2, 0.1) | ||
384 | << Okular::NormalizedRect(0.3, 0.0, 0.5, 0.1) | 445 | << Okular::NormalizedRect(0.3, 0.0, 0.5, 0.1) | ||
385 | << Okular::NormalizedRect(0.6, 0.0, 0.9, 0.1) | 446 | << Okular::NormalizedRect(0.6, 0.0, 0.9, 0.1) | ||
386 | << Okular::NormalizedRect(0.0, 0.15, 0.2, 0.25); | 447 | << Okular::NormalizedRect(0.0, 0.15, 0.2, 0.25); | ||
387 | 448 | | |||
388 | CREATE_PAGE; | 449 | CREATE_PAGE; | ||
389 | 450 | | |||
390 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("Only one column"), | 451 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("Only one column"), | ||
391 | Okular::FromTop, Qt::CaseSensitive, nullptr); | 452 | Okular::FromTop, Qt::CaseSensitive, nullptr, false); | ||
392 | QVERIFY(result); | 453 | QVERIFY(result); | ||
393 | delete result; | 454 | delete result; | ||
394 | 455 | | |||
395 | delete page; | 456 | delete page; | ||
396 | } | 457 | } | ||
397 | 458 | | |||
398 | void SearchTest::testTwoColumns() | 459 | void SearchTest::testTwoColumns() | ||
399 | { | 460 | { | ||
Show All 11 Lines | 469 | rect << Okular::NormalizedRect(0.0, 0.0, 0.20, 0.1) | |||
411 | << Okular::NormalizedRect(0.75, 0.0, 0.9, 0.1) | 472 | << Okular::NormalizedRect(0.75, 0.0, 0.9, 0.1) | ||
412 | << Okular::NormalizedRect(0.0, 0.15, 0.1, 0.25) | 473 | << Okular::NormalizedRect(0.0, 0.15, 0.1, 0.25) | ||
413 | << Okular::NormalizedRect(0.15, 0.15, 0.3, 0.25) | 474 | << Okular::NormalizedRect(0.15, 0.15, 0.3, 0.25) | ||
414 | << Okular::NormalizedRect(0.6, 0.15, 1.0, 0.25); | 475 | << Okular::NormalizedRect(0.6, 0.15, 1.0, 0.25); | ||
415 | 476 | | |||
416 | CREATE_PAGE; | 477 | CREATE_PAGE; | ||
417 | 478 | | |||
418 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("This text in"), | 479 | Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("This text in"), | ||
419 | Okular::FromTop, Qt::CaseSensitive, nullptr); | 480 | Okular::FromTop, Qt::CaseSensitive, nullptr, false); | ||
420 | QVERIFY(!result); | 481 | QVERIFY(!result); | ||
421 | delete result; | 482 | delete result; | ||
422 | 483 | | |||
423 | delete page; | 484 | delete page; | ||
424 | } | 485 | } | ||
425 | 486 | | |||
426 | QTEST_MAIN( SearchTest ) | 487 | QTEST_MAIN( SearchTest ) | ||
427 | #include "searchtest.moc" | 488 | #include "searchtest.moc" |
Seems like using a _data function here so that "test data" and "test code" are separated may be a good idea.
Can you please investigate?