author | Jan Vrany <jan.vrany@labware.com> |
Sat, 04 Jul 2020 08:14:13 +0100 | |
branch | jv |
changeset 1121 | c5661215109c |
parent 822 | 509715fb5cf5 |
permissions | -rw-r--r-- |
1121
c5661215109c
Tonel: various fixes here and there (part 2)
Jan Vrany <jan.vrany@labware.com>
parents:
822
diff
changeset
|
1 |
" |
c5661215109c
Tonel: various fixes here and there (part 2)
Jan Vrany <jan.vrany@labware.com>
parents:
822
diff
changeset
|
2 |
COPYRIGHT (c) 2020 LabWare |
c5661215109c
Tonel: various fixes here and there (part 2)
Jan Vrany <jan.vrany@labware.com>
parents:
822
diff
changeset
|
3 |
" |
24 | 4 |
"{ Package: 'stx:goodies/monticello/test' }" |
5 |
||
1121
c5661215109c
Tonel: various fixes here and there (part 2)
Jan Vrany <jan.vrany@labware.com>
parents:
822
diff
changeset
|
6 |
"{ NameSpace: Smalltalk }" |
c5661215109c
Tonel: various fixes here and there (part 2)
Jan Vrany <jan.vrany@labware.com>
parents:
822
diff
changeset
|
7 |
|
24 | 8 |
MCTestCase subclass:#MCSnapshotBrowserTest |
9 |
instanceVariableNames:'model morph' |
|
10 |
classVariableNames:'' |
|
11 |
poolDictionaries:'' |
|
822
509715fb5cf5
Tests moved to category SCM-Monticello-Tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
24
diff
changeset
|
12 |
category:'SCM-Monticello-Tests' |
24 | 13 |
! |
14 |
||
1121
c5661215109c
Tonel: various fixes here and there (part 2)
Jan Vrany <jan.vrany@labware.com>
parents:
822
diff
changeset
|
15 |
!MCSnapshotBrowserTest class methodsFor:'documentation'! |
c5661215109c
Tonel: various fixes here and there (part 2)
Jan Vrany <jan.vrany@labware.com>
parents:
822
diff
changeset
|
16 |
|
c5661215109c
Tonel: various fixes here and there (part 2)
Jan Vrany <jan.vrany@labware.com>
parents:
822
diff
changeset
|
17 |
copyright |
c5661215109c
Tonel: various fixes here and there (part 2)
Jan Vrany <jan.vrany@labware.com>
parents:
822
diff
changeset
|
18 |
" |
c5661215109c
Tonel: various fixes here and there (part 2)
Jan Vrany <jan.vrany@labware.com>
parents:
822
diff
changeset
|
19 |
COPYRIGHT (c) 2020 LabWare |
c5661215109c
Tonel: various fixes here and there (part 2)
Jan Vrany <jan.vrany@labware.com>
parents:
822
diff
changeset
|
20 |
|
c5661215109c
Tonel: various fixes here and there (part 2)
Jan Vrany <jan.vrany@labware.com>
parents:
822
diff
changeset
|
21 |
|
c5661215109c
Tonel: various fixes here and there (part 2)
Jan Vrany <jan.vrany@labware.com>
parents:
822
diff
changeset
|
22 |
" |
c5661215109c
Tonel: various fixes here and there (part 2)
Jan Vrany <jan.vrany@labware.com>
parents:
822
diff
changeset
|
23 |
! ! |
24 | 24 |
|
25 |
!MCSnapshotBrowserTest class methodsFor:'as yet unclassified'! |
|
26 |
||
27 |
resources |
|
28 |
^ Array with: MCSnapshotResource |
|
29 |
! ! |
|
30 |
||
31 |
!MCSnapshotBrowserTest methodsFor:'asserting'! |
|
32 |
||
33 |
assertAListIncludes: anArrayOfStrings |
|
34 |
self listMorphs |
|
35 |
detect: [:m | m getList includesAllOf: anArrayOfStrings] |
|
36 |
ifNone: [self assert: false]. |
|
37 |
! |
|
38 |
||
39 |
assertAListMatches: strings |
|
40 |
| listMorphs list | |
|
41 |
listMorphs _ self listMorphs. |
|
42 |
listMorphs |
|
43 |
detect: [:m | list _ m getList. (list size = strings size) and: [list includesAllOf: strings]] |
|
44 |
ifNone: [self assert: false]. |
|
45 |
! |
|
46 |
||
47 |
assertButtonExists: aString |
|
48 |
self buttonMorphs detect: [:m | m label = aString] ifNone: [self assert: false]. |
|
49 |
||
50 |
! |
|
51 |
||
52 |
assertButtonOn: aString |
|
53 |
self assert: (self findButtonWithLabel: aString) getModelState. |
|
54 |
||
55 |
! |
|
56 |
||
57 |
assertTextIs: aString |
|
58 |
self assert: self textMorph contents = aString. |
|
59 |
! |
|
60 |
||
61 |
denyAListHasSelection: aString |
|
62 |
| found | |
|
63 |
found _ true. |
|
64 |
self listMorphs |
|
65 |
detect: [:m | m selection = aString] |
|
66 |
ifNone: [found _ false]. |
|
67 |
self deny: found. |
|
68 |
! |
|
69 |
||
70 |
denyAListIncludesAnyOf: anArrayOfStrings |
|
71 |
| found | |
|
72 |
found _ true. |
|
73 |
self listMorphs |
|
74 |
detect: [:m | m getList includesAnyOf: anArrayOfStrings] |
|
75 |
ifNone: [found _ false]. |
|
76 |
self deny: found. |
|
77 |
! |
|
78 |
||
79 |
denyButtonOn: aString |
|
80 |
self deny: (self findButtonWithLabel: aString) getModelState. |
|
81 |
||
82 |
! ! |
|
83 |
||
84 |
!MCSnapshotBrowserTest methodsFor:'morphic'! |
|
85 |
||
86 |
annotationTextMorph |
|
87 |
^ (self morphsOfClass: TextMorph) first |
|
88 |
! |
|
89 |
||
90 |
buttonMorphs |
|
91 |
^ self morphsOfClass: PluggableButtonMorph |
|
92 |
! |
|
93 |
||
94 |
findButtonWithLabel: aString |
|
95 |
^ self buttonMorphs detect: [:m | m label = aString] |
|
96 |
! |
|
97 |
||
98 |
findListContaining: aString |
|
99 |
^ self listMorphs detect: [:m | m getList includes: aString] |
|
100 |
! |
|
101 |
||
102 |
listMorphs |
|
103 |
^ self morphsOfClass: PluggableListMorph |
|
104 |
! |
|
105 |
||
106 |
morphsOfClass: aMorphClass |
|
107 |
| morphs | |
|
108 |
morphs _ OrderedCollection new. |
|
109 |
morph allMorphsDo: [:m | (m isKindOf: aMorphClass) ifTrue: [morphs add: m]]. |
|
110 |
^ morphs |
|
111 |
! |
|
112 |
||
113 |
textMorph |
|
114 |
^ (self morphsOfClass: TextMorph) last |
|
115 |
! ! |
|
116 |
||
117 |
!MCSnapshotBrowserTest methodsFor:'private'! |
|
118 |
||
119 |
allCategories |
|
120 |
^ Array with: model extensionsCategory with: self mockCategoryName. |
|
121 |
! |
|
122 |
||
123 |
allMethods |
|
124 |
^ MCSnapshotResource current definitions |
|
125 |
select: [:def | def isMethodDefinition] |
|
126 |
thenCollect: [:def | def selector] |
|
127 |
! |
|
128 |
||
129 |
allProtocols |
|
130 |
^ MCSnapshotResource current definitions |
|
131 |
select: [:def | def isMethodDefinition] |
|
132 |
thenCollect: [:def | def category] |
|
133 |
! |
|
134 |
||
135 |
classABooleanMethods |
|
136 |
^ #(falsehood moreTruth truth) |
|
137 |
! |
|
138 |
||
139 |
classAClassProtocols |
|
140 |
^ self protocolsForClass: self mockClassA class. |
|
141 |
! |
|
142 |
||
143 |
classAComment |
|
144 |
^ self mockClassA organization classComment. |
|
145 |
! |
|
146 |
||
147 |
classADefinitionString |
|
148 |
^ self mockClassA definition |
|
149 |
! |
|
150 |
||
151 |
classAProtocols |
|
152 |
^ self protocolsForClass: self mockClassA. |
|
153 |
! |
|
154 |
||
155 |
definedClasses |
|
156 |
^ MCSnapshotResource current definitions |
|
157 |
select: [:def | def isClassDefinition] |
|
158 |
thenCollect: [:def | def className]. |
|
159 |
! |
|
160 |
||
161 |
falsehoodMethodSource |
|
162 |
^ 'falsehood |
|
163 |
^ false' |
|
164 |
! |
|
165 |
||
166 |
protocolsForClass: aClass |
|
167 |
| protocols | |
|
168 |
protocols _ aClass organization categories. |
|
169 |
protocols size > 1 ifTrue: [protocols _ protocols copyWith: '-- all --']. |
|
170 |
^ protocols. |
|
171 |
! ! |
|
172 |
||
173 |
!MCSnapshotBrowserTest methodsFor:'running'! |
|
174 |
||
175 |
setUp |
|
176 |
model _ MCSnapshotBrowser forSnapshot: MCSnapshotResource current snapshot. |
|
177 |
morph _ model buildWindow. |
|
178 |
! ! |
|
179 |
||
180 |
!MCSnapshotBrowserTest methodsFor:'selecting'! |
|
181 |
||
182 |
selectMockClassA |
|
183 |
self clickOnListItem: self mockCategoryName. |
|
184 |
self clickOnListItem: 'MCMockClassA'. |
|
185 |
||
186 |
! ! |
|
187 |
||
188 |
!MCSnapshotBrowserTest methodsFor:'simulating'! |
|
189 |
||
190 |
clickOnButton: aString |
|
191 |
(self findButtonWithLabel: aString) performAction. |
|
192 |
! |
|
193 |
||
194 |
clickOnListItem: aString |
|
195 |
| listMorph | |
|
196 |
listMorph _ self findListContaining: aString. |
|
197 |
listMorph changeModelSelection: (listMorph getList indexOf: aString). |
|
198 |
! ! |
|
199 |
||
200 |
!MCSnapshotBrowserTest methodsFor:'testing'! |
|
201 |
||
202 |
testAnnotationPane |
|
203 |
| oldPref | |
|
204 |
oldPref _ Preferences annotationPanes. |
|
205 |
||
206 |
Preferences disable: #annotationPanes. |
|
207 |
morph _ model buildWindow. |
|
208 |
self assert: (self morphsOfClass: TextMorph) size = 1. |
|
209 |
||
210 |
Preferences enable: #annotationPanes. |
|
211 |
morph _ model buildWindow. |
|
212 |
self assert: (self morphsOfClass: TextMorph) size = 2. |
|
213 |
||
214 |
Preferences setPreference: #annotationPanes toValue: oldPref |
|
215 |
! |
|
216 |
||
217 |
testButtonMutex |
|
218 |
self assertButtonOn: 'instance'. |
|
219 |
self denyButtonOn: '?'. |
|
220 |
self denyButtonOn: 'class'. |
|
221 |
||
222 |
self clickOnButton: '?'. |
|
223 |
self assertButtonOn: '?'. |
|
224 |
self denyButtonOn: 'instance'. |
|
225 |
self denyButtonOn: 'class'. |
|
226 |
||
227 |
self clickOnButton: 'class'. |
|
228 |
self assertButtonOn: 'class'. |
|
229 |
self denyButtonOn: '?'. |
|
230 |
self denyButtonOn: 'instance'. |
|
231 |
! |
|
232 |
||
233 |
testCategorySelected |
|
234 |
self clickOnListItem: self mockCategoryName. |
|
235 |
||
236 |
self assertAListMatches: self allCategories. |
|
237 |
self assertAListMatches: self definedClasses. |
|
238 |
self denyAListIncludesAnyOf: self allProtocols. |
|
239 |
self denyAListIncludesAnyOf: self allMethods. |
|
240 |
self assertTextIs: ''. |
|
241 |
! |
|
242 |
||
243 |
testClassSelected |
|
244 |
self selectMockClassA. |
|
245 |
||
246 |
self assertAListMatches: self allCategories. |
|
247 |
self assertAListMatches: self definedClasses. |
|
248 |
self assertAListMatches: self classAProtocols. |
|
249 |
self denyAListIncludesAnyOf: self allMethods. |
|
250 |
self assertTextIs: self classADefinitionString. |
|
251 |
! |
|
252 |
||
253 |
testClassSideClassSelected |
|
254 |
self clickOnButton: 'class'. |
|
255 |
self selectMockClassA. |
|
256 |
||
257 |
self assertAListMatches: self allCategories. |
|
258 |
self assertAListMatches: self definedClasses. |
|
259 |
self assertAListMatches: self classAClassProtocols. |
|
260 |
self denyAListIncludesAnyOf: self allMethods. |
|
261 |
self assertTextIs: self classADefinitionString. |
|
262 |
! |
|
263 |
||
264 |
testComment |
|
265 |
self clickOnButton: '?'. |
|
266 |
self assertTextIs: ''. |
|
267 |
||
268 |
self clickOnListItem: self mockCategoryName. |
|
269 |
self assertTextIs: ''. |
|
270 |
||
271 |
self clickOnListItem: 'MCMockClassA'. |
|
272 |
self assertTextIs: self classAComment. |
|
273 |
! |
|
274 |
||
275 |
testFourColumns |
|
276 |
self assert: self listMorphs size = 4. |
|
277 |
! |
|
278 |
||
279 |
testMethodIsCleared |
|
280 |
self clickOnListItem: self mockCategoryName. |
|
281 |
self clickOnListItem: 'MCMockClassA'. |
|
282 |
self clickOnListItem: 'boolean'. |
|
283 |
self clickOnListItem: 'falsehood'. |
|
284 |
self clickOnListItem: '-- all --'. |
|
285 |
||
286 |
self denyAListHasSelection: 'falsehood'. |
|
287 |
! |
|
288 |
||
289 |
testMethodSelected |
|
290 |
self clickOnListItem: self mockCategoryName. |
|
291 |
self clickOnListItem: 'MCMockClassA'. |
|
292 |
self clickOnListItem: 'boolean'. |
|
293 |
self clickOnListItem: 'falsehood'. |
|
294 |
||
295 |
self assertAListMatches: self allCategories. |
|
296 |
self assertAListMatches: self definedClasses. |
|
297 |
self assertAListMatches: self classAProtocols. |
|
298 |
self assertAListMatches: self classABooleanMethods. |
|
299 |
self assertTextIs: self falsehoodMethodSource. |
|
300 |
! |
|
301 |
||
302 |
testNoSelection |
|
303 |
self assertAListMatches: self allCategories. |
|
304 |
self denyAListIncludesAnyOf: self definedClasses. |
|
305 |
self denyAListIncludesAnyOf: self allProtocols. |
|
306 |
self denyAListIncludesAnyOf: self allMethods. |
|
307 |
self assertTextIs: ''. |
|
308 |
! |
|
309 |
||
310 |
testProtocolIsCleared |
|
311 |
self clickOnListItem: self mockCategoryName. |
|
312 |
self clickOnListItem: 'MCMockASubclass'. |
|
313 |
self clickOnListItem: 'as yet unclassified'. |
|
314 |
self clickOnListItem: 'MCMockClassA'. |
|
315 |
||
316 |
self denyAListHasSelection: 'as yet unclassified'. |
|
317 |
! |
|
318 |
||
319 |
testProtocolSelected |
|
320 |
self clickOnListItem: self mockCategoryName. |
|
321 |
self clickOnListItem: 'MCMockClassA'. |
|
322 |
self clickOnListItem: 'boolean'. |
|
323 |
||
324 |
self assertAListMatches: self allCategories. |
|
325 |
self assertAListMatches: self definedClasses. |
|
326 |
self assertAListMatches: self classAProtocols. |
|
327 |
self assertAListMatches: self classABooleanMethods. |
|
328 |
self assertTextIs: ''. |
|
329 |
! |
|
330 |
||
331 |
testTextPane |
|
332 |
self shouldnt: [self textMorph] raise: Exception. |
|
333 |
! |
|
334 |
||
335 |
testThreeButtons |
|
336 |
self assertButtonExists: 'instance'. |
|
337 |
self assertButtonExists: '?'. |
|
338 |
self assertButtonExists: 'class'. |
|
339 |
! ! |
|
340 |
||
341 |
!MCSnapshotBrowserTest class methodsFor:'documentation'! |
|
342 |
||
343 |
version |
|
822
509715fb5cf5
Tests moved to category SCM-Monticello-Tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
24
diff
changeset
|
344 |
^ '$Header: /cvs/stx/stx/goodies/monticello/test/MCSnapshotBrowserTest.st,v 1.2 2013-05-29 00:02:19 vrany Exp $' |
24 | 345 |
! ! |
822
509715fb5cf5
Tests moved to category SCM-Monticello-Tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
24
diff
changeset
|
346 |