Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / DummyMovieDefinition.h
blob4d92ec5c0bbd1c8bdef7771e093dc8808351f876
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
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.
9 //
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.
14 //
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
19 #ifndef GNASH_DUMMYMOVIEDEFINITION_H
20 #define GNASH_DUMMYMOVIEDEFINITION_H
22 #include "SWFMovieDefinition.h" // for inheritance
23 #include "SWFRect.h" // for composition
24 #include "SWFMovie.h" // for createMovie
25 #include "Global_as.h"
26 #include "namedStrings.h"
28 #include <vector>
29 #include <string>
30 #include <memory> // for unique_ptr
33 namespace gnash
36 /// A dummy movie definition, for use by unit tests
38 /// This class provides implementation of all virtual
39 /// methods of movie_definition by returning user-defined
40 /// values for version/size/frame rate etc..
41 ///
42 /// The createMovie function will return the same
43 /// object created by createEmptyMovieClip() calls
44 /// (an empty movieclip... still to be designed)
45 ///
46 class DummyMovieDefinition : public SWFMovieDefinition
48 int _version;
49 SWFRect _framesize;
50 size_t _framecount;
51 std::vector<PlayList> _playlist;
52 float _framerate;
53 std::string _url;
55 public:
58 /// Default constructor
60 /// Will be initialized with the following values
61 ///
62 /// - SWF version 6
63 /// - 640x480 size
64 /// - Single frame (unlabeled)
65 /// - 12 FPS
66 /// - 0 bytes (for get_bytes_loaded()/get_bytes_total())
67 /// - empty url
68 ///
69 DummyMovieDefinition(const RunResources& ri)
71 SWFMovieDefinition(ri),
72 _version(6),
73 _framesize(0, 0, 640*20, 480*20),
74 _framecount(1),
75 _playlist(_framecount),
76 _framerate(12),
77 _url("http://www.gnu.org/software/gnash")
81 /// Overloaded constructor for specifying target version
83 /// This is particularly useful for unit tests.
84 /// All but the target version will be initialized
85 /// exactly as with the default constructor.
86 ///
87 DummyMovieDefinition(const RunResources& ri, int version)
89 SWFMovieDefinition(ri),
90 _version(version),
91 _framesize(0, 0, 640*20, 480*20),
92 _framecount(1),
93 _playlist(_framecount),
94 _framerate(12),
95 _url("http://www.gnu.org/software/gnash")
99 virtual bool ensure_frame_loaded(size_t) const {
100 return true;
103 virtual int get_version() const {
104 return _version;
107 virtual size_t get_width_pixels() const {
108 return _framesize.width()/20;
111 virtual size_t get_height_pixels() const {
112 return _framesize.height()/20;
115 virtual size_t get_frame_count() const {
116 return _framecount;
119 virtual float get_frame_rate() const {
120 return _framerate;
123 virtual const SWFRect& get_frame_size() const {
124 return _framesize;
127 virtual size_t get_bytes_loaded() const {
128 return 0;
131 virtual size_t get_bytes_total() const {
132 return 0;
135 /// Create a playable movie instance from a def.
136 virtual Movie* createMovie(Global_as& gl, DisplayObject* parent=NULL)
138 as_object* o = getObjectWithPrototype(gl, NSV::CLASS_MOVIE_CLIP);
139 return new SWFMovie(o, this, parent);
142 virtual const PlayList& get_playlist(size_t frame_number) const
144 assert ( frame_number < _playlist.size() );
145 return _playlist[frame_number];
149 // For use during creation.
152 /// Returns 1 based index. Ex: if 1 then 1st frame as been fully loaded
153 virtual size_t get_loading_frame() const {
154 return 1;
157 virtual const std::string& get_url() const {
158 return _url;
163 } // namespace gnash
165 #endif // GNASH_DUMMYMOVIEDEFINITION_H