From c5a3e785fd7867566409ac6c6f9b59fe1d6ed315 Mon Sep 17 00:00:00 2001 From: jordanmontt Date: Mon, 30 Nov 2026 16:59:19 -0400 Subject: [PATCH] Lay out the window through the test backend in the box layout tests SpVerticalBoxLayoutAdapterTest>>#layOutWindow sent Morphic's #fullBounds to the window's widget, so its tests failed on other backends before checking anything. The test backends now lay out a window with #layOutWindowOf:: by default it waits until the UI is redrawn, and the Morphic backend lays out twice around a UI cycle, as before. Co-Authored-By: Claude Opus 5.5 --- .../SpAbstractBackendForTest.class.st | 7 +++++++ src/Spec2-Backend-Tests/SpMorphicBackendForTest.class.st | 9 +++++++++ .../SpVerticalBoxLayoutAdapterTest.class.st | 6 +----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Spec2-Backend-Tests/SpAbstractBackendForTest.class.st b/src/Spec2-Backend-Tests/SpAbstractBackendForTest.class.st index 48e134c7..a8ec6d7e 100644 --- a/src/Spec2-Backend-Tests/SpAbstractBackendForTest.class.st +++ b/src/Spec2-Backend-Tests/SpAbstractBackendForTest.class.st @@ -20,6 +20,13 @@ SpAbstractBackendForTest >> emulateClick: mouseButtonCode onTest: anAdapterTest self waitUntilUIRedrawed ] +{ #category : 'testing' } +SpAbstractBackendForTest >> layOutWindowOf: aTest [ + "Hook. I lay out the window of aTest, as the UI would, so that its widgets have their final bounds." + + self waitUntilUIRedrawed +] + { #category : 'testing' } SpAbstractBackendForTest >> waitUntilUIRedrawed [ "Hook. I wait until the UI has been redrawn and events have been handled." diff --git a/src/Spec2-Backend-Tests/SpMorphicBackendForTest.class.st b/src/Spec2-Backend-Tests/SpMorphicBackendForTest.class.st index 8fd23d57..439f8803 100644 --- a/src/Spec2-Backend-Tests/SpMorphicBackendForTest.class.st +++ b/src/Spec2-Backend-Tests/SpMorphicBackendForTest.class.st @@ -121,6 +121,15 @@ SpMorphicBackendForTest >> initialize [ self initializeSemaphore ] +{ #category : 'testing' } +SpMorphicBackendForTest >> layOutWindowOf: aTest [ + "Twice: when the width of a wrapping label changes, its height may change too, and it asks its owner to lay out again in the next UI cycle." + + aTest window adapter widget fullBounds. + self waitUntilUIRedrawed. + aTest window adapter widget fullBounds +] + { #category : 'opening' } SpMorphicBackendForTest >> openInstanceOf: aTest [ diff --git a/src/Spec2-Backend-Tests/SpVerticalBoxLayoutAdapterTest.class.st b/src/Spec2-Backend-Tests/SpVerticalBoxLayoutAdapterTest.class.st index 1fc8c3c7..0261c055 100644 --- a/src/Spec2-Backend-Tests/SpVerticalBoxLayoutAdapterTest.class.st +++ b/src/Spec2-Backend-Tests/SpVerticalBoxLayoutAdapterTest.class.st @@ -8,12 +8,8 @@ Class { { #category : 'helpers' } SpVerticalBoxLayoutAdapterTest >> layOutWindow [ - "We need to lay out twice. As this is a wrapping morph, when the width changes, the height may change too (because of the wrapping, narrowing it can make it larger). We need to lay out twice to apply the changes to the height, too." - self window adapter widget fullBounds. - "a wrapping label whose height changed asks its owner to lay out again, in the next UI cycle" - self adapter. - self window adapter widget fullBounds + backendForTest layOutWindowOf: self ] { #category : 'accessing' }