<table><tr><td style="">simgunz added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D10792">View Revision</a></tr></table><br /><div><div><p>Thanks to your suggestions I made some progresses.</p>
<p>My current autotest looks as in the block below.</p>
<p>Problems:</p>
<ol class="remarkup-list">
<li class="remarkup-list-item">If I do not export <tt style="background: #ebebeb; font-size: 13px;">AnnotWindow</tt> and call <tt style="background: #ebebeb; font-size: 13px;">QVERIFY( part.m_pageView->findChildren<QFrame *>().size() == 1 )</tt> it fails, while calling <tt style="background: #ebebeb; font-size: 13px;">QVERIFY( part.m_pageView->findChildren<AnnotWindow *>().size() == 1 )</tt> would succeed.</li>
</ol>
<ol class="remarkup-list" start="2">
<li class="remarkup-list-item">The value returned by <tt style="background: #ebebeb; font-size: 13px;"> annot1->boundingRectangle().center(); </tt> is wrong.</li>
</ol>
<p>Moreover if I I pass to <tt style="background: #ebebeb; font-size: 13px;">mouseMove</tt> a point within the coordinates I specify when I construct the annotation the mouse moves to the wrong position.<br />
In particular the mouse moves to a Y position way below the annotation.<br />
So either I am missing something or there is a bug.</p>
<p>Example where it fails:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">annot1->setBoundingRectangle( Okular::NormalizedRect( 0.8, 0.1, 0.85, 0.15 ) );
QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.82, height * 0.13));</pre></div>
<p>For now I am using values find through trial and error.</p>
<ol class="remarkup-list" start="3">
<li class="remarkup-list-item">How do I click on the annotation window?</li>
</ol>
<p>These two commands both fail</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">QTest::mouseClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.1, height * 0.06)); // The window is under the mouse
QTest::mouseClick(win2, Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.1, height * 0.06)); // win2 is the annotation window widget (under the mouse again)</pre></div>
<p>Isn't it possible to call mouseClick without specifying the target widget, as if I would click manually so that the top widget is the target of the click?</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">void PartTest::testAnnotWindow()
{
QVariantList dummyArgs;
Okular::Part part(nullptr, nullptr, dummyArgs);
QVERIFY(openDocument(&part, QStringLiteral(KDESRCDIR "data/file2.pdf")));
part.widget()->show();
QVERIFY(QTest::qWaitForWindowExposed(part.widget()));
const int width = part.m_pageView->horizontalScrollBar()->maximum() +
part.m_pageView->viewport()->width();
const int height = part.m_pageView->verticalScrollBar()->maximum() +
part.m_pageView->viewport()->height();
part.m_document->setViewportPage(0);
// wait foqqr pixmap
QTRY_VERIFY(part.m_document->page(0)->hasPixmap(part.m_pageView));
QMetaObject::invokeMethod(part.m_pageView, "slotSetMouseNormal");
QCOMPARE(part.m_document->currentPage(), 0u);
// Create two distinct text annotations
Okular::Annotation * annot1 = new Okular::TextAnnotation();
annot1->setBoundingRectangle( Okular::NormalizedRect( 0.8, 0.1, 0.85, 0.15 ) );
annot1->setContents( QStringLiteral("Annot contents 111111") );
Okular::Annotation *annot2 = new Okular::TextAnnotation();
annot2->setBoundingRectangle( Okular::NormalizedRect( 0.8, 0.3, 0.85, 0.35 ) );
annot2->setContents( QStringLiteral("Annot contents 222222") );
int waitDealy = 1000;
// Add annot1 and annot2 to document
QTest::qWait(waitDealy);
part.m_document->addPageAnnotation( 0, annot1 );
QTest::qWait(waitDealy);
part.m_document->addPageAnnotation( 0, annot2 );
QTest::qWait(waitDealy);
QVERIFY( part.m_document->page( 0 )->annotations().size() == 2 );
// Double click the first annotation to open its window (move mouse for visual feedback)
//NormalizedPoint pt = annot1->boundingRectangle().center();
QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.81, height * 0.06));
//QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * pt.x, height * pt.y));
QTest::qWait(waitDealy);
QTest::mouseDClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.81, height * 0.06));
//QTest::mouseDClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * pt.x, height * pt.y));
QTest::qWait(waitDealy);
QVERIFY( part.m_pageView->findChildren<AnnotWindow *>().size() == 1 );
// Verify that the window is visible
AnnotWindow * win1 = part.m_pageView->findChild<AnnotWindow *>();
QVERIFY( !win1->visibleRegion().isEmpty() );
// Double click the second annotation to open its window (move mouse for visual feedback)
QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.81, height * 0.16));
QTest::qWait(waitDealy);
QTest::mouseDClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.81, height * 0.16));
QTest::qWait(waitDealy);
QVERIFY( part.m_pageView->findChildren<AnnotWindow *>().size() == 2 );
// Verify that the first window is hidden covered by the second, which is visible
QList<AnnotWindow *> lstWin = part.m_pageView->findChildren<AnnotWindow *>();
QFrame * win2;
if (lstWin[0] == win1) {
win2 = lstWin[1];
} else {
win2 = lstWin[0];
}
QVERIFY( win1->visibleRegion().isEmpty() );
QVERIFY( !win2->visibleRegion().isEmpty() );
// Double click the first annotation to raise its window (move mouse for visual feedback)
QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.81, height * 0.06));
QTest::qWait(waitDealy);
QTest::mouseDClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.81, height * 0.06));
QTest::qWait(waitDealy);
// Verify that the second window is hidden covered by the first, which is visible
QVERIFY( !win1->visibleRegion().isEmpty() );
QVERIFY( win2->visibleRegion().isEmpty() );
// Move annotation window 1 to partially show annotation window 2
QTest::qWait(waitDealy);
win1->move(QPoint(width * 0.15, height * 0.1));
QTest::qWait(waitDealy);
// Verify that both windows are partially visible
QVERIFY( !win1->visibleRegion().isEmpty() );
QVERIFY( !win2->visibleRegion().isEmpty() );
// Double click the first annotation to raise its window (move mouse for visual feedback)
QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.1, height * 0.06));
QTest::qWait(1000);
QTest::mouseClick(win2, Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.1, height * 0.06));
QTest::qWait(5000);
}</pre></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R223 Okular</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D10792">https://phabricator.kde.org/D10792</a></div></div><br /><div><strong>To: </strong>simgunz, Okular, aacid<br /><strong>Cc: </strong>ngraham, Okular, michaelweghorn, aacid<br /></div>