diff options
| author | Mitch Curtis <mitch.curtis@qt.io> | 2016-06-28 10:13:17 +0200 |
|---|---|---|
| committer | Mitch Curtis <mitch.curtis@qt.io> | 2016-07-20 07:55:27 +0000 |
| commit | aa5f09a0d22e9fa6e125afc798f6b3289088b791 (patch) | |
| tree | 3d9c8844e0b22f7fac7b157fcee6f3a540414681 /src/qml/compiler/qv4isel_moth.cpp | |
| parent | 877ce4d446b34375096f5e7fae30101405d7ea95 (diff) | |
Add tryVerify()
This is useful for conditions which can't be tested using tryCompare.
One such situation is that of the currentItem property of ListView.
In Qt Quick Controls 2, the currentItem property of the ListView that
is internally a child of Tumbler can be null for a certain period of
time, so using tryCompare() would result in errors due to trying to
access a property of a null object:
tryCompare(tumblerView.currentItem, "text", "2")
The current workaround is to use wait(50) in a for loop, which is ugly
and could lead to flaky tests:
for (var delay = 1000; delay >= 0; delay -= 50) {
if (tumblerView.currentItem)
break;
wait(50);
}
verify(tumblerView.currentItem);
compare(tumblerView.currentItem.text, data.currentIndex.toString());
Using tryVerify(), we can first ensure that currentItem isn't null, and
then use a regular synchronous compare afterwards:
tryVerify(function(){ return tumblerView.currentItem; });
compare(tumbler.currentItem.text, data.currentIndex.toString());
[ChangeLog][QtTest][TestCase] Added tryVerify() function to allow
verification of asynchronous conditions that can't be tested using
tryCompare().
Change-Id: Ie93052b650f7fe0bf26853054a8f0f35a483e387
Task-number: QTBUG-19708
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4isel_moth.cpp')
0 files changed, 0 insertions, 0 deletions
