Changeset View
Changeset View
Standalone View
Standalone View
autotests/mainshelltest.cpp
Show First 20 Lines • Show All 177 Lines • ▼ Show 20 Line(s) | 166 | { | |||
---|---|---|---|---|---|
178 | 178 | | |||
179 | const QStringList contentsEpub = QStringList(QStringLiteral(KDESRCDIR "data/contents.epub")); | 179 | const QStringList contentsEpub = QStringList(QStringLiteral(KDESRCDIR "data/contents.epub")); | ||
180 | const QStringList file1 = QStringList(QStringLiteral(KDESRCDIR "data/file1.pdf")); | 180 | const QStringList file1 = QStringList(QStringLiteral(KDESRCDIR "data/file1.pdf")); | ||
181 | QStringList file1AndToc; | 181 | QStringList file1AndToc; | ||
182 | file1AndToc << QStringLiteral(KDESRCDIR "data/file1.pdf"); | 182 | file1AndToc << QStringLiteral(KDESRCDIR "data/file1.pdf"); | ||
183 | file1AndToc << QStringLiteral(KDESRCDIR "data/tocreload.pdf"); | 183 | file1AndToc << QStringLiteral(KDESRCDIR "data/tocreload.pdf"); | ||
184 | const QString tocReload = QStringLiteral(KDESRCDIR "data/tocreload.pdf"); | 184 | const QString tocReload = QStringLiteral(KDESRCDIR "data/tocreload.pdf"); | ||
185 | 185 | | |||
186 | const QString optionsPage2 = ShellUtils::serializeOptions(false, false, false, false, QStringLiteral("2")); | 186 | const QString optionsPage2 = ShellUtils::serializeOptions(false, false, false, false, false, QStringLiteral("2")); | ||
187 | const QString optionsPage2Presentation = ShellUtils::serializeOptions(true, false, false, false, QStringLiteral("2")); | 187 | const QString optionsPage2Presentation = ShellUtils::serializeOptions(true, false, false, false, false, QStringLiteral("2")); | ||
188 | const QString optionsPrint = ShellUtils::serializeOptions(false, true, false, false, QString()); | 188 | const QString optionsPrint = ShellUtils::serializeOptions(false, true, false, false, false, QString()); | ||
189 | const QString optionsUnique = ShellUtils::serializeOptions(false, false, true, false, QString()); | 189 | const QString optionsPrintAndExit = ShellUtils::serializeOptions(false, false, true, false, false, QString()); | ||
190 | 190 | const QString optionsUnique = ShellUtils::serializeOptions(false, false, false, true, false, QString()); | |||
191 | QTest::newRow("just show shell") << QStringList() << QString() << false << QString() << 0u << false << false << false << 0u << false << false; | 191 | | ||
192 | QTest::newRow("open file") << file1 << QString() << false << QString() << 0u << false << false << false << 0u << false << false; | 192 | QTest::newRow("just show shell") << QStringList() << QString() << false << QString() << 0u << false << false << false << false << 0u << false << false; | ||
193 | QTest::newRow("two files no tabs") << file1AndToc << QString() << false << QString() << 0u << false << false << false << 0u << false << false; | 193 | QTest::newRow("open file") << file1 << QString() << false << QString() << 0u << false << false << false << false << 0u << false << false; | ||
194 | QTest::newRow("two files with tabs") << file1AndToc << QString() << true << QString() << 0u << false << false << false << 0u << false << false; | 194 | QTest::newRow("two files no tabs") << file1AndToc << QString() << false << QString() << 0u << false << false << false << false << 0u << false << false; | ||
195 | QTest::newRow("two files sequence no tabs") << file1 << QString() << false << tocReload << 0u << false << false << false << 0u << false << false; | 195 | QTest::newRow("two files with tabs") << file1AndToc << QString() << true << QString() << 0u << false << false << false << false << 0u << false << false; | ||
196 | QTest::newRow("two files sequence with tabs") << file1 << QString() << true << tocReload << 0u << false << false << false << 0u << false << false; | 196 | QTest::newRow("two files sequence no tabs") << file1 << QString() << false << tocReload << 0u << false << false << false << false << 0u << false << false; | ||
197 | QTest::newRow("open file page number") << contentsEpub << optionsPage2 << false << QString() << 1u << false << false << false << 0u << false << false; | 197 | QTest::newRow("two files sequence with tabs") << file1 << QString() << true << tocReload << 0u << false << false << false << false << 0u << false << false; | ||
198 | QTest::newRow("open file page number and presentation") << contentsEpub << optionsPage2Presentation << false << QString() << 1u << true << false << false << 0u << false << false; | 198 | QTest::newRow("open file page number") << contentsEpub << optionsPage2 << false << QString() << 1u << false << false << false << false << 0u << false << false; | ||
199 | QTest::newRow("open file print") << file1 << optionsPrint << false << QString() << 0u << false << true << false << 0u << false << false; | 199 | QTest::newRow("open file page number and presentation") << contentsEpub << optionsPage2Presentation << false << QString() << 1u << true << false << false << false << 0u << false << false; | ||
200 | QTest::newRow("open two files unique") << file1 << optionsUnique << false << tocReload << 0u << false << false << true << 0u << false << false; | 200 | QTest::newRow("open file print") << file1 << optionsPrint << false << QString() << 0u << false << true << false << false << 0u << false << false; | ||
201 | QTest::newRow("open two files unique tabs") << file1 << optionsUnique << true << tocReload << 0u << false << false << true << 0u << false << false; | 201 | QTest::newRow("open file print and exit") << file1 << optionsPrint << false << QString() << 0u << false << false << true << false << 0u << false << false; | ||
202 | QTest::newRow("page number attach tabs") << file1 << QString() << true << contentsEpub[0] << 0u << false << false << false << 2u << false << false; | 202 | QTest::newRow("open two files unique") << file1 << optionsUnique << false << tocReload << 0u << false << false << false << true << 0u << false << false; | ||
203 | QTest::newRow("presentation attach tabs") << file1 << QString() << true << contentsEpub[0] << 0u << false << false << false << 2u << true << false; | 203 | QTest::newRow("open two files unique tabs") << file1 << optionsUnique << true << tocReload << 0u << false << false << false << true << 0u << false << false; | ||
204 | QTest::newRow("print attach tabs") << file1 << QString() << true << contentsEpub[0] << 0u << false << true << false << 2u << false << true; | 204 | QTest::newRow("page number attach tabs") << file1 << QString() << true << contentsEpub[0] << 0u << false << false << false << false << 2u << false << false; | ||
205 | QTest::newRow("page number attach unique") << file1 << optionsUnique << false << contentsEpub[0] << 0u << false << false << true << 3u << false << false; | 205 | QTest::newRow("presentation attach tabs") << file1 << QString() << true << contentsEpub[0] << 0u << false << false << false << false << 2u << true << false; | ||
206 | QTest::newRow("presentation attach unique") << file1 << optionsUnique << false << contentsEpub[0] << 0u << false << false << true << 2u << true << false; | 206 | QTest::newRow("print attach tabs") << file1 << QString() << true << contentsEpub[0] << 0u << false << true << false << false << 2u << false << true; | ||
207 | QTest::newRow("print attach unique") << file1 << optionsUnique << false << contentsEpub[0] << 0u << false << false << true << 2u << false << true; | 207 | QTest::newRow("print attach tabs and exit") << file1 << QString() << true << contentsEpub[0] << 0u << false << false << true << false << false << 2u << false << true; | ||
208 | QTest::newRow("page number attach unique tabs") << file1 << optionsUnique << true << contentsEpub[0] << 0u << false << false << true << 3u << false << false; | 208 | QTest::newRow("page number attach unique") << file1 << optionsUnique << false << contentsEpub[0] << 0u << false << false << false << true << 3u << false << false; | ||
209 | QTest::newRow("presentation attach unique tabs") << file1 << optionsUnique << true << contentsEpub[0] << 0u << false << false << true << 2u << true << false; | 209 | QTest::newRow("presentation attach unique") << file1 << optionsUnique << false << contentsEpub[0] << 0u << false << false << false << true << 2u << true << false; | ||
210 | QTest::newRow("print attach unique tabs") << file1 << optionsUnique << true << contentsEpub[0] << 0u << false << false << true << 2u << false << true; | 210 | QTest::newRow("print attach unique") << file1 << optionsUnique << false << contentsEpub[0] << 0u << false << false << false << true << 2u << false << true; | ||
211 | QTest::newRow("print attach unique and exit") << file1 << optionsUnique << false << contentsEpub[0] << 0u << false << false << false << true << 2u << false << true; | ||||
212 | QTest::newRow("page number attach unique tabs") << file1 << optionsUnique << true << contentsEpub[0] << 0u << false << false << false << true << 3u << false << false; | ||||
213 | QTest::newRow("presentation attach unique tabs") << file1 << optionsUnique << true << contentsEpub[0] << 0u << false << false << false << true << 2u << true << false; | ||||
214 | QTest::newRow("print attach unique tabs") << file1 << optionsUnique << true << contentsEpub[0] << 0u << false << false << false << true << 2u << false << true; | ||||
215 | QTest::newRow("print attach unique tabs and exit") << file1 << optionsUnique << true << contentsEpub[0] << 0u << false << false << false << true << 2u << false << true; | ||||
aacid: isn't this row exactly the same as the previous? | |||||
211 | } | 216 | } | ||
212 | 217 | | |||
213 | void MainShellTest::testShell() | 218 | void MainShellTest::testShell() | ||
214 | { | 219 | { | ||
215 | QFETCH(QStringList, paths); | 220 | QFETCH(QStringList, paths); | ||
216 | QFETCH(QString, serializedOptions); | 221 | QFETCH(QString, serializedOptions); | ||
217 | QFETCH(bool, useTabs); | 222 | QFETCH(bool, useTabs); | ||
218 | QFETCH(QString, externalProcessPath); | 223 | QFETCH(QString, externalProcessPath); | ||
219 | QFETCH(uint, expectedPage); | 224 | QFETCH(uint, expectedPage); | ||
220 | QFETCH(bool, expectPresentation); | 225 | QFETCH(bool, expectPresentation); | ||
221 | QFETCH(bool, expectPrintDialog); | 226 | QFETCH(bool, expectPrintDialog); | ||
227 | QFETCH(bool, expectPrintDialogAndExit); | ||||
222 | QFETCH(bool, unique); | 228 | QFETCH(bool, unique); | ||
223 | QFETCH(uint, externalProcessExpectedPage); | 229 | QFETCH(uint, externalProcessExpectedPage); | ||
224 | QFETCH(bool, externalProcessExpectPresentation); | 230 | QFETCH(bool, externalProcessExpectPresentation); | ||
225 | QFETCH(bool, externalProcessExpectPrintDialog); | 231 | QFETCH(bool, externalProcessExpectPrintDialog); | ||
232 | QFETCH(bool, externalProcessExpectPrintDialogAndExit); | ||||
226 | 233 | | |||
227 | QScopedPointer<ClosePrintDialogHelper> helper; | 234 | QScopedPointer<ClosePrintDialogHelper> helper; | ||
228 | 235 | | |||
229 | Okular::Settings::self()->setShellOpenFileInTabs(useTabs); | 236 | Okular::Settings::self()->setShellOpenFileInTabs(useTabs); | ||
230 | 237 | | |||
231 | if (expectPrintDialog || externalProcessExpectPrintDialog) { | 238 | if (expectPrintDialog || externalProcessExpectPrintDialog) { | ||
232 | const int expectedTab = externalProcessExpectPrintDialog && !unique ? 1 : 0; | 239 | const int expectedTab = externalProcessExpectPrintDialog && !unique ? 1 : 0; | ||
233 | helper.reset(new ClosePrintDialogHelper(expectedTab)); | 240 | helper.reset(new ClosePrintDialogHelper(expectedTab)); | ||
234 | QTimer::singleShot(0, helper.data(), SLOT(closePrintDialog())); | 241 | QTimer::singleShot(0, helper.data(), SLOT(closePrintDialog())); | ||
235 | } | 242 | } | ||
236 | 243 | | |||
244 | if (expectPrintDialogAndExit || externalProcessExpectPrintDialogAndExit) { | ||||
245 | const int expectedTab = externalProcessExpectPrintDialogAndExit && !unique ? 1 : 0; | ||||
246 | helper.reset(new ClosePrintDialogHelper(expectedTab)); | ||||
247 | QTimer::singleShot(0, helper.data(), SLOT(closePrintDialog())); | ||||
248 | } | ||||
249 | | ||||
237 | Okular::Status status = Okular::main(paths, serializedOptions); | 250 | Okular::Status status = Okular::main(paths, serializedOptions); | ||
238 | QCOMPARE(status, Okular::Success); | 251 | QCOMPARE(status, Okular::Success); | ||
239 | Shell *s = findShell(); | 252 | Shell *s = findShell(); | ||
240 | QVERIFY(s); | 253 | QVERIFY(s); | ||
241 | 254 | | |||
242 | if (paths.count() == 1) | 255 | if (paths.count() == 1) | ||
243 | { | 256 | { | ||
244 | QCOMPARE(s->m_tabs.count(), 1); | 257 | QCOMPARE(s->m_tabs.count(), 1); | ||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 305 | { | |||
298 | if (unique) | 311 | if (unique) | ||
299 | args << QStringLiteral("-unique"); | 312 | args << QStringLiteral("-unique"); | ||
300 | if (externalProcessExpectedPage != 0) | 313 | if (externalProcessExpectedPage != 0) | ||
301 | args << QStringLiteral("-page") << QString::number(externalProcessExpectedPage + 1); | 314 | args << QStringLiteral("-page") << QString::number(externalProcessExpectedPage + 1); | ||
302 | if (externalProcessExpectPresentation) | 315 | if (externalProcessExpectPresentation) | ||
303 | args << QStringLiteral("-presentation"); | 316 | args << QStringLiteral("-presentation"); | ||
304 | if (externalProcessExpectPrintDialog) | 317 | if (externalProcessExpectPrintDialog) | ||
305 | args << QStringLiteral("-print"); | 318 | args << QStringLiteral("-print"); | ||
319 | if (externalProcessExpectPrintDialogAndExit) | ||||
320 | args << QStringLiteral("-print_and_exit"); | ||||
Regarding this option: shouldn't it be -print-and-exit instead? I don't think that underscores are normally used in option names. ltoscano: Regarding this option: shouldn't it be -print-and-exit instead? I don't think that underscores… | |||||
306 | p.start(QStringLiteral(OKULAR_BINARY), args); | 321 | p.start(QStringLiteral(OKULAR_BINARY), args); | ||
307 | p.waitForStarted(); | 322 | p.waitForStarted(); | ||
308 | QCOMPARE(p.state(), QProcess::Running); | 323 | QCOMPARE(p.state(), QProcess::Running); | ||
309 | 324 | | |||
310 | if (useTabs || unique) | 325 | if (useTabs || unique) | ||
311 | { | 326 | { | ||
312 | // It is attaching to us, so will eventually stop | 327 | // It is attaching to us, so will eventually stop | ||
313 | QTRY_COMPARE_WITH_TIMEOUT(p.state(), QProcess::NotRunning, 20000); | 328 | QTRY_COMPARE_WITH_TIMEOUT(p.state(), QProcess::NotRunning, 20000); | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | |||||
401 | 416 | | |||
402 | void MainShellTest::testFileRemembersPagePosition() | 417 | void MainShellTest::testFileRemembersPagePosition() | ||
403 | { | 418 | { | ||
404 | QFETCH(int, mode); | 419 | QFETCH(int, mode); | ||
405 | 420 | | |||
406 | const QStringList paths = QStringList(QStringLiteral(KDESRCDIR "data/contents.epub")); | 421 | const QStringList paths = QStringList(QStringLiteral(KDESRCDIR "data/contents.epub")); | ||
407 | QString serializedOptions; | 422 | QString serializedOptions; | ||
408 | if (mode == 1 || mode == 3) | 423 | if (mode == 1 || mode == 3) | ||
409 | serializedOptions = ShellUtils::serializeOptions(false, false, false, false, QString()); | 424 | serializedOptions = ShellUtils::serializeOptions(false, false, false, false, false, QString()); | ||
410 | else | 425 | else | ||
411 | serializedOptions = ShellUtils::serializeOptions(false, false, true, false, QString()); | 426 | serializedOptions = ShellUtils::serializeOptions(false, false, false, true, false, QString()); | ||
412 | 427 | | |||
413 | Okular::Settings::self()->setShellOpenFileInTabs(mode == 3); | 428 | Okular::Settings::self()->setShellOpenFileInTabs(mode == 3); | ||
414 | 429 | | |||
415 | Okular::Status status = Okular::main(paths, serializedOptions); | 430 | Okular::Status status = Okular::main(paths, serializedOptions); | ||
416 | QCOMPARE(status, Okular::Success); | 431 | QCOMPARE(status, Okular::Success); | ||
417 | Shell *s = findShell(); | 432 | Shell *s = findShell(); | ||
418 | QVERIFY(s); | 433 | QVERIFY(s); | ||
419 | Okular::Part *part = s->findChild<Okular::Part*>(); | 434 | Okular::Part *part = s->findChild<Okular::Part*>(); | ||
Show All 34 Lines | |||||
454 | QCOMPARE(part->url().url(), QStringLiteral("file://%1").arg(paths[0])); | 469 | QCOMPARE(part->url().url(), QStringLiteral("file://%1").arg(paths[0])); | ||
455 | QCOMPARE(partDocument(part)->currentPage(), 3u); | 470 | QCOMPARE(partDocument(part)->currentPage(), 3u); | ||
456 | } | 471 | } | ||
457 | 472 | | |||
458 | void MainShellTest::test2FilesError_data() | 473 | void MainShellTest::test2FilesError_data() | ||
459 | { | 474 | { | ||
460 | QTest::addColumn<QString>("serializedOptions"); | 475 | QTest::addColumn<QString>("serializedOptions"); | ||
461 | 476 | | |||
462 | QTest::newRow("startInPresentation") << ShellUtils::serializeOptions(true, false, false, false, QString()); | 477 | QTest::newRow("startInPresentation") << ShellUtils::serializeOptions(true, false, false, false, false, QString()); | ||
463 | QTest::newRow("showPrintDialog") << ShellUtils::serializeOptions(false, true, false, false, QString()); | 478 | QTest::newRow("showPrintDialog") << ShellUtils::serializeOptions(false, true, false, false, false, QString()); | ||
464 | QTest::newRow("unique") << ShellUtils::serializeOptions(false, false, true, false, QString()); | 479 | QTest::newRow("showPrintDialogAndExit") << ShellUtils::serializeOptions(false, false, true, false, false, QString()); | ||
465 | QTest::newRow("pageNumger") << ShellUtils::serializeOptions(false, false, false, false, QStringLiteral("3")); | 480 | QTest::newRow("unique") << ShellUtils::serializeOptions(false, false, false, true, false, QString()); | ||
481 | QTest::newRow("pageNumger") << ShellUtils::serializeOptions(false, false, false, false, false, QStringLiteral("3")); | ||||
466 | } | 482 | } | ||
467 | 483 | | |||
468 | void MainShellTest::test2FilesError() | 484 | void MainShellTest::test2FilesError() | ||
469 | { | 485 | { | ||
470 | QFETCH(QString, serializedOptions); | 486 | QFETCH(QString, serializedOptions); | ||
471 | 487 | | |||
472 | QStringList paths; | 488 | QStringList paths; | ||
473 | paths << QStringLiteral(KDESRCDIR "data/file1.pdf") << QStringLiteral(KDESRCDIR "data/tocreload.pdf"); | 489 | paths << QStringLiteral(KDESRCDIR "data/file1.pdf") << QStringLiteral(KDESRCDIR "data/tocreload.pdf"); | ||
Show All 11 Lines | 499 | { | |||
485 | QTest::addColumn<QString>("options"); | 501 | QTest::addColumn<QString>("options"); | ||
486 | QTest::addColumn<bool>("useTabsOpen"); | 502 | QTest::addColumn<bool>("useTabsOpen"); | ||
487 | QTest::addColumn<bool>("useTabsRestore"); | 503 | QTest::addColumn<bool>("useTabsRestore"); | ||
488 | 504 | | |||
489 | QStringList oneDocPaths(QStringLiteral( KDESRCDIR "data/file1.pdf" ) ); | 505 | QStringList oneDocPaths(QStringLiteral( KDESRCDIR "data/file1.pdf" ) ); | ||
490 | QStringList twoDocPaths( oneDocPaths ); | 506 | QStringList twoDocPaths( oneDocPaths ); | ||
491 | twoDocPaths << QStringLiteral(KDESRCDIR "data/formSamples.pdf"); | 507 | twoDocPaths << QStringLiteral(KDESRCDIR "data/formSamples.pdf"); | ||
492 | 508 | | |||
493 | const QString options = ShellUtils::serializeOptions(false, false, false, false, QString()); | 509 | const QString options = ShellUtils::serializeOptions(false, false, false, false, false, QString()); | ||
494 | 510 | | |||
495 | QTest::newRow("1 doc, 1 window, tabs") << oneDocPaths << options << true << true; | 511 | QTest::newRow("1 doc, 1 window, tabs") << oneDocPaths << options << true << true; | ||
496 | QTest::newRow("2 docs, 1 window, tabs") << twoDocPaths << options << true << true; | 512 | QTest::newRow("2 docs, 1 window, tabs") << twoDocPaths << options << true << true; | ||
497 | QTest::newRow("2 docs, 2 windows, tabs") << twoDocPaths << options << false << true; | 513 | QTest::newRow("2 docs, 2 windows, tabs") << twoDocPaths << options << false << true; | ||
498 | QTest::newRow("2 docs, 2 windows, no tabs") << twoDocPaths << options << false << false; | 514 | QTest::newRow("2 docs, 2 windows, no tabs") << twoDocPaths << options << false << false; | ||
499 | QTest::newRow("2 docs, 1 window, no tabs") << twoDocPaths << options << true << false; | 515 | QTest::newRow("2 docs, 1 window, no tabs") << twoDocPaths << options << true << false; | ||
500 | } | 516 | } | ||
501 | 517 | | |||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |
isn't this row exactly the same as the previous?