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 optionsUnique = ShellUtils::serializeOptions(false, false, false, true, false, QString()); | ||
190 | 190 | | |||
191 | QTest::newRow("just show shell") << QStringList() << QString() << false << QString() << 0u << false << false << false << 0u << false << false; | 191 | QTest::newRow("just show shell") << QStringList() << QString() << false << QString() << 0u << false << false << false << 0u << false << false; | ||
192 | QTest::newRow("open file") << file1 << QString() << false << QString() << 0u << false << false << false << 0u << false << false; | 192 | QTest::newRow("open file") << file1 << QString() << false << QString() << 0u << 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("two files no tabs") << file1AndToc << QString() << false << QString() << 0u << 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 with tabs") << file1AndToc << QString() << true << QString() << 0u << 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 sequence no tabs") << file1 << QString() << false << tocReload << 0u << 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 with tabs") << file1 << QString() << true << tocReload << 0u << 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("open file page number") << contentsEpub << optionsPage2 << false << QString() << 1u << false << false << false << 0u << false << false; | ||
Show All 33 Lines | 214 | { | |||
231 | if (expectPrintDialog || externalProcessExpectPrintDialog) { | 231 | if (expectPrintDialog || externalProcessExpectPrintDialog) { | ||
232 | const int expectedTab = externalProcessExpectPrintDialog && !unique ? 1 : 0; | 232 | const int expectedTab = externalProcessExpectPrintDialog && !unique ? 1 : 0; | ||
233 | helper.reset(new ClosePrintDialogHelper(expectedTab)); | 233 | helper.reset(new ClosePrintDialogHelper(expectedTab)); | ||
234 | QTimer::singleShot(0, helper.data(), SLOT(closePrintDialog())); | 234 | QTimer::singleShot(0, helper.data(), SLOT(closePrintDialog())); | ||
235 | } | 235 | } | ||
236 | 236 | | |||
237 | Okular::Status status = Okular::main(paths, serializedOptions); | 237 | Okular::Status status = Okular::main(paths, serializedOptions); | ||
238 | QCOMPARE(status, Okular::Success); | 238 | QCOMPARE(status, Okular::Success); | ||
239 | Shell *s = findShell(); | 239 | Shell *s = findShell(); | ||
aacid: isn't this row exactly the same as the previous? | |||||
240 | QVERIFY(s); | 240 | QVERIFY(s); | ||
241 | 241 | | |||
242 | if (paths.count() == 1) | 242 | if (paths.count() == 1) | ||
243 | { | 243 | { | ||
244 | QCOMPARE(s->m_tabs.count(), 1); | 244 | QCOMPARE(s->m_tabs.count(), 1); | ||
245 | Okular::Part *part = s->findChild<Okular::Part*>(); | 245 | Okular::Part *part = s->findChild<Okular::Part*>(); | ||
246 | QVERIFY(part); | 246 | QVERIFY(part); | ||
247 | QCOMPARE(part->url().url(), QStringLiteral("file://%1").arg(paths[0])); | 247 | QCOMPARE(part->url().url(), QStringLiteral("file://%1").arg(paths[0])); | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 298 | if (unique) | |||
299 | args << QStringLiteral("-unique"); | 299 | args << QStringLiteral("-unique"); | ||
300 | if (externalProcessExpectedPage != 0) | 300 | if (externalProcessExpectedPage != 0) | ||
301 | args << QStringLiteral("-page") << QString::number(externalProcessExpectedPage + 1); | 301 | args << QStringLiteral("-page") << QString::number(externalProcessExpectedPage + 1); | ||
302 | if (externalProcessExpectPresentation) | 302 | if (externalProcessExpectPresentation) | ||
303 | args << QStringLiteral("-presentation"); | 303 | args << QStringLiteral("-presentation"); | ||
304 | if (externalProcessExpectPrintDialog) | 304 | if (externalProcessExpectPrintDialog) | ||
305 | args << QStringLiteral("-print"); | 305 | args << QStringLiteral("-print"); | ||
306 | p.start(QStringLiteral(OKULAR_BINARY), args); | 306 | p.start(QStringLiteral(OKULAR_BINARY), args); | ||
307 | p.waitForStarted(); | 307 | p.waitForStarted(); | ||
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… | |||||
308 | QCOMPARE(p.state(), QProcess::Running); | 308 | QCOMPARE(p.state(), QProcess::Running); | ||
309 | 309 | | |||
310 | if (useTabs || unique) | 310 | if (useTabs || unique) | ||
311 | { | 311 | { | ||
312 | // It is attaching to us, so will eventually stop | 312 | // It is attaching to us, so will eventually stop | ||
313 | QTRY_COMPARE_WITH_TIMEOUT(p.state(), QProcess::NotRunning, 20000); | 313 | QTRY_COMPARE_WITH_TIMEOUT(p.state(), QProcess::NotRunning, 20000); | ||
314 | QCOMPARE(p.exitStatus(), QProcess::NormalExit); | 314 | QCOMPARE(p.exitStatus(), QProcess::NormalExit); | ||
315 | QCOMPARE(p.exitCode(), 0); | 315 | QCOMPARE(p.exitCode(), 0); | ||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | |||||
401 | 401 | | |||
402 | void MainShellTest::testFileRemembersPagePosition() | 402 | void MainShellTest::testFileRemembersPagePosition() | ||
403 | { | 403 | { | ||
404 | QFETCH(int, mode); | 404 | QFETCH(int, mode); | ||
405 | 405 | | |||
406 | const QStringList paths = QStringList(QStringLiteral(KDESRCDIR "data/contents.epub")); | 406 | const QStringList paths = QStringList(QStringLiteral(KDESRCDIR "data/contents.epub")); | ||
407 | QString serializedOptions; | 407 | QString serializedOptions; | ||
408 | if (mode == 1 || mode == 3) | 408 | if (mode == 1 || mode == 3) | ||
409 | serializedOptions = ShellUtils::serializeOptions(false, false, false, false, QString()); | 409 | serializedOptions = ShellUtils::serializeOptions(false, false, false, false, false, QString()); | ||
410 | else | 410 | else | ||
411 | serializedOptions = ShellUtils::serializeOptions(false, false, true, false, QString()); | 411 | serializedOptions = ShellUtils::serializeOptions(false, false, false, true, false, QString()); | ||
412 | 412 | | |||
413 | Okular::Settings::self()->setShellOpenFileInTabs(mode == 3); | 413 | Okular::Settings::self()->setShellOpenFileInTabs(mode == 3); | ||
414 | 414 | | |||
415 | Okular::Status status = Okular::main(paths, serializedOptions); | 415 | Okular::Status status = Okular::main(paths, serializedOptions); | ||
416 | QCOMPARE(status, Okular::Success); | 416 | QCOMPARE(status, Okular::Success); | ||
417 | Shell *s = findShell(); | 417 | Shell *s = findShell(); | ||
418 | QVERIFY(s); | 418 | QVERIFY(s); | ||
419 | Okular::Part *part = s->findChild<Okular::Part*>(); | 419 | Okular::Part *part = s->findChild<Okular::Part*>(); | ||
Show All 34 Lines | |||||
454 | QCOMPARE(part->url().url(), QStringLiteral("file://%1").arg(paths[0])); | 454 | QCOMPARE(part->url().url(), QStringLiteral("file://%1").arg(paths[0])); | ||
455 | QCOMPARE(partDocument(part)->currentPage(), 3u); | 455 | QCOMPARE(partDocument(part)->currentPage(), 3u); | ||
456 | } | 456 | } | ||
457 | 457 | | |||
458 | void MainShellTest::test2FilesError_data() | 458 | void MainShellTest::test2FilesError_data() | ||
459 | { | 459 | { | ||
460 | QTest::addColumn<QString>("serializedOptions"); | 460 | QTest::addColumn<QString>("serializedOptions"); | ||
461 | 461 | | |||
462 | QTest::newRow("startInPresentation") << ShellUtils::serializeOptions(true, false, false, false, QString()); | 462 | QTest::newRow("startInPresentation") << ShellUtils::serializeOptions(true, false, false, false, false, QString()); | ||
463 | QTest::newRow("showPrintDialog") << ShellUtils::serializeOptions(false, true, false, false, QString()); | 463 | QTest::newRow("showPrintDialog") << ShellUtils::serializeOptions(false, true, false, false, false, QString()); | ||
464 | QTest::newRow("unique") << ShellUtils::serializeOptions(false, false, true, false, QString()); | 464 | QTest::newRow("unique") << ShellUtils::serializeOptions(false, false, false, true, false, QString()); | ||
465 | QTest::newRow("pageNumger") << ShellUtils::serializeOptions(false, false, false, false, QStringLiteral("3")); | 465 | QTest::newRow("pageNumger") << ShellUtils::serializeOptions(false, false, false, false, false, QStringLiteral("3")); | ||
466 | } | 466 | } | ||
467 | 467 | | |||
468 | void MainShellTest::test2FilesError() | 468 | void MainShellTest::test2FilesError() | ||
469 | { | 469 | { | ||
470 | QFETCH(QString, serializedOptions); | 470 | QFETCH(QString, serializedOptions); | ||
471 | 471 | | |||
472 | QStringList paths; | 472 | QStringList paths; | ||
473 | paths << QStringLiteral(KDESRCDIR "data/file1.pdf") << QStringLiteral(KDESRCDIR "data/tocreload.pdf"); | 473 | paths << QStringLiteral(KDESRCDIR "data/file1.pdf") << QStringLiteral(KDESRCDIR "data/tocreload.pdf"); | ||
Show All 11 Lines | 483 | { | |||
485 | QTest::addColumn<QString>("options"); | 485 | QTest::addColumn<QString>("options"); | ||
486 | QTest::addColumn<bool>("useTabsOpen"); | 486 | QTest::addColumn<bool>("useTabsOpen"); | ||
487 | QTest::addColumn<bool>("useTabsRestore"); | 487 | QTest::addColumn<bool>("useTabsRestore"); | ||
488 | 488 | | |||
489 | QStringList oneDocPaths(QStringLiteral( KDESRCDIR "data/file1.pdf" ) ); | 489 | QStringList oneDocPaths(QStringLiteral( KDESRCDIR "data/file1.pdf" ) ); | ||
490 | QStringList twoDocPaths( oneDocPaths ); | 490 | QStringList twoDocPaths( oneDocPaths ); | ||
491 | twoDocPaths << QStringLiteral(KDESRCDIR "data/formSamples.pdf"); | 491 | twoDocPaths << QStringLiteral(KDESRCDIR "data/formSamples.pdf"); | ||
492 | 492 | | |||
493 | const QString options = ShellUtils::serializeOptions(false, false, false, false, QString()); | 493 | const QString options = ShellUtils::serializeOptions(false, false, false, false, false, QString()); | ||
494 | 494 | | |||
495 | QTest::newRow("1 doc, 1 window, tabs") << oneDocPaths << options << true << true; | 495 | QTest::newRow("1 doc, 1 window, tabs") << oneDocPaths << options << true << true; | ||
496 | QTest::newRow("2 docs, 1 window, tabs") << twoDocPaths << options << true << true; | 496 | QTest::newRow("2 docs, 1 window, tabs") << twoDocPaths << options << true << true; | ||
497 | QTest::newRow("2 docs, 2 windows, tabs") << twoDocPaths << options << false << true; | 497 | QTest::newRow("2 docs, 2 windows, tabs") << twoDocPaths << options << false << true; | ||
498 | QTest::newRow("2 docs, 2 windows, no tabs") << twoDocPaths << options << false << false; | 498 | 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; | 499 | QTest::newRow("2 docs, 1 window, no tabs") << twoDocPaths << options << true << false; | ||
500 | } | 500 | } | ||
501 | 501 | | |||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |
isn't this row exactly the same as the previous?