Faculty of Information Technology
Software Engineering Group

Opened 7 months ago

Closed 4 months 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 Changed 7 months ago by Jan Vrany

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.

Changed 7 months ago by Jan Vrany

comment:2 Changed 7 months ago by Jan Vrany

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 Changed 7 months ago by Jan Vrany

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 months ago by Jan Vrany (previous) (diff)

comment:4 in reply to:  3 ; Changed 5 months ago by Patrik Svestka

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 5 months ago by Patrik Svestka (previous) (diff)

comment:5 in reply to:  4 ; Changed 5 months ago by 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

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.

comment:6 in reply to:  5 Changed 5 months ago by Patrik Svestka

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 Changed 4 months ago by Patrik Svestka

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.