2 // Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 // Test case for Camera ActionScript class
21 // compile this test case with Ming makeswf, and then
22 // execute it like this gnash -1 -r 0 -v out.swf
28 #if OUTPUT_VERSION
< 6
30 check_equals
(typeof(Camera), 'function');
32 #else // OUTPUT_VERSION >= 6
34 //trace("NOTE: System.capabilities.hasVideoEncoder: " + System.capabilities.hasVideoEncoder);
36 // This is not the proper way to construct a camera object. According to the
37 // livedoc a camera should be retrieved using Camera.get(). The constructor
38 // returns an object with camera functions.
40 //test the Camera constuctor
41 check_equals
(typeof(Camera), "function");
43 var cameraObj
= new Camera;
45 var cameraObj2
= new Camera();
47 check
(cameraObj
!= cameraObj2
);
48 check_equals
(typeof(cameraObj
), 'object');
49 check_equals
(typeof(cameraObj
.setCursor
), "function");
50 check_equals
(typeof(cameraObj
.setKeyFrameInterval
), "function");
51 check_equals
(typeof(cameraObj
.setLoopback
), "function");
53 // These properties are never present before Camera.get() is called.
54 check
(!Camera.prototype
.hasOwnProperty
("activityLevel"));
55 check
(!Camera.prototype
.hasOwnProperty
("bandwidth"));
56 check
(!Camera.prototype
.hasOwnProperty
("currentFps"));
57 check
(!Camera.prototype
.hasOwnProperty
("fps"));
58 check
(!Camera.prototype
.hasOwnProperty
("height"));
59 check
(!Camera.prototype
.hasOwnProperty
("index"));
60 check
(!Camera.prototype
.hasOwnProperty
("width"));
61 check
(!Camera.prototype
.hasOwnProperty
("motionLevel"));
62 check
(!Camera.prototype
.hasOwnProperty
("motionTimeout"));
63 check
(!Camera.prototype
.hasOwnProperty
("muted"));
64 check
(!Camera.prototype
.hasOwnProperty
("name"));
65 check
(!Camera.prototype
.hasOwnProperty
("quality"));
68 // The .get() method is a class method, not exported
71 check_equals
(cameraObj
.get, undefined);
73 var cam
= Camera.get();
75 trace
("Camera.get() returns: " + cam
);
78 check
(!Camera.prototype
.hasOwnProperty
("names"));
79 check
(!Camera.prototype
.hasOwnProperty
("get"));
81 // These properties are added to the prototype if a camera is present
82 // after get is called.
84 check
(Camera.prototype
.hasOwnProperty
("activityLevel"));
85 check
(Camera.prototype
.hasOwnProperty
("bandwidth"));
86 check
(Camera.prototype
.hasOwnProperty
("currentFps"));
87 check
(Camera.prototype
.hasOwnProperty
("fps"));
88 check
(Camera.prototype
.hasOwnProperty
("height"));
89 check
(Camera.prototype
.hasOwnProperty
("index"));
90 check
(Camera.prototype
.hasOwnProperty
("width"));
91 check
(Camera.prototype
.hasOwnProperty
("motionLevel"));
92 check
(Camera.prototype
.hasOwnProperty
("motionTimeout"));
93 check
(Camera.prototype
.hasOwnProperty
("muted"));
94 check
(Camera.prototype
.hasOwnProperty
("name"));
95 check
(Camera.prototype
.hasOwnProperty
("quality"));
98 check
(!Camera.prototype
.hasOwnProperty
("activityLevel"));
99 check
(!Camera.prototype
.hasOwnProperty
("bandwidth"));
100 check
(!Camera.prototype
.hasOwnProperty
("currentFps"));
101 check
(!Camera.prototype
.hasOwnProperty
("fps"));
102 check
(!Camera.prototype
.hasOwnProperty
("height"));
103 check
(!Camera.prototype
.hasOwnProperty
("index"));
104 check
(!Camera.prototype
.hasOwnProperty
("width"));
105 check
(!Camera.prototype
.hasOwnProperty
("motionLevel"));
106 check
(!Camera.prototype
.hasOwnProperty
("motionTimeout"));
107 check
(!Camera.prototype
.hasOwnProperty
("muted"));
108 check
(!Camera.prototype
.hasOwnProperty
("name"));
109 check
(!Camera.prototype
.hasOwnProperty
("quality"));
112 // test that the methods do not exist in the class
113 check_equals
(Camera.setMode
, undefined);
114 check_equals
(Camera.setMotionLevel
, undefined);
115 check_equals
(Camera.setQuality
, undefined);
116 check_equals
(Camera.setCursor
, undefined);
118 check_equals
( typeof(cam
.setMode
), 'function' );
119 check_equals
( typeof(cam
.setMotionLevel
), 'function' );
120 check_equals
( typeof(cam
.setQuality
), 'function');
121 check_equals
( typeof(cam
.setCursor
), 'function');
122 check_equals
( typeof(cam
.setKeyFrameInterval
), 'function');
123 check_equals
( typeof(cam
.setLoopback
), 'function');
126 check_equals
( typeof(cam
.activityLevel
), 'number' );
127 check_equals
( typeof(cam
.bandwidth
), 'number');
128 check_equals
( typeof(cam
.currentFps
), 'number');
129 check_equals
( typeof(cam
.fps
), 'number');
130 check_equals
( typeof(cam
.height
), 'number');
131 check_equals
( typeof(cam
.index
), 'string'); //differs from spec, testing real bhvior
132 check_equals
( typeof(cam
.motionLevel
), 'number');
133 check_equals
( typeof(cam
.motionTimeout
), 'number');
134 check_equals
( typeof(cam
.muted
), 'boolean');
135 check_equals
( typeof(cam
.name
), 'string');
136 check_equals
( typeof(cam
.names
), 'undefined');
137 check_equals
( typeof(cam
.quality
), 'number');
138 check_equals
( typeof(cam
.width
), 'number');
140 // check initialized values as in spec (gnash initializes to default)
141 check_equals
( cam
.activityLevel
, -1 );
142 check_equals
( cam
.bandwidth
, 16384);
143 check_equals
( cam
.height
, 120);
144 check_equals
( cam
.motionLevel
, 50);
145 check_equals
( cam
.motionTimeout
, 2000);
146 check_equals
( cam
.muted
, true);
147 check_equals
( cam
.width
, 160);
149 // setting and getting
151 // check Camera::setMode with no args
153 check_equals
( cam
.width
, 160);
154 check_equals
( cam
.height
, 120);
155 check_equals
( cam
.fps
, 15);
157 // check Camera::setMode with all arguments set
158 cam
.setMode
(320, 280, 30, false);
159 check_equals
( cam
.width
, 320);
160 check_equals
( cam
.height
, 280);
161 check_equals
( cam
.fps
, 30);
163 // check Camera::setMotionLevel with no args
164 cam
.setMotionLevel
();
165 check_equals
(cam
.motionLevel
, 50);
166 check_equals
(cam
.motionTimeout
, 2000);
168 // check Camera::setMotionLevel with all arguments set
169 cam
.setMotionLevel
(75, 3000);
170 check_equals
(cam
.motionLevel
, 75);
171 check_equals
(cam
.motionTimeout
, 3000);
173 // check Camera::setMotionLevel with bad motionLevel argument
174 cam
.setMotionLevel
(200, 2000);
175 check_equals
(cam
.motionLevel
, 100);
177 // check Camera::setQuality with no args
179 check_equals
(cam
.bandwidth
, 16384);
180 check_equals
(cam
.quality
, 0);
182 // check Camera::setQuality with all arguments set
183 cam
.setQuality
(18000, 75);
184 check_equals
(cam
.bandwidth
, 18000);
185 check_equals
(cam
.quality
, 75);
187 // check Camera::setQuality with bad quality value
188 cam
.setQuality
(18000, 420);
189 check_equals
(cam
.bandwidth
, 18000);
190 check_equals
(cam
.quality
, 100);
192 #endif
// OUTPUT_VERSION >= 6