2.0_beta sync to rsa
[framework/web/web-ui-fw.git] / tests / unit-tests / popupwindow / popup-tests.js
1 /*
2  * Unit Test: Popup window
3  *
4  * Minkyu Kang <mk7.kang@samsung.com>
5  */
6
7 (function ($) {
8         module("Popup Window");
9
10         var unit_popup = function ( widget, type ) {
11                 var popupwindow = function ( widget ) {
12                                 return widget.parent(".ui-popupwindow");
13                         },
14                         check_text = function ( widget, selector, type ) {
15                                 if ( !widget.find( selector ).length ) {
16                                         return;
17                                 }
18                                 equal( widget.find( selector ).text(), type, type );
19                         };
20
21                 /* Create */
22                 widget.popupwindow();
23                 ok( popupwindow( widget ), "Create" );
24
25                 /* Open */
26                 widget.popupwindow("open");
27                 ok( parseInt( popupwindow( widget ).css("top") ) > 0, "API: open" );
28
29                 /* Close */
30                 widget.popupwindow("close");
31                 ok( popupwindow( widget ).hasClass("ui-selectmenu-hidden") ||
32                         popupwindow( widget ).hasClass("reverse out"),
33                         "API: close" );
34
35                 /* Close the popup by click the screen */
36                 widget.popupwindow("open");
37                 $(".ui-selectmenu-screen").trigger("vclick");
38                 ok( popupwindow( widget ).hasClass("ui-selectmenu-hidden") ||
39                         popupwindow( widget ).hasClass("reverse out"),
40                                 "Close the popup by click the screen" );
41
42                 /* Check Texts */
43                 check_text( widget, ":jqmData(role='text')", "text" );
44                 check_text( widget, ":jqmData(role='title')", "title" );
45                 check_text( widget, ".ui-btn", "button" );
46         };
47
48         test( "Center Info", function () {
49                 unit_popup( $("#center_info"), "center_info" );
50         });
51
52         test( "Center Title", function () {
53                 unit_popup( $("#center_title"), "center_title" );
54         });
55
56         test( "Center Basic 1 Button", function () {
57                 unit_popup( $("#center_basic_1btn"), "center_basic_1btn" );
58         });
59
60         test( "Center Title 1 Button", function () {
61                 unit_popup( $("#center_title_1btn"), "center_title_1btn" );
62         });
63
64 }( jQuery ));