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