6607
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2015 Jan Vrany
|
|
3 |
COPYRIGHT (c) 2017 Jan Vrany
|
|
4 |
All Rights Reserved
|
|
5 |
|
|
6 |
This software is furnished under a license and may be used
|
|
7 |
only in accordance with the terms of that license and with the
|
|
8 |
inclusion of the above copyright notice. This software may not
|
|
9 |
be provided or otherwise made available to, or used by, any
|
|
10 |
other person. No title to or ownership of the software is
|
|
11 |
hereby transferred.
|
|
12 |
"
|
|
13 |
"{ Package: 'stx:libwidg/tests' }"
|
|
14 |
|
|
15 |
"{ NameSpace: Smalltalk }"
|
|
16 |
|
|
17 |
TestCase subclass:#EditFieldTests
|
|
18 |
instanceVariableNames:'window'
|
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'Views-Basic-Tests'
|
|
22 |
!
|
|
23 |
|
|
24 |
!EditFieldTests class methodsFor:'documentation'!
|
|
25 |
|
|
26 |
copyright
|
|
27 |
"
|
|
28 |
COPYRIGHT (c) 2015 Jan Vrany
|
|
29 |
COPYRIGHT (c) 2017 Jan Vrany
|
|
30 |
All Rights Reserved
|
|
31 |
|
|
32 |
This software is furnished under a license and may be used
|
|
33 |
only in accordance with the terms of that license and with the
|
|
34 |
inclusion of the above copyright notice. This software may not
|
|
35 |
be provided or otherwise made available to, or used by, any
|
|
36 |
other person. No title to or ownership of the software is
|
|
37 |
hereby transferred.
|
|
38 |
"
|
|
39 |
! !
|
|
40 |
|
|
41 |
!EditFieldTests methodsFor:'running'!
|
|
42 |
|
|
43 |
setUp
|
|
44 |
| firstEditField |
|
|
45 |
|
|
46 |
super setUp.
|
|
47 |
Smalltalk loadPackage:'stx:goodies/sunit/ext/ui'.
|
|
48 |
|
|
49 |
Screen current isNil ifTrue:[
|
|
50 |
Smalltalk openDisplay.
|
|
51 |
].
|
|
52 |
self skipIf:Screen current isNil description:'No display connection'.
|
|
53 |
|
|
54 |
"Add your own code here..."
|
|
55 |
window := StandardSystemView new.
|
|
56 |
window label: self printString.
|
|
57 |
window extent: 200@100.
|
|
58 |
|
|
59 |
firstEditField := EditField origin: (0.0@0.0) in: window.
|
|
60 |
firstEditField name: #FirstEditField.
|
|
61 |
firstEditField width: 1.0.
|
|
62 |
firstEditField model: 'Text to be tested' asValue.
|
|
63 |
|
|
64 |
window open.
|
|
65 |
window waitUntilVisible.
|
|
66 |
|
|
67 |
"Modified: / 23-01-2019 / 16:00:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
68 |
"Modified (format): / 20-03-2019 / 13:20:13 / svestkap"
|
|
69 |
!
|
|
70 |
|
|
71 |
tearDown
|
|
72 |
window isOpen ifTrue: [
|
|
73 |
window close
|
|
74 |
]
|
|
75 |
|
|
76 |
"Created: / 23-01-2019 / 15:08:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
77 |
"Modified: / 20-03-2019 / 13:17:02 / svestkap"
|
|
78 |
! !
|
|
79 |
|
|
80 |
!EditFieldTests methodsFor:'tests'!
|
|
81 |
|
|
82 |
test_issue_261a
|
|
83 |
"Do a screenshot of an EditField before pressing right arrow key and after. The results should match."
|
|
84 |
| editField editFieldInteractor image firstDetectedPixelColors secondDetectedPixelColors |
|
|
85 |
|
|
86 |
editField := (window subViews select: [ :subView |
|
|
87 |
subView name = #FirstEditField
|
|
88 |
]) first.
|
|
89 |
|
|
90 |
editFieldInteractor := editField interactor.
|
|
91 |
|
|
92 |
editField takeFocus.
|
|
93 |
editFieldInteractor type: #Home.
|
|
94 |
|
|
95 |
Delay waitForSeconds:1.
|
|
96 |
image := Image fromView:window grab:false.
|
|
97 |
firstDetectedPixelColors := Set new.
|
|
98 |
1 to: 30 do: [ :y |
|
|
99 |
5 to: 50 do: [ :x |
|
|
100 |
firstDetectedPixelColors add:(image colorAtX:x y:y)
|
|
101 |
]
|
|
102 |
].
|
|
103 |
|
|
104 |
editFieldInteractor type: #End.
|
|
105 |
editFieldInteractor type: #CursorRight.
|
|
106 |
|
|
107 |
Delay waitForSeconds:1.
|
|
108 |
image := Image fromView:window grab:false.
|
|
109 |
secondDetectedPixelColors := Set new.
|
|
110 |
1 to: 30 do: [ :y |
|
|
111 |
5 to: 50 do: [ :x |
|
|
112 |
secondDetectedPixelColors add:(image colorAtX:x y:y)
|
|
113 |
]
|
|
114 |
].
|
|
115 |
|
|
116 |
self assert:(firstDetectedPixelColors = secondDetectedPixelColors).
|
|
117 |
|
|
118 |
"Created: / 21-03-2019 / 11:05:48 / jv"
|
|
119 |
! !
|
|
120 |
|
|
121 |
!EditFieldTests class methodsFor:'documentation'!
|
|
122 |
|
|
123 |
version_HG
|
|
124 |
|
|
125 |
^ '$Changeset: <not expanded> $'
|
|
126 |
! !
|
|
127 |
|