2.0_beta sync to rsa
[framework/web/web-ui-fw.git] / tests / unit-tests / controlbar / controlbar-tests.js
1 /*
2  * controlbar unit tests
3  */
4
5 (function ($) {
6         $.mobile.defaultTransition = "none";
7
8         module( "Controlbar" );
9
10         var unit_controlbar = function ( widget, type, drayStyle ) {
11                 var controlbar,
12                         controlbar_style,
13                         item_count,
14                         activeIndex,
15                         deactiveReturn,
16                         activeReturn,
17                         created_controlbar = widget.controlbar();
18
19                 /* Create */
20                 ok( created_controlbar, "Create" );
21
22                 /* Check Parameters */
23                 equal( type, created_controlbar.jqmData("style"), "Parameter: data-style" );
24
25                 if ( drayStyle ) {
26                         if ( drayStyle == "icon" ) {
27                                 equal( created_controlbar.find( "a" ).is(".ui-btn-icon_only" ), true, "Icon only style test");
28                         } else if ( drayStyle == "text" ) {
29                                 equal( created_controlbar.is(".ui-navbar-noicons" ), true, "Text only style test");
30                         }
31                 }
32
33                 /* Check APIs */
34                 activeIndex = created_controlbar.find(".ui-btn-active").index();
35                 created_controlbar.controlbar( "disable", activeIndex );
36                 deactiveReturn = created_controlbar.find("li:eq(" + activeIndex + ")").is(".ui-disabled");
37
38                 equal( deactiveReturn, true, "List Deactive test" );
39
40                 created_controlbar.controlbar("enable", activeIndex);
41                 activeReturn = created_controlbar.find("li:eq(" + activeIndex + ")").is(".ui-disabled");
42                 equal( activeReturn, false, "List Active test" );
43         };
44
45         test( "controlbar normal style test -> tabbar", function () {
46                 unit_controlbar( $("#controlbar-tabbar-test"), "tabbar" );
47         });
48
49         test( "controlbar icon style test -> tabbar", function () {
50                 unit_controlbar( $("#controlbar-tabbar-test-icon-only"), "tabbar", "icon" );
51         });
52
53         test( "controlbar text style test -> tabbar", function () {
54                 unit_controlbar( $("#controlbar-tabbar-test-text-only"), "tabbar", "text" );
55         });
56
57         test( "controlbar normal style test -> toolbar", function () {
58                 unit_controlbar( $("#controlbar-toolbar-test"), "toolbar" );
59         });
60
61         test( "controlbar icon style test -> toolbar", function () {
62                 unit_controlbar( $("#controlbar-toolbar-test-icon-only"), "toolbar", "icon" );
63         });
64
65         test( "controlbar text style test -> tabbar", function () {
66                 unit_controlbar( $("#controlbar-toolbar-test-text-only"), "toolbar", "text" );
67         });
68 })(jQuery);