UnitTC: Additional unit testcases have been added
[platform/framework/web/web-ui-fw.git] / tests / additional-unit-tests / navigationbar / navigationbar-tests.js
1 /*
2  * navigationbar unit tests
3 */
4 /*jslint browser: true*/
5 /*global $, jQuery, test, equal, ok*/
6 ( function ( $ ) {
7         module("Navigationbar");
8
9         var unit_navigationbar = function ( widget, anchorCount, position, extendedValue ) {
10                 /* Create */
11                 var created_navigationbar = $( widget );
12                 ok( created_navigationbar, "Create");
13
14                 /* Check Parameters */
15                 equal( created_navigationbar.jqmData("nstest-role"), position, "Basic test");
16
17                 if ( extendedValue ) {
18                         equal( created_navigationbar.find("input").length, anchorCount, "Groupcontrol button test");
19                 } else {
20                         equal( created_navigationbar.children("a").length, anchorCount, "button test");
21                 }
22         };
23
24         test("navigationbar no button test -header", function ( ) {
25                 unit_navigationbar( $("#normalnavigation1"), 0, 'header');
26         } );
27
28         test("navigationbar one button test -header", function ( ) {
29                 unit_navigationbar( $("#normalnavigation2"), 1, 'header');
30         } );
31
32         test("navigationbar two button test -header", function ( ) {
33                 unit_navigationbar( $("#normalnavigation3"), 2 , 'header');
34         } );
35
36         test("navigationbar three button test -header", function ( ) {
37                 unit_navigationbar( $("#normalnavigation4"), 3 , 'header');
38         } );
39
40         test("navigationbar extended two button test -header", function ( ) {
41                 unit_navigationbar( $("#extendedstyle2btn"), 2, 'header', true );
42         } );
43
44         test("navigationbar extended three button test - header", function ( ) {
45                 unit_navigationbar( $("#extendedstyle3btn"), 3, 'header', true );
46         } );
47
48         test("navigationbar extended four button test -header", function ( ) {
49                 unit_navigationbar( $("#extendedstyle4btn"), 4, 'header', true );
50         } );
51
52         test("navigationbar no button test -header - Dynamic", function ( ) {
53
54                 var markup = '<h1>Navigationbar Test - markup</h1>';
55                 $('#normalnavigation11').append( markup ).trigger('create');
56
57                 unit_navigationbar( $("#normalnavigation11"), 0, 'header');
58         } );
59
60         test("navigationbar extended four button test -header- Dymanic", function ( ) {
61
62                 var markup = '<div data-role= "fieldcontain">' +
63                                                                 '<fieldset data-role= "controlgroup"data-type= "horizontal">' +
64                                                                         '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment1"value= "on"checked= "checked"/>' +
65                                                                         '<label for= "segment1">All</label>' +
66                                                                         '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment2"value= "off"/>' +
67                                                                         '<label for= "segment2">Call</label>' +
68                                                                         '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment3"value= "off"/>' +
69                                                                         '<label for= "segment3">Save</label>' +
70                                                                         '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment4"value= "off"/>' +
71                                                                         '<label for= "segment4">Back</label>' +
72                                                                 '</fieldset>' +
73                                                         '</div>';
74
75                 $('#extendedstyle5btn').append( markup ).trigger('create');
76                 $('#extendedstyle5btn').find(":jqmData(role=fieldcontain)").trigger('create');
77                 unit_navigationbar( $("#extendedstyle5btn"), 4, 'header', true );
78         } );
79
80
81         test("navigationbar no button test -footer", function ( ) {
82                 unit_navigationbar( $("#normalnavigation12"), 0 , 'footer');
83         } );
84
85         test("navigationbar one button test -footer", function ( ) {
86                 unit_navigationbar( $("#normalnavigation22"), 1 , 'footer');
87         } );
88
89         test("navigationbar two button test -footer", function ( ) {
90                 unit_navigationbar( $("#normalnavigation32"), 2 , 'footer');
91         } );
92
93         test("navigationbar three button test -footer", function ( ) {
94                 unit_navigationbar( $("#normalnavigation42"), 3 , 'footer');
95         } );
96
97         test("navigationbar extended two button test -footer", function ( ) {
98                 unit_navigationbar( $("#extendedstyle22btn"), 2 , 'footer', true );
99         } );
100
101         test("navigationbar extended three button test -footer", function ( ) {
102                 unit_navigationbar( $("#extendedstyle32btn"), 3 , 'footer', true );
103         } );
104
105         test("navigationbar extended four button test -footer", function ( ) {
106                 unit_navigationbar( $("#extendedstyle42btn"), 4 , 'footer', true );
107         } );
108
109         test("navigationbar no button test -footer - Dynamic", function ( ) {
110
111                 var markup = '<h1>Navigationbar Test - markup</h1>';
112                 $('#normalnavigation111').append( markup ).trigger('create');
113
114                 unit_navigationbar( $("#normalnavigation111"), 0 , 'footer');
115         } );
116
117         test("navigationbar extended four button test -footer- Dymanic", function ( ) {
118
119                 var markup = '<div data-role= "fieldcontain">' +
120                                                                 '<fieldset data-role= "controlgroup"data-type= "horizontal">' +
121                                                                         '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment1"value= "on"checked= "checked"/>' +
122                                                                         '<label for= "segment1">All</label>' +
123                                                                         '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment2"value= "off"/>' +
124                                                                         '<label for= "segment2">Call</label>' +
125                                                                         '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment3"value= "off"/>' +
126                                                                         '<label for= "segment3">Save</label>' +
127                                                                         '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment4"value= "off"/>' +
128                                                                         '<label for= "segment4">Back</label>' +
129                                                                 '</fieldset>' +
130                                                         '</div>';
131
132                 $('#extendedstyle52btn').append( markup ).trigger('create');
133                 $('#extendedstyle52btn').find(":jqmData(role=fieldcontain)").trigger('create');
134                 unit_navigationbar( $("#extendedstyle52btn"), 4 , 'footer', true );
135         } );
136 } ( jQuery ));