Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 546333 - [Win32] test_disposeItemNotTriggerSelection JUnit test failing.
Summary: [Win32] test_disposeItemNotTriggerSelection JUnit test failing.
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.12   Edit
Hardware: PC Windows All
: P3 normal (vote)
Target Milestone: 4.14 M1   Edit
Assignee: Conrad Groth CLA
QA Contact: Alexandr Miloslavskiy CLA
URL:
Whiteboard:
Keywords:
Depends on: 489751
Blocks:
  Show dependency tree
 
Reported: 2019-04-11 08:16 EDT by Niraj Modi CLA
Modified: 2019-09-16 05:19 EDT (History)
6 users (show)

See Also:


Attachments
test snippet (2.50 KB, text/x-java)
2019-04-11 10:18 EDT, Xi Yan CLA
no flags Details
Native snippet demonstrating bug (9.12 KB, text/plain)
2019-09-04 10:27 EDT, Alexandr Miloslavskiy CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Niraj Modi CLA 2019-04-11 08:16:24 EDT
Problem originally reported on https://bugs.eclipse.org/bugs/show_bug.cgi?id=489751#c12


With fix for bug 489751 which introduced "test_disposeItemNotTriggerSelection" JUnit which is failing since then on Windows.

This bug is to address this failing JUnit on Windows.
Comment 1 Niraj Modi CLA 2019-04-11 08:21:55 EDT
Hi Xi,
Followup of https://bugs.eclipse.org/bugs/show_bug.cgi?id=489751#c14

> Hi, I don't have a Windows machine to test on, the test checks for whether
> disposing the tree item will trigger a SWT.Selection event.
Can you please share a test snippet for this scenario, I can try it out and let you know ?
Comment 2 Xi Yan CLA 2019-04-11 10:18:25 EDT
Created attachment 278237 [details]
test snippet
Comment 3 Xi Yan CLA 2019-04-11 10:19:40 EDT
(In reply to Niraj Modi from comment #1)
> Can you please share a test snippet for this scenario, I can try it out and
> let you know ?

Hi Niraj, I've attached the test snippet. When a TreeItem is disposed, there should not be any "Selection Event" printed to console.
Comment 4 Niraj Modi CLA 2019-04-15 02:18:15 EDT
(In reply to Xi Yan from comment #3)
> (In reply to Niraj Modi from comment #1)
> > Can you please share a test snippet for this scenario, I can try it out and
> > let you know ?
> 
> Hi Niraj, I've attached the test snippet. When a TreeItem is disposed, there
> should not be any "Selection Event" printed to console.

Tried attachment 278237 [details], currently I notice "Selection Event" getting printed on console as tested on Win7/Win10.
Comment 5 Niraj Modi CLA 2019-04-22 06:56:41 EDT
Hi Xi,
Do you see any possible reason for this behavior as seen on Windows comment 4 ?
Comment 6 Andrey Loskutov CLA 2019-05-13 08:02:53 EDT
@Xi, Niraj: if we don't have a better solution, can we please disable this test on Windows? 

We can't add new tests that immediately start to fail without fixing them, we will end up with the build full of failures (as of today on 4.12 master).
Comment 7 Eclipse Genie CLA 2019-05-20 03:27:22 EDT
New Gerrit change created: https://git.eclipse.org/r/142414
Comment 9 Niraj Modi CLA 2019-05-20 03:46:28 EDT
(In reply to Eclipse Genie from comment #8)
> Gerrit change https://git.eclipse.org/r/142414 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=b006d0866f3706628c216cf9cbbb9f4f10b3ab8f

With above patch, I have disabled the failing JUnit test on Windows.
Comment 10 Andrey Loskutov CLA 2019-05-20 10:09:05 EDT
(In reply to Niraj Modi from comment #9)
> (In reply to Eclipse Genie from comment #8)
> > Gerrit change https://git.eclipse.org/r/142414 was merged to [master].
> > Commit:
> > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> > ?id=b006d0866f3706628c216cf9cbbb9f4f10b3ab8f
> 
> With above patch, I have disabled the failing JUnit test on Windows.

Thanks.

Xi, would you look at this on 4.13 please (to enable the test)?
Comment 11 Eric Williams CLA 2019-08-16 12:46:58 EDT
Moving to 4.14 as I didn't get a chance to look at this.
Comment 12 Eclipse Genie CLA 2019-09-03 14:29:25 EDT
New Gerrit change created: https://git.eclipse.org/r/148837
Comment 13 Niraj Modi CLA 2019-09-04 05:55:15 EDT
(In reply to Eclipse Genie from comment #12)
> New Gerrit change created: https://git.eclipse.org/r/148837

Thanks Conrad for the patch, targeting for 4.14 M1.
Comment 14 Alexandr Miloslavskiy CLA 2019-09-04 10:25:47 EDT
I've studied this as bit deeper and here are my findings:
1) On Windows, Tree has a "caret" item, which can be set/retrieved via TVGN_CARET.
2) TVGN_CARET item can be thought of as keyboard navigation position.
3) TVGN_CARET item can be selected or not selected.
4) There seems to be no API to move TVGN_CARET without also selecting an item.
5) When TVGN_CARET item is deleted, windows sets selection to another item.
6) SWT unselects item using TVM_SETITEM, but that doesn't move TVGN_CARET, leading to the bug.

So it seems that indeed the simplest solution is to prevent item selection done by Windows.
Comment 15 Alexandr Miloslavskiy CLA 2019-09-04 10:27:47 EDT
Created attachment 279773 [details]
Native snippet demonstrating bug
Comment 17 Niraj Modi CLA 2019-09-16 05:19:17 EDT
(In reply to Eclipse Genie from comment #16)
> Gerrit change https://git.eclipse.org/r/148837 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=04de8d58a6bc8a5af52d39d0764972f496d10db0

Thanks Conrad for the patch and Alexandr for the review, resolving now.