UnitTC: Additional unit testcases have been added
[platform/framework/web/web-ui-fw.git] / tests / additional-unit-tests / multimediaview / multimediaview-tests.js
1 /*
2  * Unit Test: MultiMediaView
3  *
4  * Wonseop Kim <wonseop.kim@samsung.com>
5  */
6 /*jslint browser: true*/
7 /*global $, jQuery, test, equal, ok*/
8 $( document ).ready( function ( ) {
9         module("MultiMediaView");
10
11         var unit_multimediaview = function ( widget, type ) {
12                 var control,
13                         fullscreenButton,
14                         width,
15                         height,
16                         played,
17                         fullScreen,
18                         timeupdated,
19                         ended,
20                         param,
21                         volumebutton,
22                         seekerbar,
23                         playpause;
24
25                 /* Create */
26                 widget.multimediaview( );
27                 ok( widget.hasClass("ui-multimediaview") , "Create");
28
29                 playpause = widget.parent( ).find('.ui-playpausebutton') ;
30                 ok( playpause.hasClass("ui-play-icon") , "Markup: Play button present");
31                 if ( type == 'vedio') {
32                         fullScreen = widget.parent( ).find('.ui-fullscreenbutton') ;
33                         ok( fullScreen.hasClass("ui-fullscreen-on") , "Markup: fullscreen button present");
34                 }
35                 volumebutton = widget.parent( ).find('.ui-volumebutton') ;
36                 ok( volumebutton.hasClass("ui-volume-icon") , "Markup: Volume button present");
37                 seekerbar = widget.parent( ).find('.ui-seekbar') ;
38                 equal( seekerbar.find(".ui-currenttime").css('width'), '0px', "Markup: initial current time");
39                 ok( widget.parent( ).find(".ui-durationlabel"), "Markup : duration label");
40                 ok( widget.parent( ).find(".ui-timestamplabel"), "Markup : current time label");
41                 ok( widget.parent( ).find(".ui-volumecontrol"), "Markup : volume control");
42
43                 /* width */
44                 width = 100;
45                 widget.multimediaview("width", width );
46                 equal( width, widget.width( ), "API: width");
47
48                 equal( width, widget.multimediaview("width") , "API: width multimediaview");
49
50                 /* height */
51                 height = 200;
52                 widget.multimediaview("height", height );
53                 equal( height, widget.height( ), "API: height");
54                 equal( height, widget.multimediaview("height") , "API: height multimediaview");
55                 if ( type === "video") {
56
57                         /* fullscreen */
58                         fullscreenButton = widget.parent( ).find(".ui-fullscreenbutton");
59                         equal( false, widget.multimediaview("fullScreen") , "API: fullScreen initially value - multimediaview");
60
61                         widget.multimediaview("fullScreen", true );
62                         ok( fullscreenButton.hasClass("ui-fullscreen-off"), "API: fullScreen ( on ) - markup");
63                         equal( true, widget.multimediaview("fullScreen") , "API: fullScreen set to true - multimediaview");
64                         equal( $("body")[0].clientHeight - 1 , widget.height( ), "API: height after full screen on");
65                         equal( $("body")[0].clientWidth , widget.width( ), "API: width after full screen on");
66
67                         widget.multimediaview("fullScreen", false );
68                         ok( fullscreenButton.hasClass("ui-fullscreen-on"), "API: fullScreen ( off ) - markup");
69                         equal( false, widget.multimediaview("fullScreen") , "API: fullScreen set to true - multimediaview");
70                         equal( widget.height( ) , height, "API: height after full screen off");
71                         equal( widget.width( ) , width, "API: width after full screen off");
72
73                 }
74         };
75
76         test("video", function ( ) {
77                 $('#multimediaview0').page( );
78                 unit_multimediaview( $("#video"), "video");
79         } );
80
81         test("audio", function ( ) {
82                 $('#multimediaview1').page( );
83                 unit_multimediaview( $("#audio"), "audio");
84         } );
85
86         test("audio dymanic", function ( ) {
87
88                 var createEvent = false,
89                         audioHTML = '<audio data-controls= "false"style= "width:100%;"id= "audioControl2"data-fullscreen= "false"class= "multimediaobjetc">' +
90                                                                                 '<source src= "http://www.w3schools.com/html5/mov_bbb.mp4"type= "audio/mp4"/>' +
91                                                                                 '<source src= "http://www.w3schools.com/html5/mov_bbb.ogg"type= "audio/ogg"/>' +
92                                                                                 '<p>Your browser does not support the audio tag.</p>' +
93                                                                         '</audio>';
94                 $('#multimediaview11').page( );
95                 $('#multimediaview11').find(":jqmData(role=content)").append( audioHTML );
96
97                 $("#audioControl").bind("create", function ( ) {
98                         createEvent = true ;
99                 } );
100
101                 $('#audioControl2').trigger("create") ;
102                 equal( createEvent, true, "Audio Create Event") ;
103                 unit_multimediaview( $("#audioControl2"), "audio");
104         } );
105
106         test("video dymanic", function ( ) {
107
108                 var createEvent = false,
109                         videoHTML = '<video data-controls= "true"style= "width:100%;"id= "vedioControl1"data-fullscreen= "false"class= "multimediaobjetc">' +
110                                                                         '<source src= "http://www.w3schools.com/html5/mov_bbb.mp4"type= "video/mp4"/>' +
111                                                                         '<source src= "http://www.w3schools.com/html5/mov_bbb.ogg"type= "video/ogg"/>' +
112                                                                         '<source src= "http://www.w3schools.com/html5/mov_bbb.webm"type= "video/webm"/>' +
113                                                                         '<p>Your browser does not support the video tag.</p>' +
114                                                                 '</video>';
115                 $('#multimediaview01').page( );
116                 $('#multimediaview01').find(":jqmData(role=content)").append( videoHTML ) ;
117
118                 $("#vedioControl1").bind("create", function ( ) {
119                         createEvent = true ;
120                 } );
121                 $('#vedioControl1').trigger("create") ;
122                 equal( createEvent, true, "Vedio Create Event") ;
123                 unit_multimediaview( $("#vedioControl1"), "video");
124         } );
125
126 } );