Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.

Squish/Waiting for Input from the Test Operator: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=Waiting for input from the test operator=
[[Category:Tools::Squish]]


In the cases where Squish cannot automate the whole test case, such as when a coin needs to be inserted into a slot machine or a physical button needs to be pressed which Squish cannot simulate, you need some way of notifying the test operator. As we have access to the whole Qt <span class="caps">API</span> from Squish, this can easily be done with a QMessageBox:<br />
= Waiting for input from the test operator =


As the call to information() won’t return until the user clicks the OK button, the script will be paused until that happens.
In the cases where Squish cannot automate the whole test case, such as when a coin needs to be inserted into a slot machine or a physical button needs to be pressed which Squish cannot simulate, you need some way of notifying the test operator. As we have access to the whole Qt API from Squish, this can easily be done with a QMessageBox:<br /><code>QMessageBox.information(0, &quot;Input needed&amp;quot;, &quot;Please insert coin now!&quot;)<code>


We can also use Squish’s powerful waitFor() command to continue the script immediately when the required action has occurred, without the user having to click a button, which can be useful in situations where an input cursor is not available for the test operator:<br />
As the call to information() won't return until the user clicks the OK button, the script will be paused until that happens.


The waitFor() command will execute the specified code statement until it returns true, in which case it will continue. You can also specify a timeout as a second parameter to avoid the abscence of the test operator blocking the execution of all the remaining test cases.
We can also use Squish's powerful waitFor() command to continue the script immediately when the required action has occurred, without the user having to click a button, which can be useful in situations where an input cursor is not available for the test operator:<br /></code>label = QLabel(&quot;Please insert coin now!&quot;)<br />label.show()<br />waitFor(&quot;findObject(':CoinCounter_QLabel').text == '1'&quot;)<br />label.close()<code>
 
===Categories:===
 
* [[:Category:Tools|Tools]]
** [[:Category:Tools::Squish|Squish]]

Revision as of 11:29, 24 February 2015


Waiting for input from the test operator

In the cases where Squish cannot automate the whole test case, such as when a coin needs to be inserted into a slot machine or a physical button needs to be pressed which Squish cannot simulate, you need some way of notifying the test operator. As we have access to the whole Qt API from Squish, this can easily be done with a QMessageBox:

QMessageBox.information(0, &quot;Input needed&amp;quot;, &quot;Please insert coin now!&quot;)<code>

As the call to information() won't return until the user clicks the OK button, the script will be paused until that happens.

We can also use Squish's powerful waitFor() command to continue the script immediately when the required action has occurred, without the user having to click a button, which can be useful in situations where an input cursor is not available for the test operator:<br />

label = QLabel("Please insert coin now!")
label.show()
waitFor("findObject(':CoinCounter_QLabel').text == '1'")
label.close()