needs emulator for "close on screen keyboard"

Bug #1239753 reported by Martin Pitt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubuntu-ui-toolkit (Ubuntu)
Confirmed
High
Unassigned

Bug Description

I'm currently writing tests for messaging-app. To go back from composing a message, the user currently has to (1) swipe down to close the OSK (on-screen keyboard), (2) swipe up to get the toolbar, and (3) press back.

Turns out that it is rather hard to close the keyboard, as you cannot even get an object for it. Right now I came up with the following hack:

    def close_osk(self):
        '''Swipe down to close on-screen keyboard'''

        # TODO: hack! this belongs into the Ubuntu UI toolkit emulator
        x1, y1, x2, y2 = self.main_view.globalRect
        mid_x = (x2 - x1) // 2
        mid_y = (y2 - y1) * 7 // 10
        self.pointing_device.drag(mid_x, mid_y, mid_x, y2)
        time.sleep(1)

Revision history for this message
Christopher Lee (veebers) wrote :

Hi Martin,

The ubuntu-keyboard emulator provides this but you of course have to have the maliit-server started with testability as well as having ubuntu-keyboard-autopilot installed.

If you are able to satisfy this prerequisite than the code looks like this:

>>> from ubuntu_keyboard.emulators.keyboard import Keyboard
>>> kb = Keyboard()
>>> kb.dismiss()

I'm not sure if it helps you much at this stage but it's a possibility.

Revision history for this message
Martin Pitt (pitti) wrote :

How would I do that? I tried this loop a few times until "my" maliit-server was faster than the D-BUS (re-)spawned one:

$ pkill -e maliit-server; maliit-server -testability
maliit-server killed (pid 8584)
maliit-server: invalid option -- 't'
maliit-server: invalid option -- 'e'
maliit-server: invalid option -- 's'
maliit-server: invalid option -- 't'
maliit-server: invalid option -- 'a'
maliit-server: invalid option -- 'b'
maliit-server: invalid option -- 'i'
maliit-server: invalid option -- 'l'
maliit-server: invalid option -- 'i'
maliit-server: invalid option -- 't'
maliit-server: invalid option -- 'y'
__pthread_gettid -2
error: empty dic file
Hash Manager Error : 2
WARNING: file:///usr/lib/arm-linux-gnueabihf/qt5/qml/Ubuntu/Components/OrientationHelper.qml:100: ReferenceError: window is not defined

Then I ran my tests, which now fail because the OSK isn't shown at all any more. So the keyboard emulator fails with

Traceback (most recent call last):
  File "/home/phablet/messaging-app/tests/autopilot/messaging_app/tests/test_messaging.py", line 95, in test_write_new_message
    kb = Keyboard()
  File "/usr/lib/python2.7/dist-packages/ubuntu_keyboard/emulators/keyboard.py", line 55, in __init__
    self.orientation = self.maliit.select_single(
  File "/usr/lib/python2.7/dist-packages/ubuntu_keyboard/emulators/keyboard.py", line 105, in maliit
    emulator_base=UbuntuKeyboardEmulatorBase
  File "/usr/lib/python2.7/dist-packages/autopilot/introspection/__init__.py", line 271, in get_proxy_object_for_existing_process
    raise ProcessSearchError("Search criteria returned no results")
ProcessSearchError: ('Search criteria returned no results', 'Unable to find maliit-server dbus object. Has it been started with introspection enabled?')

Did you mean something else with "maliit-server started with testability"?

Revision history for this message
Christopher Lee (veebers) wrote :

oh sorry, maliit-server is handled my upstart, so to stop it:

$ initctl stop maliit-server

and to start it with test ability either

$ echo exec maliit-server -testability > ~/.config/upstart/maliit-server.override && initctl startmaliit-server
( don't forget to rm that file when your done )

or this should do it too:
$ initctl set-env QT_LOAD_TESTABILITY=1 && start maliit-server

Revision history for this message
Martin Pitt (pitti) wrote :

> $ initctl set-env QT_LOAD_TESTABILITY=1 && start maliit-server

That looks reasonably elegant. I tried that, but I still get the error from comment 2. With the maliit-server.override approach I get a different crash:

  File "/home/phablet/messaging-app/tests/autopilot/messaging_app/tests/test_messaging.py", line 102, in test_write_new_message
    self.close_osk()
  File "/home/phablet/messaging-app/tests/autopilot/messaging_app/tests/test_messaging.py", line 154, in close_osk
    kb.dismiss()
  File "/usr/lib/python2.7/dist-packages/ubuntu_keyboard/emulators/keyboard.py", line 170, in dismiss
    self.keyboard.state.wait_for("HIDDEN")
  File "/usr/lib/python2.7/dist-packages/autopilot/introspection/dbus.py", line 234, in wait_for
    failure_msg))
AssertionError: After 10.0 seconds test on QQuickItem.state failed: 'HIDDEN' != dbus.String(u'SHOWN', variant_level=1)

It's notable that for both approaches the application crashes the first time after running the test after restarting maliit, the second time it injects an additional "00" keyboard keys into the application, and only at the third time it actually starts functioning normally. That sounds like a bug in maliit itself, though.

Bill Filler (bfiller)
Changed in ubuntu-ui-toolkit:
status: New → Confirmed
importance: Undecided → High
Zoltan Balogh (bzoltan)
Changed in ubuntu-ui-toolkit (Ubuntu):
importance: Undecided → High
status: New → Confirmed
Zoltan Balogh (bzoltan)
no longer affects: ubuntu-ui-toolkit
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.