Sometimes SWTBotTable.select sends event.item=Null in SelectionEvent [message #1749167] |
Fri, 02 December 2016 09:59  |
Eclipse User |
|
|
|
If we do SWTBotTable.select(int) as the first operation on the table, it gives event.item as Null in the selectionEvent caused due to unselect().
Here is the flow-
table.select(int) calls unselect() which then calls selectionEvent().
Here lastSelectionItem is yet uninitialized, so event.item is set to null. notifySelect() then sends item=null to notify Selection event.
Suppose if the application implements widgetSelected(SelectionEvent e), then it gets event.item=null.
Later in the SWTBotTable.select, selection happens.
How about checking null condition at SWTBotTable's line 333 ?
if(lastSelectionItem != null)
unselect();
This way, unnecessary events will not get triggered and also the application will not get null item in selectionEvent.
|
|
|
Re: Sometimes SWTBotTable.select sends event.item=Null in SelectionEvent [message #1749340 is a reply to message #1749167] |
Mon, 05 December 2016 11:36   |
Eclipse User |
|
|
|
Hi Aparna,
Thanks for reporting this. It doesn't seem like SWTBot is behaving like a real SWT application.
What I see testing with real user actions is that there shouldn't be any SelectionEvent at all sent to the previously selected item when you select a new one.
The only time that a SelectionEvent is sent to an unselected event is when you specifically unselect it (e.g. Ctrl+click or Ctrl+space) and this is only possible if the table has SWT.MULTI style, you can't unselect when the table is SWT.SINGLE.
Also the unselect() method unselects all, presumably if it is a SWT.MULTI table with many selected items, you would have to either unselect each item one by one, or select one item and then unselect it. The method now unselects all items then sends only one selection event. The method also doesn't check that it's a SWT.MULTI table.
SWTBotTree also has the same issues, even more, it doesn't set the event.item at all on selection.
So there's a few bugs here, would like to open a bug report?
Thanks,
Patrick
|
|
|
|
Powered by
FUDForum. Page generated in 0.04159 seconds