gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash/testsuite/misc-ming.all RollOverOutTest-R...


From: Zou Lunkai
Subject: [Gnash-commit] gnash/testsuite/misc-ming.all RollOverOutTest-R...
Date: Tue, 06 May 2008 05:32:18 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Zou Lunkai <zoulunkai>  08/05/06 05:32:18

Modified files:
        testsuite/misc-ming.all: RollOverOutTest-Runner.cpp 
                                 RollOverOutTest.c 

Log message:
        add tests for hitTest().

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/RollOverOutTest-Runner.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/RollOverOutTest.c?cvsroot=gnash&r1=1.4&r2=1.5

Patches:
Index: RollOverOutTest-Runner.cpp
===================================================================
RCS file: 
/sources/gnash/gnash/testsuite/misc-ming.all/RollOverOutTest-Runner.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- RollOverOutTest-Runner.cpp  21 Jan 2008 23:26:51 -0000      1.11
+++ RollOverOutTest-Runner.cpp  6 May 2008 05:32:18 -0000       1.12
@@ -45,24 +45,19 @@
        sprite_instance* root = tester.getRootMovie();
        assert(root);
 
-       check_equals(root->get_frame_count(), 3);
+       check_equals(root->get_frame_count(), 4);
        check_equals(root->get_play_state(), sprite_instance::PLAY);
        check_equals(root->get_current_frame(), 0);
 
+       tester.advance();  // advance to the second frame.
+
        const character* mc1 = tester.findDisplayItemByName(*root, "square1");
        check(mc1);
        const character* mc2 = tester.findDisplayItemByName(*root, "square2");
        check(mc2);
-       check_equals(mc1->get_visible(), false);
-       check_equals(mc2->get_visible(), false);
-
-       tester.advance();
 
        check_equals(mc1->get_visible(), true);
        check_equals(mc2->get_visible(), false);
-
-       //check_equals(mc1->get_height(), 40*20);
-       //check_equals(mc1->get_width(), 40*20);
        check_equals(root->get_play_state(), sprite_instance::STOP);
        check_equals(root->get_current_frame(), 1);
 
@@ -71,11 +66,9 @@
        check_equals(root->get_current_frame(), 1);
        tester.advance();
        check_equals(root->get_current_frame(), 1);
-       tester.advance();
-       check_equals(root->get_current_frame(), 1);
 
        // roll over the middle of the square, this should trigger
-       // the addition of a goto_frame(2) action, which is executed
+       // the addition of a goto_frame(3) action, which is executed
        // at advance() time.
        tester.movePointerTo(60, 60);
        tester.advance();
@@ -94,5 +87,17 @@
        tester.advance();
        check_equals(root->get_current_frame(), 2);
 
+       // pointer out of the square.
+       tester.movePointerTo(300, 60);
+       //tester.advance();  // mouse event handler should drive the movie
+       check_equals(root->get_current_frame(), 1);
+       
+       // pointer back to the square again.
+       tester.movePointerTo(60, 60);
+       tester.click();
+       //tester.advance(); // mouse event handler should drive the movie
+       check_equals(root->get_current_frame(), 3);
 }
 
+
+

Index: RollOverOutTest.c
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/RollOverOutTest.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- RollOverOutTest.c   1 Jul 2007 10:54:47 -0000       1.4
+++ RollOverOutTest.c   6 May 2008 05:32:18 -0000       1.5
@@ -1,6 +1,6 @@
 /***********************************************************************
  *
- *   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ *   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,19 +19,17 @@
  *
  ***********************************************************************
  *
- * Test case for mouse events.
- *
- * In a movie of 120x120 pixels, it places a movieclip containing a squared
- * shape in the middle of the stage.
- *
  * The movie has 3 frames.
+ * Test1: mouse events.  Test2: hitTest.
  *
  *     - frame1: initialization
- *     - frame2: the square is red
- *     - frame3: the square is green
+ *  - frame2: place a red and a green square, red square is set to invisible.
+ *  - frame3: red square is set to visible, green square is set to invisible.
+ *  - frame4: remove the red and green squares, place 4 black squares.
  *
  * In frame2, rollOver event moves the playhead to frame3.
  * In frame3, rollOut  event moves the playhead to frame2.
+ * In frame3, press    event moves the playhead to frame4.
  *
  ***********************************************************************/
 
@@ -47,9 +45,7 @@
 SWFFont font;
 
 void add_event(SWFMovie mo, const char* name, const char* event, const char* 
action);
-void add_code(SWFMovie mo, const char* code);
 void add_text_field(SWFMovie mo, const char* name, int depth);
-void set_text(SWFMovie mo, const char* text);
 SWFDisplayItem add_square(SWFMovie mo, byte r, byte g, byte b, int depth);
 
 void
@@ -68,16 +64,6 @@
        SWFMovie_add(mo, (SWFBlock)ac);
 }
 
-void
-add_code(SWFMovie mo, const char* code)
-{
-       SWFAction ac;
-
-       ac = compileSWFActionCode(code);
-
-       SWFMovie_add(mo, (SWFBlock)ac);
-}
-
 SWFDisplayItem add_square(SWFMovie mo, byte r, byte g, byte b, int depth)
 {
        SWFDisplayItem it;
@@ -105,26 +91,17 @@
        SWFTextField_setVariableName(tf, name);
 
        it = SWFMovie_add(mo, (SWFBlock)tf);
-       SWFDisplayItem_scale(it, 0.3, 0.3);
        SWFDisplayItem_moveTo(it, 0, 10);
-       SWFTextField_setBounds(tf, 120*(1/0.3), 10*(1/0.3));
+    SWFTextField_setBounds(tf, 600, 20);
        SWFDisplayItem_setDepth(it, depth);
 }
 
-void
-set_text(SWFMovie mo, const char* text)
-{
-       char buf[1024];
-       sprintf(buf, "_root.msg=\"%s\";", text);
-       add_code(mo, buf);
-}
-
 int
 main(int argc, char **argv)
 {
        SWFMovie mo;
-       SWFDisplayItem it;
-       const char *srcdir=".";
+    SWFDisplayItem it1, it2, it3;
+    SWFMovieClip dejagnuclip;
        char fdbfont[256];
 
        /*********************************************
@@ -132,6 +109,14 @@
         * Initialization
         *
         *********************************************/
+    const char *srcdir=".";
+    if ( argc>1 ) 
+        srcdir=argv[1];
+    else
+    {
+       fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
+       return 1;
+    }
 
        puts("Setting things up");
 
@@ -140,14 +125,10 @@
        Ming_setScale(20.0); 
  
        mo = newSWFMovie();
-       SWFMovie_setDimension(mo, 120, 120);
+    SWFMovie_setDimension(mo, 800, 600);
 
-       if ( argc>1 ) srcdir=argv[1];
-       else
-       {
-               fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
-               return 1;
-       }
+    dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 
0, 800, 600);
+    SWFMovie_add(mo, (SWFBlock)dejagnuclip);
 
        sprintf(fdbfont, "%s/Bitstream Vera Sans.fdb", srcdir);
        FILE *font_file = fopen(fdbfont, "r");
@@ -156,10 +137,10 @@
                perror(fdbfont);
                exit(1);
        }
-       /*SWFBrowserFont bfont = newSWFBrowserFont("_sans");*/
        font = loadSWFFontFromFile(font_file);
+    add_text_field(mo, "_root.msg", 100);
 
-       add_text_field(mo, "_root.msg", 1);
+    SWFMovie_nextFrame(mo); // frame1
 
        /*****************************************************
         *
@@ -167,66 +148,113 @@
         *
         *****************************************************/
 
-       it = add_square(mo, 255, 0, 0, 2);
-       SWFDisplayItem_moveTo(it, 40, 40);
-       SWFDisplayItem_setName(it, "square1");
-
-       it = add_square(mo, 0, 255, 0, 3);
-       SWFDisplayItem_moveTo(it, 40, 40);
-       SWFDisplayItem_setName(it, "square2");
-
-       add_code(mo, "square1._visible = false; square2._visible=false;");
-
-       SWFMovie_nextFrame(mo); /* showFrame */
-
+    it1 = add_square(mo, 255, 0, 0, 3);
+    SWFDisplayItem_moveTo(it1, 40, 40);
+    SWFDisplayItem_setName(it1, "square1");
+
+    it2 = add_square(mo, 0, 255, 0, 4);
+    SWFDisplayItem_moveTo(it2, 40, 40);
+    SWFDisplayItem_setName(it2, "square2");
 
        /*****************************************************
         *
-        * Frame 1: display a red square.
-        *          onRollOver: goto frame2
+     * Frame 2: display a red square.
+     *          onRollOver: goto frame3
         *
         *****************************************************/
 
-       set_text(mo, "Frame1: move the mouse on the square");
-       add_code(mo, "square1._visible = true; square2._visible=false;");
+    add_actions(mo, "_root.msg = 'Frame2: move the mouse on the square'; ");
+    add_actions(mo, "square1._visible = true; square2._visible=false;");
 
-       add_event(mo, "square1", "RollOver", "gotoAndPlay(2)");
-       //add_event(mo, "square", "RollOver", "");
-       //add_event(mo, "square", "RollOut", "");
-       //add_event(mo, "square", "MouseDown", "");
-       //add_event(mo, "square", "MouseUp", "");
+    add_event(mo, "square1", "RollOver", "gotoAndPlay(3)");
 
-       add_code(mo, "stop();");
-       SWFMovie_nextFrame(mo); /* showFrame */
+    add_actions(mo, "stop();");
+    SWFMovie_nextFrame(mo); // frame2
 
        /*****************************************************
         *
-        * Frame 2: display a green square.
-        *          onRollOut: goto frame1
+     * Frame 3: display a green square.
+     *          onRollOut: goto frame2
         *
         *****************************************************/
 
-       set_text(mo, "Frame2: move the mouse off the square");
-       add_code(mo, "square2._visible = true; square1._visible=false;");
-
-       //add_event(mo, "square", "RollOver", "gotoAndPlay(2)");
-       //add_event(mo, "square", "RollOver", "");
-       add_event(mo, "square2", "RollOut", "gotoAndPlay(1)");
-       //add_event(mo, "square", "MouseDown", "");
-       //add_event(mo, "square", "MouseUp", "");
-
-       add_code(mo, "stop();");
-       SWFMovie_nextFrame(mo); /* showFrame */
-
-       /*****************************************************
-        *
-        * Save it...
-        *
-        *****************************************************/
+    add_actions(mo, 
+        " _root.msg = 'Frame3: move the mouse off the square"
+        " or press the square with the left button'; ");
+    add_actions(mo, "square2._visible = true; square1._visible=false;");
+
+    add_event(mo, "square2", "RollOut", "gotoAndPlay(2)");
+    add_event(mo, "square2", "Press", "gotoAndPlay(4)"  );
+
+    add_actions(mo, "stop();");
+    SWFMovie_nextFrame(mo); // frame3
+
+    //
+    //  Frame4: 
+    //  (0) remove the squares placed at frame1.
+    //  (1) place a visible black square. 
+    //  (2) place a invisible black square.
+    //  (3) place a static mask.
+    //  (4) place a dynamic mask.
+    //  
+    // Expected behaviour:
+    //  (1)hitTest works for both visible and invisible sprites.
+    //  (2)hitTest works for both static mask and maskee sprites.
+    //  (3)hitTest does not work for dynamic masks created by drawing API.
+    //
+    SWFDisplayItem_remove(it1);
+    SWFDisplayItem_remove(it2);
+    add_actions(mo, "_root.msg = 'Frame3: move the mouse on the squares'; ");
+    
+    it3 = add_square(mo, 0, 0, 0, 10);
+    SWFDisplayItem_moveTo(it3, 60, 100);
+    SWFDisplayItem_setName(it3, "visible_mc");
+    
+    it3 = add_square(mo, 0, 0, 0, 11);
+    SWFDisplayItem_moveTo(it3, 60, 150);
+    SWFDisplayItem_setName(it3, "invisible_mc");
+    add_actions(mo, "invisible_mc._visible = false; ");
+    
+    it3 = add_square(mo, 0, 0, 0, 12);
+    SWFDisplayItem_moveTo(it3, 60, 200);
+    SWFDisplayItem_setName(it3, "static_mask");
+    SWFDisplayItem_setMaskLevel(it3, 13);
+    
+    add_actions(mo, 
+        " _root.createEmptyMovieClip('dynamic_mask', 15); "
+        " _root.createEmptyMovieClip('maskee', 14); "
+        " with(maskee) {"
+        "   beginFill(0); "
+        "    moveTo( 60, 250); "
+        "    lineTo(100, 250); "
+        "    lineTo(100, 290); "
+        "    lineTo( 60, 290); "
+        "}"
+        " maskee.setMask(dynamic_mask); "
+        " with(dynamic_mask) { "
+        "    beginFill(0xff0000); "
+        "    moveTo( 60, 250); "
+        "    lineTo(100, 250); "
+        "    lineTo(100, 290); "
+        "    lineTo( 60, 290); "
+        "}"
+        "stop();");
+    // hitTest works for visible sprites.
+    check(mo, "visible_mc.hitTest(80, 120, true)");
+    // hitTest works for invisible sprites.
+    xcheck(mo, "invisible_mc.hitTest(80, 180, true)");
+    // hitTest works for static placed maskes.
+    check(mo, "static_mask.hitTest(80, 240, true)");
+    // hitTest does not work for dynamic masks created by drawing API.
+    check(mo, "! dynamic_mask.hitTest(80, 280, true)");
+    // hitTest works for maskee sprites.
+    check(mo, "maskee.hitTest(80, 280, true)");
+    SWFMovie_nextFrame(mo); // frame4
 
+    // save this file to a swf.
        puts("Saving " OUTPUT_FILENAME );
-
        SWFMovie_save(mo, OUTPUT_FILENAME);
 
        return 0;
 }
+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]