-
Notifications
You must be signed in to change notification settings - Fork 31
/
unitTestListing.lua
executable file
·283 lines (242 loc) · 6.7 KB
/
unitTestListing.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
-- Abstract: Widget test listing
-- Code is MIT licensed; see https://www.coronalabs.com/links/code/license
---------------------------------------------------------------------------------------
local widget = require( "widget" )
local composer = require( "composer" )
local scene = composer.newScene()
local USE_IOS_THEME = false
local USE_IOS7_THEME = false
local USE_ANDROID_THEME = false
local USE_ANDROID_HOLO_LIGHT_THEME = false
local USE_ANDROID_HOLO_DARK_THEME = false
local isGraphicsV1 = ( 1 == display.getDefault( "graphicsCompatibility" ) )
local topGrayColor = { 0.92, 0.92, 0.92, 1 }
local separatorColor = { 0.77, 0.77, 0.77, 1 }
local headerTextColor = { 0, 0, 0, 1 }
if isGraphicsV1 then
widget._convertColorToV1( topGrayColor )
widget._convertColorToV1( separatorColor )
widget._convertColorToV1( headerTextColor )
end
function scene:create( event )
local group = self.view
-- Set theme
if USE_ANDROID_THEME then
widget.setTheme( "widget_theme_android" )
end
if USE_IOS_THEME then
widget.setTheme( "widget_theme_ios" )
end
if USE_IOS7_THEME then
widget.setTheme( "widget_theme_ios7" )
end
if USE_ANDROID_HOLO_LIGHT_THEME then
widget.setTheme( "widget_theme_android_holo_light" )
end
if USE_ANDROID_HOLO_DARK_THEME then
widget.setTheme( "widget_theme_android_holo_dark" )
end
local xAnchor, yAnchor
if not isGraphicsV1 then
xAnchor = display.contentCenterX
yAnchor = display.contentCenterY
else
xAnchor = 0
yAnchor = 0
end
local background = display.newRect( xAnchor, yAnchor, display.contentWidth, display.contentHeight )
if USE_IOS_THEME then
if isGraphicsV1 then background:setFillColor( 197, 204, 212, 255 )
else background:setFillColor( 197/255, 204/255, 212/255, 1 ) end
widget.USE_IOS_THEME = true
elseif USE_ANDROID_HOLO_LIGHT_THEME then
if isGraphicsV1 then background:setFillColor( 255, 255, 255, 255 )
else background:setFillColor( 1, 1, 1, 1 ) end
widget.USE_ANDROID_HOLO_LIGHT_THEME = true
elseif USE_ANDROID_HOLO_DARK_THEME then
if isGraphicsV1 then background:setFillColor( 34, 34, 34, 255 )
else background:setFillColor( 34/255, 34/255, 34/255, 1 ) end
widget.USE_ANDROID_HOLO_DARK_THEME = true
headerTextColor = { 0.5 }
else
if isGraphicsV1 then background:setFillColor( 255, 255, 255, 255 )
else background:setFillColor( 1, 1, 1, 1 ) end
end
group:insert( background )
-- create some skinning variables
local fontUsed = native.systemFont
local headerTextSize = 20
local separatorColor = { unpack( separatorColor ) }
local title = display.newText( group, "Select a unit test to view", 0, 0, fontUsed, headerTextSize )
title:setFillColor( unpack( headerTextColor ) )
title.x, title.y = display.contentCenterX, 20
group:insert( title )
if USE_IOS7_THEME then
local separator = display.newRect( group, display.contentCenterX, title.contentHeight + title.y, display.contentWidth, 0.5 )
separator:setFillColor( unpack ( separatorColor ) )
end
--Go to selected unit test
local function gotoSelection( event )
local phase = event.phase
if "ended" == phase then
local targetScene = event.target.id
composer.gotoScene( targetScene )
end
return true
end
local buttonX = 160
-- spinner unit test
local spinnerButton = widget.newButton
{
id = "spinner",
x = buttonX,
y = 75,
label = "Spinner",
width = 200, height = 34,
emboss = false,
onEvent = gotoSelection
}
group:insert( spinnerButton )
-- switch unit test
local switchButton = widget.newButton
{
id = "switch",
x = buttonX,
y = spinnerButton.y + 36,
label = "Switch",
width = 200, height = 34,
emboss = false,
onEvent = gotoSelection
}
group:insert( switchButton )
-- Stepper unit test
local stepperButton = widget.newButton
{
id = "stepper",
x = buttonX,
y = switchButton.y + 36,
label = "Stepper",
width = 200, height = 34,
emboss = false,
onEvent = gotoSelection
}
group:insert( stepperButton )
-- Search field unit test
--[[
local searchFieldButton = widget.newButton
{
id = "searchField",
x = buttonX,
y = stepperButton.y + 36,
label = "Search Field",
width = 200, height = 34,
emboss = false,
onEvent = gotoSelection
}
group:insert( searchFieldButton )
--]]
-- progressView unit test
local progressViewButton = widget.newButton
{
id = "progressView",
x = buttonX,
y = stepperButton.y + 36,
label = "ProgressView",
width = 200, height = 34,
emboss = false,
onEvent = gotoSelection
}
group:insert( progressViewButton )
-- segmentedControl unit test
local segmentedControlButton = widget.newButton
{
id = "segmentedControl",
x = buttonX,
y = progressViewButton.y + 36,
label = "SegmentedControl",
width = 200, height = 34,
emboss = false,
onEvent = gotoSelection
}
group:insert( segmentedControlButton )
-- button unit test
local buttonButton = widget.newButton
{
id = "button",
x = buttonX,
y = segmentedControlButton.y + 36,
label = "Button",
width = 200, height = 34,
emboss = false,
onEvent = gotoSelection
}
group:insert( buttonButton )
-- tabBar unit test
local tabBarButton = widget.newButton
{
id = "tabBar",
x = buttonX,
y = buttonButton.y + 36,
label = "TabBar",
width = 200, height = 34,
emboss = false,
onEvent = gotoSelection
}
group:insert( tabBarButton )
-- slider unit test
local sliderButton = widget.newButton
{
id = "slider",
x = buttonX,
y = tabBarButton.y + 36,
label = "Slider",
width = 200, height = 34,
emboss = false,
onEvent = gotoSelection
}
group:insert( sliderButton )
-- picker unit test
local pickerButton = widget.newButton
{
id = "picker",
x = buttonX,
y = sliderButton.y + 36,
label = "PickerWheel",
width = 200, height = 34,
emboss = false,
onEvent = gotoSelection
}
group:insert( pickerButton )
-- tableView unit test
local tableViewButton = widget.newButton
{
id = "tableView",
x = buttonX,
y = pickerButton.y + 36,
label = "TableView",
width = 200, height = 34,
emboss = false,
onEvent = gotoSelection
}
group:insert( tableViewButton )
-- scrollView unit test
local scrollViewButton = widget.newButton
{
id = "scrollView",
x = buttonX,
y = tableViewButton.y + 36,
label = "ScrollView",
width = 200, height = 34,
emboss = false,
onEvent = gotoSelection
}
group:insert( scrollViewButton )
end
function scene:hide( event )
if ( "did" == event.phase ) then
composer.removeHidden( false )
end
end
scene:addEventListener( "create", scene )
scene:addEventListener( "hide", scene )
return scene