MovieClip* getCoverArt() { DisplayObject* coverartch = const_cast<DisplayObject*>(tester->findDisplayItemByName(*root, "coverart")); MovieClip* coverart = coverartch->to_movie(); //log_debug("Coverart is %p, displaylist is:", coverart); //coverart->getDisplayList().dump(); return coverart; }
int main(int /*argc*/, char** /*argv*/) { gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance(); dbglogfile.setVerbosity(1); string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME); tester.reset(new MovieTester(filename)); URL baseURL(filename); URL mediaURL(MEDIADIR"/"); URL lynchURL("lynch.swf", mediaURL); URL greenURL("green.jpg", mediaURL); URL offspringURL("offspring.swf", mediaURL); std::string url; gnash::RcInitFile& rc = gnash::RcInitFile::getDefaultInstance(); rc.addLocalSandboxPath(MEDIADIR); root = tester->getRootMovie(); assert(root); check_equals(root->get_frame_count(), 2); check_equals(root->get_current_frame(), 0); tester->advance(); check_equals(root->get_current_frame(), 1); // Verify that 'coverart' exists and is empty DisplayObject* coverartch = const_cast<DisplayObject*>(tester->findDisplayItemByName(*root, "coverart")); MovieClip* coverart = coverartch->to_movie(); check(coverart); url = coverart->get_root()->url(); check_equals(coverart->get_root()->url(), baseURL.str()); // Check scribbling on the empty canvas checkScribbling(); // Click on the first (lynch) tester->movePointerTo(80, 80); check(tester->isMouseOverMouseEntity()); tester->pressMouseButton(); // Wait for the movie to load // TODO: drop this test and use a self-containment instead do { usleep(500); // give it some time... tester->advance(); // loads (should) happen on next advance coverartch = const_cast<DisplayObject*>(tester->findDisplayItemByName(*root, "coverart")); } while (coverartch->to_movie() == coverart); coverart = coverartch->to_movie(); check_equals(coverart->get_root()->url(), lynchURL.str()); tester->depressMouseButton(); // Check scribbling on the lynch checkScribbling(); // Run 'coverart' tests.. tester->movePointerTo(640,180); tester->click(); tester->advance(); // Click on the second (green) tester->movePointerTo(280, 80); check(tester->isMouseOverMouseEntity()); tester->click(); // Wait for the movie to load // TODO: drop this test and use a self-containment instead do { usleep(500); // give it some time... tester->advance(); // loads (should) happen on next advance coverartch = const_cast<DisplayObject*>(tester->findDisplayItemByName(*root, "coverart")); } while (coverartch->to_movie() == coverart); coverart = coverartch->to_movie(); check_equals(coverart->get_root()->url(), greenURL.str()); // TODO: find a way to test if the jpeg is really displayed // (like turn it into a mouse-event-handling char and use isMouseOverActiveEntity ?) // Check scribbling on the jpeg checkScribbling(); // Run 'coverart' tests.. tester->movePointerTo(640,180); tester->click(); tester->advance(); // Click on the third (offspring) tester->movePointerTo(480, 80); check(tester->isMouseOverMouseEntity()); tester->click(); // Wait for the movie to load // TODO: drop this test and use a self-containment instead do { usleep(500); // give it some time... tester->advance(); // loads (should) happen on next advance coverartch = const_cast<DisplayObject*>(tester->findDisplayItemByName(*root, "coverart")); } while (coverartch->to_movie() == coverart); coverart = coverartch->to_movie(); check_equals(coverart->get_root()->url(), offspringURL.str()); // Check scribbling on the offspring checkScribbling(); // Run 'coverart' tests.. tester->movePointerTo(640,180); tester->click(); tester->advance(); // Get summary ... tester->pressKey(key::SHIFT); tester->click(); tester->advance(); tester->releaseKey(key::SHIFT); // Consistency checking VM& vm = getVM(*getObject(root)); as_value eot; // It's an swf6, so lowercase 'END_OF_TEST' bool endOfTestFound = getObject(root)->get_member(getURI(vm, "end_of_test"), &eot); check(endOfTestFound); if ( endOfTestFound ) { check_equals(eot.to_bool(8), true); } }