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