Skip to content

Commit 63be19f

Browse files
author
Scott Jehl
committed
sample test for image loading by expected path.
1 parent fd8680a commit 63be19f

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed
43 Bytes
Loading
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
</head>
6+
<body>
7+
<div data-nstest-role="page" id="imagetest">
8+
<img src="images/test.gif" onload="imageLoad(event)" onerror="imageError(event)" >
9+
</div>
10+
</body>
11+
</html>

tests/unit/navigation/navigation_core.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
* mobile navigation unit tests
33
*/
44
(function($){
5+
6+
7+
58
// TODO move siteDirectory over to the nav path helper
69
var changePageFn = $.mobile.changePage,
710
originalTitle = document.title,
@@ -28,6 +31,8 @@
2831
}
2932
});
3033

34+
35+
3136
asyncTest( "window.history.back() from external to internal page", function(){
3237

3338
$.testHelper.pageSequence([
@@ -1341,4 +1346,41 @@
13411346

13421347
$.mobile.changePage( requestPath );
13431348
});
1349+
1350+
1351+
1352+
// test path/image loading
1353+
window.imageError = function(e){
1354+
1355+
$( "#imagetest" ).trigger( "imgerror" );
1356+
};
1357+
1358+
window.imageLoad = function(e){
1359+
1360+
$( "#imagetest" ).trigger( "imgload" );
1361+
};
1362+
1363+
asyncTest( "image path is working properly", function(){
1364+
1365+
expect( 1 );
1366+
1367+
$( document ).on( "imgload imgerror", function( e ){
1368+
1369+
ok( e.type === "imgload", "the event is imgload" );
1370+
1371+
start();
1372+
1373+
});
1374+
1375+
1376+
$.mobile.changePage( "imagetest/imagetest.html" );
1377+
1378+
});
1379+
1380+
1381+
1382+
1383+
1384+
1385+
13441386
})(jQuery);

tests/unit/navigation/navigation_paths.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,10 @@
173173
asyncTest( "dir refrence with parent dir", function(){
174174
testPageLoad("#absolute-test-six", "doc rel test six");
175175
});
176+
177+
178+
179+
180+
181+
176182
})(jQuery);

0 commit comments

Comments
 (0)