Update with current status
[gnash.git] / testsuite / misc-ming.all / key_event_testrunner.cpp
blob9860c4e32744cdd37d6bdb32026d59958e6f672d
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.
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 */
22 #define INPUT_FILENAME "key_event_test.swf"
24 #include "MovieTester.h"
25 #include "MovieClip.h"
26 #include "DisplayObject.h"
27 #include "DisplayList.h"
28 #include "log.h"
29 #include "VM.h"
31 #include "check.h"
32 #include <string>
33 #include <cassert>
35 using namespace gnash;
36 using namespace std;
38 TRYMAIN(_runtest);
39 int
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();
49 assert(root);
51 check_equals(root->get_frame_count(), 24);
52 check_equals(root->get_current_frame(), 0);
54 tester.advance();
55 tester.advance();
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);
63 tester.advance();
64 check_equals(root->get_current_frame(), 2);
66 tester.advance();
67 tester.advance();
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);
75 tester.advance();
76 check_equals(root->get_current_frame(), 4);
78 tester.advance();
79 tester.advance();
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);
87 tester.advance();
88 check_equals(root->get_current_frame(), 6);
90 tester.advance();
91 check_equals(root->get_current_frame(), 7);
93 tester.advance();
94 tester.advance();
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);
105 tester.advance();
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);
116 tester.advance();
117 check_equals(root->get_current_frame(), 10);
119 tester.advance();
120 tester.advance();
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);
131 tester.advance();
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);
141 tester.advance();
142 tester.advance();
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);
150 tester.advance();
151 tester.advance();
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++)
164 tester.advance();
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);
175 tester.advance();
176 tester.advance();
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);
183 tester.advance();
185 // Select the text field
186 tester.movePointerTo(310, 25);
187 tester.click();
189 // Enter 'i'
190 tester.pressKey(key::i);
191 tester.advance();
193 // reached frame23, test finished
194 check_equals(root->get_current_frame(), 23);
195 return 0;