@@ -32,53 +32,28 @@ casper.test.begin('Testing ' + htmlPath, function (test) {
3232 } ) ;
3333
3434 // click on one example code for each language
35- casper . then ( function ( ) {
36- casper . click ( "#aliasExampleLink" ) ;
37- phantomcss . screenshot ( '#pyInputPane' , 'pyInputPane' ) ;
38- } ) ;
39-
40- casper . then ( function ( ) {
41- casper . click ( "#tortureLink" ) ;
42- phantomcss . screenshot ( '#pyInputPane' , 'pyInputPane' ) ;
43- } ) ;
44-
45- casper . then ( function ( ) {
46- casper . click ( "#javaVarLink" ) ;
47- phantomcss . screenshot ( '#pyInputPane' , 'pyInputPane' ) ;
48- } ) ;
49-
50- casper . then ( function ( ) {
51- casper . click ( "#jsDatatypesExLink" ) ;
52- phantomcss . screenshot ( '#pyInputPane' , 'pyInputPane' ) ;
53- } ) ;
54-
55- casper . then ( function ( ) {
56- casper . click ( "#tsGreeterExLink" ) ;
57- phantomcss . screenshot ( '#pyInputPane' , 'pyInputPane' ) ;
58- } ) ;
59-
60- casper . then ( function ( ) {
61- casper . click ( "#rubyConstantsLink" ) ;
62- phantomcss . screenshot ( '#pyInputPane' , 'pyInputPane' ) ;
63- } ) ;
64-
65- casper . then ( function ( ) {
66- casper . click ( "#cMengThesisLink" ) ;
67- phantomcss . screenshot ( '#pyInputPane' , 'pyInputPane' ) ;
68- } ) ;
69-
70- casper . then ( function ( ) {
71- casper . click ( "#cppFirstLink" ) ;
72- phantomcss . screenshot ( '#pyInputPane' , 'pyInputPane' ) ;
35+ var exampleLinksToClick = [
36+ "#aliasExampleLink" ,
37+ "#tortureLink" ,
38+ "#javaVarLink" ,
39+ "#jsDatatypesExLink" ,
40+ "#tsGreeterExLink" ,
41+ "#rubyConstantsLink" ,
42+ "#cMengThesisLink" ,
43+ "#cppFirstLink" ] ;
44+
45+ exampleLinksToClick . forEach ( function ( e , i ) {
46+ casper . thenClick ( e , function ( ) {
47+ phantomcss . screenshot ( '#pyInputPane' , 'pyInputPane' ) ;
48+ } ) ;
7349 } ) ;
7450
7551
7652 // now test the visualize mode:
77- casper . then ( function ( ) {
78- casper . click ( "#aliasExampleLink" ) ;
53+ casper . thenClick ( "#aliasExampleLink" , function ( ) {
7954 // brief wait for code to load
8055 this . wait ( DELAY_MS , function ( ) {
81- casper . click ( "#executeBtn" ) ;
56+ this . click ( "#executeBtn" ) ;
8257 } ) ;
8358 } ) ;
8459
@@ -94,22 +69,20 @@ casper.test.begin('Testing ' + htmlPath, function (test) {
9469
9570 // this example has 31 steps:
9671 for ( var i = 0 ; i < 31 ; i ++ ) {
97- casper . then ( function ( ) {
98- casper . click ( "#jmpStepFwd" ) ;
72+ casper . thenClick ( "#jmpStepFwd" , function ( ) {
9973 // slight pause for vis to settle
10074 this . wait ( DELAY_MS , function ( ) {
10175 phantomcss . screenshot ( '.visualizer' , 'visualizer' ) ;
10276 } ) ;
10377 } ) ;
10478 }
10579
80+
10681 // for the remaining examples, be brief and take only a snapshot of
10782 // the FINAL state of the visualization
10883
109-
11084 // test instruction limit reached
111- casper . then ( function ( ) {
112- casper . click ( "#genPrimesLink" ) ;
85+ casper . thenClick ( "#genPrimesLink" , function ( ) {
11386 // brief wait for code to load
11487 this . wait ( DELAY_MS , function ( ) {
11588 casper . click ( "#executeBtn" ) ;
@@ -120,17 +93,13 @@ casper.test.begin('Testing ' + htmlPath, function (test) {
12093 } ) ;
12194 } , function then ( ) {
12295 casper . click ( '#jmpLastInstr' ) ;
123- // slight pause for vis to settle
124- this . wait ( DELAY_MS , function ( ) {
125- phantomcss . screenshot ( '.visualizer' , 'visualizer_instr_limit_reached' ) ;
126- } ) ;
96+ phantomcss . screenshot ( '.visualizer' , 'visualizer_instr_limit_reached' ) ;
12797 } ) ;
12898 } ) ;
12999 } ) ;
130100
131101 // test exception
132- casper . then ( function ( ) {
133- casper . click ( "#pwTryFinallyLink" ) ;
102+ casper . thenClick ( "#pwTryFinallyLink" , function ( ) {
134103 // brief wait for code to load
135104 this . wait ( DELAY_MS , function ( ) {
136105 casper . click ( "#executeBtn" ) ;
@@ -141,17 +110,21 @@ casper.test.begin('Testing ' + htmlPath, function (test) {
141110 } ) ;
142111 } , function then ( ) {
143112 casper . click ( '#jmpLastInstr' ) ;
144- // slight pause for vis to settle
145- this . wait ( DELAY_MS , function ( ) {
146- phantomcss . screenshot ( '.visualizer' , 'visualizer_exception' ) ;
147- } ) ;
113+ phantomcss . screenshot ( '.visualizer' , 'visualizer_exception' ) ;
148114 } ) ;
149115 } ) ;
150116 } ) ;
151117
152118
153119 // for these examples, just snapshot dataViz to be even briefer:
154- var exampleTestLinks = [ '#tutorialExampleLink' , '#ll2Link' , '#inheritanceExampleLink' , '#aliasing2Link' , '#aliasing3Link' , '#aliasing7Link' , '#closure5Link' ] ;
120+ var exampleTestLinks = [
121+ '#tutorialExampleLink' ,
122+ '#ll2Link' ,
123+ '#inheritanceExampleLink' ,
124+ '#aliasing2Link' ,
125+ '#aliasing3Link' ,
126+ '#aliasing7Link' ,
127+ '#closure5Link' ] ;
155128
156129 exampleTestLinks . forEach ( function ( e , i ) {
157130 // reset all toggles to test regular visualizer
@@ -173,10 +146,7 @@ casper.test.begin('Testing ' + htmlPath, function (test) {
173146 } ) ;
174147 } , function then ( ) {
175148 casper . click ( '#jmpLastInstr' ) ;
176- // slight pause for vis to settle
177- this . wait ( DELAY_MS , function ( ) {
178- phantomcss . screenshot ( '#dataViz' , 'dataViz_' + e ) ;
179- } ) ;
149+ phantomcss . screenshot ( '#dataViz' , 'dataViz_' + e ) ;
180150 } ) ;
181151 } ) ;
182152 } ) ;
@@ -200,10 +170,7 @@ casper.test.begin('Testing ' + htmlPath, function (test) {
200170 } ) ;
201171 } , function then ( ) {
202172 casper . click ( '#jmpLastInstr' ) ;
203- // slight pause for vis to settle
204- this . wait ( DELAY_MS , function ( ) {
205- phantomcss . screenshot ( '#dataViz' , 'dataViz_' + e + '_CUMULATIVE' ) ;
206- } ) ;
173+ phantomcss . screenshot ( '#dataViz' , 'dataViz_' + e + '_CUMULATIVE' ) ;
207174 } ) ;
208175 } ) ;
209176 } ) ;
@@ -227,10 +194,7 @@ casper.test.begin('Testing ' + htmlPath, function (test) {
227194 } ) ;
228195 } , function then ( ) {
229196 casper . click ( '#jmpLastInstr' ) ;
230- // slight pause for vis to settle
231- this . wait ( DELAY_MS , function ( ) {
232- phantomcss . screenshot ( '#dataViz' , 'dataViz_' + e + '_TEXTLABELS' ) ;
233- } ) ;
197+ phantomcss . screenshot ( '#dataViz' , 'dataViz_' + e + '_TEXTLABELS' ) ;
234198 } ) ;
235199 } ) ;
236200 } ) ;
0 commit comments