-
Notifications
You must be signed in to change notification settings - Fork 5
/
auto-tests.js
1446 lines (1255 loc) · 36.9 KB
/
auto-tests.js
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
__author__ = "Craig Wieczorek, John Wieczorek"
__copyright__ = "Copyright 2015 Regents of the University of California"
__version__ = "auto_tests.js 2015-12-21T13:10-03:00"
*/
//NOT USED
var enum_report_level =
{
FULL: 1,
FAIL_ONLY: 2
}
//USED but somewhat silly
var tr =
{
FAIL: false,
PASS: true
// SKIP: 3
}
//NOT USED
var g_test_report = enum_report_level.FULL;
var g_PASS = tr.PASS;
var g_FAIL = tr.FAIL;
//var g_SKIP = tr.SKIP;
var g_report_max_depth=2;
var g_report_current_depth=0;
function onChoiceTest()
{
var testindex = uiGetSelectedIndex("ChoiceTest");
var test_obj = [];
var tc_base = "test " + testindex;
var fName = "onChoiceTest" + testindex;
test_obj[0] = g_tests[testindex];
g_report_max_depth = 2;
g_report_current_depth = 1;
runStandardTests( tc_base, test_obj, fName );
}
function testCaseName( tc, add )
{
g_report_current_depth = g_report_current_depth + 1;
var prepend = "-";
if( tc === null || tc == "null" || tc == undefined || tc == "" )
{
tc = "";
prepend = "";
}
if( add && add.length > 0 )
{
tc = tc + prepend + add;
}
return tc;
}
function testHelperfName( callstack )
{
var fName = arguments.callee.caller.toString();
fName = fName.substr('function ', fName.length );
fName = fName.substr(0, fName.indexOf('('));
fName = fName.substr(9, fName.length );
//fName = fName.substr(0, fName.indexOf('('));
if(callstack)
{
fName = callstack + ":" + fName;
}
return fName;
}
function log_test_result( tc_base, callstack, result, extra )
{
var rs = "%cFAIL%c";
var failed = true;
var cssnorm = "color: #000"
var cssstr = "color: #800"
if( result )
{
cssstr = "color: #060"
rs = "%cPASS%c";
failed = false;
}
//console.log('%c Oh my heavens! ', 'background: #222; color: #bada55');
if( ( g_report_current_depth <= g_report_max_depth ) || failed )
{
rs = rs + " " + tc_base + ": " + callstack;
if( extra )
{
rs = rs + " Extra: " + extra;
}
console.log( rs, cssstr, cssnorm);
}
else
{
var i;//console.log( "Skipping because g_report_current_depth = " + g_report_current_depth + " " + rs );
}
g_report_current_depth = g_report_current_depth - 1;
}
function testHiddenDisplay( tc_base, name, expected_hid, expected_dis, callstack )
{
tc_base = testCaseName( tc_base, "H/D" );
var fName = testHelperfName( callstack );
var test_result_h = testHidden( tc_base, name, expected_hid, fName );
var test_result_d = testDisplay( tc_base, name, expected_dis, fName );
var test_result = g_FAIL;
if( test_result_h && test_result_d )
{
test_result = g_PASS;
}
else
{
test_extra = "expected_hid: " + expected_hid + " expected_dis: " + expected_dis;
}
log_test_result( tc_base, fName, test_result );
return test_result;
}
function testHidden( tc_base, name, expected, callstack )
{
var fName = testHelperfName( callstack );
tc_base = testCaseName( tc_base, "HIDDEN" );
var test_result = g_FAIL;
var test_extra = "";
var el = document.getElementById( name );
if( el )
{
var st = el.hidden;
if( st !== undefined )
{
var actual = st.toString();
if( actual == expected )
{
test_result = g_PASS;
test_extra = "Actual: " + actual + " Expected: " + expected;
}
else
{
test_extra = "Element " + name + " hidden Actual: " + actual + " Expected: " + expected;
}
}
else
{
test_extra = "Element " + name + " has no HTML attribute 'hidden'";
}
}
else
(
test_extra = "Element " + name + " not found "
)
log_test_result(tc_base, fName, test_result, test_extra );
return test_result;
}
function testGetElement( tc_base, name, callstack )
{
var fName = testHelperfName( callstack );
tc_base = testCaseName( tc_base, "GETEL(" + name + ")");
var test_result = g_FAIL;
var test_extra = name + " not found";
var el = document.getElementById( name );
if( el )
{
test_result = g_PASS;
}
log_test_result(tc_base, fName, test_result, test_extra );
return el;
}
function testChooseSelectValue( tc_base, name, value, callstack )
{
var fName = testHelperfName( callstack );
tc_base = testCaseName( tc_base, "SELECT" );
var test_result = g_FAIL;
var sub_result = g_FAIL;
var temp = "";
var test_extra = "";
var el = testGetElement( tc_base, name, fName );
if( el )
{
if( name.indexOf("Dir") > -1 || name.indexOf("Scale") > -1 || name.indexOf("Units") > -1 || name.indexOf("Dist") > -1 )
{
temp = value;
}
else
{
temp = testLazyLookUpSelect( tc_base, name, value, fName );
}
if( temp )
{
value = temp;
uiSetSelectedValue( name, value );
sub_result = uiGetSelectedValue( name );
}
if( sub_result && sub_result == value )
{
temp = "on"+ name.substr( 6,name.length ) + "Select()";
var c = "";
var caught = false;
try
{
c = eval( temp );
}
catch(err)
{
test_extra = "error eval()ing " + temp + " " + err.messsage;
caught = true;
}
finally
{
if( caught == false )
{
test_result = g_PASS;
}
}
}
else
{
test_extra = "could select value" + value + " from " + name;
}
}
else
{
test_extra = " could not find element name " + name;
}
log_test_result(tc_base, fName, test_result, test_extra );
return test_result;
}
function testSetTextValue( tc_base, name, value, raw_name, callstack )
{
var fName = testHelperfName( callstack );
tc_base = testCaseName( tc_base, "SetText" );
var test_result = g_FAIL;
var sub_result = "";
var temp = "";
var test_extra = "";
var el = testGetElement( tc_base, name, fName );
if( el )
{
uiSetLabelExplicit( name, value );
sub_result = uiGetTextValue( name );
if( sub_result == value )
{
temp = name + "_focusGained()";
var c = "";
var caught = false;
try
{
c = eval( temp );
}
catch(err)
{
test_extra = "error eval()ing " + temp + " " + err.messsage;
caught = true;
}
finally
{
if( caught == false )
{
test_result = g_PASS;
}
}
}
else
{
test_extra = "could not get value" + value + " from " + name +" got "+sub_result+" instead";
}
}
else
{
test_extra = " could not find element name " + name;
}
log_test_result(tc_base, fName, test_result, test_extra );
return test_result;
}
function testButtonClick( tc_base, name, value, raw_name, callstack )
{
var fName = testHelperfName( callstack );
tc_base = testCaseName( tc_base, "button click" );
var test_result = g_FAIL;
var sub_result = "";
var temp = "";
var test_extra = "";
var el = testGetElement( tc_base, name, fName );
if( el )
{
temp = name + "_afterActionPerformed()";
var c = "";
var caught = false;
//try
//{
c = eval( temp );
//}
//catch(err)
//{
//test_extra = "error eval()ing " + temp + " " + err.messsage;
//caught = true;
//}
//finally
//{
//if( caught == false )
//{
test_result = g_PASS;
//}
//}
}
else
{
test_extra = " could not find element name " + name;
}
log_test_result(tc_base, fName, test_result, test_extra );
return test_result;
}
function testDisplay( tc_base, name, expected, callstack )
{
var fName = testHelperfName( callstack );
tc_base = testCaseName( tc_base, "DISPLAY" );
var test_result = g_FAIL;
var test_extra = "";
var el = document.getElementById( name );
var actual = null;
if( el )
{
var st = el.style.display;
if( st )
{
actual = st.toString();
if( actual == expected )
{
test_result = g_PASS;
test_extra = "Actual: " + actual + " Expected: " + expected;
}
else
{
test_extra = "Element " + name + " style.display Actual: " + actual + " Expected: " + expected;
}
}
else if( ( expected === null || expected == "null" || expected == undefined || expected == "" )
&&
( st === null || st == "null" || st == undefined || st == "" )
)
{
test_result = g_PASS;
test_extra = "Actual: " + actual + " Expected: " + expected;
}
else
{
test_extra = "Element " + name + " has no CSS style property 'display'";
}
}
else
(
test_extra = "Element " + name + " not found"
)
log_test_result(tc_base, fName, test_result, test_extra );
return test_result;
}
//TODO make this language independent
function testCalcType( tc_base, calctype, callstack )
{
var fName = testHelperfName( callstack );
tc_base = testCaseName( tc_base, "CalcType" );
var test_result = g_FAIL;
var test_extra = "";
//tc_base = tc_base + "-CalcType";
if( calctype == "err only" || calctype == "Error only" || calctype == "Error only (because we already know the coordinates of the final location)")
{
test_result = testChooseSelectValue( tc_base, "ChoiceCalcType", "Error only - enter Lat/Long for the actual locality", fName )
}
else if( calctype == "Coordinates and error" || calctype == "coords and error" )
{
test_result = testChooseSelectValue( tc_base, "ChoiceCalcType", "Coordinates and error - enter the Lat/Long for the named place or starting point", fName )
}
else if( calctype == "Coordinate only" || calctype == "coords only")
{
test_result = testChooseSelectValue( tc_base, "ChoiceCalcType", "Coordinates only - enter the Lat/Long for the named place or starting point", fName )
}
else if( calctype == "" || calctype == "empty" )
{
test_result = testChooseSelectValue( tc_base, "ChoiceCalcType", "", fName )
}
else
{
test_extra = " calcctype :" + calctype + ": not found in if/else"
}
log_test_result(tc_base, fName, test_result, test_extra );
return test_result;
}
//TODO make this language independent
function testLocType( tc_base, loctype, callstack )
{
var fName = testHelperfName( callstack );
tc_base = testCaseName( tc_base, "LocType" );
var test_result = g_FAIL;
var test_extra = "";
//tc_base = tc_base + "-LocType";
if( loctype == "coords only" || loctype == "Coordinates only" )
{
test_result = testChooseSelectValue( tc_base, "ChoiceModel", "Coordinates only (e.g., 27\u00b034'23.4\" N, 121\u00b056'42.3\" W)", fName )
}
else if( loctype == "named place" || loctype == "Named place" || loctype == "Named place only" )
{
test_result = testChooseSelectValue( tc_base, "ChoiceModel", "Named place only (e.g., Bakersfield)", fName )
}
else if( loctype == "dist only" || loctype == "Distance only" )
{
test_result = testChooseSelectValue( tc_base, "ChoiceModel", "Distance only (e.g., 5 mi from Bakersfield)", fName )
}
else if( loctype == "dist path" || loctype == "Distance along path" )
{
test_result = testChooseSelectValue( tc_base, "ChoiceModel", "Distance along path (e.g., 13 mi E (by road) Bakersfield)", fName )
}
else if( loctype == "dist ortho" || loctype == "Distance along orthogonal directions" )
{
test_result = testChooseSelectValue( tc_base, "ChoiceModel", "Distance along orthogonal directions (e.g., 2 mi E and 3 mi N of Bakersfield)", fName )
}
else if( loctype == "dist at" || loctype == "Distance at a heading" )
{
test_result = testChooseSelectValue( tc_base, "ChoiceModel", "Distance at a heading (e.g., 10 mi E (by air) Bakersfield)", fName )
}
else if( loctype == "" || loctype == "empty" )
{
test_result = testChooseSelectValue( tc_base, "ChoiceModel", "", fName )
}
else
{
test_extra = " calcctype " + loctype + " not found in if else"
}
log_test_result(tc_base, fName, test_result, test_extra );
return test_result;
}
function testEmptyTextBoxes()
{
uiSetLabelExplicit("TextFieldOffset", "" );
uiSetLabelExplicit("TextFieldHeading", "" );
uiSetLabelExplicit("TextFieldOffsetEW", "" );
uiSetLabelExplicit("txtT7Lat_DegDMS", "" );
uiSetLabelExplicit("txtT7Lat_MinDMS", "" );
uiSetLabelExplicit("txtT7Lat_Sec", "" );
uiSetLabelExplicit("txtT2Dec_Lat", "" );
uiSetLabelExplicit("txtT7Lat_DegMM", "" );
uiSetLabelExplicit("txtT7Lat_MinMM", "" );
uiSetLabelExplicit("TextFieldExtent", "" );
uiSetLabelExplicit("txtT7Long_DegDMS", "" );
uiSetLabelExplicit("txtT7Long_MinDMS", "" );
uiSetLabelExplicit("txtT7Long_Sec", "" );
uiSetLabelExplicit("txtT2Dec_Long", "" );
uiSetLabelExplicit("txtT7Long_DegMM", "" );
uiSetLabelExplicit("txtT7Long_MinMM", "" );
uiSetLabelExplicit("TextFieldMeasurementError", "" );
uiSetLabelExplicit("TextFieldCalcDecLat", "" );
uiSetLabelExplicit("TextFieldCalcDecLong", "" );
uiSetLabelExplicit("TextFieldCalcErrorDist", "" );
uiSetLabelExplicit("TextFieldCalcErrorUnits", "" );
uiSetLabelExplicit("TextFieldFullResult", "" );
uiSetLabelExplicit("TextFieldFromDistance", "" );
uiSetLabelExplicit("TextFieldFromDistance", "" );
uiSetLabelExplicit("TextFieldScaleFromDistance", "" );
}
function testSetSelectsDefault()
{
//Note: ORDER OF EXECUTION MATTERS
uiSetSelectedIndex("ChoiceScale", 0 );
onScaleSelect();
uiSetSelectedIndex("ChoiceScaleFromDistUnits", 0 );
onScaleFromDistUnitsSelect();
uiSetSelectedIndex("ChoiceScaleToDistUnits", 0 );
onScaleToDistUnitsSelect();
uiSetSelectedIndex("ChoiceToDistUnits", 0 );
onToDistUnitsSelect();
uiSetSelectedIndex("ChoiceFromDistUnits", 0 );
onFromDistUnitsSelect();
uiSetSelectedIndex("ChoiceDistancePrecision", 0 );
onDistancePrecisionSelect();
uiSetSelectedIndex("ChoiceLatPrecision", 0 );
onLatPrecisionSelect();
uiSetSelectedIndex("ChoiceDistUnits", 0 );
onDistUnitsSelect();
uiSetSelectedIndex("ChoiceLongDirDMS", 0 );
onLongDirDMSSelect();
uiSetSelectedIndex("ChoiceLatDirDMS", 0 );
onLatDirDMSSelect();
uiSetSelectedIndex("ChoiceLongDirMM", 0 );
onLongDirMMSelect();
uiSetSelectedIndex("ChoiceLatDirMM", 0 );
onLatDirMMSelect();
uiSetSelectedIndex("ChoiceOffsetEWDir", 0 );
onOffsetEWDirSelect();
uiSetSelectedIndex("ChoiceCoordSystem", 0 );
onCoordSystemSelect();
uiSetSelectedIndex("ChoiceOffsetNSDir", 0 );
onOffsetNSDirSelect();
uiSetSelectedIndex("ChoiceDatum", 0 );
onDatumSelect();
uiSetSelectedIndex("ChoiceDirection", 0 );
onDirectionSelect();
uiSetSelectedIndex("ChoiceCoordSource", 0 );
onCoordSourceSelect();
uiSetSelectedValue("ChoiceModel", "" );
onModelSelect();
uiSetSelectedValue("ChoiceCalcType", "" );
onCalcTypeSelect();
}
function testReset()
{
testSetSelectsDefault();
testEmptyTextBoxes();
}
function testMapElementToProperty( name )
{
var returnVal = null;
if( name )
{
if( name == "ChoiceScale" )
{
returnVal={ d:0, a:["static"] };
}
else if( name == "ChoiceScaleFromDistUnits" )
{
returnVal={ d:0, a:["static"] };
}
else if( name == "ChoiceScaleToDistUnits" )
{
returnVal={ d:0, a:["static"] };
}
else if( name == "ChoiceToDistUnits" )
{
returnVal={ d:0, a:["static"] };
}
else if( name == "ChoiceFromDistUnits" )
{
returnVal={ d:0, a:["static"] };
}
else if( name == "ChoiceDistancePrecision" )
{
returnVal={ d:0, a:["static"] };
}
else if( name == "ChoiceLatPrecision" )
{
returnVal={ d:0, a:["static"] };
}
else if( name == "ChoiceDistUnits" )
{
returnVal={ d:0, a:["static"] };
}
else if( name == "ChoiceLatDirDMS" )
{
//TODO nw /ew are all included imn heading making it possible to screw up test data
returnVal={ d:1, a:[ "headings.n", "headings.s" ] };
}
else if( name == "ChoiceLongDirDMS" )
{
//TODO nw /ew are all included imn heading making it possible to screw up test data
returnVal={ d:1, a:[ "headings.e", "headings.w" ] };
}
else if( name == "ChoiceLatDirMM" )
{
//TODO nw /ew are all included imn heading making it possible to screw up test data
returnVal={ d:1, a:[ "headings.n", "headings.s" ] };
}
else if( name == "ChoiceLongDirMM" )
{
//TODO nw /ew are all included imn heading making it possible to screw up test data
returnVal={ d:1, a:[ "headings.e", "headings.w" ] };
}
else if( name == "ChoiceOffsetEWDir" )
{
//TODO nw /ew are all included imn heading making it possible to screw up test data
returnVal={ d:1, a:[ "headings.e", "headings.w" ] };
}
else if( name == "ChoiceCoordSystem" )
{
returnVal={ d:2, a:["coordsys"] };
}
else if( name == "ChoiceOffsetNSDir" )
{
//TODO nw /ew are all included imn heading making it possible to screw up test data
returnVal={ d:1, a:[ "headings.n", "headings.s" ] };
}
else if( name == "ChoiceDatum" )
{
returnVal={ d:0, a:[ "static" ] }; //not really rtue, datum not recorded is special cased
}
else if( name == "ChoiceDirection" )
{
returnVal={ d:2, a:[ "headings"] };
}
else if( name == "ChoiceCoordSource" )
{
returnVal={ d:2, a:[ "coordsource" ] };
}
else if( name == "ChoiceModel" )
{
returnVal={ d:2, a:["loctype"] };
}
else if( name == "ChoiceCalcType" )
{
returnVal={ d:2, a:["calctype"] };
}
else if( name == "ChoiceLanguage" )
{
returnVal={ d:0, a:["static"] };
}
}
if( !returnVal )
{
consoloe.log("ERROR testMapElementToProperty element not found:"+name+":")
}
return returnVal;
}
function testMapLanguageToShortName( language )
{
var returnVal = null;
if( language )
{
var l = toLowerCase(language);
if( l == "en" ||
l == "english" ||
l == "english(local)" ||
l == "eng")
{
returnVal="en";
}
else if(l == "es" ||
l == "esp" ||
l == "espa" ||
l == "span" ||
l == "spanish" //||
//wont work l == "español"
)
{
returnVal="esp";
}
else if(//wont work l == "português" ||
l == "pt" ||
l == "portuguese" ||
l == "port" )
{
returnVal="pt";
}
else if(l == "fr" ||
l == "french" ||
//wont work l == "français" ||
l == "fren" )
{
returnVal="fr";
}
else if(l == "nl" ||
l == "neder" ||
l == "nederlands" ||
l == "ederlander" )
{
returnVal="nl";
}
}
if( !returnVal )
{
consoloe.log("ERROR testMapLanguageToShortName language not found:"+language+":")
}
return returnVal;
}
//poorly mnamed, source is not used
function testGetLangEquiv( src_lang, writ_lang, props_from )
{
returnVal = null;
var src_val = g_properties.getProperty(props_from, src_lang );
var w_val = g_properties.getProperty(props_from, writ_from );
if( w_val && src_val )
{
returnVal = w_val;
}
return returnVal;
}
function testGetStaticValuesFromChoice( element, src_lang, writ_lang )
{
var el=document.getElementById(element);
var additions=[];
//testGetLangEquiv( src_lang, writ_lang, props_from )
var slv = g_properties.getProperty( "datum.notrecorded", src_lang );
//var elv = g_properties.getProperty( "datum.notrecorded", "en" );
var wlv = g_properties.getProperty( "datum.notrecorded", writ_lang );
if( el )
{
for( var i=0; i< el.length; i++ )
{
var val = el[i].text;
if( src_lang && val && val == slv )
{
additions.push( wlv );
}
else
{
additions.push( val );
}
}
}
return additions
}
function runChoiceElement( tc_base, element, value, raw_name, callstack )
{
var fName = testHelperfName( callstack );
tc_base = testCaseName( tc_base, "runChoice" );
var test_result = g_FAIL;
var test_extra = "";
test_result = testChooseSelectValue(tc_base, element, value, fName);
log_test_result(tc_base, fName, test_result, test_extra );
return test_result;
}
function runChoiceElement_crap( tc_base, element, value, raw_name, callstack, ltf, ltw )
{
var fName = testHelperfName( callstack );
tc_base = testCaseName( tc_base, "runChoice" );
var test_result = g_FAIL;
var test_extra = "";
var addition = [];
var t = value;
var lookup_table = {};
if( ltf !== ltw )
{
var lt = testMapLanguageToShortName(ltf);
var lw = testMapLanguageToShortName(ltw);
var props= testMapElementToProperty(element);
if( props && props.length )
{
var l = props.length
for( var i=0; i< l; i++)
{
if( props[i] == "static" ) //i should always end at for static
{
var additions = testGetStaticValuesFromChoice( element, ltf, ltw )
}
else
{
var str = props[i];
//TODO this is a really weak determine hack, lookds for "coords" rather than "headings.n"
var split_count = str.split(".");
if( split_count == 0 )
{
c = eval( "props" )
for( var k in c )
{
var a = eval( props + k + ltf );
var b = eval( props + k + ltw );
if( a && b )
{
aditions.push( ltw );
}
}
}
}
}
}
}
test_result = testChooseSelectValue(tc_base, element, t, fName)
log_test_result(tc_base, fName, test_result, test_extra );
return test_result;
}
function runTextElement( tc_base, element, value, raw_name, callstack, ltf, ltw )
{
var fName = testHelperfName( callstack );
tc_base = testCaseName( tc_base, "runText" );
var test_result = g_FAIL;
var test_extra = "";
test_result = testSetTextValue(tc_base, element, value, raw_name, fName)
log_test_result(tc_base, fName, test_result, test_extra );
return test_result;
}
function runButtonElement( tc_base, element, value, raw_name, callstack, ltf, ltw )
{
var fName = testHelperfName( callstack );
tc_base = testCaseName( tc_base, "runText" );
var test_result = g_FAIL;
var test_extra = "";
test_result = testButtonClick(tc_base, element, value, raw_name, fName)
log_test_result(tc_base, fName, test_result, test_extra );
return test_result;
}
function runStandardCheckTextElement( tc_base, name, value, callstack, ltf, ltw )
{
var fName = testHelperfName( callstack );
tc_base = testCaseName( tc_base, "CheckTextElement" );
var test_result = g_FAIL;
var test_extra = "";
var temp = "";
temp = uiGetTextValue( name );
if( temp == value )
{
test_result = g_PASS;
}
else
{
test_extra = "value :" + value + ": found :" + temp + ": for element :" + name +":";
}
log_test_result(tc_base, fName, test_result, test_extra );
return test_result;
}
function testGetValuesFromProps( props, ltw)
{
returnArray = null;
returnArray = [];
for(var p in props )
{
}
return[];
}
//TODO this should be for check or set choice, OR label, not just check choice
function runStandardCheckChoiceElement( tc_base, name, value, callstack, ltf, ltw )
{
var fName = testHelperfName( callstack );
tc_base = testCaseName( tc_base, "CheckChoiceElement" );
var test_result = g_FAIL;
var test_extra = "";
var versus_val = uiGetSelectedValue( name );
var full_eng_equiv = null;
var target_lang_equiv = null;
var prop_types = testMapElementToProperty( name )
var eng_array_lookup = [];
var ltf_array_lookup = [];
//purpose of eng_array
//a test case a choice may short hand a set or an expect as "Distance at orth"
//"error only", nad27, and so on.
//we need to turn that short handvalue into the *exact* value to expect
//'error only' gets lookup being "Error only - enter Lat/Long for the actual locality"
//if we are testing versus spanish, we can then say in english I said "Error only - enter Lat/Long for the actual locality",
//what is the exact equiv in spanish
//ex: text case right 'expect the spanish equiv for 'local' in 'ChoiceCoordSource'
//so we lookup 'local' for possible matches in 'enn', finding only 1, "locality description"
//we then look up the spanish equiv to "locality description" as being "localidad textual"
//check the selected item of "ChoiceCoordSource" to be sure it equals "localidad textual"
//this is more useful for the calc and loc lookups
//short hand is very nice for datum
//language jumping is very nice if you dont know the other language, ex: french y nederlander ?Dutch? y potuguese.
//AND for now, some characters just wont work, ?cildilla?cidila?, e with accent grave, the n w/ tilde in spanish
//there are auto conversion issues in JS, css, HTML, or something I just cant figure out, so I have to short hand it.
//note soon eng_array will be ltw array
//that way a test could be short-hartned in any language, than translated to the target language
//TODO very buggy check, if 1 and static, look up static, + special vars(special for datum)
// if 1 then assume like coordsys.*.*lang
// if 2 assume xxx.{yyy}.lang and loop trough, for dms, ddm, dd and such
//if property type is static is not stored in any canonical array
//it is stuffed into SELECTS programatically, most the time
//ex: [km, m, yds, in]
//another type of static are mixed in 1 of 2??? ways
//1) ChoiceDatum, element option [0] is based on "datum.notrecorded.+language, then a very large array of static static data, then NAD27, Adindan...
//2) distance precision, mixed, "static number" + units based lang, and "exact" for lang
//3)??
//testGetStaticValuesFromChoice special cases 1), and soon 2)
//short hand rules find the value of test data, lower cases, *in* one and only one of all the strings in the array supplied
//'dist' matches 4 for of the possible loc type, no bueno. 'distance at' matches one and only one, bueno. 'named', again, bueno.
//BEGIN SHORTHAND TO FILL possible eng values into array
//if static, grab values from text choice boxes, special casing ChoiceDatum and ChoiceCoordSource
if( prop_types.d == 0 && prop_types.a[0]=="static" )
{
if( name == "ChoiceDatum" )
{
//eng_array_lookup = testGetStaticValuesFromChoice(name);
//TODO FIXME look this up lagnuage dependant
eng_array_lookup.push(g_properties.getProperty("datum.notrecorded", "en"))
eng_array_lookup = testGetStaticValuesFromChoice(name, ltf, ltw);