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