2 * Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #define INPUT_FILENAME "DragDropTest.swf"
23 #include "MovieTester.h"
24 #include "MovieClip.h"
25 #include "DisplayObject.h"
26 #include "DisplayList.h"
30 #include "string_table.h"
36 #include "GnashSystemIOHeaders.h"
39 using namespace gnash
;
40 using namespace gnash::geometry
;
44 main(int /*argc*/, char** /*argv*/)
46 string filename
= string(TGTDIR
) + string("/") + string(INPUT_FILENAME
);
47 MovieTester
tester(filename
);
49 gnash::LogFile
& dbglogfile
= gnash::LogFile::getDefaultInstance();
50 dbglogfile
.setVerbosity(1);
52 MovieClip
* root
= tester
.getRootMovie();
55 // for variables lookup (consistency checking)
56 VM
& vm
= getVM(*getObject(root
));
58 rgba
white(255, 255, 255, 255); // background color
59 rgba
blue(0, 0, 255, 255); // blue circles fill color
60 rgba
green(0, 255, 0, 255); // green circles fill color
61 rgba
red(255, 0, 0, 255); // red circles fill color
63 point
out(350, 100); // out of any drawing
65 point
rc1(50, 50); // first red circle
66 point
gc1(100, 50); // first green circle
67 point
bc1(70, 100); // first blue circle
69 point
rc2(150, 50); // second red circle
70 point
gc2(200, 50); // second green circle
71 point
bc2(170, 100); // second blue circle
73 point
rc3(250, 50); // third red circle
74 point
gc3(300, 50); // third green circle
75 point
bc3(270, 100); // third blue circle
77 check_equals(root
->get_frame_count(), 2);
78 check_equals(root
->get_current_frame(), 0);
80 // first frame is just Dejagnu clip...
83 check_equals(root
->get_current_frame(), 1);
85 // Wait for _level50 and loadedTarget to be loaded...
86 unsigned long sleepTime
= 100000; // microseconds
87 unsigned int attempts
=10;
90 // loads should happen on next advance...
93 // if _root displaylist contains loadedTarget and loadedTarget
94 // contains target100, we've loaded it
95 const MovieClip
* loadedTarget
= 0;
96 //const DisplayObject* ch = tester.findDisplayItemByName(*root, "loadedTarget");
97 const DisplayObject
* ch
= tester
.findDisplayItemByDepth(*root
, 30);
98 if ( ch
) loadedTarget
= const_cast<DisplayObject
*>(ch
)->to_movie();
101 const DisplayObject
* target100
= tester
.findDisplayItemByName(*loadedTarget
, "target100");
102 if ( target100
) break;
103 else cerr
<< "target100 not yet found in loadedTarget" << endl
;
107 cerr
<< "loadedTarget not yet not found" << endl
;
112 check(!"loadTarget was never loaded");
113 cerr
<< "Root display list is: " << endl
;
114 std::cerr
<< root
->getDisplayList();
121 check_equals(root
->get_current_frame(), 1);
124 // 1. Click OUTSIDE of any drawing.
125 tester
.movePointerTo(out
.x
, out
.y
);
128 // 2. Click on the FIRST RED circle.
129 tester
.movePointerTo(rc1
.x
, rc1
.y
);
132 // 3. Click on the FIRST GREEN circle.
133 tester
.movePointerTo(gc1
.x
, gc1
.y
);
136 // 4. Click on the FIRST BLUE circle.
137 tester
.movePointerTo(bc1
.x
, bc1
.y
);
140 // 5. Click on the SECOND RED circle.
141 tester
.movePointerTo(rc2
.x
, rc2
.y
);
144 // 6. Click on the SECOND GREEN circle.
145 tester
.movePointerTo(gc2
.x
, gc2
.y
);
148 // 7. Click on the SECOND BLUE circle.
149 tester
.movePointerTo(bc2
.x
, bc2
.y
);
152 // 8. Click on the THIRD RED circle.
153 tester
.movePointerTo(rc3
.x
, rc3
.y
);
156 // 9. Click on the THIRD GREEN circle.
157 tester
.movePointerTo(gc3
.x
, gc3
.y
);
160 // 10. Click on the THIRD BLUE circle.
161 tester
.movePointerTo(bc3
.x
, bc3
.y
);
164 // 11. Click ANYWHERE OUT of the THIRD BLUE circle (on another circle makes a better test)
165 tester
.movePointerTo(rc1
.x
, rc1
.y
);
168 // Consistency check !!
170 // It's an swf6, so lowercase 'ENDOFTEST'
171 bool endOfTestFound
= getObject(root
)->get_member(getURI(vm
, "endoftest"), &eot
);
172 check(endOfTestFound
);
173 if ( endOfTestFound
)
176 check_equals(eot
.to_bool(8), true);
180 cerr
<< "Didn't find ENDOFTEST... dumping all members" << endl
;
181 // root->dump_members();