<table><tr><td style="">loh.tar 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/D20264">View Revision</a></tr></table><br /><div><div><p><a href="https://phabricator.kde.org/p/dhaumann/" style="
border-color: #f1f7ff;
color: #19558d;
background-color: #f1f7ff;
border: 1px solid transparent;
border-radius: 3px;
font-weight: bold;
padding: 0 4px;">@dhaumann</a> asked elsewhere</p>
<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>Instead of waiting so long, we could alternatively also have a while loop waiting up to 20 times for 50ms. This way, the test would be faster if possible.</p></blockquote>
<p>Like this?</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="diff" 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);"><span style="color: #000080">diff --git a/autotests/src/katedocument_test.cpp b/autotests/src/katedocument_test.cpp</span>
<span style="color: #000080">index 4be9d7c3..e24a8ad9 100644</span>
<span style="color: #a00000">--- a/autotests/src/katedocument_test.cpp</span>
<span style="color: #00a000">+++ b/autotests/src/katedocument_test.cpp</span>
<span style="color: #800080">@@ -655,14 +655,23 @@ void KateDocumentTest::testAutoReload()</span>
// without to wait before it doesn't work here. It mostly fails with 500,
// it tend to work with 600, but is not guarantied to work even with 800
QTest::qWait(1000);
<span style="color: #00a000">+ // No idea how to do some slice test here</span>
stream << "\nTest";
stream.flush();
<span style="color: #a00000">- // Hardcoded delay m_modOnHdTimer in DocumentPrivate</span>
<span style="color: #00a000">+ // Try not to waste more time than needed, but we need to wait</span>
<span style="color: #00a000">+ const int timeSlice = 50;</span>
<span style="color: #00a000">+ // Hardcoded delay m_modOnHdTimer in DocumentPrivate</span>
// + min val with which it looks working reliable here
<span style="color: #a00000">- QTest::qWait(200 + 800);</span>
<span style="color: #a00000">- QCOMPARE(doc.text(), "Hello\nTest");</span>
<span style="color: #00a000">+ const int totalPatience = 200 + 800;</span>
<span style="color: #00a000">+</span>
<span style="color: #00a000">+ QString refTxT = ("Hello\nTest");</span>
<span style="color: #00a000">+ for (int w = 0; w <= totalPatience; w += timeSlice) {</span>
<span style="color: #00a000">+ QTest::qWait(timeSlice);</span>
<span style="color: #00a000">+ if (doc.text() == refTxT) break;</span>
<span style="color: #00a000">+ }</span>
<span style="color: #00a000">+ QCOMPARE(doc.text(), refTxT);</span>
// ...stay in the last line after reload!
QCOMPARE(view->cursorPosition().line(), doc.documentEnd().line());
<span style="color: #800080">@@ -674,8 +683,12 @@ void KateDocumentTest::testAutoReload()</span>
stream.flush();
file.close();
<span style="color: #a00000">- QTest::qWait(200 + 800);</span>
<span style="color: #a00000">- QCOMPARE(doc.text(), "Hello\nTest\nWorld!");</span>
<span style="color: #00a000">+ refTxT = ("Hello\nTest\nWorld!");</span>
<span style="color: #00a000">+ for (int w = 0; w <= totalPatience; w += timeSlice) {</span>
<span style="color: #00a000">+ QTest::qWait(timeSlice);</span>
<span style="color: #00a000">+ if (doc.text() == refTxT) break;</span>
<span style="color: #00a000">+ }</span>
<span style="color: #00a000">+ QCOMPARE(doc.text(), refTxT);</span>
// ...and ensure we have not move around
QCOMPARE(view->cursorPosition(), c);
}</pre></div>
<p>No Patch</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);">Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 3152ms</pre></div>
<p>With Patch</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);">Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 2619ms
533ms saved</pre></div>
<p>But it can still fail now :-(</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);">Totals: 2 passed, 1 failed, 0 skipped, 0 blacklisted, 3127ms</pre></div>
<p>also with increased waiting times</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);">Totals: 2 passed, 1 failed, 0 skipped, 0 blacklisted, 3787ms
Totals: 2 passed, 1 failed, 0 skipped, 0 blacklisted, 4802ms</pre></div>
<p>Does maybe the check "if (doc.text() == " disturbs the nice waiting?<br />
Playing with longer slice shows an effect around a 500ms slice, but then we have no benefit</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);">Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 3147ms</pre></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R39 KTextEditor</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D20264">https://phabricator.kde.org/D20264</a></div></div><br /><div><strong>To: </strong>loh.tar, dhaumann, cullmann<br /><strong>Cc: </strong>cullmann, kwrite-devel, kde-frameworks-devel, KTextEditor, domson, michaelh, ngraham, bruns, demsking, sars, dhaumann<br /></div>