Ticket #261: EditFieldTests.st

File EditFieldTests.st, 2.6 KB (added by patrik.svestka@…, 5 years ago)

Test which shows the bug

Line 
1'From Smalltalk/X jv-branch, Version:8.0.99.0 on 20-03-2019 at 01:21:24 PM' !
2
3"{ Package: 'stx:libview/tests' }"
4
5"{ NameSpace: Smalltalk }"
6
7TestCase subclass:#EditFieldTests
8 instanceVariableNames:'window'
9 classVariableNames:''
10 poolDictionaries:''
11 category:'Views-Basic-Tests'
12!
13
14!EditFieldTests methodsFor:'editFieldTests'!
15
16testEditFieldEnd
17 "Do a screenshot of an EditField before pressing right arrow key and after. The results should match."
18 | editField editFieldInteractor image firstDetectedPixelColors secondDetectedPixelColors |
19
20 editField := (window subViews select: [ :subView |
21 subView name = #FirstEditField
22 ]) first.
23
24 editFieldInteractor := editField interactor.
25
26 editField takeFocus.
27 editFieldInteractor type: #Home.
28
29 Delay waitForSeconds:1.
30 image := Image fromView:window grab:false.
31 firstDetectedPixelColors := Set new.
32 1 to: 30 do: [ :y |
33 5 to: 50 do: [ :x |
34 firstDetectedPixelColors add:(image colorAtX:x y:y)
35 ]
36 ].
37
38 editFieldInteractor type: #End.
39 editFieldInteractor type: #CursorRight.
40
41 Delay waitForSeconds:1.
42 image := Image fromView:window grab:false.
43 secondDetectedPixelColors := Set new.
44 1 to: 30 do: [ :y |
45 5 to: 50 do: [ :x |
46 secondDetectedPixelColors add:(image colorAtX:x y:y)
47 ]
48 ].
49
50 self assert:(firstDetectedPixelColors = secondDetectedPixelColors).
51
52 "Created: / 20-03-2019 / 12:30:56 / svestkap"
53! !
54
55!EditFieldTests methodsFor:'running'!
56
57setUp
58 | firstEditField |
59
60 super setUp.
61 Smalltalk loadPackage:'stx:goodies/sunit/ext/ui'.
62
63 Screen current isNil ifTrue:[
64 Smalltalk openDisplay.
65 ].
66 self skipIf:Screen current isNil description:'No display connection'.
67
68 "Add your own code here..."
69 window := StandardSystemView new.
70 window label: self printString.
71 window extent: 200@100.
72
73 firstEditField := EditField origin: (0.0@0.0) in: window.
74 firstEditField name: #FirstEditField.
75 firstEditField width: 1.0.
76 firstEditField model: 'Text to be tested' asValue.
77
78 window open.
79 window waitUntilVisible.
80
81 "Modified: / 23-01-2019 / 16:00:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
82 "Modified (format): / 20-03-2019 / 13:20:13 / svestkap"
83!
84
85tearDown
86 window isOpen ifTrue: [
87 window close
88 ]
89
90 "Created: / 23-01-2019 / 15:08:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
91 "Modified: / 20-03-2019 / 13:17:02 / svestkap"
92! !
93