@@ -58,8 +58,7 @@ pub struct TestingInner {
58
58
bench_button : DerefCell < gtk:: ToggleButton > ,
59
59
bench_labels : DerefCell < HashMap < & ' static str , gtk:: Label > > ,
60
60
num_runs_spin_2 : DerefCell < gtk:: SpinButton > ,
61
- num_runs_spin_3 : DerefCell < gtk:: SpinButton > ,
62
- test_buttons : DerefCell < [ gtk:: Button ; 3 ] > ,
61
+ test_buttons : DerefCell < [ gtk:: Button ; 2 ] > ,
63
62
test_labels : DerefCell < [ gtk:: Label ; 3 ] > ,
64
63
selma_start_button : DerefCell < gtk:: Button > ,
65
64
selma_stop_button : DerefCell < gtk:: Button > ,
@@ -140,7 +139,7 @@ impl ObjectImpl for TestingInner {
140
139
141
140
let bench_button = gtk:: ToggleButton :: with_label ( "Run USB test" ) ;
142
141
143
- obj . add ( & cascade ! {
142
+ let usb_test = & cascade ! {
144
143
gtk:: Box :: new( gtk:: Orientation :: Vertical , 12 ) ;
145
144
..add( & gtk:: Label :: new( Some ( "USB Port Test" ) ) ) ;
146
145
..add( & cascade! {
@@ -150,24 +149,22 @@ impl ObjectImpl for TestingInner {
150
149
..add( & row( & bench_button) ) ;
151
150
..set_header_func( Some ( Box :: new( header_func) ) ) ;
152
151
} ) ;
153
- } ) ;
152
+ } ;
154
153
155
154
let num_runs_spin_2 = gtk:: SpinButton :: with_range ( 1.0 , 1000.0 , 1.0 ) ;
156
- let num_runs_spin_3 = gtk:: SpinButton :: with_range ( 1.0 , 1000.0 , 1.0 ) ;
157
- num_runs_spin_3. set_value ( 100.0 ) ;
155
+ num_runs_spin_2. set_value ( 100.0 ) ;
158
156
159
157
let test_buttons = [
160
158
gtk:: Button :: with_label ( & fl ! ( "button-test" ) ) ,
161
159
gtk:: Button :: with_label ( & fl ! ( "button-test" ) ) ,
162
- gtk:: Button :: with_label ( & fl ! ( "button-test" ) ) ,
163
160
] ;
164
161
let test_labels = [
165
162
gtk:: Label :: new ( None ) ,
166
163
gtk:: Label :: new ( None ) ,
167
164
gtk:: Label :: new ( None ) ,
168
165
] ;
169
166
170
- obj . add ( & cascade ! {
167
+ let nelson_test_1 = & cascade ! {
171
168
gtk:: Box :: new( gtk:: Orientation :: Vertical , 12 ) ;
172
169
..add( & gtk:: Label :: new( Some ( "Nelson Test 1" ) ) ) ;
173
170
..add( & cascade! {
@@ -180,46 +177,31 @@ impl ObjectImpl for TestingInner {
180
177
..add( & label_row( "Check key (sticking)" , & color_box( 0. , 1. , 0. ) ) ) ;
181
178
..set_header_func( Some ( Box :: new( header_func) ) ) ;
182
179
} ) ;
183
- } ) ;
180
+ } ;
184
181
185
- obj . add ( & cascade ! {
182
+ let nelson_test_2 = & cascade ! {
186
183
gtk:: Box :: new( gtk:: Orientation :: Vertical , 12 ) ;
187
184
..add( & gtk:: Label :: new( Some ( "Nelson Test 2" ) ) ) ;
188
185
..add( & cascade! {
189
186
gtk:: ListBox :: new( ) ;
190
187
..set_valign( gtk:: Align :: Start ) ;
191
188
..style_context( ) . add_class( "frame" ) ;
192
- ..add( & label_row( "Number of runs", & num_runs_spin_2) ) ;
189
+ ..add( & label_row( & fl! ( "test-number-of- runs") , & num_runs_spin_2) ) ;
193
190
..add( & row( & test_buttons[ 1 ] ) ) ;
194
- ..add( & row( & test_labels[ 1 ] ) ) ;
195
- ..add( & label_row( "Replace switch (bouncing)" , & color_box( 0. , 0. , 1. ) ) ) ;
196
- ..set_header_func( Some ( Box :: new( header_func) ) ) ;
197
- } ) ;
198
- } ) ;
199
-
200
- obj. add ( & cascade ! {
201
- gtk:: Box :: new( gtk:: Orientation :: Vertical , 12 ) ;
202
- ..add( & gtk:: Label :: new( Some ( "Nelson Test 3" ) ) ) ;
203
- ..add( & cascade! {
204
- gtk:: ListBox :: new( ) ;
205
- ..set_valign( gtk:: Align :: Start ) ;
206
- ..style_context( ) . add_class( "frame" ) ;
207
- ..add( & label_row( & fl!( "test-number-of-runs" ) , & num_runs_spin_3) ) ;
208
- ..add( & row( & test_buttons[ 2 ] ) ) ;
209
191
..add( & row( & test_labels[ 2 ] ) ) ;
210
192
..add( & label_row( & fl!( "test-check-pins" ) , & color_box( 1. , 0. , 0. ) ) ) ;
211
193
..add( & label_row( & fl!( "test-check-key" ) , & color_box( 0. , 1. , 0. ) ) ) ;
212
194
..set_header_func( Some ( Box :: new( header_func) ) ) ;
213
195
} ) ;
214
- } ) ;
196
+ } ;
215
197
216
198
let selma_start_button = gtk:: Button :: with_label ( & fl ! ( "button-start" ) ) ;
217
199
let selma_stop_button = cascade ! {
218
200
gtk:: Button :: with_label( & fl!( "button-stop" ) ) ;
219
201
..set_sensitive( false ) ;
220
202
} ;
221
203
222
- obj . add ( & cascade ! {
204
+ let selma_test = & cascade ! {
223
205
gtk:: Box :: new( gtk:: Orientation :: Vertical , 12 ) ;
224
206
..add( & gtk:: Label :: new( Some ( "Selma Test" ) ) ) ;
225
207
..add( & cascade! {
@@ -235,13 +217,29 @@ impl ObjectImpl for TestingInner {
235
217
..add( & label_row( & fl!( "test-spurious-keypress" ) , & color_box( 1. , 0. , 0. ) ) ) ;
236
218
..set_header_func( Some ( Box :: new( header_func) ) ) ;
237
219
} ) ;
220
+ } ;
221
+
222
+ obj. add ( & cascade ! {
223
+ gtk:: Box :: new( gtk:: Orientation :: Horizontal , 18 ) ;
224
+ ..set_valign( gtk:: Align :: Start ) ;
225
+ ..add( & cascade! {
226
+ gtk:: Box :: new( gtk:: Orientation :: Vertical , 18 ) ;
227
+ ..set_valign( gtk:: Align :: Start ) ;
228
+ ..add( & row( usb_test) ) ;
229
+ ..add( & row( selma_test) ) ;
230
+ } ) ;
231
+ ..add( & cascade! {
232
+ gtk:: Box :: new( gtk:: Orientation :: Vertical , 18 ) ;
233
+ ..set_valign( gtk:: Align :: Start ) ;
234
+ ..add( & row( nelson_test_1) ) ;
235
+ ..add( & row( nelson_test_2) ) ;
236
+ } ) ;
238
237
} ) ;
239
238
240
239
self . reset_button . set ( reset_button) ;
241
240
self . bench_button . set ( bench_button) ;
242
241
self . bench_labels . set ( bench_labels) ;
243
242
self . num_runs_spin_2 . set ( num_runs_spin_2) ;
244
- self . num_runs_spin_3 . set ( num_runs_spin_3) ;
245
243
self . test_buttons . set ( test_buttons) ;
246
244
self . test_labels . set ( test_labels) ;
247
245
self . selma_start_button . set ( selma_start_button) ;
@@ -372,7 +370,7 @@ impl Testing {
372
370
}
373
371
374
372
fn test_buttons_sensitive ( & self , sensitive : bool ) {
375
- for i in 0 ..3 {
373
+ for i in 0 ..2 {
376
374
self . inner ( ) . test_buttons [ i] . set_sensitive ( sensitive) ;
377
375
}
378
376
self . inner ( ) . selma_start_button . set_sensitive ( sensitive) ;
@@ -435,7 +433,7 @@ impl Testing {
435
433
436
434
self . notify ( "colors" ) ;
437
435
438
- if nelson. success ( ) {
436
+ if nelson. success ( testing . board . layout ( ) . layout ( ) ) {
439
437
let message = format ! ( "Test {}/{} successful" , test_run, test_runs) ;
440
438
info ! ( "{}" , message) ;
441
439
test_label. set_text ( & message) ;
@@ -467,18 +465,6 @@ impl Testing {
467
465
glib:: MainContext :: default ( ) . spawn_local( clone!( @strong self_ => async move {
468
466
self_. nelson(
469
467
self_. inner( ) . num_runs_spin_2. value_as_int( ) ,
470
- 1 ,
471
- NelsonKind :: Bouncing ,
472
- ) . await ;
473
- } ) ) ;
474
- } ) ) ;
475
- }
476
-
477
- fn connect_test_button_3 ( & self ) {
478
- self . inner ( ) . test_buttons [ 2 ] . connect_clicked ( clone ! ( @strong self as self_ => move |_| {
479
- glib:: MainContext :: default ( ) . spawn_local( clone!( @strong self_ => async move {
480
- self_. nelson(
481
- self_. inner( ) . num_runs_spin_3. value_as_int( ) ,
482
468
2 ,
483
469
NelsonKind :: Normal ,
484
470
) . await ;
@@ -569,7 +555,6 @@ impl Testing {
569
555
obj. connect_bench_button ( ) ;
570
556
obj. connect_test_button_1 ( ) ;
571
557
obj. connect_test_button_2 ( ) ;
572
- obj. connect_test_button_3 ( ) ;
573
558
obj. connect_selma_buttons ( ) ;
574
559
obj. connect_reset_button ( ) ;
575
560
obj. update_benchmarks ( ) ;
0 commit comments