2 * Unit Test : Popup window
4 * Minkyu Kang <mk7.kang@samsung.com>
6 /*jslint browser: true*/
7 /*global $, jQuery, test, equal, ok*/
8 $( document ).bind( "pageshow", function ( ) {
10 module("Popup Window" );
11 var unit_popup = function ( widget, type, buttoncount ) {
13 var popupbeforepositionEvent = 0,
14 popupafteropenEvent = 0,
15 popupaftercloseEvent = 0,
17 popupwindow = function ( widget ) {
18 return widget.parent('.ui-popup-container') ;
20 check_text = function ( widget, selector, type ) {
21 if ( !widget.find( selector ).length ) {
24 equal( widget.find( selector ).text( ), type, type );
27 $('#popupbutton').unbind('vclick') ;
28 $('#popupbutton').bind('vclick', function ( ) {
29 widget.popup("open", {positionTo : 'window', transition : 'none', x : '0', y : '0', link : widget } );
34 ok( popupwindow( widget ), "Create" );
37 $('#popupbutton').trigger('vclick') ;
38 ok( parseInt( popupwindow( widget ).css("top" ), 10 ) > 0, "API : open" );
41 widget.popup("close" );
42 ok( popupwindow( widget ).hasClass("ui-selectmenu-hidden" ) ||
43 popupwindow( widget ).hasClass("reverse out" ),
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" );
52 if ( widget.find(".ui-popup-text" ) != undefined ) {
53 equal( widget.find(".ui-popup-text" ).html( ), "text" );
55 if ( widget.find(".ui-popup-title" ) != undefined ) {
56 equal( widget.find(".ui-popup-title" ).html( ), "title" );
59 buttonList = widget.find(":jqmData(role=button )" ) ;
60 equal( buttonList.length, buttoncount, "Button count correct" );
64 $("#popupwindow" ).page( );
66 test( "Center Title", function ( ) {
67 unit_popup( $("#center_title" ), "center_title" , 0 );
69 test( "Center Info", function ( ) {
70 unit_popup( $("#center_info" ), "center_info", 0 );
72 test( "Center Basic 1 Button", function ( ) {
73 unit_popup( $("#center_basic_1btn" ), "center_basic_1btn" , 1 );
75 test( "Center Title 1 Button", function ( ) {
76 unit_popup( $("#center_title_1btn" ), "center_title_1btn" , 1 );
78 test( "Center social style", function ( ) {
79 unit_popup( $("#center_social_style1" ), "center_liststyle_2btn" , 2 );
81 test( "center_social_style2", function ( ) {
82 unit_popup( $("#center_social_style2" ), "center_title_2btn" , 2 );
84 test( "center_basic_2btn", function ( ) {
85 unit_popup( $("#center_basic_2btn" ), "center_basic_2btn" , 2 );
87 test( "center_basic_3btn", function ( ) {
88 unit_popup( $("#center_basic_3btn" ), "center_basic_3btn" , 3 );
90 test( "center_title_2btn", function ( ) {
91 unit_popup( $("#center_title_2btn" ), "center_title_2btn" , 2 );
93 test( "Center_title_3btn", function ( ) {
94 unit_popup( $("#center_title_3btn" ), "center_title_3btn" , 3 );
96 test( "center_button_vertical", function ( ) {
97 unit_popup( $("#center_button_vertical" ), "center_button_vertical" , 3 );
99 test( "Center_checkbox", function ( ) {
100 unit_popup( $("#center_checkbox" ), "center_checkbox" , 2 );
102 test( "center_liststyle_1btn", function ( ) {
103 unit_popup( $("#center_liststyle_1btn" ), "center_liststyle_1btn" , 1 );
105 test( "center_liststyle_2btn", function ( ) {
106 unit_popup( $("#center_liststyle_2btn" ), "center_liststyle_2btn" , 2 );
108 test( "center_liststyle_3btn", function ( ) {
109 unit_popup( $("#center_liststyle_3btn" ), "center_liststyle_3btn" , 3 );