2 * Copyright (C) 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 "DragDropTest.swf"
24 #include "MovieTester.h"
25 #include "MovieClip.h"
26 #include "DisplayObject.h"
27 #include "DisplayList.h"
31 #include "string_table.h"
37 #include "GnashSystemIOHeaders.h"
40 using namespace gnash
;
41 using namespace gnash::geometry
;
46 trymain(int /*argc*/, char** /*argv*/)
48 string filename
= string(TGTDIR
) + string("/") + string(INPUT_FILENAME
);
49 MovieTester
tester(filename
);
51 gnash::LogFile
& dbglogfile
= gnash::LogFile::getDefaultInstance();
52 dbglogfile
.setVerbosity(1);
54 MovieClip
* root
= tester
.getRootMovie();
57 // for variables lookup (consistency checking)
58 VM
& vm
= getVM(*getObject(root
));
60 rgba
white(255, 255, 255, 255); // background color
61 rgba
blue(0, 0, 255, 255); // blue circles fill color
62 rgba
green(0, 255, 0, 255); // green circles fill color
63 rgba
red(255, 0, 0, 255); // red circles fill color
65 point
out(350, 100); // out of any drawing
67 point
rc1(50, 50); // first red circle
68 point
gc1(100, 50); // first green circle
69 point
bc1(70, 100); // first blue circle
71 point
rc2(150, 50); // second red circle
72 point
gc2(200, 50); // second green circle
73 point
bc2(170, 100); // second blue circle
75 point
rc3(250, 50); // third red circle
76 point
gc3(300, 50); // third green circle
77 point
bc3(270, 100); // third blue circle
79 check_equals(root
->get_frame_count(), 2);
80 check_equals(root
->get_current_frame(), 0);
82 // first frame is just Dejagnu clip...
85 check_equals(root
->get_current_frame(), 1);
87 // Wait for _level50 and loadedTarget to be loaded...
88 unsigned long sleepTime
= 100000; // microseconds
89 unsigned int attempts
=10;
92 // loads should happen on next advance...
95 // if _root displaylist contains loadedTarget and loadedTarget
96 // contains target100, we've loaded it
97 const MovieClip
* loadedTarget
= 0;
98 //const DisplayObject* ch = tester.findDisplayItemByName(*root, "loadedTarget");
99 const DisplayObject
* ch
= tester
.findDisplayItemByDepth(*root
, 30);
100 if ( ch
) loadedTarget
= const_cast<DisplayObject
*>(ch
)->to_movie();
103 const DisplayObject
* target100
= tester
.findDisplayItemByName(*loadedTarget
, "target100");
104 if ( target100
) break;
105 else cerr
<< "target100 not yet found in loadedTarget" << endl
;
109 cerr
<< "loadedTarget not yet not found" << endl
;
114 check(!"loadTarget was never loaded");
115 cerr
<< "Root display list is: " << endl
;
116 std::cerr
<< root
->getDisplayList();
123 check_equals(root
->get_current_frame(), 1);
126 // 1. Click OUTSIDE of any drawing.
127 tester
.movePointerTo(out
.x
, out
.y
);
130 // 2. Click on the FIRST RED circle.
131 tester
.movePointerTo(rc1
.x
, rc1
.y
);
134 // 3. Click on the FIRST GREEN circle.
135 tester
.movePointerTo(gc1
.x
, gc1
.y
);
138 // 4. Click on the FIRST BLUE circle.
139 tester
.movePointerTo(bc1
.x
, bc1
.y
);
142 // 5. Click on the SECOND RED circle.
143 tester
.movePointerTo(rc2
.x
, rc2
.y
);
146 // 6. Click on the SECOND GREEN circle.
147 tester
.movePointerTo(gc2
.x
, gc2
.y
);
150 // 7. Click on the SECOND BLUE circle.
151 tester
.movePointerTo(bc2
.x
, bc2
.y
);
154 // 8. Click on the THIRD RED circle.
155 tester
.movePointerTo(rc3
.x
, rc3
.y
);
158 // 9. Click on the THIRD GREEN circle.
159 tester
.movePointerTo(gc3
.x
, gc3
.y
);
162 // 10. Click on the THIRD BLUE circle.
163 tester
.movePointerTo(bc3
.x
, bc3
.y
);
166 // 11. Click on the SECOND GREEN circle.
167 // (Checks that the textfield has moved)
168 tester
.movePointerTo(gc2
.x
, gc2
.y
);
170 // Make sure the position is updated!
175 // 12. Click ANYWHERE OUT of the THIRD BLUE circle (on another circle makes a better test)
176 tester
.movePointerTo(rc1
.x
, rc1
.y
);
179 // Consistency check !!
181 // It's an swf6, so lowercase 'ENDOFTEST'
182 bool endOfTestFound
= getObject(root
)->get_member(getURI(vm
, "endoftest"), &eot
);
183 check(endOfTestFound
);
184 if ( endOfTestFound
)
187 check_equals(eot
.to_bool(8), true);
191 cerr
<< "Didn't find ENDOFTEST... dumping all members" << endl
;
192 // root->dump_members();