def test_selection_focus(self): """Focusing on a field with selected text should leave the text unchanged. """ text_area = self.launch_test_input_area() self.ensure_focus_on_input(text_area) keyboard = Keyboard() self.addCleanup(keyboard.dismiss) keyboard.type('This is a test') # Double tap to select a word self.pointer.click_object(text_area) self.pointer.click_object(text_area) keyboard.dismiss() self.ensure_focus_on_input(text_area) expected = 'This is a test' self.assertThat( text_area.text, Eventually(Equals(expected)) )
def test_hiding(self): """Verify that the keyboard remains hidden after being dismissed from a field that is no longer enabled. """ qml = dedent(""" import QtQuick 2.4 import Ubuntu.Components 1.1 import Ubuntu.Web 0.2 Rectangle { id: window objectName: "windowRectangle" color: "lightgrey" WebView { anchors.fill: parent objectName: "webview" Component.onCompleted: { loadHtml(" <html><body><div id='scroll' style='width: 100%; height: 200%; position: absolute; background: green; visibility: hidden;'></div><input id='input' style='height: 50%; width: 100%' type='text' onkeyup=\\\"if (event.keyCode == 13) {document.getElementById('input').disabled=true; document.getElementById('scroll').style.visibility= 'visible';}\\\" style='width: 100%%; height: 100%%;' /></body></html>"); } } } """) app = self._start_qml_script(qml) webview = app.select_single(objectName='webview') self.ensure_focus_on_input(webview) keyboard = Keyboard() self.addCleanup(keyboard.dismiss) keyboard.type('Test\n') keyboard.dismiss() pointer = Pointer(Touch.create()) pointer.drag( webview.width / 2.0, webview.height / 2.0, webview.width / 2.0, webview.height / 2.0 + 100 ) self.assertThat( keyboard.is_available, Eventually(Equals(False)) )
def test_visibility_reporting(self): """The keyboard should only report visibility changes once. """ # Test bug #1436076 which only occurs after maliit is restarted subprocess.check_call(['initctl', 'set-env', 'QT_LOAD_TESTABILITY=1']) subprocess.check_call(['restart', 'maliit-server']) sleep(10) qml = dedent(""" import QtQuick 2.4 import Ubuntu.Components 1.3 Rectangle { id: window objectName: "windowRectangle" color: "lightgrey" TextField { id: input; objectName: "input" anchors.centerIn: parent property int visibilityChangeCount: 0 } Connections { target: Qt.inputMethod onVisibleChanged: { input.visibilityChangeCount++; } } } """) app = self._start_qml_script(qml) text_area = app.select_single(objectName='input') self.ensure_focus_on_input(text_area) keyboard = Keyboard() keyboard.dismiss() self.assertThat( text_area.visibilityChangeCount, Eventually(Equals(2)) )
def close_osk(self): """Swipe down to close on-screen keyboard""" if is_maliit_process_running(): osk = UbuntuKeyboard() osk.dismiss()
def dismiss_osk(): if is_maliit_process_running(): osk = Keyboard() osk.dismiss()