Skip to content

Commit 028b521

Browse files
authored
Adopt new Bloc's #deferAndSettle: API + other secondary clean ups (#66)
- Converted `AlbTextEditorOperatorTest` hierarchy and `AlbEditorStructureTest` to subclass `BlSpaceTestCase`. - Adopted `deferAndSettle:` and `settle` across editor tests. - Converted `AlbTextEditorByScripterExamples` into `AlbTextEditorByScripterTest` TestCase using `#syncPlay`. - Removed obsolete unused packages (`Album-Brick-NU` and `Album-Sparta`). - Replaced usages of deprecated `privateText` with `text` - AlbEditorElementHandler: Add #isElementEnabled as helper/workaround. See: #67 - CI: extend timeout to 15 min
1 parent f587377 commit 028b521

19 files changed

Lines changed: 1270 additions & 1249 deletions

.github/workflows/Tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Load in New Image and Run Tests
2626
run: smalltalkci -s ${{ matrix.smalltalk }} ${{ matrix.ston }}
2727
shell: bash
28-
timeout-minutes: 10
28+
timeout-minutes: 15
2929
env:
3030
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3131

src/Album-Alexandrie/AlbExamplesSeeClassSide.extension.st

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ AlbExamplesSeeClassSide class >> example_AlexandrieFixedMeasurer [
3434

3535
| anEditor host |
3636
anEditor := self alexandrieEditorFor: 'Hello'.
37-
host := BlMorphicWindowHost new.
37+
host := BlMorphicWindowHost default.
3838
BlSpace new
3939
in: [ :sp | sp root addChild: anEditor ];
4040
host: host;
@@ -52,7 +52,7 @@ AlbExamplesSeeClassSide class >> example_AlexandrieFixedMeasurer0 [
5252
fontName: 'Helvetica Neue'.
5353
element := text asElement.
5454
element measurer: self alexandrieFixedMeasurer.
55-
host := BlMorphicWindowHost new.
55+
host := BlMorphicWindowHost default.
5656
BlSpace new in: [ :sp | sp root addChild: element ];
5757
host: host;
5858
title: host asString;
@@ -87,7 +87,7 @@ TTTCCATTCAGATGCGACCCCAGGTCAGGCGGGGCCACCCGCTGAGTTGAGGC'.
8787
elem measurer: (BATextElementMockedMeasurer new).
8888
root addChild: elem ].
8989

90-
host := BlMorphicWindowHost new.
90+
host := BlMorphicWindowHost default.
9191
space := BlSpace new
9292
host: host;
9393
title: host asString;

src/Album-Examples/AlbTextEditorByScripterExamples.class.st

Lines changed: 0 additions & 99 deletions
This file was deleted.

src/Album-Examples/AlbTextEditorExamples.class.st

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
Class {
3434
#name : #AlbTextEditorExamples,
3535
#superclass : #Object,
36+
#classInstVars : [
37+
'loremIpsum'
38+
],
3639
#category : #'Album-Examples-Editor'
3740
}
3841

@@ -271,6 +274,7 @@ AlbTextEditorExamples class >> loremIpsum [
271274

272275
{ #category : #'examples - comparison' }
273276
AlbTextEditorExamples class >> loremIpsum: aLength [
277+
274278
loremIpsum ifNil: [ loremIpsum := Dictionary new ].
275279
^ loremIpsum
276280
at: aLength asString asSymbol
Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Class {
22
#name : #AlbEditorStructureTest,
3-
#superclass : #TestCase,
3+
#superclass : #BlSpaceTestCase,
44
#instVars : [
55
'editor'
66
],
@@ -9,47 +9,41 @@ Class {
99

1010
{ #category : #initialization }
1111
AlbEditorStructureTest >> setUp [
12+
13+
super setUp.
14+
space extent: 400 @ 300.
1215
editor := AlbInfiniteEditorElement new.
16+
editor exact: 400 @ 300.
17+
space deferAndSettle: [ space root addChild: editor ]
1318
]
1419

1520
{ #category : #segments }
1621
AlbEditorStructureTest >> test_segments_count0 [
1722

1823
| segments |
19-
2024

2125
segments := editor children
2226
select: [ :eachChild | eachChild isKindOf: AlbTextEditorSegmentElement ].
23-
self assert: segments size equals: 0.
27+
self assert: segments size equals: 1.
2428

25-
editor text: 'A'.
26-
self assert: editor children size isZero.
27-
28-
editor forceLayout.
29+
space deferAndSettle: [ editor text: 'A' ].
2930
self assert: editor children size equals: 1.
3031

3132
segments := editor children
3233
select: [ :eachChild | eachChild isKindOf: AlbTextEditorSegmentElement ].
3334
self assert: segments size equals: 1.
3435

35-
editor text: 'A A'.
36-
self assert: editor children size equals: 1.
37-
38-
editor forceLayout.
36+
space deferAndSettle: [ editor text: 'A A' ].
3937
self assert: editor children size equals: 1.
4038

4139
segments := editor children
4240
select: [ :eachChild | eachChild isKindOf: AlbTextEditorSegmentElement ].
4341
self assert: segments size equals: 1.
4442

45-
editor text: 'A A', String cr.
46-
self assert: editor children size equals: 1.
47-
48-
editor forceLayout.
43+
space deferAndSettle: [ editor text: 'A A', String cr ].
4944
self assert: editor children size equals: 2.
5045

5146
segments := editor children
5247
select: [ :eachChild | eachChild isKindOf: AlbTextEditorSegmentElement ].
53-
self assert: segments size equals: 2.
54-
48+
self assert: editor children size equals: 2
5549
]
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
Class {
2+
#name : #AlbTextEditorByScripterTest,
3+
#superclass : #TestCase,
4+
#instVars : [
5+
'scripter'
6+
],
7+
#category : #'Album-Tests'
8+
}
9+
10+
{ #category : #running }
11+
AlbTextEditorByScripterTest >> setUp [
12+
13+
super setUp.
14+
scripter := BlDevScripter new
15+
]
16+
17+
{ #category : #running }
18+
AlbTextEditorByScripterTest >> tearDown [
19+
20+
scripter close.
21+
super tearDown
22+
]
23+
24+
{ #category : #tests }
25+
AlbTextEditorByScripterTest >> testClickRequestsFocus [
26+
27+
scripter element:
28+
(AlbEditorElement new
29+
text: '' asRopedText;
30+
yourself).
31+
32+
scripter check
33+
value: [ :aAlbTextEditor | aAlbTextEditor cursor position ] equals: 0;
34+
onAlbum.
35+
36+
scripter check
37+
satisfies: [ :aAlbEditor | aAlbEditor hasFocus not ];
38+
onSelf.
39+
40+
scripter click onSelf.
41+
42+
scripter check
43+
value: [ :aAlbTextEditor | aAlbTextEditor cursor position ] equals: 0;
44+
onAlbum.
45+
46+
scripter check
47+
satisfies: [ :aAlbEditor | aAlbEditor hasFocus ];
48+
onSelf.
49+
50+
scripter syncPlay
51+
]
52+
53+
{ #category : #tests }
54+
AlbTextEditorByScripterTest >> testCursorMovementAndInsert [
55+
56+
scripter element:
57+
(AlbEditorElement new
58+
text: '' asRopedText;
59+
yourself).
60+
61+
scripter click onSelf.
62+
scripter type: 'Hello'.
63+
scripter keyClick: KeyboardKey left.
64+
scripter keyClick: KeyboardKey left.
65+
scripter type: 'x'.
66+
67+
scripter check
68+
value: [ :aAlbTextEditor | aAlbTextEditor text asString ] equals: 'Helxlo';
69+
onAlbum.
70+
71+
scripter check
72+
value: [ :aAlbTextEditor | aAlbTextEditor cursor position ] equals: 4;
73+
onAlbum.
74+
75+
scripter syncPlay
76+
]
77+
78+
{ #category : #tests }
79+
AlbTextEditorByScripterTest >> testTypeAndBackspace [
80+
81+
scripter element:
82+
(AlbEditorElement new
83+
text: '' asRopedText;
84+
yourself).
85+
86+
scripter click onSelf.
87+
scripter type: 'Hello'.
88+
scripter keyClick: KeyboardKey backspace.
89+
90+
scripter check
91+
value: [ :aAlbTextEditor | aAlbTextEditor text asString ] equals: 'Hell';
92+
onAlbum.
93+
94+
scripter check
95+
value: [ :aAlbTextEditor | aAlbTextEditor cursor position ] equals: 4;
96+
onAlbum.
97+
98+
scripter syncPlay
99+
]
100+
101+
{ #category : #tests }
102+
AlbTextEditorByScripterTest >> testTypeText [
103+
104+
scripter element:
105+
(AlbEditorElement new
106+
text: '' asRopedText;
107+
yourself).
108+
109+
scripter click onSelf.
110+
scripter type: 'Hello'.
111+
112+
scripter check
113+
value: [ :aAlbTextEditor | aAlbTextEditor text asString ] equals: 'Hello';
114+
onAlbum.
115+
116+
scripter check
117+
value: [ :aAlbTextEditor | aAlbTextEditor cursor position ] equals: 5;
118+
onAlbum.
119+
120+
scripter syncPlay
121+
]

0 commit comments

Comments
 (0)