[Pharo-dev] How to test UI staff?

Juraj Kubelka juraj.kubelka at gmail.com
Mon Nov 11 14:22:36 EST 2013

Thanks for the explanation!


El 11-11-2013, a las 16:04, Camillo Bruni <camillobruni at gmail.com> escribió:

> On 2013-11-11, at 18:41, Juraj Kubelka <juraj.kubelka at gmail.com> wrote:
>> Hi!
>> I am trying to fix bug 12138 (https://pharo.fogbugz.com/f/cases/12138/Finding-a-class-is-kind-of-broken)
>> And I would like to write test like that:
>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>> testSearchSelectAndOK
>> 	|classes |
>> 	waitSemaphore := Semaphore new.
>> 	classes := { Object . BlockClosure. Class }.
>> 	listDialogWindow := SearchFacade classSearchIn: classes.
>> 	"listDialogWindow open."
>> 	listDialogWindow addDependent: self.
>> 	listDialogWindow searchUpdate: 'BlockClosure'.
>> 	waitSemaphore wait.
>> 	listDialogWindow listIndex: 1.
>> 	waitSemaphore wait.
>> 	listDialogWindow ok.
>> 	self assert: listDialogWindow answer notNil.
>> 	self assert: (listDialogWindow answer = BlockClosure).
>> handleUpdate: aMorphChanged 
>> 	waitSemaphore signal.
>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>> If I run the test from debugger — context menu on test method and select debug tests — and then I do proceed, it works. If I press the green button in Nautilus which run the test, it is frozen and I have to kill it by Cmd+. The same happens if the test it run from Test Runner.
>> It waits for testSemaphoreForMethod semaphore in method PackageTreeNautilusUI(NautilusUI)>>runTestForAMethod:notifying:priority:
> Hi,
> Note that the Debugger uses a separate UI Thread to avoid side-effects.
> However if you run the test directly from nautilus this is not the case.
> Instead the tests are directly run in the UIThread.
> If you do `waitSemaphore wait` you will instantaneously block the UI thread,
> which in return means that #handleUpdate: will never be called (since the
> UI thread execution halted).
> I just propose an outline for a solution (not well thought through.. :P):
> Somehow you have to run the test in a separate thread ([...] fork) to make
> sure `waitSemaphore wait` does not block the UI Thread. At the same time 
> you do not want to wait forever, so #valueWithin:onTimeout: is your friend :)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20131111/9ce2877f/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4168 bytes
Desc: not available
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20131111/9ce2877f/attachment.p7s>

More information about the Pharo-dev mailing list