2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 * Free Software Foundation, Inc.
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
22 #define INPUT_FILENAME "key_event_test.swf"
24 #include "MovieTester.h"
25 #include "MovieClip.h"
26 #include "DisplayObject.h"
27 #include "DisplayList.h"
35 using namespace gnash
;
40 trymain(int /*argc*/, char** /*argv*/)
42 string filename
= string(INPUT_FILENAME
);
43 MovieTester
tester(filename
);
45 gnash::LogFile
& dbglogfile
= gnash::LogFile::getDefaultInstance();
46 dbglogfile
.setVerbosity(1);
48 MovieClip
* root
= tester
.getRootMovie();
51 check_equals(root
->get_frame_count(), 24);
52 check_equals(root
->get_current_frame(), 0);
56 // check we are stopped at frame2
57 check_equals(root
->get_current_frame(), 1);
59 // provide a key press to continue the test
60 tester
.pressKey(key::A
);
61 tester
.releaseKey(key::A
);
64 check_equals(root
->get_current_frame(), 2);
68 // check we are stopped at frame4
69 check_equals(root
->get_current_frame(), 3);
71 // provide a key press to continue the test
72 tester
.pressKey(key::B
);
73 tester
.releaseKey(key::B
);
76 check_equals(root
->get_current_frame(), 4);
80 // check we are stopped at frame6
81 check_equals(root
->get_current_frame(), 5);
83 // provide a key press to continue the test
84 tester
.pressKey(key::C
);
85 tester
.releaseKey(key::C
);
88 check_equals(root
->get_current_frame(), 6);
91 check_equals(root
->get_current_frame(), 7);
95 // check we are stopped at frame9
96 check_equals(root
->get_current_frame(), 8);
98 // provide a key press to continue the test
99 tester
.pressKey(key::D
);
100 tester
.releaseKey(key::D
);
102 // we have jumped back to frame8
103 check_equals(root
->get_current_frame(), 7);
106 // and we are in frame9 again
107 check_equals(root
->get_current_frame(), 8);
109 // provide a key press to continue the test
110 tester
.pressKey(key::E
);
111 tester
.releaseKey(key::E
);
113 // we have jumped forward to frame10
114 check_equals(root
->get_current_frame(), 9);
117 check_equals(root
->get_current_frame(), 10);
121 // check we are stopped at frame12
122 check_equals(root
->get_current_frame(), 11);
124 // provide a key press to continue the test
125 tester
.pressKey(key::F
);
126 tester
.releaseKey(key::F
);
128 // we have jumped backward to frame11
129 check_equals(root
->get_current_frame(), 10);
132 // and we are in frame12 again
133 check_equals(root
->get_current_frame(), 11);
135 // provide a key press to continue the test
136 tester
.pressKey(key::G
);
137 tester
.releaseKey(key::G
);
138 // we have jumped forward to frame13
139 check_equals(root
->get_current_frame(), 12);
143 // check we are stopped at frame14
144 check_equals(root
->get_current_frame(), 13);
146 // provide a key press to continue the test
147 tester
.pressKey(key::H
);
148 tester
.releaseKey(key::H
);
152 // check we are stopped at frame15
153 check_equals(root
->get_current_frame(), 14);
155 // provide a key press to continue the test
156 tester
.pressKey(key::I
);
157 tester
.releaseKey(key::I
);
159 // check we have jumped to frame16
160 check_equals(root
->get_current_frame(), 15);
162 for(int i
=0; i
<10; i
++)
166 // check we are stopped at frame20
167 check_equals(root
->get_current_frame(), 19);
169 // provide a key press to continue the test
170 tester
.pressKey(key::J
);
171 tester
.releaseKey(key::J
);
172 // check have jumped to frame21
173 check_equals(root
->get_current_frame(), 20);
177 // check we are stopped at frame22
178 check_equals(root
->get_current_frame(), 21);
180 // provide a key press to continue the test
181 tester
.pressKey(key::K
);
182 tester
.releaseKey(key::K
);
185 // Select the text field
186 tester
.movePointerTo(310, 25);
190 tester
.pressKey(key::i
);
193 // reached frame23, test finished
194 check_equals(root
->get_current_frame(), 23);