Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 316879

Summary: SWTBotTableItem does not dispatch events correctly for click
Product: [Technology] SWTBot Reporter: Tim Moore <tmm-bugs.eclipse>
Component: SWTBotAssignee: Project Inbox <swtbot-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: dsb-eclipsebugs
Version: 2.0.0-dev   
Target Milestone: 2.0.0   
Hardware: All   
OS: All   
Whiteboard:

Description Tim Moore CLA 2010-06-15 06:37:21 EDT
Build Identifier: M20100211-1343

We've been affected by at least two issues in the click event dispatching, which currently does:

notifyTable(SWT.MouseEnter);
notifyTable(SWT.MouseMove);
notifyTable(SWT.Activate);
notifyTable(SWT.FocusIn);
notifyTable(SWT.MouseDown, createMouseEvent(x, y, 1, SWT.BUTTON1, 1));
notifyTable(SWT.MouseUp);
notifyTable(SWT.Selection, createEvent());
notifyTable(SWT.MouseHover);
notifyTable(SWT.MouseMove);
notifyTable(SWT.MouseExit);
notifyTable(SWT.Deactivate);
notifyTable(SWT.FocusOut);

The first issue is that Selection normally occurs immediately after MouseDown, i.e. before MouseUp.
The second issue is that the MouseUp event (at least) should be a proper mouse event with coordinates, button pressed, etc - in the same way as MouseDown.

We believe this is more correct - fixing our specific issue:

notifyTable(SWT.MouseEnter);
notifyTable(SWT.MouseMove);
notifyTable(SWT.Activate);
notifyTable(SWT.FocusIn);
notifyTable(SWT.MouseDown, createMouseEvent(x, y, 1, SWT.BUTTON1, 1));
notifyTable(SWT.Selection, createEvent());
notifyTable(SWT.MouseUp, createMouseEvent(x, y, 1, SWT.BUTTON1, 1));
notifyTable(SWT.MouseHover);
notifyTable(SWT.MouseMove);
notifyTable(SWT.MouseExit);
notifyTable(SWT.Deactivate);
notifyTable(SWT.FocusOut);

As far as we know, other events might require a proper mouse event? - but our code doesn't rely on these at the moment.

Reproducible: Always
Comment 1 Ketan Padegaonkar CLA 2010-09-07 13:20:45 EDT
Applied this change. The mouse up event should definitely be providing the mouse event, especially given that SWTBot knows the co-ordinates and provides it to the mouse up event.

The existing tests pass; I believe this should not break any existing fuctionality.
Comment 2 Tim Moore CLA 2011-02-10 09:53:39 EST
Same problem in clickXY for SWTBotTreeItem :)
Comment 3 Ketan Padegaonkar CLA 2011-02-18 23:40:57 EST
Tim,

Which particular method in TreeItem do you refer to ? I'd fixed a lot of these issues a while ago as part of bug 333611. See https://github.com/ketan/SWTBot/commit/1357babfcc2 for the changeset.

The current master(https://github.com/ketan/SWTBot/blame/master/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItem.java) has the correct implementation of clickXY as far as I understand, am I missing something obvious ?
Comment 4 Tim Moore CLA 2011-02-23 05:44:18 EST
Ah, sorry Ketan, that looks good - hadn't seen the other bug. I checked the code from the latest release when I reopened, but I guess that the changes from git hadn't been built into a release at that time.