Skip to content

Commit e8d4277

Browse files
committed
Cleaning up some examples and tests
1 parent 23ecd08 commit e8d4277

9 files changed

Lines changed: 429 additions & 441 deletions

src/Bloc-Examples/BlClickEventTest.class.st

Lines changed: 226 additions & 217 deletions
Large diffs are not rendered by default.

src/Bloc-Examples/BlElementBoundsByScripterTest.class.st

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Class {
22
#name : #BlElementBoundsByScripterTest,
33
#superclass : #TestCase,
4+
#instVars : [
5+
'scripter'
6+
],
47
#category : #'Bloc-Examples-Basic'
58
}
69

@@ -42,16 +45,6 @@ BlElementBoundsByScripterTest >> newContainer [
4245
yourself
4346
]
4447

45-
{ #category : #running }
46-
BlElementBoundsByScripterTest >> newDevScripter [
47-
48-
| aScripter |
49-
aScripter := BlDevScripter new.
50-
aScripter element: self newContainer.
51-
52-
^ aScripter syncContinue
53-
]
54-
5548
{ #category : #running }
5649
BlElementBoundsByScripterTest >> newParent1 [
5750

@@ -73,26 +66,40 @@ BlElementBoundsByScripterTest >> newParent2 [
7366
yourself
7467
]
7568

69+
{ #category : #running }
70+
BlElementBoundsByScripterTest >> setUp [
71+
72+
super setUp.
73+
scripter := BlDevScripter new.
74+
scripter element: self newContainer.
75+
scripter syncContinue
76+
]
77+
78+
{ #category : #running }
79+
BlElementBoundsByScripterTest >> tearDown [
80+
81+
scripter close.
82+
super tearDown
83+
]
84+
7685
{ #category : #tests }
7786
BlElementBoundsByScripterTest >> testBoundsInSpace1 [
7887

79-
| aScripter |
80-
aScripter := self newDevScripter.
81-
aScripter check
88+
scripter check
8289
id: #parent_1;
8390
value: [ :anElement | anElement extent ]
8491
equals: [ self expectedElementExtent ];
8592
value: [ :anElement | anElement boundsInSpace ]
8693
equals: [ self expectedElementBounds ].
8794

88-
aScripter check
95+
scripter check
8996
id: #parent_2;
9097
value: [ :anElement | anElement extent ]
9198
equals: [ self expectedElementExtent ];
9299
value: [ :anElement | anElement boundsInSpace ]
93100
equals: [ self expectedElementBounds translateBy: 50 @ 50 ].
94101

95-
aScripter check
102+
scripter check
96103
id: #child;
97104
value: [ :anElement | anElement extent ]
98105
equals: [ self expectedElementExtent ];
@@ -101,46 +108,44 @@ BlElementBoundsByScripterTest >> testBoundsInSpace1 [
101108
value: [ :anElement | anElement positionInSpaceChangedCount ]
102109
equals: [ 0 ].
103110

104-
^ aScripter syncContinue
111+
^ scripter syncContinue
105112
]
106113

107114
{ #category : #tests }
108115
BlElementBoundsByScripterTest >> testBoundsInSpace2 [
109116

110-
| aScripter |
111-
aScripter := self testBoundsInSpace1.
117+
self testBoundsInSpace1.
112118

113-
aScripter do action: [ :anElement |
119+
scripter do action: [ :anElement |
114120
| aChild |
115121
aChild := anElement childWithId: #child.
116122
aChild removeFromParent.
117123
(anElement childWithId: #parent_2) addChild: aChild ].
118124

119-
^ aScripter syncContinue
125+
^ scripter syncContinue
120126
]
121127

122128
{ #category : #tests }
123129
BlElementBoundsByScripterTest >> testBoundsInSpace3 [
124130
<expectedFailure>
125131

126-
| aScripter |
127-
aScripter := self testBoundsInSpace2.
132+
self testBoundsInSpace2.
128133

129-
aScripter check
134+
scripter check
130135
id: #parent_1;
131136
value: [ :anElement | anElement extent ]
132137
equals: [ self expectedElementExtent ];
133138
value: [ :anElement | anElement boundsInSpace ]
134139
equals: [ self expectedElementBounds ].
135140

136-
aScripter check
141+
scripter check
137142
id: #parent_2;
138143
value: [ :anElement | anElement extent ]
139144
equals: [ self expectedElementExtent ];
140145
value: [ :anElement | anElement boundsInSpace ]
141146
equals: [ self expectedElementBounds translateBy: 50 @ 50 ].
142147

143-
aScripter check
148+
scripter check
144149
id: #child;
145150
value: [ :anElement | anElement extent ]
146151
equals: [ self expectedElementExtent ];
@@ -149,5 +154,5 @@ BlElementBoundsByScripterTest >> testBoundsInSpace3 [
149154
value: [ :anElement | anElement positionInSpaceChangedCount ]
150155
equals: [ 1 ].
151156

152-
^ aScripter syncContinue
157+
^ scripter syncContinue
153158
]

src/Bloc-Examples/BlEventCountingElement.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Class {
2222
'blurCount',
2323
'positionInSpaceChangedCount'
2424
],
25-
#category : #'Bloc-Examples-Event'
25+
#category : #'Bloc-Examples-EventHandling'
2626
}
2727

2828
{ #category : #accessing }

src/Bloc-Examples/BlFocusProcessorTest.class.st

Lines changed: 58 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
Class {
22
#name : #BlFocusProcessorTest,
33
#superclass : #TestCase,
4-
#category : #'Bloc-Examples-Event-Scripter'
4+
#instVars : [
5+
'scripter'
6+
],
7+
#category : #'Bloc-Examples-EventHandling'
58
}
69

710
{ #category : #running }
@@ -171,14 +174,25 @@ BlFocusProcessorTest >> newScripterElement [
171174
yourself
172175
]
173176

177+
{ #category : #running }
178+
BlFocusProcessorTest >> setUp [
179+
180+
super setUp.
181+
scripter := BlDevScripter new.
182+
scripter element: self newScripterElement
183+
]
184+
185+
{ #category : #running }
186+
BlFocusProcessorTest >> tearDown [
187+
188+
scripter close.
189+
super tearDown
190+
]
191+
174192
{ #category : #'tests - lose focus' }
175193
BlFocusProcessorTest >> testLoseFocus01GiveFocusToChild1 [
176194

177-
| aScripter |
178-
aScripter := BlDevScripter new.
179-
aScripter element: self newScripterElement.
180-
181-
aScripter substeps: 'Give focus to child-1' do: [ :aStep |
195+
scripter substeps: 'Give focus to child-1' do: [ :aStep |
182196
aStep requestFocus onChildNamed: #'child-1'.
183197

184198
aStep check
@@ -264,22 +278,22 @@ BlFocusProcessorTest >> testLoseFocus01GiveFocusToChild1 [
264278
aStep check
265279
label: 'Check focus owner';
266280
value: [ :aFocusProcessor | aFocusProcessor focusOwner ]
267-
equals: [ aScripter element childWithId: #'child-1' ];
281+
equals: [ scripter element childWithId: #'child-1' ];
268282
onFocusProcessor ].
269283

270-
^ aScripter syncContinue
284+
scripter syncContinue
271285
]
272286

273287
{ #category : #'tests - lose focus' }
274288
BlFocusProcessorTest >> testLoseFocus02RemoveChild1 [
275289

276-
| aScripter aChild1 |
277-
aScripter := self testLoseFocus01GiveFocusToChild1.
290+
| aChild1 |
291+
self testLoseFocus01GiveFocusToChild1.
278292

279-
aChild1 := aScripter root childWithId: #'child-1'.
280-
aScripter set key: #'child-1' value: [ aChild1 ].
293+
aChild1 := scripter root childWithId: #'child-1'.
294+
scripter set key: #'child-1' value: [ aChild1 ].
281295

282-
aScripter substeps: 'Remove child-1' do: [ :aStep |
296+
scripter substeps: 'Remove child-1' do: [ :aStep |
283297
aStep do
284298
action: [ :anElement | anElement removeFromParent ];
285299
id: #'child-1'.
@@ -372,21 +386,21 @@ BlFocusProcessorTest >> testLoseFocus02RemoveChild1 [
372386
aStep check
373387
label: 'Check focus owner';
374388
value: [ :aFocusProcessor | aFocusProcessor focusOwner ]
375-
equals: [ aScripter element childWithId: #'container-1' ];
389+
equals: [ scripter element childWithId: #'container-1' ];
376390
onFocusProcessor ].
377391

378-
^ aScripter syncContinue
392+
scripter syncContinue
379393
]
380394

381395
{ #category : #'tests - lose focus' }
382396
BlFocusProcessorTest >> testLoseFocus03AddBackChild1 [
383397

384-
| aScripter aChild1 |
385-
aScripter := self testLoseFocus02RemoveChild1.
398+
| aChild1 |
399+
self testLoseFocus02RemoveChild1.
386400

387-
aChild1 := aScripter userData at: #'child-1'.
401+
aChild1 := scripter userData at: #'child-1'.
388402

389-
aScripter substeps: 'Add child-1 back' do: [ :aStep |
403+
scripter substeps: 'Add child-1 back' do: [ :aStep |
390404
aStep do
391405
action: [ :anElement | anElement addChild: aChild1 ];
392406
id: #'container-1'.
@@ -479,20 +493,16 @@ BlFocusProcessorTest >> testLoseFocus03AddBackChild1 [
479493
aStep check
480494
label: 'Check focus owner';
481495
value: [ :aFocusProcessor | aFocusProcessor focusOwner ]
482-
equals: [ aScripter element childWithId: #'child-1' ];
496+
equals: [ scripter element childWithId: #'child-1' ];
483497
onFocusProcessor ].
484498

485-
^ aScripter syncContinue
499+
scripter syncContinue
486500
]
487501

488502
{ #category : #'tests - request focus' }
489503
BlFocusProcessorTest >> testRequestFocus01Parent [
490504

491-
| aScripter |
492-
aScripter := BlDevScripter new.
493-
aScripter element: self newScripterElement.
494-
495-
aScripter substeps: 'Request focus on parent' do: [ :aStep |
505+
scripter substeps: 'Request focus on parent' do: [ :aStep |
496506
aStep requestFocus.
497507

498508
aStep check
@@ -518,19 +528,18 @@ BlFocusProcessorTest >> testRequestFocus01Parent [
518528
aStep check
519529
label: 'Check focus owner';
520530
value: [ :aFocusProcessor | aFocusProcessor focusOwner ]
521-
equals: [ aScripter element ];
531+
equals: [ scripter element ];
522532
onFocusProcessor ].
523533

524-
^ aScripter syncContinue
534+
scripter syncContinue
525535
]
526536

527537
{ #category : #'tests - request focus' }
528538
BlFocusProcessorTest >> testRequestFocus02Container1 [
529539

530-
| aScripter |
531-
aScripter := self testRequestFocus01Parent.
540+
self testRequestFocus01Parent.
532541

533-
aScripter substeps: 'Request focus on container-1' do: [ :aStep |
542+
scripter substeps: 'Request focus on container-1' do: [ :aStep |
534543
aStep requestFocus onChildNamed: #'container-1'.
535544

536545
aStep check
@@ -576,19 +585,18 @@ BlFocusProcessorTest >> testRequestFocus02Container1 [
576585
aStep check
577586
label: 'Check focus owner';
578587
value: [ :aFocusProcessor | aFocusProcessor focusOwner ]
579-
equals: [ aScripter element childWithId: #'container-1' ];
588+
equals: [ scripter element childWithId: #'container-1' ];
580589
onFocusProcessor ].
581590

582-
^ aScripter syncContinue
591+
scripter syncContinue
583592
]
584593

585594
{ #category : #'tests - request focus' }
586595
BlFocusProcessorTest >> testRequestFocus03Container2 [
587596

588-
| aScripter |
589-
aScripter := self testRequestFocus02Container1.
597+
self testRequestFocus02Container1.
590598

591-
aScripter substeps: 'Request focus on container-2' do: [ :aStep |
599+
scripter substeps: 'Request focus on container-2' do: [ :aStep |
592600
aStep requestFocus onChildNamed: #'container-2'.
593601

594602
aStep check
@@ -654,19 +662,18 @@ BlFocusProcessorTest >> testRequestFocus03Container2 [
654662
aStep check
655663
label: 'Check focus owner';
656664
value: [ :aFocusProcessor | aFocusProcessor focusOwner ]
657-
equals: [ aScripter element childWithId: #'container-2' ];
665+
equals: [ scripter element childWithId: #'container-2' ];
658666
onFocusProcessor ].
659667

660-
^ aScripter syncContinue
668+
scripter syncContinue
661669
]
662670

663671
{ #category : #'tests - request focus' }
664672
BlFocusProcessorTest >> testRequestFocus04Child1 [
665673

666-
| aScripter |
667-
aScripter := self testRequestFocus03Container2.
674+
self testRequestFocus03Container2.
668675

669-
aScripter substeps: 'Request focus on child-1' do: [ :aStep |
676+
scripter substeps: 'Request focus on child-1' do: [ :aStep |
670677
aStep requestFocus onChildNamed: #'child-1'.
671678

672679
aStep check
@@ -752,19 +759,18 @@ BlFocusProcessorTest >> testRequestFocus04Child1 [
752759
aStep check
753760
label: 'Check focus owner';
754761
value: [ :aFocusProcessor | aFocusProcessor focusOwner ]
755-
equals: [ aScripter element childWithId: #'child-1' ];
762+
equals: [ scripter element childWithId: #'child-1' ];
756763
onFocusProcessor ].
757764

758-
^ aScripter syncContinue
765+
scripter syncContinue
759766
]
760767

761768
{ #category : #'tests - request focus' }
762769
BlFocusProcessorTest >> testRequestFocus05Child4 [
763770

764-
| aScripter |
765-
aScripter := self testRequestFocus04Child1.
771+
self testRequestFocus04Child1.
766772

767-
aScripter substeps: 'Request focus on child-4' do: [ :aStep |
773+
scripter substeps: 'Request focus on child-4' do: [ :aStep |
768774
aStep requestFocus onChildNamed: #'child-4'.
769775

770776
aStep check
@@ -870,19 +876,18 @@ BlFocusProcessorTest >> testRequestFocus05Child4 [
870876
aStep check
871877
label: 'Check focus owner';
872878
value: [ :aFocusProcessor | aFocusProcessor focusOwner ]
873-
equals: [ aScripter element childWithId: #'child-4' ];
879+
equals: [ scripter element childWithId: #'child-4' ];
874880
onFocusProcessor ].
875881

876-
^ aScripter syncContinue
882+
scripter syncContinue
877883
]
878884

879885
{ #category : #'tests - request focus' }
880886
BlFocusProcessorTest >> testRequestFocus06Container1 [
881887

882-
| aScripter |
883-
aScripter := self testRequestFocus05Child4.
888+
self testRequestFocus05Child4.
884889

885-
aScripter substeps: 'Request focus on container-1' do: [ :aStep |
890+
scripter substeps: 'Request focus on container-1' do: [ :aStep |
886891
aStep requestFocus onChildNamed: #'container-1'.
887892

888893
aStep check
@@ -988,8 +993,8 @@ BlFocusProcessorTest >> testRequestFocus06Container1 [
988993
aStep check
989994
label: 'Check focus owner';
990995
value: [ :aFocusProcessor | aFocusProcessor focusOwner ]
991-
equals: [ aScripter element childWithId: #'container-1' ];
996+
equals: [ scripter element childWithId: #'container-1' ];
992997
onFocusProcessor ].
993998

994-
^ aScripter syncContinue
999+
scripter syncContinue
9951000
]

0 commit comments

Comments
 (0)