Skip to content

Add #isSettledIn: support on space phases + adopt Bloc #deferAndSettle: in tests - #401

Merged
tinchodias merged 1 commit into
devfrom
DeferAndSettle
Sep 7, 2026
Merged

Add #isSettledIn: support on space phases + adopt Bloc #deferAndSettle: in tests#401
tinchodias merged 1 commit into
devfrom
DeferAndSettle

Conversation

@tinchodias

Copy link
Copy Markdown
Collaborator

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 #settle and #deferAndSettle:, and updates tests to avoid timing issues:

  • Implement #isSettledIn: in Toplo frame phases to ensure that space settle and space deferAndSettle: wait while Toplo skin installations, state queues, or configuration passes are still pending.
  • Migrated tests across lists, tabs, menus, tooltips, windows, and themes to use deferAndSettle:, settle, and eventSimulator.

Related Issues:

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds #eventSimulator to elements with all the classic BlSpace simulate* (the old class-side API in BlSpace to simulate events is deprecated).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tinchodias

Copy link
Copy Markdown
Collaborator Author

self
assert: horizontalElem background paint color
equals: Color blue.
self assert: biggerElem background paint color equals: Color red ].

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new BlSpaces #settle and #deferAndSettle: replace this use of whenLayoutedDoOnce:

ToExWorkspace class >> open [

<script>
self openInHost: BlOSWindowSDL2Host new

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#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 ] ] ].

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ].

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ]

@tinchodias
tinchodias merged commit 15e74a4 into dev Sep 7, 2026
12 of 15 checks passed
@tinchodias
tinchodias deleted the DeferAndSettle branch September 7, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant