Opened 7 years ago

Closed 7 years ago

#134 closed todo (fixed)

Implement WinWorkstation>>sendKeyOrButtonEvent:x:y:keyOrButton:state:toViewId:

Reported by: jan vrany Owned by:
Priority: major Milestone:
Component: default Keywords:
Cc: patrik.svestka@… Also affects CVS HEAD (eXept version): no

Description

This method is required to make UI testing framework to work on Windows.

Ideally it should be implemented by means of SendInput() API.

Change History (9)

comment:1 by jan vrany, 7 years ago

Cc: patrik.svestka@… added

I just noted that eXept finally had the need to implement this :-) - see Claus's attempt:

I tried to graft them but it does not even compile. Besides, it uses an obsolete API (keybd_event() and mouse_event(). However, it could be a good starting point. Alternatively, we may wait until eXept fixes this and then cherry-pick the code.

by jan vrany, 7 years ago

comment:2 by jan vrany, 7 years ago

Attached changeset contains an initial attempt for generic, pure-smalltalk solution that injects smalltalk events into window group's event queue. Does not work yet, though, not sure why. Further investigation needed.

comment:3 by jan vrany, 7 years ago

Status: newtesting

Patch 57888ed51447 contains a generic implementation that directly inject events to window group's event queue. Bit hacky to make modifier keys working...

All tests in EditTextViewTests passes on Windows with this implementation.

A proper implementation using SendInput() is still desirable, but this may allow us to work on text editor issues menawhile, until Windows-specific implementation is fixed.

Give it try and let me know if it works for you.

Last edited 7 years ago by jan vrany (previous) (diff)

in reply to:  3 ; comment:4 by patrik.svestka@…, 7 years ago

Replying to jan vrany:

Patch 57888ed51447 contains a generic implementation that directly inject events to window group's event queue. Bit hacky to make modifier keys working...

All tests in EditTextViewTests passes on Windows with this implementation.

A proper implementation using SendInput() is still desirable, but this may allow us to work on text editor issues menawhile, until Windows-specific implementation is fixed.

Give it try and let me know if it works for you.

This does not work for me:

1) I have tried already done test (probably yours):

test_01
    textView contents: 'Hello, here is Smalltalk X'.
    textView setCursorCol: 14.

    textViewInteractor type: #SelectWord.
    self assert: textView selectionAsString = 'is'.

    textViewInteractor type: #CtrlShiftCursorRight.
    textViewInteractor type: #CtrlShiftCursorRight.

    self assert: textView selectionAsString = 'is Smalltalk'.

This fails at: [AssertionFailedError]: Assertion failed in EditTextView >> addToSelectionAfter: [36][36] in process EditTextViewTests>>#test_01 [8529]

The issue appears to be with the #CtrlShiftCursorRight and #CtrlShiftCursorRight as from the window it appears the word 'is' is selected.

2) I have tried to create my own test which also fails as it does not press delete key:

test_03 

    textView contents:'This text is to ' , String lf , 'continue'.

    textView hideCursor.  
    textView setCursorCol: 16. 
    textView showCursor.  

    textViewInteractor type: #Delete.

    self assert: textView selectionAsString = 'This text is to continue'.     
Last edited 7 years ago by patrik.svestka@… (previous) (diff)

in reply to:  4 ; comment:5 by jan vrany, 7 years ago

Replying to patrik.svestka@…:

This does not work for me:

1) I have tried already done test (probably yours):

This fails at: [AssertionFailedError]: Assertion failed in EditTextView >> addToSelectionAfter: [36][36] in process EditTextViewTests>>#test_01 [8529]

Well, are you sure you have ef289d40b266/stx.libwidg or newer? This commit contains
fix for this test - see issue #124

2) I have tried to create my own test which also fails as it does not press delete key:

This cannot work as of now. Pressing Del at the end of line does not merge lines. Keep in mind that St/X editor uses the "sheet of paper" metaphor. Try to textViewInteractor type: #Delete. when in the middle of a line and check the character right to cursor has been deleted. This should work.

in reply to:  5 comment:6 by patrik.svestka@…, 7 years ago

Replying to jan vrany:

Replying to patrik.svestka@…:

This does not work for me:

1) I have tried already done test (probably yours):

This fails at: [AssertionFailedError]: Assertion failed in EditTextView >> addToSelectionAfter: [36][36] in process EditTextViewTests>>#test_01 [8529]

Well, are you sure you have ef289d40b266/stx.libwidg or newer? This commit contains
fix for this test - see issue #124

I had only part of it. After compiling StX I'll check it again.

2) I have tried to create my own test which also fails as it does not press delete key:

This cannot work as of now. Pressing Del at the end of line does not merge lines. Keep in mind that St/X editor uses the "sheet of paper" metaphor. Try to textViewInteractor type: #Delete. when in the middle of a line and check the character right to cursor has been deleted. This should work.

Yes I remember you telling me that in the original StX this does not work. I have created first attempt to patch this functionality for which I'm writing a test. My idea is that this should work as it works in the StX Workspace.

comment:7 by patrik.svestka@…, 7 years ago

Resolution: fixed
Status: testingclosed

After using your SimpleViewInteractor_patch.st which fixes code from "Major cleanup and refactoring of keyboard mapping" (which should be now part of the build).

The original patch libview_fix_1_of_1_rev_57888ed51447_Issue__134__Added_generic_implementation_of___sendKeyOrButtonEvent_____to__DeviceWorkstation_.patch​ to this ticket works correctly. The smalltalk injection to the window queue - in the future if there is a C code it can be added to this ticket so we have complete history.

For now, I'm now closing this ticket as fixed.

Note: See TracTickets for help on using tickets.