modify wrong changelog date
[platform/framework/web/web-ui-fw.git] / tests / additional-unit-tests / popup / popup-tests.js
1 /*
2  * Unit Test : Popup window
3  *
4  * Minkyu Kang <mk7.kang@samsung.com>
5  */
6 /*jslint browser: true*/
7 /*global $, jQuery, test, equal, ok*/
8 $( document ).bind( "pageshow", function ( ) {
9
10         module("Popup Window" );
11         var unit_popup = function ( widget, type, buttoncount ) {
12
13                 var popupbeforepositionEvent = 0,
14                         popupafteropenEvent = 0,
15                         popupaftercloseEvent = 0,
16                         buttonList,
17                         popupwindow = function ( widget ) {
18                                 return widget.parent('.ui-popup-container') ;
19                         },
20                         check_text = function ( widget, selector, type ) {
21                                 if ( !widget.find( selector ).length ) {
22                                         return;
23                                 }
24                                 equal( widget.find( selector ).text( ), type, type );
25                         };
26
27                 $('#popupbutton').unbind('vclick') ;
28                 $('#popupbutton').bind('vclick', function ( ) {
29                         widget.popup("open", {positionTo : 'window', transition : 'none', x : '0', y : '0', link : widget } );
30                 } ) ;
31
32                 /* Create */
33                 widget.popup( );
34                 ok( popupwindow( widget ), "Create" );
35
36                 /* Open */
37                 $('#popupbutton').trigger('vclick') ;
38                 ok( parseInt( popupwindow( widget ).css("top" ), 10 ) > 0, "API : open" );
39
40                 /* Close */
41                 widget.popup("close" );
42                 ok( popupwindow( widget ).hasClass("ui-selectmenu-hidden" ) ||
43                                 popupwindow( widget ).hasClass("reverse out" ),
44                                 "API : close" );
45
46                 /* Close the popup by click the screen */
47                 $('#popupbutton').trigger('vlick') ;
48                 $(".ui-selectmenu-screen" ).trigger("vclick" );
49                 ok( popupwindow( widget ).hasClass("ui-selectmenu-hidden" ) || popupwindow( widget ).hasClass("reverse out" ), "Close the popup by click the screen" );
50
51                 /* Check Texts */
52                 if ( widget.find(".ui-popup-text" ) != undefined ) {
53                         equal( widget.find(".ui-popup-text" ).html( ), "text" );
54                 }
55                 if ( widget.find(".ui-popup-title" ) != undefined ) {
56                         equal( widget.find(".ui-popup-title" ).html( ), "title" );
57                 }
58
59                 buttonList = widget.find(":jqmData(role=button )" ) ;
60                 equal( buttonList.length, buttoncount, "Button count correct" );
61
62         };
63
64         $("#popupwindow" ).page( );
65
66         test( "Center Title", function ( ) {
67                 unit_popup( $("#center_title" ), "center_title" , 0 );
68         } );
69         test( "Center Info", function ( ) {
70                 unit_popup( $("#center_info" ), "center_info", 0 );
71         } );
72         test( "Center Basic 1 Button", function ( ) {
73                 unit_popup( $("#center_basic_1btn" ), "center_basic_1btn" , 1 );
74         } );
75         test( "Center Title 1 Button", function ( ) {
76                 unit_popup( $("#center_title_1btn" ), "center_title_1btn" , 1 );
77         } );
78         test( "Center social style", function ( ) {
79                 unit_popup( $("#center_social_style1" ), "center_liststyle_2btn" , 2 );
80         } );
81         test( "center_social_style2", function ( ) {
82                 unit_popup( $("#center_social_style2" ), "center_title_2btn" , 2 );
83         } );
84         test( "center_basic_2btn", function ( ) {
85                 unit_popup( $("#center_basic_2btn" ), "center_basic_2btn" , 2 );
86         } );
87         test( "center_basic_3btn", function ( ) {
88                 unit_popup( $("#center_basic_3btn" ), "center_basic_3btn" , 3 );
89         } );
90         test( "center_title_2btn", function ( ) {
91                 unit_popup( $("#center_title_2btn" ), "center_title_2btn" , 2 );
92         } );
93         test( "Center_title_3btn", function ( ) {
94                 unit_popup( $("#center_title_3btn" ), "center_title_3btn" , 3 );
95         } );
96         test( "center_button_vertical", function ( ) {
97                 unit_popup( $("#center_button_vertical" ), "center_button_vertical" , 3 );
98         } );
99         test( "Center_checkbox", function ( ) {
100                 unit_popup( $("#center_checkbox" ), "center_checkbox" , 2 );
101         } );
102         test( "center_liststyle_1btn", function ( ) {
103                 unit_popup( $("#center_liststyle_1btn" ), "center_liststyle_1btn" , 1 );
104         } );
105         test( "center_liststyle_2btn", function ( ) {
106                 unit_popup( $("#center_liststyle_2btn" ), "center_liststyle_2btn" , 2 );
107         } );
108         test( "center_liststyle_3btn", function ( ) {
109                 unit_popup( $("#center_liststyle_3btn" ), "center_liststyle_3btn" , 3 );
110         } );
111
112 } );