f21dddf3a43b372f5ca1117147f65975dbe62b4d
[test/tct/web/uifw.git] /
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         test( "multimediaview", function () {
76                 ok($.tizen.multimediaview, 'widget loaded');
77         });
78
79         if (!window.navigator.userAgent.match('PhantomJS')) {
80         test("video", function ( ) {
81                 $('#multimediaview0').page( );
82                 unit_multimediaview( $("#video"), "video");
83         } );
84
85         test("audio", function ( ) {
86                 $('#multimediaview1').page( );
87                 unit_multimediaview( $("#audio"), "audio");
88         } );
89
90         test("audio dymanic", function ( ) {
91
92                 var createEvent = false,
93                         audioHTML = '<audio data-controls= "false"style= "width:100%;"id= "audioControl2"data-fullscreen= "false"class= "multimediaobjetc">' +
94                                                                                 '<source src= "http://www.w3schools.com/html5/mov_bbb.mp4"type= "audio/mp4"/>' +
95                                                                                 '<source src= "http://www.w3schools.com/html5/mov_bbb.ogg"type= "audio/ogg"/>' +
96                                                                                 '<p>Your browser does not support the audio tag.</p>' +
97                                                                         '</audio>';
98                 $('#multimediaview11').page( );
99                 $('#multimediaview11').find(":jqmData(role=content)").append( audioHTML );
100
101                 $("#audioControl").bind("create", function ( ) {
102                         createEvent = true ;
103                 } );
104
105                 $('#audioControl2').trigger("create") ;
106                 equal( createEvent, true, "Audio Create Event") ;
107                 unit_multimediaview( $("#audioControl2"), "audio");
108         } );
109
110         test("video dymanic", function ( ) {
111
112                 var createEvent = false,
113                         videoHTML = '<video data-controls= "true"style= "width:100%;"id= "vedioControl1"data-fullscreen= "false"class= "multimediaobjetc">' +
114                                                                         '<source src= "http://www.w3schools.com/html5/mov_bbb.mp4"type= "video/mp4"/>' +
115                                                                         '<source src= "http://www.w3schools.com/html5/mov_bbb.ogg"type= "video/ogg"/>' +
116                                                                         '<source src= "http://www.w3schools.com/html5/mov_bbb.webm"type= "video/webm"/>' +
117                                                                         '<p>Your browser does not support the video tag.</p>' +
118                                                                 '</video>';
119                 $('#multimediaview01').page( );
120                 $('#multimediaview01').find(":jqmData(role=content)").append( videoHTML ) ;
121
122                 $("#vedioControl1").bind("create", function ( ) {
123                         createEvent = true ;
124                 } );
125                 $('#vedioControl1').trigger("create") ;
126                 equal( createEvent, true, "Vedio Create Event") ;
127                 unit_multimediaview( $("#vedioControl1"), "video");
128         } );
129         }
130 } );