harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexei Fedotov" <alexei.fedo...@gmail.com>
Subject Re: [harmony-demo-1] Reasons for java.awt.ComponentTest failure
Date Thu, 01 May 2008 00:14:31 GMT
Hello Tharindu,
This is a good question.

1.
Accessing a private hash map such as oldEventsMap could be only done
from the same class. There are no direct puts into this hash map, the
hash map is accessed via ComponentTest.putEvent() method.

2.
I can notice that package private putEvent() is called from package
private callback(). The latter one is called 12 times from different
test methods which receive an  event as a parameter.

3.
For example, consider

    class MyComponent extends Canvas {

        @Override
        public boolean gotFocus(Event evt, Object what) {
            synchronized(robot) {
                return callback(evt);
            }
        }
        [...]
    }

When a class MyComponent is drawn, and gets focus, AWT calls
getFocus() method, which calls callback(), which calls putEvent(),
which updates oldEventsMap. The hash map itself is then used in
waitForEvent() implementation used for scenario tests for AWT
components.

Please let me know if you have more questions!

Thanks!

On Wed, Apr 30, 2008 at 12:32 AM, Mackie Mathew <mccloud35@gmail.com> wrote:
> How do events get registered in the oldEventsMap in ComponentTest? I cannot
>  find put method being called when events occur? How do events get registered
>  when graphical events occur?
>
>
>
>  On Mon, Apr 28, 2008 at 11:32 PM, Sergey Salishev <
>  sergey.i.salishev@gmail.com> wrote:
>
>  > Hi,
>  >
>  > If you look into waitForEvent impl, you'll see it assigns event field. I
>  > agree it's not the best idea to relay on method's side effect. Some other
>  > tests use Event event = waitForEvent(... to do the same check and it
>  > looks clearer to me. But the test by itself seems valid.
>  >
>  > Thanks.
>  > Sergey.
>  >
>  > On Mon, Apr 28, 2008 at 3:22 PM, Mackie Mathew <mccloud35@gmail.com>
>  > wrote:
>  >
>  > > The testAction method that fails is due to:
>  > >
>  > > public final void testAction() {
>  > >       int eventId = Event.ACTION_EVENT;
>  > >        myTestComp = new MyButton();
>  > >        createFrameAndWait();
>  > >        robot.setAutoDelay(700);
>  > >        Point screenLoc = myTestComp.getLocationOnScreen();
>  > >        int centerX = myTestComp.getWidth() / 2;
>  > >        int centerY = myTestComp.getHeight() / 2;
>  > >        screenLoc.translate(centerX, centerY);
>  > >        final Point absPos = screenLoc;
>  > >
>  > >        waitForEvent(new Runnable() {
>  > >            public void run() {
>  > >                robot.mouseMove(absPos.x, absPos.y);
>  > >                robot.mousePress(InputEvent.BUTTON1_MASK |
>  > > InputEvent.BUTTON2_MASK);
>  > >                robot.mouseRelease(InputEvent.BUTTON1_MASK |
>  > > InputEvent.BUTTON2_MASK);
>  > >            }
>  > >        }, eventId, waitTime);
>  > >    *    assertNotNull(event);*
>  > >        Event actionEvt = new Event(myTestComp, eventId,
>  > >                ((Button) myTestComp).getLabel());
>  > >        actionEvt.modifiers = Event.ALT_MASK;
>  > >        checkOldEvent(actionEvt);
>  > >    }
>  > >
>  > >
>  > > The private variable event is declared to null at setUp() and it is not
>  > > changed and checked for not being null. I do not understand the logic
>  > > behind
>  > > this. Shouldn't the test obviously fail as event is not assigned a not
>  > > null
>  > > value.
>  > >
>  > > --
>  > > Regards,
>  > >
>  > > Tharindu
>  > >
>  >
>
>
>
>  --
>  Regards,
>
>  Tharindu
>



-- 
With best regards,
Alexei

Mime
View raw message