|
0
|
1 |
|
|
|
2 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
|
|
3 |
<html> |
|
|
4 |
<head> |
|
|
5 |
<title>YUI Library Examples: Test: Asynchronous Event Testing</title> |
|
|
6 |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> |
|
|
7 |
<link rel="stylesheet" type="text/css" href="../../assets/yui.css" > |
|
|
8 |
|
|
|
9 |
<style> |
|
|
10 |
/*Supplemental CSS for the YUI distribution*/ |
|
|
11 |
#custom-doc { width: 95%; min-width: 950px; } |
|
|
12 |
#pagetitle {background-image: url(../../assets/bg_hd.gif);} |
|
|
13 |
/* #pagetitle h1 {background-image: url(../../assets/title_h_bg.gif);}*/ |
|
|
14 |
</style> |
|
|
15 |
|
|
|
16 |
<link rel="stylesheet" type="text/css" href="../../assets/dpSyntaxHighlighter.css"> |
|
|
17 |
<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" /> |
|
|
18 |
<script type="text/javascript" src="../../build/yui/yui-min.js"></script> |
|
|
19 |
<style type="text/css"> |
|
|
20 |
#testLogger { |
|
|
21 |
margin-bottom: 1em; |
|
|
22 |
} |
|
|
23 |
|
|
|
24 |
#testLogger .yui-console .yui-console-title { |
|
|
25 |
border: 0 none; |
|
|
26 |
color: #000; |
|
|
27 |
font-size: 13px; |
|
|
28 |
font-weight: bold; |
|
|
29 |
margin: 0; |
|
|
30 |
text-transform: none; |
|
|
31 |
} |
|
|
32 |
#testLogger .yui-console .yui-console-entry-meta { |
|
|
33 |
margin: 0; |
|
|
34 |
} |
|
|
35 |
|
|
|
36 |
.yui-skin-sam .yui-console-entry-pass .yui-console-entry-cat { |
|
|
37 |
background: #070; |
|
|
38 |
color: #fff; |
|
|
39 |
} |
|
|
40 |
</style> |
|
|
41 |
|
|
|
42 |
</head> |
|
|
43 |
<body id="yahoo-com" class=" yui-skin-sam"> |
|
|
44 |
<div id="custom-doc" class="yui-t2"> |
|
|
45 |
<div id="hd"> |
|
|
46 |
<div id="ygunav"> |
|
|
47 |
<p> |
|
|
48 |
<em> |
|
|
49 |
<a href="http://developer.yahoo.com/yui/3/">YUI 3.x Home</a> <i> - </i> |
|
|
50 |
</em> |
|
|
51 |
</p> |
|
|
52 |
<form action="http://search.yahoo.com/search" id="sitesearchform"> |
|
|
53 |
<input name="vs" type="hidden" value="developer.yahoo.com"> |
|
|
54 |
<input name="vs" type="hidden" value="yuiblog.com"> |
|
|
55 |
<div id="sitesearch"> |
|
|
56 |
<label for="searchinput">Site Search (YDN & YUIBlog): </label> |
|
|
57 |
<input type="text" id="searchinput" name="p"> |
|
|
58 |
<input type="submit" value="Search" id="searchsubmit" class="ygbt"> |
|
|
59 |
</div> |
|
|
60 |
</form> |
|
|
61 |
</div> |
|
|
62 |
<div id="ygma"><a href="../../"><img src="../../assets/logo.gif" border="0" width="200" height="93"></a></div> |
|
|
63 |
<div id="pagetitle"><h1>YUI Library Examples: Test: Asynchronous Event Testing</h1></div> |
|
|
64 |
</div> |
|
|
65 |
<div id="bd"> |
|
|
66 |
|
|
|
67 |
|
|
|
68 |
<div id="yui-main"> |
|
|
69 |
<div class="yui-b"> |
|
|
70 |
<div class="yui-ge"> |
|
|
71 |
<div class="yui-u first example" id="main"> |
|
|
72 |
|
|
|
73 |
<h2>Test: Asynchronous Event Testing</h2> |
|
|
74 |
|
|
|
75 |
<div id="example" class="promo"> |
|
|
76 |
<div class="example-intro"> |
|
|
77 |
<p>This example shows how to create an asynchronous test with the YUI Test framework for testing browser-based JavaScript code. |
|
|
78 |
A code>Y.Test.Case</code></a> object is created to test the |
|
|
79 |
<code>Y.Anim</code> object. The test waits until the animation is complete |
|
|
80 |
before checking the settings of the animated element.</p> </div> |
|
|
81 |
|
|
|
82 |
<div class="module example-container "> |
|
|
83 |
<div class="hd exampleHd"> |
|
|
84 |
<p class="newWindowButton yui-skin-sam"> |
|
|
85 |
<a href="test-async-event-tests_clean.html" target="_blank">View example in new window.</a> |
|
|
86 |
</p> |
|
|
87 |
</div> <div id="example-canvas" class="bd"> |
|
|
88 |
|
|
|
89 |
|
|
|
90 |
<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
91 |
|
|
|
92 |
<div id="testLogger"></div> |
|
|
93 |
<div id="testDiv" style="position:absolute;width:10px;height:10px; background-color:red"></div> |
|
|
94 |
<script type="text/javascript"> |
|
|
95 |
YUI({base:"../../build/", timeout: 10000}).use("anim", "console", "test",function (Y) { |
|
|
96 |
|
|
|
97 |
Y.namespace("example.test"); |
|
|
98 |
|
|
|
99 |
Y.example.test.AsyncTestCase = new Y.Test.Case({ |
|
|
100 |
|
|
|
101 |
//name of the test case - if not provided, one is auto-generated |
|
|
102 |
name : "Animation Tests", |
|
|
103 |
|
|
|
104 |
//--------------------------------------------------------------------- |
|
|
105 |
// Test methods - names must begin with "test" |
|
|
106 |
//--------------------------------------------------------------------- |
|
|
107 |
|
|
|
108 |
testAnimation : function (){ |
|
|
109 |
|
|
|
110 |
var myAnim = new Y.Anim({ |
|
|
111 |
node: '#testDiv', |
|
|
112 |
to: { |
|
|
113 |
width: 400 |
|
|
114 |
}, |
|
|
115 |
duration: 3, |
|
|
116 |
easing: Y.Easing.easeOut |
|
|
117 |
}); |
|
|
118 |
|
|
|
119 |
//assign oncomplete handler |
|
|
120 |
myAnim.on("end", function(){ |
|
|
121 |
|
|
|
122 |
//tell the TestRunner to resume |
|
|
123 |
this.resume(function(){ |
|
|
124 |
|
|
|
125 |
Y.Assert.areEqual(document.getElementById("testDiv").offsetWidth, 400, "Width of the DIV should be 400."); |
|
|
126 |
|
|
|
127 |
}); |
|
|
128 |
|
|
|
129 |
}, this, true); |
|
|
130 |
|
|
|
131 |
//start the animation |
|
|
132 |
myAnim.run(); |
|
|
133 |
|
|
|
134 |
//wait until something happens |
|
|
135 |
this.wait(); |
|
|
136 |
|
|
|
137 |
} |
|
|
138 |
|
|
|
139 |
}); |
|
|
140 |
|
|
|
141 |
//create the console |
|
|
142 |
var r = new Y.Console({ |
|
|
143 |
newestOnTop : false, |
|
|
144 |
style: 'block' // to anchor in the example content |
|
|
145 |
}); |
|
|
146 |
|
|
|
147 |
r.render('#testLogger'); |
|
|
148 |
|
|
|
149 |
//create the logger |
|
|
150 |
Y.Test.Runner.add(Y.example.test.AsyncTestCase); |
|
|
151 |
|
|
|
152 |
//run the tests |
|
|
153 |
Y.Test.Runner.run(); |
|
|
154 |
}); |
|
|
155 |
|
|
|
156 |
</script> |
|
|
157 |
|
|
|
158 |
<!--END SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
159 |
|
|
|
160 |
|
|
|
161 |
</div> |
|
|
162 |
</div> |
|
|
163 |
</div> |
|
|
164 |
|
|
|
165 |
<h2 class="first">Asynchronous Events Test Example</h2> |
|
|
166 |
|
|
|
167 |
<p>This example begins by creating a namespace:</p> |
|
|
168 |
<div id="syntax1" class="yui-syntax-highlight"><div class="numbers"><pre class="javascript" style="font-family:monospace;"><ol><li class="li1"><div class="de1">Y.<span class="kw2">namespace</span><span class="br0">(</span><span class="st0">"example.test"</span><span class="br0">)</span><span class="sy0">;</span></div></li></ol></pre></div><div class="nonumbers"><pre class="javascript" style="font-family:monospace;">Y.<span class="kw2">namespace</span><span class="br0">(</span><span class="st0">"example.test"</span><span class="br0">)</span><span class="sy0">;</span></pre></div><textarea id="syntax1-plain">Y.namespace("example.test");</textarea></div><p>This namespace serves as the core object upon which others will be added (to prevent creating global objects).</p> |
|
|
169 |
|
|
|
170 |
<h3>Creating the TestCase</h3> |
|
|
171 |
|
|
|
172 |
<p>The first step is to create a new <code>Y.Test.Case</code>object called <code>AsyncTestCase</code>. |
|
|
173 |
To do so, using the <code>Y.Test.Case</code>constructor and pass in an object literal containing information about the tests to be run:</p> |
|
|
174 |
<div id="syntax2" class="yui-syntax-highlight"><div class="numbers"><pre class="javascript" style="font-family:monospace;"><ol><li class="li1"><div class="de1">Y.<span class="me1">example</span>.<span class="me1">test</span>.<span class="me1">AsyncTestCase</span> <span class="sy0">=</span> <span class="kw2">new</span> Y.<span class="me1">Test</span>.<span class="kw1">Case</span><span class="br0">(</span><span class="br0">{</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"> <span class="co1">//name of the test case - if not provided, one is auto-generated</span></div></li><li class="li1"><div class="de1"> <span class="kw3">name</span> <span class="sy0">:</span> <span class="st0">"Animation Tests"</span><span class="sy0">,</span></div></li><li class="li2"><div class="de2"> </div></li><li class="li1"><div class="de1"> <span class="co1">//---------------------------------------------------------------------</span></div></li><li class="li1"><div class="de1"> <span class="co1">// Test methods - names must begin with "test"</span></div></li><li class="li1"><div class="de1"> <span class="co1">//---------------------------------------------------------------------</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li2"><div class="de2"> testAnimation <span class="sy0">:</span> <span class="kw2">function</span> <span class="br0">(</span><span class="br0">)</span><span class="br0">{</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"> <span class="kw2">var</span> myAnim <span class="sy0">=</span> <span class="kw2">new</span> Y.<span class="me1">Anim</span><span class="br0">(</span><span class="br0">{</span></div></li><li class="li1"><div class="de1"> node<span class="sy0">:</span> <span class="st0">'#testDiv'</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1"> to<span class="sy0">:</span> <span class="br0">{</span></div></li><li class="li2"><div class="de2"> width<span class="sy0">:</span> <span class="nu0">400</span></div></li><li class="li1"><div class="de1"> <span class="br0">}</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1"> duration<span class="sy0">:</span> <span class="nu0">3</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1"> easing<span class="sy0">:</span> Y.<span class="me1">Easing</span>.<span class="me1">easeOut</span></div></li><li class="li1"><div class="de1"> <span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2"> </div></li><li class="li1"><div class="de1"> <span class="co1">//assign oncomplete handler</span></div></li><li class="li1"><div class="de1"> myAnim.<span class="me1">on</span><span class="br0">(</span><span class="st0">"end"</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">(</span><span class="br0">)</span><span class="br0">{</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"> <span class="co1">//tell the TestRunner to resume</span></div></li><li class="li2"><div class="de2"> <span class="kw1">this</span>.<span class="me1">resume</span><span class="br0">(</span><span class="kw2">function</span><span class="br0">(</span><span class="br0">)</span><span class="br0">{</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"> Y.<span class="me1">Assert</span>.<span class="me1">areEqual</span><span class="br0">(</span>document.<span class="me1">getElementById</span><span class="br0">(</span><span class="st0">"testDiv"</span><span class="br0">)</span>.<span class="me1">offsetWidth</span><span class="sy0">,</span> <span class="nu0">400</span><span class="sy0">,</span> <span class="st0">"Width of the DIV should be 400."</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"> <span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2"> </div></li><li class="li1"><div class="de1"> <span class="br0">}</span><span class="sy0">,</span> <span class="kw1">this</span><span class="sy0">,</span> <span class="kw2">true</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"> <span class="co1">//start the animation</span></div></li><li class="li1"><div class="de1"> myAnim.<span class="me1">run</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2"> </div></li><li class="li1"><div class="de1"> <span class="co1">//wait until something happens</span></div></li><li class="li1"><div class="de1"> <span class="kw1">this</span>.<span class="me1">wait</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"> <span class="br0">}</span></div></li><li class="li2"><div class="de2"> </div></li><li class="li1"><div class="de1"><span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span></div></li></ol></pre></div><div class="nonumbers"><pre class="javascript" style="font-family:monospace;">Y.<span class="me1">example</span>.<span class="me1">test</span>.<span class="me1">AsyncTestCase</span> <span class="sy0">=</span> <span class="kw2">new</span> Y.<span class="me1">Test</span>.<span class="kw1">Case</span><span class="br0">(</span><span class="br0">{</span> |
|
|
175 |
|
|
|
176 |
<span class="co1">//name of the test case - if not provided, one is auto-generated</span> |
|
|
177 |
<span class="kw3">name</span> <span class="sy0">:</span> <span class="st0">"Animation Tests"</span><span class="sy0">,</span> |
|
|
178 |
|
|
|
179 |
<span class="co1">//---------------------------------------------------------------------</span> |
|
|
180 |
<span class="co1">// Test methods - names must begin with "test"</span> |
|
|
181 |
<span class="co1">//---------------------------------------------------------------------</span> |
|
|
182 |
|
|
|
183 |
testAnimation <span class="sy0">:</span> <span class="kw2">function</span> <span class="br0">(</span><span class="br0">)</span><span class="br0">{</span> |
|
|
184 |
|
|
|
185 |
<span class="kw2">var</span> myAnim <span class="sy0">=</span> <span class="kw2">new</span> Y.<span class="me1">Anim</span><span class="br0">(</span><span class="br0">{</span> |
|
|
186 |
node<span class="sy0">:</span> <span class="st0">'#testDiv'</span><span class="sy0">,</span> |
|
|
187 |
to<span class="sy0">:</span> <span class="br0">{</span> |
|
|
188 |
width<span class="sy0">:</span> <span class="nu0">400</span> |
|
|
189 |
<span class="br0">}</span><span class="sy0">,</span> |
|
|
190 |
duration<span class="sy0">:</span> <span class="nu0">3</span><span class="sy0">,</span> |
|
|
191 |
easing<span class="sy0">:</span> Y.<span class="me1">Easing</span>.<span class="me1">easeOut</span> |
|
|
192 |
<span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span> |
|
|
193 |
|
|
|
194 |
<span class="co1">//assign oncomplete handler</span> |
|
|
195 |
myAnim.<span class="me1">on</span><span class="br0">(</span><span class="st0">"end"</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">(</span><span class="br0">)</span><span class="br0">{</span> |
|
|
196 |
|
|
|
197 |
<span class="co1">//tell the TestRunner to resume</span> |
|
|
198 |
<span class="kw1">this</span>.<span class="me1">resume</span><span class="br0">(</span><span class="kw2">function</span><span class="br0">(</span><span class="br0">)</span><span class="br0">{</span> |
|
|
199 |
|
|
|
200 |
Y.<span class="me1">Assert</span>.<span class="me1">areEqual</span><span class="br0">(</span>document.<span class="me1">getElementById</span><span class="br0">(</span><span class="st0">"testDiv"</span><span class="br0">)</span>.<span class="me1">offsetWidth</span><span class="sy0">,</span> <span class="nu0">400</span><span class="sy0">,</span> <span class="st0">"Width of the DIV should be 400."</span><span class="br0">)</span><span class="sy0">;</span> |
|
|
201 |
|
|
|
202 |
<span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span> |
|
|
203 |
|
|
|
204 |
<span class="br0">}</span><span class="sy0">,</span> <span class="kw1">this</span><span class="sy0">,</span> <span class="kw2">true</span><span class="br0">)</span><span class="sy0">;</span> |
|
|
205 |
|
|
|
206 |
<span class="co1">//start the animation</span> |
|
|
207 |
myAnim.<span class="me1">run</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span> |
|
|
208 |
|
|
|
209 |
<span class="co1">//wait until something happens</span> |
|
|
210 |
<span class="kw1">this</span>.<span class="me1">wait</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span> |
|
|
211 |
|
|
|
212 |
<span class="br0">}</span> |
|
|
213 |
|
|
|
214 |
<span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span></pre></div><textarea id="syntax2-plain">Y.example.test.AsyncTestCase = new Y.Test.Case({ |
|
|
215 |
|
|
|
216 |
//name of the test case - if not provided, one is auto-generated |
|
|
217 |
name : "Animation Tests", |
|
|
218 |
|
|
|
219 |
//--------------------------------------------------------------------- |
|
|
220 |
// Test methods - names must begin with "test" |
|
|
221 |
//--------------------------------------------------------------------- |
|
|
222 |
|
|
|
223 |
testAnimation : function (){ |
|
|
224 |
|
|
|
225 |
var myAnim = new Y.Anim({ |
|
|
226 |
node: '#testDiv', |
|
|
227 |
to: { |
|
|
228 |
width: 400 |
|
|
229 |
}, |
|
|
230 |
duration: 3, |
|
|
231 |
easing: Y.Easing.easeOut |
|
|
232 |
}); |
|
|
233 |
|
|
|
234 |
//assign oncomplete handler |
|
|
235 |
myAnim.on("end", function(){ |
|
|
236 |
|
|
|
237 |
//tell the TestRunner to resume |
|
|
238 |
this.resume(function(){ |
|
|
239 |
|
|
|
240 |
Y.Assert.areEqual(document.getElementById("testDiv").offsetWidth, 400, "Width of the DIV should be 400."); |
|
|
241 |
|
|
|
242 |
}); |
|
|
243 |
|
|
|
244 |
}, this, true); |
|
|
245 |
|
|
|
246 |
//start the animation |
|
|
247 |
myAnim.run(); |
|
|
248 |
|
|
|
249 |
//wait until something happens |
|
|
250 |
this.wait(); |
|
|
251 |
|
|
|
252 |
} |
|
|
253 |
|
|
|
254 |
});</textarea></div><p>The only test in the <code>Y.Test.Case</code>is called <code>testAnimation</code>. It begins by creating a new |
|
|
255 |
<code>Anim</code> object that will animate the width of a <code>div</code> to 400 pixels over three seconds. An |
|
|
256 |
event handler is assigned to the <code>Anim</code> object's <code>end</code> event, within which the |
|
|
257 |
<code>resume()</code> method is called. A function is passed into the <code>resume()</code> method to indicate |
|
|
258 |
the code to run when the test resumes, which is a test to make sure the width is 400 pixels. After that, the |
|
|
259 |
<code>run()</code> method is called to begin the animation and the <code>wait()</code> method is called to |
|
|
260 |
tell the <code>Y.Test.Runner</code> to wait until it is told to resume testing again. When the animation completes, |
|
|
261 |
the <code>end</code> event is fired and the test resumes, assuring that the width is correct.</p> |
|
|
262 |
<h3>Running the tests</h3> |
|
|
263 |
|
|
|
264 |
<p>With all of the tests defined, the last step is to run them:</p> |
|
|
265 |
|
|
|
266 |
<div id="syntax3" class="yui-syntax-highlight"><div class="numbers"><pre class="javascript" style="font-family:monospace;"><ol><li class="li1"><div class="de1"><span class="co1">//create the console</span></div></li><li class="li1"><div class="de1"><span class="kw2">var</span> r <span class="sy0">=</span> <span class="kw2">new</span> Y.<span class="me1">Console</span><span class="br0">(</span><span class="br0">{</span></div></li><li class="li1"><div class="de1"> verbose <span class="sy0">:</span> <span class="kw2">true</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1"> newestOnTop <span class="sy0">:</span> <span class="kw2">false</span></div></li><li class="li2"><div class="de2"><span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1">r.<span class="me1">render</span><span class="br0">(</span><span class="st0">'#testLogger'</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"><span class="co1">//create the logger</span></div></li><li class="li2"><div class="de2">Y.<span class="me1">Test</span>.<span class="me1">Runner</span>.<span class="me1">add</span><span class="br0">(</span>Y.<span class="me1">example</span>.<span class="me1">test</span>.<span class="me1">AsyncTestCase</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"><span class="co1">//run the tests</span></div></li><li class="li1"><div class="de1">Y.<span class="me1">Test</span>.<span class="me1">Runner</span>.<span class="me1">run</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></div></li></ol></pre></div><div class="nonumbers"><pre class="javascript" style="font-family:monospace;"><span class="co1">//create the console</span> |
|
|
267 |
<span class="kw2">var</span> r <span class="sy0">=</span> <span class="kw2">new</span> Y.<span class="me1">Console</span><span class="br0">(</span><span class="br0">{</span> |
|
|
268 |
verbose <span class="sy0">:</span> <span class="kw2">true</span><span class="sy0">,</span> |
|
|
269 |
newestOnTop <span class="sy0">:</span> <span class="kw2">false</span> |
|
|
270 |
<span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span> |
|
|
271 |
|
|
|
272 |
r.<span class="me1">render</span><span class="br0">(</span><span class="st0">'#testLogger'</span><span class="br0">)</span><span class="sy0">;</span> |
|
|
273 |
|
|
|
274 |
<span class="co1">//create the logger</span> |
|
|
275 |
Y.<span class="me1">Test</span>.<span class="me1">Runner</span>.<span class="me1">add</span><span class="br0">(</span>Y.<span class="me1">example</span>.<span class="me1">test</span>.<span class="me1">AsyncTestCase</span><span class="br0">)</span><span class="sy0">;</span> |
|
|
276 |
|
|
|
277 |
<span class="co1">//run the tests</span> |
|
|
278 |
Y.<span class="me1">Test</span>.<span class="me1">Runner</span>.<span class="me1">run</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></pre></div><textarea id="syntax3-plain">//create the console |
|
|
279 |
var r = new Y.Console({ |
|
|
280 |
verbose : true, |
|
|
281 |
newestOnTop : false |
|
|
282 |
}); |
|
|
283 |
|
|
|
284 |
r.render('#testLogger'); |
|
|
285 |
|
|
|
286 |
//create the logger |
|
|
287 |
Y.Test.Runner.add(Y.example.test.AsyncTestCase); |
|
|
288 |
|
|
|
289 |
//run the tests |
|
|
290 |
Y.Test.Runner.run();</textarea></div> |
|
|
291 |
<p>Before running the tests, it's necessary to create a <code>Y.Console</code> object to display the results (otherwise the tests would run |
|
|
292 |
but you wouldn't see the results). After that, the <code>Y.Test.Runner</code> is loaded with the <code>Y.Test.Case</code>object by calling |
|
|
293 |
<code>add()</code> (any number of <code>Y.Test.Case</code>and <code>TestSuite</code> objects can be added to a <code>Y.Test.Runner</code>, |
|
|
294 |
this example only adds one for simplicity). The very last step is to call <code>run()</code>, which begins executing the tests in its |
|
|
295 |
queue and displays the results in the <code>Y.Console</code>.</p> </div> |
|
|
296 |
<div class="yui-u sidebar"> |
|
|
297 |
|
|
|
298 |
|
|
|
299 |
<div id="examples" class="mod box4"> |
|
|
300 |
<div class="hd"> |
|
|
301 |
<h4> |
|
|
302 |
Test Examples:</h4> |
|
|
303 |
</div> |
|
|
304 |
<div class="bd"> |
|
|
305 |
<ul> |
|
|
306 |
<li><a href='../test/test-simple-example.html'>Simple Testing Example</a></li><li><a href='../test/test-advanced-test-options.html'>Advanced Test Options</a></li><li><a href='../test/test-array-tests.html'>Array Processing</a></li><li><a href='../test/test-async-test.html'>Asynchronous Testing</a></li><li class='selected'><a href='../test/test-async-event-tests.html'>Asynchronous Event Testing</a></li> </ul> |
|
|
307 |
</div> |
|
|
308 |
</div> |
|
|
309 |
|
|
|
310 |
<div class="mod box4"> |
|
|
311 |
<div class="hd"> |
|
|
312 |
<h4>More Test Resources:</h4> |
|
|
313 |
</div> |
|
|
314 |
<div class="bd"> |
|
|
315 |
<ul> |
|
|
316 |
<!-- <li><a href="http://developer.yahoo.com/yui/test/">User's Guide</a> (external)</li> --> |
|
|
317 |
<li><a href="../../api/module_test.html">API Documentation</a></li></ul> |
|
|
318 |
</div> |
|
|
319 |
</div> |
|
|
320 |
</div> |
|
|
321 |
</div> |
|
|
322 |
|
|
|
323 |
</div> |
|
|
324 |
</div> |
|
|
325 |
|
|
|
326 |
|
|
|
327 |
<div class="yui-b toc3" id="tocWrapper"> |
|
|
328 |
<!-- TABLE OF CONTENTS --> |
|
|
329 |
<div id="toc"> |
|
|
330 |
|
|
|
331 |
<ul> |
|
|
332 |
<li class="sect first">YUI 3 Resources</li><li class="item"><a title="YUI 3 -- Yahoo! User Interface (YUI) Library" href="http://developer.yahoo.com/yui/3/">YUI 3 Web Site</a></li><li class="item"><a title="Examples of every YUI utility and control in action" href="../../examples/">YUI 3 Examples</a></li><li class="item"><a title="Instantly searchable API documentation for the entire YUI library." href="../../api/">YUI 3 API Docs</a></li><li class="item"><a title="YUI 3 Dependency Configurator -- configure your custom YUI implementation" href="http://developer.yahoo.com/yui/3/configurator">YUI 3 Dependency Configurator</a></li><li class="item"><a title="The YUI 3 Forum on YUILibrary.com" href="http://yuilibrary.com/forum/viewforum.php?f=15">YUI 3 Forums (external)</a></li><li class="item"><a title="Found a bug or a missing feature? Let us know on YUILibrary.com." href="http://developer.yahoo.com/yui/articles/reportingbugs/">Bug Reports/Feature Requests</a></li><li class="item"><a title="YUI is free and open, offered under a BSD license." href="http://developer.yahoo.com/yui/license.html">YUI License</a></li><li class="item"><a title="Download and fork the YUI project on GitHub" href="http://github.com/yui">YUI on Github</a></li><li class="item"><a title="The Yahoo! User Interface Blog" href="http://yuiblog.com">YUI Blog (external)</a></li><li class="sect">YUI 3 Core - Examples</li><li class="item"><a title="YUI Global Object - Functional Examples" href="../../examples/yui/index.html">YUI Global Object</a></li><li class="item"><a title="Event - Functional Examples" href="../../examples/event/index.html">Event</a></li><li class="item"><a title="Node - Functional Examples" href="../../examples/node/index.html">Node</a></li><li class="sect">YUI 3 Component Infrastructure - Examples</li><li class="item"><a title="Attribute - Functional Examples" href="../../examples/attribute/index.html">Attribute</a></li><li class="item"><a title="Plugin - Functional Examples" href="../../examples/plugin/index.html">Plugin <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Widget - Functional Examples" href="../../examples/widget/index.html">Widget <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="sect">YUI 3 Utilities - Examples</li><li class="item"><a title="Animation - Functional Examples" href="../../examples/anim/index.html">Animation</a></li><li class="item"><a title="AsyncQueue - Functional Examples" href="../../examples/async-queue/index.html">AsyncQueue</a></li><li class="item"><a title="Browser History - Functional Examples" href="../../examples/history/index.html">Browser History</a></li><li class="item"><a title="Cache - Functional Examples" href="../../examples/cache/index.html">Cache</a></li><li class="item"><a title="Cookie - Functional Examples" href="../../examples/cookie/index.html">Cookie</a></li><li class="item"><a title="DataSchema - Functional Examples" href="../../examples/dataschema/index.html">DataSchema <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="DataSource - Functional Examples" href="../../examples/datasource/index.html">DataSource <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="DataType - Functional Examples" href="../../examples/datatype/index.html">DataType <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Drag & Drop - Functional Examples" href="../../examples/dd/index.html">Drag & Drop</a></li><li class="item"><a title="Get - Functional Examples" href="../../examples/get/index.html">Get</a></li><li class="item"><a title="ImageLoader - Functional Examples" href="../../examples/imageloader/index.html">ImageLoader</a></li><li class="item"><a title="IO - Functional Examples" href="../../examples/io/index.html">IO</a></li><li class="item"><a title="JSON (JavaScript Object Notation) - Functional Examples" href="../../examples/json/index.html">JSON</a></li><li class="item"><a title="Stylesheet - Functional Examples" href="../../examples/stylesheet/index.html">Stylesheet</a></li><li class="sect">YUI 3 Widgets - Examples</li><li class="item"><a title="Overlay - Functional Examples" href="../../examples/overlay/index.html">Overlay <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Slider - Functional Examples" href="../../examples/slider/index.html">Slider <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="sect">YUI 3 Node Plugins - Examples</li><li class="item"><a title="FocusManager Node Plugin - Functional Examples" href="../../examples/node-focusmanager/index.html">FocusManager Node Plugin <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="MenuNav Node Plugin - Functional Examples" href="../../examples/node-menunav/index.html">MenuNav Node Plugin <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="sect">YUI 3 CSS - Examples</li><li class="item"><a title="YUI CSS Reset - Functional Examples" href="../../examples/cssreset/index.html">CSS Reset</a></li><li class="item"><a title="YUI Fonts - Functional Examples" href="../../examples/cssfonts/index.html">CSS Fonts</a></li><li class="item"><a title="YUI Base - Functional Examples" href="../../examples/cssbase/index.html">CSS Base</a></li><li class="sect">YUI 3 Developer Tools - Examples</li><li class="item"><a title="Console - Functional Examples" href="../../examples/console/index.html">Console <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Console Filters Plugin- Functional Examples" href="../../examples/console-filters/index.html">Plugin.ConsoleFilters <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Profiler - Functional Examples" href="../../examples/profiler/index.html">Profiler</a></li><li class="selected "><a title="Test - Functional Examples" href="../../examples/test/index.html">Test</a></li><li class="sect">Other Useful YUI 3 Resources</li><li class="item"><a title="Answers to Frequently Asked Questions about the YUI Library" href="http://developer.yahoo.com/yui/articles/faq/">YUI FAQ (external)</a></li><li class="item"><a title="Yahoo!'s philosophy of Graded Browser Support" href="http://developer.yahoo.com/yui/articles/gbs/">Graded Browser Support (external)</a></li><li class="item"><a title="Videos and podcasts from the YUI Team and from the Yahoo! frontend engineering community." href="http://developer.yahoo.com/yui/theater/">YUI Theater (external)</a></li></ul> |
|
|
333 |
</div> |
|
|
334 |
</div> |
|
|
335 |
</div><!--closes bd--> |
|
|
336 |
|
|
|
337 |
<div id="ft"> |
|
|
338 |
<p class="first">Copyright © 2009 Yahoo! Inc. All rights reserved.</p> |
|
|
339 |
<p><a href="http://privacy.yahoo.com/privacy/us/devel/index.html">Privacy Policy</a> - |
|
|
340 |
<a href="http://docs.yahoo.com/info/terms/">Terms of Service</a> - |
|
|
341 |
<a href="http://docs.yahoo.com/info/copyright/copyright.html">Copyright Policy</a> - |
|
|
342 |
<a href="http://careers.yahoo.com/">Job Openings</a></p> |
|
|
343 |
</div> |
|
|
344 |
</div> |
|
|
345 |
<script language="javascript"> |
|
|
346 |
var yuiConfig = {base:"../../build/", timeout: 10000}; |
|
|
347 |
</script> |
|
|
348 |
<script src="../../assets/syntax.js"></script> |
|
|
349 |
<script src="../../assets/dpSyntaxHighlighter.js"></script> |
|
|
350 |
<script language="javascript"> |
|
|
351 |
dp.SyntaxHighlighter.HighlightAll('code'); |
|
|
352 |
</script> |
|
|
353 |
</body> |
|
|
354 |
</html> |