Add #isSettledIn: support on space phases + adopt Bloc #deferAndSettle: in tests - #401
Conversation
| space deferAndSettle: [ l dataAccessor add: 'third' ]. | ||
| self assert: l disabledSelecter selectedIndexes equals: { 2 }. | ||
| self assert: l nodes first isEnabled. | ||
| self assert: l nodes second isDisabled. |
There was a problem hiding this comment.
@plantec @badetitou the PR diff is large but big part of it is adding this pattern/rule to the tests:
Enclose in #deferAndSettle: sentences that change an element that is attached to a space (to a space that is opened... as in the test). You can assume immediatelly afterwards that the required pulses to apply the changes e.g. in the layout and skins, are applied.
| BlSpace simulateMouseDownOn: but icon. | ||
| BlSpace simulateMouseUpOn: but. | ||
| self waitTestingSpaces. | ||
|
|
There was a problem hiding this comment.
This PR adds #eventSimulator to elements with all the classic BlSpace simulate* (the old class-side API in BlSpace to simulate events is deprecated).
There was a problem hiding this comment.
The BlEventSimulator sends #settle to the space before and after the "simulation". In fact it only sends it before if it needs to calculate the position inside/outside of the target element, to wait the layout phase until it calculates the bounds.
| self | ||
| assert: horizontalElem background paint color | ||
| equals: Color blue. | ||
| self assert: biggerElem background paint color equals: Color red ]. |
There was a problem hiding this comment.
The new BlSpaces #settle and #deferAndSettle: replace this use of whenLayoutedDoOnce:
| ToExWorkspace class >> open [ | ||
|
|
||
| <script> | ||
| self openInHost: BlOSWindowSDL2Host new |
There was a problem hiding this comment.
The hosts are now singletons, to represent better what they are... we were creating new hosts with #new but behind the scenes all instances of e.g. BlOSWindowSDL2Host had the same loop Process and universe (that send #pulse and evaluate the deferred actions), so I moved the hosts methods to instance side and made them singletons and #default returns the singleton instance
|
|
||
| space := BlSpace new. | ||
| space root addChild: moveListElement. | ||
| space pulse. |
There was a problem hiding this comment.
the #pulse is now named #basicPulse in the space, and only the host is supposed to send it. Users can only wait that the hosts sends it (via its parallel universe and its pulse loop Process)
| space toTheme: theme. | ||
| space root addChild: elem. | ||
| space root addChild: parentElem. | ||
| self waitTestingSpaces. |
There was a problem hiding this comment.
#waitTestingSpaces is deprecated in the tests, replaced by space settle
| self maxRound timesRepeat: [ | ||
| round := round + 1. | ||
| self selectActionsToRun shuffled do: [ :act | | ||
| list inUIProcessDo: [ self perform: act with: list ] ] ]. |
There was a problem hiding this comment.
#inUIProcessDo: is renamed as #deferOrValue: to be consistent with space's #defer: and #deferAndSettle:.
| on: ToDisabledSkinEvent | ||
| do: [ :event | receivedDisabledEvt := event ]). | ||
| space root addChild: e. | ||
| e skinManager installNewSkinIn: e. |
There was a problem hiding this comment.
I hope I did a good conversion in this kind of skins test: instead of explicitly installing the new skin, the space #settle waits until the skin is installed.
| BlSpace simulateMouseDownOn: e. | ||
| self waitTestingSpaces. | ||
| e eventSimulator mouseDown. | ||
| space waitUntilTrue: [ windowManager currentWindow notNil ]. |
There was a problem hiding this comment.
BlSpace>>#waitUntilTrue: is also available to do a custom wait for space pulses to do their job... in this case the general BlSpace>>#isSettled answers true before the current window starts to exist and that's why the test does this custom wait on pulses.
BlSpace>>#waitUntilTrue: is behind the scenes of #settle:
BlSpace >>
settle
"Wait until the space reaches equilibrium (all deferred actions, tasks, skins, and layout requests have settled).
Blocks the active process on the host pulse semaphore until #isSettled answers true."
^ self waitUntilTrue: [ self isSettled ]
This PR updates Toplo to work with the new Bloc concurrency and pulse synchronization changes. It allows Toplo's custom space frame phases (skins, states, configurations) to participate in
#settleand#deferAndSettle:, and updates tests to avoid timing issues:#isSettledIn:in Toplo frame phases to ensure thatspace settleandspace deferAndSettle:wait while Toplo skin installations, state queues, or configuration passes are still pending.deferAndSettle:,settle, andeventSimulator.Related Issues: