Bug 516674 - Regression in Oxygen of Control.forceFocus() on CentOS
Summary: Regression in Oxygen of Control.forceFocus() on CentOS
Status: CLOSED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.7   Edit
Hardware: PC CentOS
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Leo Ufimtsev CLA
QA Contact: Patrick Tasse CLA
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2017-05-15 13:36 EDT by Patrick Tasse CLA
Modified: 2018-04-13 16:35 EDT (History)
7 users (show)

See Also:


Attachments
Snippet (1.86 KB, text/plain)
2017-06-02 17:42 EDT, Patrick Tasse CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Tasse CLA 2017-05-15 13:36:13 EDT
This issue was found when attempting to run the SWTBot unit test suite on the Oxygen platform. The problem seems to happen only in CentOS, the OS that is currently used by the SWTBot HIPP.

The test does the following steps on a Text widget:

1. Give focus to the Text widget, with following code:

  control.getShell().forceActive();
  control.getShell().forceFocus();
  control.forceFocus();

2. Clear the text with setText("");

3. Type the following keys with the AWT Robot: "Type This 123"

4. Verify that getText() returns "Type This 123"

What is observed in Oxygen on CentOS is that when the AWT Robot types "Type", the key events are not sent by the OS to the Text widget, which should be the focus control.

When the SPACE key is pressed, the OS sends two events to the Text widget, leading to a focusLost followed by a focusGained. From that point on, every key pressed by the AWT Robot is correctly received by the text widget.

Here is some debugging logs showing the difference in behaviour between Neon (platform taken from http://download.eclipse.org/releases/neon) and Oxygen (platform taken from http://download.eclipse.org/releases/oxygen) targets

=== Oxygen platform (https://hudson.eclipse.org/swtbot/job/swtbot-gerrit/837/consoleFull) ===

09:35:58   *** text.getText()=[The quick brown fox jumps over the lazy dog.
09:35:58  One Two Three]
09:35:58   *** focusGained FocusEvent{Text {} time=417597666 data=null}
09:35:58  [org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest$1$2.focusGained(SWTBotTextTest.java:79), ..., org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:4094), org.eclipse.swt.widgets.Control.gtk_event_after(Control.java:3364), org.eclipse.swt.widgets.Text.gtk_event_after(Text.java:1685), org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1962), org.eclipse.swt.widgets.Control.windowProc(Control.java:6032), org.eclipse.swt.widgets.Text.windowProc(Text.java:2904), org.eclipse.swt.widgets.Display.windowProc(Display.java:5485), org.eclipse.swt.internal.gtk.OS._gtk_widget_grab_focus(Native Method), org.eclipse.swt.internal.gtk.OS.gtk_widget_grab_focus(OS.java:13873), org.eclipse.swt.widgets.Control.forceFocus(Control.java:2659), org.eclipse.swt.widgets.Control.forceFocus(Control.java:2652), org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot$10.run(AbstractSWTBot.java:721), ...]
09:35:58   *** SWT.Activate Event {type=26 Text {} time=417597666 data=null x=0 y=0 width=0 height=0 detail=0}
09:35:58   *** text.getText()=[]
09:35:58  15 May 2017 09:35:59.869 -                      test - DEBUG -                       Keyboard - (Keyboard.java:87) - Typing text 'Type This 123' with an interval of 50ms. between characters.
09:35:58   *** AWTKeyboardStrategy.pressKey(SHIFT+) calling robot.keyPress(16) focusControl=Text {}
09:35:58   *** AWTKeyboardStrategy.pressKey(T) calling robot.keyPress(84) focusControl=Text {}
09:35:58   *** AWTKeyboardStrategy.pressKey(Y) calling robot.keyPress(89) focusControl=Text {}
09:35:59   *** AWTKeyboardStrategy.pressKey(P) calling robot.keyPress(80) focusControl=Text {}
09:35:59   *** AWTKeyboardStrategy.pressKey(E) calling robot.keyPress(69) focusControl=Text {}
09:35:59   *** AWTKeyboardStrategy.pressKey(SPACE) calling robot.keyPress(32) focusControl=Text {}
09:35:59   *** focusLost FocusEvent{Text {} time=417598497 data=null}
09:35:59  [org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest$1$2.focusLost(SWTBotTextTest.java:83), ..., org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:4094), org.eclipse.swt.widgets.Control.gtk_event_after(Control.java:3364), org.eclipse.swt.widgets.Text.gtk_event_after(Text.java:1685), org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1962), org.eclipse.swt.widgets.Control.windowProc(Control.java:6032), org.eclipse.swt.widgets.Text.windowProc(Text.java:2904), org.eclipse.swt.widgets.Display.windowProc(Display.java:5485), org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method), org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:9209), org.eclipse.swt.widgets.Display.eventProc(Display.java:1250), org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method), org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2106), org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4078), ...]
09:35:59   *** focusGained FocusEvent{Text {} time=417598548 data=null}
09:35:59  [org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest$1$2.focusGained(SWTBotTextTest.java:79), ..., org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:4094), org.eclipse.swt.widgets.Control.gtk_event_after(Control.java:3364), org.eclipse.swt.widgets.Text.gtk_event_after(Text.java:1685), org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1962), org.eclipse.swt.widgets.Control.windowProc(Control.java:6032), org.eclipse.swt.widgets.Text.windowProc(Text.java:2904), org.eclipse.swt.widgets.Display.windowProc(Display.java:5485), org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method), org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:9209), org.eclipse.swt.widgets.Display.eventProc(Display.java:1250), org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method), org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2106), org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4078), ...]
09:35:59   *** AWTKeyboardStrategy.pressKey(SHIFT+) calling robot.keyPress(16) focusControl=Text {}
09:35:59   *** KeyDown KeyEvent{Text {} time=417598599 data=null character='\0'=0x0 keyCode=0x20000 keyLocation=0x4000 stateMask=0x0 doit=true}
09:35:59   *** AWTKeyboardStrategy.pressKey(T) calling robot.keyPress(84) focusControl=Text {}
09:35:59   *** KeyDown KeyEvent{Text {} time=417598600 data=null character='T'=0x54 keyCode=0x74 keyLocation=0x0 stateMask=0x20000 doit=true}
09:35:59   *** text.getText()=[T]
09:35:59   *** AWTKeyboardStrategy.pressKey(H) calling robot.keyPress(72) focusControl=Text {}
09:35:59   *** KeyDown KeyEvent{Text {} time=417598652 data=null character='h'=0x68 keyCode=0x68 keyLocation=0x0 stateMask=0x0 doit=true}
09:35:59   *** text.getText()=[Th]
09:35:59   *** AWTKeyboardStrategy.pressKey(I) calling robot.keyPress(73) focusControl=Text {}
09:35:59   *** KeyDown KeyEvent{Text {} time=417598703 data=null character='i'=0x69 keyCode=0x69 keyLocation=0x0 stateMask=0x0 doit=true}
09:35:59   *** text.getText()=[Thi]
09:35:59   *** AWTKeyboardStrategy.pressKey(S) calling robot.keyPress(83) focusControl=Text {}
09:35:59   *** KeyDown KeyEvent{Text {} time=417598754 data=null character='s'=0x73 keyCode=0x73 keyLocation=0x0 stateMask=0x0 doit=true}
09:35:59   *** text.getText()=[This]
09:35:59   *** AWTKeyboardStrategy.pressKey(SPACE) calling robot.keyPress(32) focusControl=Text {}
09:35:59   *** KeyDown KeyEvent{Text {} time=417598805 data=null character=' '=0x20 keyCode=0x20 keyLocation=0x0 stateMask=0x0 doit=true}
09:35:59   *** text.getText()=[This ]
09:35:59   *** AWTKeyboardStrategy.pressKey(1) calling robot.keyPress(49) focusControl=Text {}
09:35:59   *** KeyDown KeyEvent{Text {} time=417598856 data=null character='1'=0x31 keyCode=0x31 keyLocation=0x0 stateMask=0x0 doit=true}
09:35:59   *** text.getText()=[This 1]
09:35:59   *** AWTKeyboardStrategy.pressKey(2) calling robot.keyPress(50) focusControl=Text {}
09:35:59   *** KeyDown KeyEvent{Text {} time=417598907 data=null character='2'=0x32 keyCode=0x32 keyLocation=0x0 stateMask=0x0 doit=true}
09:35:59   *** text.getText()=[This 12]
09:35:59   *** AWTKeyboardStrategy.pressKey(3) calling robot.keyPress(51) focusControl=Text {}
09:35:59   *** KeyDown KeyEvent{Text {} time=417598958 data=null character='3'=0x33 keyCode=0x33 keyLocation=0x0 stateMask=0x0 doit=true}
09:35:59   *** text.getText()=[This 123]
09:36:06  Tests run: 5, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 9.321 sec <<< FAILURE! - in org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest
09:36:06  elapsed: 0.747 sec
09:36:06  typesText(org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest)  Time elapsed: 6.556 sec  <<< ERROR!
09:36:06  org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after: 5000 ms.: Expected "Type This 123" but was "This 123"

=== Neon platform (https://hudson.eclipse.org/swtbot/job/swtbot-gerrit/839/consoleFull) ===

10:26:46   *** text.getText()=[The quick brown fox jumps over the lazy dog.
10:26:46  One Two Three]
10:26:46   *** focusGained FocusEvent{Text {} time=420645510 data=null}
10:26:46  [org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest$1$2.focusGained(SWTBotTextTest.java:79), ..., org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:4069), org.eclipse.swt.widgets.Control.gtk_event_after(Control.java:3341), org.eclipse.swt.widgets.Text.gtk_event_after(Text.java:1677), org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1986), org.eclipse.swt.widgets.Control.windowProc(Control.java:5827), org.eclipse.swt.widgets.Text.windowProc(Text.java:2896), org.eclipse.swt.widgets.Display.windowProc(Display.java:5498), org.eclipse.swt.internal.gtk.OS._gtk_widget_grab_focus(Native Method), org.eclipse.swt.internal.gtk.OS.gtk_widget_grab_focus(OS.java:14639), org.eclipse.swt.widgets.Control.forceFocus(Control.java:2636), org.eclipse.swt.widgets.Control.forceFocus(Control.java:2629), org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot$10.run(AbstractSWTBot.java:721), ...]
10:26:46   *** SWT.Activate Event {type=26 Text {} time=420645510 data=null x=0 y=0 width=0 height=0 detail=0}
10:26:46   *** text.getText()=[]
10:26:46  15 May 2017 10:26:47.150 -                      test - DEBUG -                       Keyboard - (Keyboard.java:87) - Typing text 'Type This 123' with an interval of 50ms. between characters.
10:26:46   *** AWTKeyboardStrategy.pressKey(SHIFT+) calling robot.keyPress(16) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420645625 data=null character='\0'=0x0 keyCode=0x20000 keyLocation=0x4000 stateMask=0x0 doit=true}
10:26:46   *** AWTKeyboardStrategy.pressKey(T) calling robot.keyPress(84) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420645626 data=null character='T'=0x54 keyCode=0x74 keyLocation=0x0 stateMask=0x20000 doit=true}
10:26:46   *** text.getText()=[T]
10:26:46   *** AWTKeyboardStrategy.pressKey(Y) calling robot.keyPress(89) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420645678 data=null character='y'=0x79 keyCode=0x79 keyLocation=0x0 stateMask=0x0 doit=true}
10:26:46   *** text.getText()=[Ty]
10:26:46   *** AWTKeyboardStrategy.pressKey(P) calling robot.keyPress(80) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420645728 data=null character='p'=0x70 keyCode=0x70 keyLocation=0x0 stateMask=0x0 doit=true}
10:26:46   *** text.getText()=[Typ]
10:26:46   *** AWTKeyboardStrategy.pressKey(E) calling robot.keyPress(69) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420645779 data=null character='e'=0x65 keyCode=0x65 keyLocation=0x0 stateMask=0x0 doit=true}
10:26:46   *** text.getText()=[Type]
10:26:46   *** AWTKeyboardStrategy.pressKey(SPACE) calling robot.keyPress(32) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420645830 data=null character=' '=0x20 keyCode=0x20 keyLocation=0x0 stateMask=0x0 doit=true}
10:26:46   *** text.getText()=[Type ]
10:26:46   *** AWTKeyboardStrategy.pressKey(SHIFT+) calling robot.keyPress(16) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420645881 data=null character='\0'=0x0 keyCode=0x20000 keyLocation=0x4000 stateMask=0x0 doit=true}
10:26:46   *** AWTKeyboardStrategy.pressKey(T) calling robot.keyPress(84) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420645881 data=null character='T'=0x54 keyCode=0x74 keyLocation=0x0 stateMask=0x20000 doit=true}
10:26:46   *** KeyDown KeyEvent{Text {} time=420645881 data=null character='T'=0x54 keyCode=0x74 keyLocation=0x0 stateMask=0x20000 doit=true}
10:26:46   *** text.getText()=[Type T]
10:26:46   *** AWTKeyboardStrategy.pressKey(H) calling robot.keyPress(72) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420645932 data=null character='h'=0x68 keyCode=0x68 keyLocation=0x0 stateMask=0x0 doit=true}
10:26:46   *** text.getText()=[Type Th]
10:26:46   *** AWTKeyboardStrategy.pressKey(I) calling robot.keyPress(73) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420645983 data=null character='i'=0x69 keyCode=0x69 keyLocation=0x0 stateMask=0x0 doit=true}
10:26:46   *** text.getText()=[Type Thi]
10:26:46   *** AWTKeyboardStrategy.pressKey(S) calling robot.keyPress(83) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420646033 data=null character='s'=0x73 keyCode=0x73 keyLocation=0x0 stateMask=0x0 doit=true}
10:26:46   *** text.getText()=[Type This]
10:26:46   *** AWTKeyboardStrategy.pressKey(SPACE) calling robot.keyPress(32) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420646084 data=null character=' '=0x20 keyCode=0x20 keyLocation=0x0 stateMask=0x0 doit=true}
10:26:46   *** text.getText()=[Type This ]
10:26:46   *** AWTKeyboardStrategy.pressKey(1) calling robot.keyPress(49) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420646135 data=null character='1'=0x31 keyCode=0x31 keyLocation=0x0 stateMask=0x0 doit=true}
10:26:46   *** text.getText()=[Type This 1]
10:26:46   *** AWTKeyboardStrategy.pressKey(2) calling robot.keyPress(50) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420646185 data=null character='2'=0x32 keyCode=0x32 keyLocation=0x0 stateMask=0x0 doit=true}
10:26:46   *** text.getText()=[Type This 12]
10:26:46   *** AWTKeyboardStrategy.pressKey(3) calling robot.keyPress(51) focusControl=Text {}
10:26:46   *** KeyDown KeyEvent{Text {} time=420646236 data=null character='3'=0x33 keyCode=0x33 keyLocation=0x0 stateMask=0x0 doit=true}
10:26:46   *** text.getText()=[Type This 123]
10:26:48  typesText(org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest)  Time elapsed: 1.384 sec

I don't have the setup to reproduce this locally, if someone has access to a CentOS machine, the test to run is org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest.typesText(), using the Oxygen target platform found in gerrit commit https://git.eclipse.org/r/#/c/96348/21.

The problem also occurs when using GTK3 (https://hudson.eclipse.org/swtbot/job/swtbot-gerrit/841/consoleFull).

On Ubuntu and Windows the test passes locally.
Comment 1 Mickael Istria CLA 2017-05-15 14:07:27 EDT
@Alex: is it worth being considered as a todo for RC1?
Comment 2 Alexander Kurtakov CLA 2017-05-15 14:19:05 EDT
Ian, would you please investigate and post findings.
Comment 3 Patrick Tasse CLA 2017-05-29 11:01:02 EDT
Was anyone able to reproduce this issue locally on a CentOS machine?
Comment 4 Leo Ufimtsev CLA 2017-05-29 17:18:05 EDT
@Patrick, would you be able to throw together a snippet that demonstrates the issue? I could do a bisect on the SWT codebase to see when it started to occur and to see if it occurs on Fedora.
Comment 5 Patrick Tasse CLA 2017-06-02 17:42:07 EDT
Created attachment 268734 [details]
Snippet

This snippet does more or less the same thing that the failing SWTBot test does.

I have no idea if it fails on Oxygen/CentOS. It works when running locally on Oxygen/Ubuntu.

The text box should contain "this is a test" after a few seconds.
Comment 6 Leo Ufimtsev CLA 2017-06-08 17:04:58 EDT
(In reply to Patrick Tasse from comment #5)
> Created attachment 268734 [details]
> Snippet
> 
> This snippet does more or less the same thing that the failing SWTBot test
> does.
> 
> I have no idea if it fails on Oxygen/CentOS. It works when running locally
> on Oxygen/Ubuntu.
> 
> The text box should contain "this is a test" after a few seconds.

I've set up a CentOS VM with eclipse.
- CentOS 7 w/ updates as of today.
  * It has Gtk 3.14.13

- Ran the snippet against newest SWT version (master, today),
- Robot prints text into the text field as expected.

I'm not sure how to proceed further. 

Does the robot use setVisible(true|false) at all? This api is kinda broken at the moment.

If you have a way to reproduce this or another snippet for me to test, that'd be great otherwise I can't bisect if I can't reproduce the issue.
Comment 7 Leo Ufimtsev CLA 2017-06-19 15:53:04 EDT
ping.
Comment 8 Patrick Tasse CLA 2017-06-20 17:35:51 EDT
Hi Leo,

I've created a patch to test this issue on top of the latest release of SWTBot.

https://git.eclipse.org/r/99401

In Patch Set 1, I only removed the workaround that was needed to pass the tests (pressing SPACE to give focus to the Text), and the problem did indeed come back.

In Patch Set 3, I removed all other test plug-ins from the pom.xml and also excluded every other test in the org.eclipse.swtbot.swt.finder.test plug-in, leaving only SWTBotTextTest.java. Then the test case passes (the build failed but for an unrelated reason).

In Patch Set 4, I included again all other test files in the org.eclipse.swtbot.swt.finder.test plug-in. The test then failed again. We can see clearly that pressing SPACE has some effect on the focus control (it takes focus away then gives it back to the Text widget, and only after this does it receive keyboard events correctly).

So I suspect that one of the other tests is creating the condition that triggers this issue (which did not happen in Neon platform with the same test code).

I will try to pinpoint exactly which other test is needed to get a failure, it might take a couple of iterations. In the meantime, if you can checkout this patch, you can try to build with maven and see if you can reproduce the failure in your environment.
Comment 9 Leo Ufimtsev CLA 2017-06-20 18:58:50 EDT
(In reply to Patrick Tasse from comment #8)
> can see clearly that pressing SPACE has some effect on the focus control (it

Hmmm. I wonder if this is the offending commit:
https://git.eclipse.org/r/#/c/87090/

It changes selection behaviour for space.

If I submit an SWT gerrit patch, do you have a way to test such a patch against this problem?

I haven't used maven much beyond a few basic commands. I've mostly only dealt with SWT. At a high level, what would I need to do to reproduce this business in a CentOS VM?
Like which repos to checkout, which Maven command to run to reproduce issue in test failures.
Comment 10 Leo Ufimtsev CLA 2017-06-20 19:08:30 EDT
btw, is this the failing tests:
https://git.eclipse.org/c/swtbot/org.eclipse.swtbot.git/tree/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTextTest.java

?

Maybe I could try to checkout the project on a CentOS box and try to run the tests via Eclipse gui to see why they're failing.
Comment 11 Patrick Tasse CLA 2017-06-20 22:54:41 EDT
Hi Leo,

I think you would need to do the following:

git clone git://git.eclipse.org/gitroot/swtbot/org.eclipse.swtbot.git

git fetch git://git.eclipse.org/gitroot/swtbot/org.eclipse.swtbot refs/changes/01/99401/4 && git checkout FETCH_HEAD

mvn clean install
Comment 12 Leo Ufimtsev CLA 2017-06-30 15:02:29 EDT
I need to setup that test business and bisect this. Might take me a bit to get to this task.

If anyone has time, by all means, please feel free to work on this.
Comment 13 Leo Ufimtsev CLA 2017-07-20 15:57:28 EDT
I can't get the tests to work.

When I try:
mvn clean install

It errors on the 'clean' part with:
Comment 14 Leo Ufimtsev CLA 2017-07-20 15:59:42 EDT
(In reply to Leo Ufimtsev from comment #13)
> I can't get the tests to work.
> 
> When I try:
> mvn clean install
> 
> It errors on the 'clean' part with:

[ERROR] An error occurred while transferring artifact packed: osgi.bundle,org.eclipse.ui.workbench,3.110.0.v20170612-1255 from repository http://download.eclipse.org/releases/oxygen:
[ERROR]    Retry another mirror:
[ERROR]       Unable to connect to repository http://mirror.cc.vt.edu/pub/eclipse/releases/oxygen/201706281000/plugins/org.eclipse.ui.workbench_3.110.0.v20170612-1255.jar.pack.gz
[ERROR] Internal error: org.eclipse.tycho.repository.local.MirroringArtifactProvider$MirroringFailedException: Could not mirror artifact osgi.bundle,org.eclipse.ui.workbench,3.110.0.v20170612-1255 into the local Maven repository.See log output for details. Network is unreachable (connect failed) -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: org.eclipse.tycho.repository.local.MirroringArtifactProvider$MirroringFailedException: Could not mirror artifact osgi.bundle,org.eclipse.ui.workbench,3.110.0.v20170612-1255 into the local Maven repository.See log output for details.

~Attaching log: mvn.log

I tried to import swtbot git projects into eclipse, but there are a lot of errors. Some of them don't seem to make much sense, e.g a reference to a private field in controlexample.java etc...
When I try to run SWTBotTextTest on it's own as a jUnit plugin test, it complains about not being able to find a display.

Can you explain how do I reproduce the issue on my machine?
Comment 15 Marc-André Laperle CLA 2017-07-20 16:03:48 EDT
(In reply to Leo Ufimtsev from comment #14)
> 
> Can you explain how do I reproduce the issue on my machine?

try disabling mirrors with

man clean install -Declipse.p2.mirrors=false

For the cannot find display error, if it's a SWTBot test, try to untick "Run in UI Thread" in the launch configuration.
Comment 16 Patrick Tasse CLA 2017-07-20 16:20:13 EDT
Actually, SWTBot's own unit tests are a special case, they require 'Run in UI thread' to be checked. It usually needs to be unchecked for users of SWTBot testing their application.

Could it be that you need to set the target from /devtools/target-platforms/oxygen/oxygen.target?
Comment 17 Leo Ufimtsev CLA 2017-07-20 16:31:19 EDT
(In reply to Marc-André Laperle from comment #15)
> (In reply to Leo Ufimtsev from comment #14)
> > 
> > Can you explain how do I reproduce the issue on my machine?
> 
> try disabling mirrors with
> 
> man clean install -Declipse.p2.mirrors=false
> 
> For the cannot find display error, if it's a SWTBot test, try to untick "Run
> in UI Thread" in the launch configuration.

With/without "Run in UI Thread", running SWTBotTextTest.java fails with:

BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_CA
Framework arguments:  -version 3 -port 45877 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest -application org.eclipse.pde.junit.runtime.nonuithreadtestapplication -product org.eclipse.sdk.ide -testpluginname org.eclipse.swtbot.swt.finder.test
Command-line arguments:  -os linux -ws gtk -arch x86_64 -consoleLog -version 3 -port 45877 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest -application org.eclipse.pde.junit.runtime.nonuithreadtestapplication -product org.eclipse.sdk.ide -data /home/lufimtse/workspace/../junit-workspace -dev file:/home/lufimtse/workspace/.metadata/.plugins/org.eclipse.pde.core/pde-junit/dev.properties -os linux -ws gtk -arch x86_64 -consoleLog -testpluginname org.eclipse.swtbot.swt.finder.test

!ENTRY org.mockito 4 0 2017-07-20 16:24:55.702
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.mockito [578]
  Unresolved requirement: Import-Package: COM.jrockit.reflect; resolution:="optional"
  Unresolved requirement: Import-Package: jrockit.vm; resolution:="optional"
  Unresolved requirement: Import-Package: org.hamcrest; version="[1.0.0,2.0.0)"

	at org.eclipse.osgi.container.Module.start(Module.java:444)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1628)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1607)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1579)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1522)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)


Now the following maven runs (a very long time... )
 mvn clean install -Declipse.p2.mirrors=false
And then the following jUnits fail:
Tests in error: 
  KeystrokesTest.getsKeystrokesForModificationKeyWithShiftAndCapitalCharacter:83 ExceptionInInitializer
  KeystrokesTest.getsKeyStrokeForCapitalCharacters:28 NoClassDefFound Could not ...
  KeystrokesTest.getsKeyStrokeForSmallCharacters:38 NoClassDefFound Could not in...
  KeystrokesTest.getsKeystrokesForModificationKeys:56 NoClassDefFound Could not ...
  KeystrokesTest.getsKeystrokesForModificationKey:66 NoClassDefFound Could not i...
  KeystrokesTest.getsKeystrokesForModificationKeyWithShiftAndSmallCharacter:74 NoClassDefFound
  KeystrokesTest.getsKeyStrokeForSpecialCharacters:46 NoClassDefFound Could not ...
  KeystrokesTest.getsKeystrokesForModificationKeyForCapitalCharacter:92 NoClassDefFound
  SWTBotStyledTextTest.typesTextAtALocation:92 » NoClassDefFound Could not initi...
  SWTBotStyledTextTest.typesSpecialCharactersAtALocation:98 » NoClassDefFound Co...
  SWTBotTextTest.typesText:86 » NoClassDefFound Could not initialize class org.e...
  SWTBotComboTest.typeAndVerifiesTextInCombo:106 » NoClassDefFound Could not ini...


Now, I need to somehow bisect the failing jUnit test case against SWT's codebase. How would I go about doing it?

1) I could try to get the failing jUnit test case to run inside eclipse and make it depend on the SWT project in my eclipse.
Is it this test case that is failing? SWTBotTextTest.java 
Any ideas how I would go about soling the local unresolved requirements? I think I can get hamcrest from orbit. What about jrockit, do you know?


2) If I were to use maven. Do you know how could I get maven to use my local SWT instead of a checked out one?
Is there a way to only run the failing SWTBotTextTest? (the whole suite takes a very long time to run..)
Comment 18 Patrick Tasse CLA 2017-07-20 17:50:58 EDT
I don't think org.mockito is required by the SWTBot test, you could try removing it from your run configuration, unless it's a dependency from another plug-in?

But I don't think you will be able to reproduce the problem running from Eclipse or running only SWTBotTextTest, because it appears to be a condition caused by a previous test, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=516674#c8. So I think we have to debug this with maven.

Did you checkout patch set 4 of https://git.eclipse.org/r/99401?

When running with maven, it shouldn't be that long, around 15 minutes unless it's using GTK3. It shouldn't, since we set SWT_GTK3 to 0 in the pom.xml.

Your maven build is failing because of a NoClassDefFound, I'm not sure which one, maybe it's in the full exception stack trace earlier in the log? It seems to be somewhere around KeyStrokes. But in any case that means the problem is not reproduced yet.

To use your own SWT with mvn you can try including it in your LD_LIBRARY_PATH.
Comment 19 Marc-André Laperle CLA 2017-07-20 18:13:26 EDT
(In reply to Patrick Tasse from comment #18)
> To use your own SWT with mvn you can try including it in your
> LD_LIBRARY_PATH.

That *might* work for the native library but not the java code. I thought we were talking about a custom built GTK when I mentioned LD_LIBRARY_PATH. You best bet is to run everything from inside Eclipse, with both SWTBot and SWT imported (that's how I usually work on GTK3 + SWTBot issues). If you need to test with a different GTK, you can set LD_LIBRARY_PATH in the launch config (also make sure custom glib, ATK, etc are included). For the test failure depending on a previous one, the best with be to add a test suite that hardcodes the order of the test and then run that from Eclipse.
Just some suggestions :)
Comment 20 Leo Ufimtsev CLA 2017-07-21 09:53:32 EDT
-----------
(In reply to Patrick Tasse from comment #18)
> I don't think org.mockito is required by the SWTBot test, you could try
> removing it from your run configuration, unless it's a dependency from
> another plug-in?
> 
> But I don't think you will be able to reproduce the problem running from
> Eclipse or running only SWTBotTextTest, because it appears to be a condition
> caused by a previous test, see
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=516674#c8. So I think we have
> to debug this with maven.

Are you sure? Can someone reproduce this issue inside Eclipse, or is it reproducible only in Maven?
If the issue is reproducible inside eclipse, then I could bisect this inside Eclipse.

> Did you checkout patch set 4 of https://git.eclipse.org/r/99401?

I'm a bit confused about that patch. What does it do? Does it make maven "hang" during the tests or cause a fail?
Like, should I be bisecting SWT with the patch above applied to SWTBot, or should I be using SWTBot master?
 
> When running with maven, it shouldn't be that long, around 15 minutes unless
> it's using GTK3. It shouldn't, since we set SWT_GTK3 to 0 in the pom.xml.

15 minutes is soooo looonngg   :-D. SWT tests run in like ~4 minutes.
But if the problem doesn't occur in isolation, then I guess we have no choice but to run the full suite.

> To use your own SWT with mvn you can try including it in your
> LD_LIBRARY_PATH.

LD_LIBRARY_PATH is used to load various compiled gtk versions. e.g Gtk3.10, Gtk3.14, Gtk3.22 etc.. not change what version of SWT java uses.
Since the issue occurs on both Gtk2 and Gtk3, it seems that the issue is in SWT rather than the underlying GTK version.

-----------

(In reply to Marc-André Laperle from comment #19)
>  Your best bet is to run everything from inside Eclipse, with both SWTBot and SWT
> imported (that's how I usually work on GTK3 + SWTBot issues). If you need to
> test with a different GTK, ...  the best with be to add a test suite that
> hardcodes the order of the test and then run that from Eclipse.


Ok, I would like to do the following:
1) Setup SWTBot test environment in Eclipse with imported SWT sources.
2) Bisect SWTBot against various SWT versions.

Now, I've never worked with SWTBot before, so I need some help.

@Marc, 
I need to figure out how to setup 1) and how to run SWTBot tests that lead to the issue (and how to identify it).
a) Could you instruct me on which SWTBot projects I should have open in my workspace? (e.g a screenshot of the list would suffice).
b) Which suite/class do I need to run (and under what "run as" option) to run the suite? (Where is that suite?)
c) What is the criteria for failure? 
  My understanding is that the following test *fails* (and not hangs??) and all other tests pass.
org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest.java  typesText()
is that correct?

Btw, do you hang out on irc (freenode#eclipse) or mattermost anywhere?
Comment 21 Patrick Tasse CLA 2017-07-21 10:41:10 EDT
(In reply to Leo Ufimtsev from comment #20)
> Are you sure? Can someone reproduce this issue inside Eclipse, or is it
> reproducible only in Maven?
> If the issue is reproducible inside eclipse, then I could bisect this inside
> Eclipse.

I'm not sure, maybe with a test suite like Marc-Andre suggested? More on that below.

> I'm a bit confused about that patch. What does it do? Does it make maven
> "hang" during the tests or cause a fail?
> Like, should I be bisecting SWT with the patch above applied to SWTBot, or
> should I be using SWTBot master?

The patch adds some logging that could be useful, but it also removes all the unnecessary plug-ins from the pom.xml. You can use the remaining list from that patch to know which SWTBot plug-in projects you need to import in Eclipse.

> 15 minutes is soooo looonngg   :-D. SWT tests run in like ~4 minutes.
> But if the problem doesn't occur in isolation, then I guess we have no
> choice but to run the full suite.

If you think that's slow, don't try it with GTK3 ;) But that's another issue (https://bugs.eclipse.org/bugs/show_bug.cgi?id=506807).

I should try to bisect with my patch to try to isolate exactly which other test is creating the condition that makes SWTBotTextTest fail. Let me try to do that first, it will save time and might help pinpoint the issue.

> Ok, I would like to do the following:
> 1) Setup SWTBot test environment in Eclipse with imported SWT sources.
> 2) Bisect SWTBot against various SWT versions.
> 
> Now, I've never worked with SWTBot before, so I need some help.
> 
> @Marc, 
> I need to figure out how to setup 1) and how to run SWTBot tests that lead
> to the issue (and how to identify it).
> a) Could you instruct me on which SWTBot projects I should have open in my
> workspace? (e.g a screenshot of the list would suffice).
> b) Which suite/class do I need to run (and under what "run as" option) to
> run the suite? (Where is that suite?)

If I am able to isolate the interfering test from maven, I'll add a test suite in my patch that will run those tests only, so you can try it from Eclipse.

> c) What is the criteria for failure? 
>   My understanding is that the following test *fails* (and not hangs??) and
> all other tests pass.
> org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest.java  typesText()
> is that correct?

Correct, this is the error you're looking for:

00:00:00  typesText(org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest)  Time elapsed: 6.556 sec  <<< ERROR!
00:00:00  org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after: 5000 ms.: Expected "Type This 123" but was "This 123"

> Btw, do you hang out on irc (freenode#eclipse) or mattermost anywhere?

Yes, I'm on mattermost, let's continue discussing the debugging steps there. Sorry to those on cc: for the noise.
Comment 22 Leo Ufimtsev CLA 2017-07-21 11:20:08 EDT
(In reply to Patrick Tasse from comment #21)
> The patch adds some logging that could be useful, but it also removes all
> the unnecessary plug-ins from the pom.xml. You can use the remaining list
> from that patch to know which SWTBot plug-in projects you need to import in
> Eclipse.

Ah, I see. So basically these are the minimum set of modules to reproduce the test failure:
		<module>devtools/target-platforms</module>

		<module>org.eclipse.swtbot.ant.junit</module>
		<module>org.eclipse.swtbot.junit4_x</module>
		<module>org.eclipse.swtbot.swt.finder</module>
		<module>org.eclipse.swtbot.swt.finder.test</module>
		<module>org.eclipse.swtbot.swt.finder.test.keyboards</module>
		<module>org.eclipse.swt.examples</module>
 
> > 15 minutes is soooo looonngg   :-D. SWT tests run in like ~4 minutes.
> > But if the problem doesn't occur in isolation, then I guess we have no
> > choice but to run the full suite.
> 
> If you think that's slow, don't try it with GTK3 ;) But that's another issue
> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=506807).

Hmmm. Interesting. I wasn't aware SWT's Gtk3 implementation introduces such significant slow down.
Gtk3 is supposedly faster than Gtk2, maybe there's some performance logic issue in SWT. <to be investigated>

> 
> I should try to bisect with my patch to try to isolate exactly which other
> test is creating the condition that makes SWTBotTextTest fail. Let me try to
> do that first, it will save time and might help pinpoint the issue.

That would help yes.

> 
> > Ok, I would like to do the following:
> > 1) Setup SWTBot test environment in Eclipse with imported SWT sources.
> > 2) Bisect SWTBot against various SWT versions.
> > 
> > Now, I've never worked with SWTBot before, so I need some help.
> > 
> > @Marc, 
> > I need to figure out how to setup 1) and how to run SWTBot tests that lead
> > to the issue (and how to identify it).
> > a) Could you instruct me on which SWTBot projects I should have open in my
> > workspace? (e.g a screenshot of the list would suffice).
> > b) Which suite/class do I need to run (and under what "run as" option) to
> > run the suite? (Where is that suite?)
> 
> If I am able to isolate the interfering test from maven, I'll add a test
> suite in my patch that will run those tests only, so you can try it from
> Eclipse.

Sound good.

> 
> > c) What is the criteria for failure? 
> >   My understanding is that the following test *fails* (and not hangs??) and
> > all other tests pass.
> > org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest.java  typesText()
> > is that correct?
> 
> Correct, this is the error you're looking for:
> 
> 00:00:00  typesText(org.eclipse.swtbot.swt.finder.widgets.SWTBotTextTest) 
> Time elapsed: 6.556 sec  <<< ERROR!
> 00:00:00  org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout
> after: 5000 ms.: Expected "Type This 123" but was "This 123"
> 
> > Btw, do you hang out on irc (freenode#eclipse) or mattermost anywhere?
> 
> Yes, I'm on mattermost, let's continue discussing the debugging steps there.
> Sorry to those on cc: for the noise.

How do I find you on Mattermost? are you "pata" ?  I'm leoufimtsev on the Eclipse mattermost server.
Comment 23 Leo Ufimtsev CLA 2017-08-02 12:00:50 EDT
Btw, does the test still fail?

I'm a litte unsure of where we are with this bug at the moment.

Afaik we wanted to try to run tests against the swt project in eclipse, and checkout various swt project versions?
Comment 24 Patrick Tasse CLA 2017-08-02 13:23:38 EDT
Sorry, I still need to figure out the minimum set of tests to run together to reproduce the problem, but I haven't had time. I'll poke you when I have it done.
Comment 25 Leo Ufimtsev CLA 2018-02-14 15:55:07 EST
Ping.

Is this issue still relevant?
Comment 26 Leo Ufimtsev CLA 2018-02-22 14:36:56 EST
Ping Strike 2 :-).
Comment 27 Patrick Tasse CLA 2018-02-27 18:46:39 EST
Yes, I rebased the SWTBot debug patch on master running on Photon target and it still fails.

https://ci.eclipse.org/swtbot/job/swtbot-gerrit/937/console

Last thing I remember about it was that the test doesn't fail by itself, it only failed if it ran some other test(s) first. Still haven't had time to figure out which one though.
Comment 28 Leo Ufimtsev CLA 2018-04-13 16:35:12 EDT
~I'm doing a spring clean of bugs assigned to me.

This bug has been very inactive for a long time.

If the issue is still relevant and you have time to look into it, then please submit a new bug with detailed steps to reproduce and summarizing what has been investigated so far that we can investigate.

Thank you.