Need help in getting started with writing the integration test
Tobias Deiminger
haxtibal at posteo.de
Fri Jun 8 20:12:42 UTC 2018
Am 08.06.2018 18:57 schrieb Dileep Sankhla:
> Hello Tobias,
>
> I have succeeded in getting the QInputDialog to write a new note:
>
> QMetaObject::invokeMethod(part.m_pageView, "slotToggleAnnotator",
> Q_ARG( bool, true )); // displayes the annotation toolbar
> QList<QToolButton *> toolbuttonList =
> part.m_pageView->findChildren<QToolButton *>(); // Get the list of all
> 10 annotation toolbuttons
>
> QToolButton* typewriterButton = toolbuttonList.at(9); // Get's
> typewriter toolbutton at 10th posiiton
>
> typewriterButton->click(); // clicks and selects the typewriter tool
>
> // Clicks on the viewport and a QInputDialog popups
> QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.5,
> height * 0.2));
> QTest::mouseClick(part.m_pageView->viewport(), Qt::LeftButton,
> Qt::NoModifier, QPoint(width * 0.5, height * 0.2));
>
> It popups a multiline QInputDialog annotation window and prompts for
> the note. I write any content, press OK and the test ends.
> My question is how to check if the popup window appears in the test as
> it doesn't have any parent widget? So I can't do findChildren on
> part.m_pageView to check for the QInputDialog.
QApplication::activeModalWidget [0], QApplication::topLevelWidgets [1]
and friends come to my mind to find the QInputDialog window. You can get
the current QApplication with the qApp macro at any scope.
> And after checking for
> the QInputDialog, how to CANCEL the dialog in the test so that my test
> doesn't pause at user's input prompt? I just need an idea as I'm stuck
> here.
Once you've got a pointer to the dialog widget, I think you can invoke
QDialog::done [2] to finish text input and continue annotation creation,
or QWidget::close [3] to just close it.
Had no time to look into the other issues in this thread yet, sorry.
Will answer later unless someone other does.
Cheers
Tobias
[0] http://doc.qt.io/qt-5/qapplication.html#activeModalWidget
[1] http://doc.qt.io/qt-5/qapplication.html#topLevelWidgets
[2] http://doc.qt.io/qt-5/qdialog.html#done
[3] http://doc.qt.io/qt-5/qwidget.html#close
More information about the Okular-devel
mailing list