UnitTC: Pass,error count save method has been changed
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.2.0 / tests / unit / support / support_core.js
1 /*
2  * mobile support unit tests
3  */
4
5 $.testHelper.excludeFileProtocol(function(){
6         var     prependToFn = $.fn.prependTo,
7                 moduleName = "jquery.mobile.support";
8
9         module(moduleName, {
10                 teardown: function(){
11                         //NOTE undo any mocking
12                         $.fn.prependTo = prependToFn;
13                 }
14         });
15
16         // NOTE following two tests have debatable value as they only
17         //      prevent property name changes and improper attribute checks
18         asyncTest( "detects functionality from basic affirmative properties and attributes", function(){
19                 // TODO expose properties for less brittle tests
20                 $.extend(window, {
21                         WebKitTransitionEvent: true,
22                 });
23
24                 window.history.pushState = function(){};
25                 window.history.replaceState = function(){};
26
27                 $.mobile.media = function(){ return true; };
28
29                 $.testHelper.reloadModule( moduleName ).done( function() {
30                         ok($.support.cssTransitions, "css transitions are supported" );
31                         ok($.support.pushState, "push state is supported" );
32                         ok($.support.mediaquery, "media queries are supported" );
33                         start();
34                 });
35         });
36
37         asyncTest( "detects orientation change", function() {
38                 $.extend(window, {
39                         orientation: true,
40                         onorientationchange: true
41                 });
42
43                 $.testHelper.reloadModule( "jquery.mobile.support.orientation" ).done( function() {
44                         ok($.support.orientation, "orientation is supported" );
45                         start();
46                 });
47         });
48
49         asyncTest( "detects touch", function() {
50                 document.ontouchend = true;
51
52                 $.testHelper.reloadModule( "jquery.mobile.support.touch" ).done( function() {
53                         ok( $.mobile.support.touch, "touch is supported" );
54                         ok( $.support.touch, "touch is supported" );
55                         start();
56                 });
57         });
58         /*
59         To delete the windows property is prohibited. (Security issue)
60
61         delete window["orientation"] is now working
62         !$.support.orientation <- return false
63
64         asyncTest( "detects functionality from basic negative properties and attributes (where possible)", function(){
65                 delete window["orientation"];
66
67                 $.testHelper.reloadModule( "jquery.mobile.support.orientation" ).done( function() {
68                         ok(!$.support.orientation, "orientation is not supported" );
69                         start();
70                 });
71         });
72         */
73
74         // NOTE mocks prependTo to simulate base href updates or lack thereof
75         var mockBaseCheck = function( url ){
76                 var prependToFn = $.fn.prependTo;
77
78                 $.fn.prependTo = function( selector ){
79                         var result = prependToFn.call(this, selector);
80                         if(this[0].href && this[0].href.indexOf("testurl") != -1)
81                                 result = [{href: url}];
82                         return result;
83                 };
84         };
85
86         asyncTest( "detects dynamic base tag when new base element added and base href updates", function(){
87                 mockBaseCheck(location.protocol + '//' + location.host + location.pathname + "ui-dir/");
88                 $.testHelper.reloadModule( moduleName ).done( function() {
89                         ok($.support.dynamicBaseTag);
90                         start();
91                 });
92         });
93
94         asyncTest( "detects no dynamic base tag when new base element added and base href unchanged", function(){
95                 mockBaseCheck('testurl');
96                 $.testHelper.reloadModule( moduleName ).done( function() {
97                         ok(!$.support.dynamicBaseTag);
98                         start();
99                 });
100         });
101
102         asyncTest( "jQM's IE browser check properly detects IE versions", function(){
103                 $.testHelper.reloadModule( moduleName ).done( function() {
104                 //here we're just comparing our version to what the conditional compilation finds
105                  var ie                         = !!$.browser.msie, //get a boolean
106                          version                = parseInt( $.browser.version, 10),
107                          jqmdetectedver = $.mobile.browser.ie;
108
109                         if( ie ){
110                                 deepEqual(version, jqmdetectedver, "It's IE and the version is correct");
111                         }
112                         else{
113                                 deepEqual(ie, jqmdetectedver, "It's not IE");
114                         }
115                         start();
116                 });
117         });
118
119
120         //TODO propExists testing, refactor propExists into mockable method
121         //TODO scrollTop testing, refactor scrollTop logic into mockable method
122 });