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

Bug 345156

Summary: DE_DE keyboard not found
Product: [Technology] SWTBot Reporter: Carsten.Ditze
Component: Keyboard LayoutsAssignee: Project Inbox <swtbot-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: daniel.kruegler, dmigowski, Frank.Sommer, mark-roesler, mistria
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
See Also: https://git.eclipse.org/r/54980
https://git.eclipse.org/r/57767
Whiteboard:
Attachments:
Description Flags
new DE_De.keyboard file
none
changes in the AbstractKeyboardStrategy to handle multiple modifiers (proof of concept)
none
Stacktrace tray to type \ and ß
none
Comprehensive DE_DE-keyboard file
none
SWTKeyboardStrategy with splitted combined key stroke modifiers none

Description Carsten.Ditze CLA 2011-05-09 11:22:18 EDT
Build Identifier: 20100917-0705

java.lang.ExceptionInInitializerError
	at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.typeCharacter(Keyboard.java:100)
	at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.typeText(Keyboard.java:89)
	at org.eclipse.swtbot.swt.finder.widgets.SWTBotText.typeText(SWTBotText.java:92)
	at org.eclipse.swtbot.swt.finder.widgets.SWTBotText.typeText(SWTBotText.java:78)
	at lsy.lido.testframework.ClientWindowTest.setTextValue(ClientWindowTest.java:141)
	at lsy.lido.workprocessadmin.FlightDateLegWindowTest.swtBOTtestTodayDate(FlightDateLegWindowTest.java:128)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.IllegalArgumentException: DE_DE.keyboard not found, see http://wiki.eclipse.org/SWTBot/Keyboard_Layouts for more information.
	at org.eclipse.swtbot.swt.finder.keyboard.KeyboardLayout.getKeyboardLayout(KeyboardLayout.java:89)
	at org.eclipse.swtbot.swt.finder.keyboard.KeyboardLayout.getDefaultKeyboardLayout(KeyboardLayout.java:75)
	at org.eclipse.swtbot.swt.finder.keyboard.Keystrokes.<clinit>(Keystrokes.java:110)
	... 33 more



Reproducible: Always

Steps to Reproduce:
1. Use a german keybord
2. call method aWidget.typeText(aText);
3.
Comment 1 Mickael Istria CLA 2013-05-30 03:32:53 EDT
Hi Carsten,
Feel free to contribute support for German keyboard: http://wiki.eclipse.org/SWTBot/Keyboard_Layouts#Creating_keyboard_layouts
Comment 2 Mickael Istria CLA 2013-05-30 03:34:27 EDT
*** Bug 344367 has been marked as a duplicate of this bug. ***
Comment 3 Mark Rösler CLA 2013-07-03 05:13:48 EDT
Created attachment 233021 [details]
new DE_De.keyboard file

Hi i use WinXp and SWTBot 2.1.0 
I tryed to type a folder path with the awt keyboard strategy
I could not type ':' so I created a new DE_DE.keyboard File (see attachment)

I removed the following lines from the file because one of them leads to an exception
Ä shift+Ä
Ü shift+Ü
Ö shift+Ö

I debug the parse of the file and some characters are not correct displayed in the viariables view (example ß)
Comment 4 Mickael Istria CLA 2013-07-03 06:22:08 EDT
Thanks Mark,
Could you please contribute this file using Gerrit? http://wiki.eclipse.org/SWTBot/Contributing#Provide_a_contribution_using_Gerrit
Comment 5 Mark Rösler CLA 2013-07-03 08:05:47 EDT
Created attachment 233028 [details]
changes in the AbstractKeyboardStrategy to handle multiple modifiers (proof of concept)

to write a [ you need to press AltGr (alt+ctrl) + 8 (on a german keyboard)
I figured out that the AWTKeyboardStrategy#pressKey(KeyStroke key) has problems if the KeyStroke#getModifierKeys() return multiple modifiers.

My proof of concept solution (in the attechment) modifed AbstractKeyboardStrategy#pressKeys(KeyStroke... keys) and AbstractKeyboardStrategy#releaseKeys(KeyStroke... keys).
If the key (keyStroke) in the loop has multiple modifiers I split the modifier in seperate KeyStrokes and call
AbstractKeyboardStrategy#pressKey(KeyStroke key) or AbstractKeyboardStrategy#releaseKey(KeyStroke key) for each.
Comment 6 Mark Rösler CLA 2013-07-03 08:31:22 EDT
Created attachment 233031 [details]
Stacktrace tray to type \ and ß

the next problem i ran into is this (stacktrace in attachment 1 [details])
java.lang.IllegalArgumentException: Invalid key code
	at sun.awt.windows.WRobotPeer.keyPress(Native Method)

if I try to type \ (backslash) alt+ctrl+ß
and if I try ß (stacktrace in attachment 2 [details])

java.lang.IllegalArgumentException: no stroke available for character 'ß'
	at org.eclipse.swtbot.swt.finder.keyboard.KeyboardLayout.keyStrokeFor(KeyboardLayout.java:60)

I could not fix this. I dont know if this is only a display thing but the ß has during the file parse phase the "i have no symboly for this" symbole � (the @ too)

@Mickael Istria: I added the keys that were logical to me and the ":" thing works but I have not tested all the keys I added.
if you still want I can try to contribute. I am still pretty new at git.
Comment 7 Mickael Istria CLA 2013-07-04 05:45:02 EDT
@Mark: it would really be easier for me to review and merge it if you can make put this on Gerrit. If you can do it soon, this DE_DE keyboard could be part of upcoming 2.1.1 release.
Comment 8 Mickael Istria CLA 2013-07-08 05:44:35 EDT
Mark, DE_DE support was included a while ago (see bug 322186 ). Do you have any hint why you can't use this layout?
Comment 9 Mickael Istria CLA 2013-07-08 05:48:06 EDT
Also, about support for Alt-Gr or Ctrl+Alt, this issue is already reported in bug 280562 .
Comment 10 Mark Rösler CLA 2013-07-09 08:19:19 EDT
>Also, about support for Alt-Gr or Ctrl+Alt, this issue is already reported in bug 280562 .
then i wrote my comments in the wrong bug sorry

>Mark, DE_DE support was included a while ago (see bug 322186 ). Do you have any hint why you can't use this layout?
the current DE_DE file lacking some keys (compare with the attachment) but in general it works (note awt robot limitation).

like in Bug 280562 German keyboards need AltGr+<key> or Ctrl+Alt+<key> to type all characters.
- awt robot cannot use the KeyEvent.VK_ALT_GRAPH 
- and cannot type all characters like ß for example
- and cannot deal with keystrokes that have multiple modifier.

workaround for AltGr:
use Ctrl+Alt+<key> instead of AltGr+<key> in the keyboard file

workaround for multiple modifier:
swtbot have to split up the modifier befor pressed/released by awt robot

workaround for spezial characters (only an idea):
use alt codes http://www.alt-codes.net/
	//? = alt+(225)
	rob.keyPress(KeyEvent.VK_ALT);
	rob.keyPress(KeyEvent.VK_NUMPAD2);
	rob.keyRelease(KeyEvent.VK_NUMPAD2);
	rob.keyPress(KeyEvent.VK_NUMPAD2);
	rob.keyRelease(KeyEvent.VK_NUMPAD2);
	rob.keyPress(KeyEvent.VK_NUMPAD5);
	rob.keyRelease(KeyEvent.VK_NUMPAD5);
	rob.keyRelease(KeyEvent.VK_ALT);

i am not sure about dead keys
so i think you can safely put this in:
_ shift+-
; shift+,
: shift+.
Comment 11 Frank Sommer CLA 2015-08-28 08:00:03 EDT
A test of our product must cover special characters, since they are allowed in general, but not for naming certain objects.
I patched the org.eclipse.swtbot.swt.finder_xxx.jar with the keyboard file and a change in SWTKeyboardStrategy.java as shown in the attachments.
Together with the options -Dorg.eclipse.swtbot.keyboard.layout=DE_DE and
-Dorg.eclipse.swtbot.keyboard.strategy=org.eclipse.swtbot.swt.finder.keyboard.SWTKeyboardStrategy in the launch configuration things are working well for me.
Comment 12 Frank Sommer CLA 2015-08-28 08:01:34 EDT
Created attachment 256214 [details]
Comprehensive DE_DE-keyboard file
Comment 13 Frank Sommer CLA 2015-08-28 08:06:30 EDT
Created attachment 256215 [details]
SWTKeyboardStrategy with splitted combined key stroke modifiers

Multiple keyboard modifiers (ALT, CTRL, ...) result currently in additional characters instead of modifying the natural key. This change works well when used together with typeText.
Comment 14 Mickael Istria CLA 2015-08-28 10:14:26 EDT
Can you please submit this as a Gerrit patch? https://wiki.eclipse.org/SWTBot/Contributing#Provide_a_contribution_using_Gerrit
Comment 15 Eclipse Genie CLA 2015-09-01 07:38:49 EDT
New Gerrit change created: https://git.eclipse.org/r/54980
Comment 16 Eclipse Genie CLA 2015-10-09 03:28:39 EDT
New Gerrit change created: https://git.eclipse.org/r/57767
Comment 17 Daniel Krügler CLA 2020-12-13 10:08:09 EST
(In reply to Eclipse Genie from comment #16)
> New Gerrit change created: https://git.eclipse.org/r/57767

I just wanted to file an issue regarding the missing key combinations for the DE_DE.layout file. The suggested additions look necessary to me except that the mapping for the backslash character is incorrect. Instead of
alt+ctrl+\
it needs to be
alt+ctrl+ß

I would like to point out that IMO the DE_DE.layout file changes are the only ones needed as part of the issue. Please note that currently non working multi-modifier key combinations are due to bug 569685. I suggest to first fix bug 569685 as suggested there and then to add the missing DE_DE.layout combinations, because they would have no observable effects when using the normal org.eclipse.swtbot.swt.finder.keyboard.Keyboard#typeText functionality.