[Pharo-project] Thread UI

Henrik Johansen henrik.s.johansen at veloxit.no
Thu Feb 25 09:26:11 EST 2010

Den 25.02.2010 15:05, skrev Alexandre Bergel:
> Dear List,
> I am extending the current set of Mondrian tests. I would like to  
> force some system window to appear on the screen in order to properly  
> test the size of its composing morphs. However, I do not know how to  
> effectively make the morph show up on the screen in a test.
> For example, consider the following test with a contrived situation:
> testDummy
> 	| morph c |
> 	morph := Morph new openInWorld.
> 	c := Display colorAt: 0 at 0.
> 	morph delete.
> 	self assert: c = morph color.
> If I run the test from a test runner, it will fail. However, if I open  
> a debugger and do a step by step, c = morph color is true.
> I guess the problem is that the morph is not actually displayed, since  
> the UI thread does not have the hand. Any idea how to force this?
> Cheers,
> Alexandre
You could insert World doOneCycle
between the lines
morph :=
c :=

>From a test-clarity (and robustness) POV though, you'd be much much
better by instead asserting properties of the morphs layout/colors than
sampling of display colors...
| morph |

	morph := Morph new. 
	morph doLayoutIn: someBounds.
	self assert: whatIExpectedWithAboveBounds equals: morph someLayoutVariable


More information about the Pharo-dev mailing list