aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2015-09-02 13:19:37 +0300
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2015-10-07 12:55:25 +0000
commit827166c155f11b2b07d7ab61254b1dd67cb2f485 (patch)
tree49d673690c69715ab64fa5321f67dd711f842439 /tests
parentb23ce255314de2f838b5892b68e1fce97f909077 (diff)
Add tests for full screen handwriting mode
Change-Id: Ie8be85fc518cdbf9219fb2ade5a0c78698dabcfd Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/inputpanel/data/inputpanel/handwriting.js7
-rw-r--r--tests/auto/inputpanel/data/inputpanel/handwritinginputpanel.qml112
-rw-r--r--tests/auto/inputpanel/data/inputpanel/inputpanel.qml4
-rw-r--r--tests/auto/inputpanel/data/inputpanel/unipen_data.js208
-rw-r--r--tests/auto/inputpanel/data/tst_inputpanel.qml68
-rw-r--r--tests/auto/inputpanel/hwr_test_data/alphanumeric/16777219_100_3.txt29
-rw-r--r--tests/auto/inputpanel/hwr_test_data/alphanumeric/32_100_3.txt27
-rwxr-xr-xtests/auto/inputpanel/hwr_test_data/build_unipen_data.py2
-rw-r--r--tests/auto/inputpanel/inputpanel.pro1
9 files changed, 451 insertions, 7 deletions
diff --git a/tests/auto/inputpanel/data/inputpanel/handwriting.js b/tests/auto/inputpanel/data/inputpanel/handwriting.js
index dc3b41ff..4063f81f 100644
--- a/tests/auto/inputpanel/data/inputpanel/handwriting.js
+++ b/tests/auto/inputpanel/data/inputpanel/handwriting.js
@@ -21,11 +21,14 @@
.import "unipen_data.js" as UnipenData
function emulate(testcase, hwrInputArea, ch, instant) {
- var chKey = "0x" + (ch.charCodeAt(0) + 0x10000).toString(16).substr(-4)
+ var chKey = (((typeof ch == "number") ? ch : ch.charCodeAt(0)) + 0x100000000).toString(16).substr(1)
+ while (chKey.length > 4 && chKey[0] === '0')
+ chKey = chKey.substring(1)
+ chKey = "0x" + chKey
if (!UnipenData.unipenData.hasOwnProperty(chKey))
return false
var chData = UnipenData.unipenData[chKey]
- var scale = hwrInputArea.height / chData[".Y_DIM"]
+ var scale = Math.min(hwrInputArea.width / chData[".X_DIM"], hwrInputArea.height / chData[".Y_DIM"])
var strokes = UnipenData.unipenData[chKey][".PEN"]
var boundingBox = calculateBoundingBox(strokes)
var boxOffset = Qt.point(-boundingBox.x * scale + (hwrInputArea.width - boundingBox.width * scale) / 2, -boundingBox.y * scale + (hwrInputArea.height - boundingBox.height * scale) / 2)
diff --git a/tests/auto/inputpanel/data/inputpanel/handwritinginputpanel.qml b/tests/auto/inputpanel/data/inputpanel/handwritinginputpanel.qml
new file mode 100644
index 00000000..9872f42a
--- /dev/null
+++ b/tests/auto/inputpanel/data/inputpanel/handwritinginputpanel.qml
@@ -0,0 +1,112 @@
+/******************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd
+** All rights reserved.
+** For any questions to The Qt Company, please use contact form at http://qt.io
+**
+** This file is part of the Qt Virtual Keyboard module.
+**
+** Licensees holding valid commercial license for Qt may use this file in
+** accordance with the Qt License Agreement provided with the Software
+** or, alternatively, in accordance with the terms contained in a written
+** agreement between you and The Qt Company.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.io
+**
+******************************************************************************/
+
+import QtTest 1.0
+import QtQuick 2.0
+import QtQuick.Enterprise.VirtualKeyboard 2.0
+import "handwriting.js" as Handwriting
+import "utils.js" as Utils
+
+HandwritingInputPanel {
+ id: handwritingInputPanel
+ z: 99
+
+ property var testcase
+ readonly property var wordCandidatePopupList: Utils.findChildByProperty(handwritingInputPanel, "objectName", "wordCandidatePopupList", null)
+
+ anchors.fill: parent
+
+ signal inputMethodResult(var text)
+
+ Connections {
+ target: InputContext
+ onPreeditTextChanged: if (InputContext.preeditText.length > 0) inputMethodResult(InputContext.preeditText)
+ }
+
+ Connections {
+ target: InputContext.inputEngine
+ onVirtualKeyClicked: inputMethodResult(text)
+ }
+
+ SignalSpy {
+ id: inputMethodResultSpy
+ target: handwritingInputPanel
+ signalName: "inputMethodResult"
+ }
+
+ function wordCandidatePopupListSearchSuggestion(suggestion, timeout) {
+ if (timeout === undefined || timeout < 0)
+ timeout = 0
+ var suggestionFound = false
+ var dt = new Date()
+ var startTime = dt.getTime()
+ while (true) {
+ var origIndex = handwritingInputPanel.wordCandidatePopupList.currentIndex
+ if (origIndex !== -1) {
+ while (true) {
+ if (handwritingInputPanel.wordCandidatePopupList.model.itemData(handwritingInputPanel.wordCandidatePopupList.currentIndex) === suggestion) {
+ suggestionFound = true
+ break
+ }
+ if (handwritingInputPanel.wordCandidatePopupList.currentIndex === handwritingInputPanel.wordCandidatePopupList.count - 1)
+ break
+ handwritingInputPanel.wordCandidatePopupList.incrementCurrentIndex()
+ }
+ if (!suggestionFound) {
+ while (handwritingInputPanel.wordCandidatePopupList.currentIndex !== origIndex) {
+ handwritingInputPanel.wordCandidatePopupList.decrementCurrentIndex()
+ }
+ }
+ testcase.waitForRendering(handwritingInputPanel)
+ }
+ dt = new Date()
+ var elapsedTime = dt.getTime() - startTime
+ if (suggestionFound || elapsedTime >= timeout)
+ break
+ var maxWait = Math.min(timeout - elapsedTime, 50)
+ testcase.wait(maxWait)
+ }
+ return suggestionFound
+ }
+
+ function wordCandidatePopupListSelectCurrentItem() {
+ if (handwritingInputPanel.wordCandidatePopupList.currentItem === -1)
+ return false
+ testcase.wait(200)
+ var itemPos = handwritingInputPanel.mapFromItem(handwritingInputPanel.wordCandidatePopupList.currentItem,
+ handwritingInputPanel.wordCandidatePopupList.currentItem.width / 2,
+ handwritingInputPanel.wordCandidatePopupList.currentItem.height / 2)
+ testcase.mouseClick(handwritingInputPanel, itemPos.x, itemPos.y, Qt.LeftButton, 0, 20)
+ testcase.waitForRendering(handwritingInputPanel)
+ return true
+ }
+
+ function emulateHandwriting(ch, instant) {
+ if (!available)
+ return false
+ active = true
+ var hwrInputArea = Utils.findChildByProperty(handwritingInputPanel, "objectName", "hwrInputArea", null)
+ inputMethodResultSpy.clear()
+ if (!Handwriting.emulate(testcase, hwrInputArea, ch, instant)) {
+ console.warn("Cannot produce the symbol '%1' in full screen handwriting mode".arg(ch))
+ return false
+ }
+ inputMethodResultSpy.wait(3000)
+ return inputMethodResultSpy.count > 0
+ }
+}
diff --git a/tests/auto/inputpanel/data/inputpanel/inputpanel.qml b/tests/auto/inputpanel/data/inputpanel/inputpanel.qml
index 78cd1af5..8c290469 100644
--- a/tests/auto/inputpanel/data/inputpanel/inputpanel.qml
+++ b/tests/auto/inputpanel/data/inputpanel/inputpanel.qml
@@ -29,7 +29,7 @@ InputPanel {
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
- visible: Qt.inputMethod.visible
+ visible: active
property var testcase
property var virtualKeyPressPoint: null
@@ -465,13 +465,13 @@ InputPanel {
if (!inputPanel.keyboard.handwritingMode)
return false
var hwrInputArea = Utils.findChildByProperty(keyboard, "objectName", "hwrInputArea", null)
+ inputMethodResultSpy.clear()
if (!Handwriting.emulate(testcase, hwrInputArea, ch, instant)) {
if (virtualKeyClick(ch))
return true
console.warn("Cannot produce the symbol '%1' in handwriting mode".arg(ch))
return false
}
- inputMethodResultSpy.clear()
inputMethodResultSpy.wait(3000)
return inputMethodResultSpy.count > 0
}
diff --git a/tests/auto/inputpanel/data/inputpanel/unipen_data.js b/tests/auto/inputpanel/data/inputpanel/unipen_data.js
index e52a5fe0..28ca3aad 100644
--- a/tests/auto/inputpanel/data/inputpanel/unipen_data.js
+++ b/tests/auto/inputpanel/data/inputpanel/unipen_data.js
@@ -17,6 +17,105 @@
******************************************************************************/
var unipenData = {
+ "0x0020": {
+ ".COORD": [
+ "X",
+ "Y",
+ "T"
+ ],
+ ".HIERARCHY": "CHARACTER",
+ ".PEN": [
+ [
+ [
+ 268,
+ 123,
+ 0
+ ],
+ [
+ 268,
+ 122,
+ 19
+ ],
+ [
+ 269,
+ 122,
+ 47
+ ],
+ [
+ 271,
+ 122,
+ 74
+ ],
+ [
+ 280,
+ 121,
+ 90
+ ],
+ [
+ 291,
+ 121,
+ 111
+ ],
+ [
+ 318,
+ 119,
+ 129
+ ],
+ [
+ 344,
+ 118,
+ 147
+ ],
+ [
+ 397,
+ 116,
+ 183
+ ],
+ [
+ 424,
+ 115,
+ 202
+ ],
+ [
+ 479,
+ 112,
+ 232
+ ],
+ [
+ 505,
+ 110,
+ 254
+ ],
+ [
+ 516,
+ 109,
+ 276
+ ],
+ [
+ 548,
+ 107,
+ 302
+ ],
+ [
+ 556,
+ 107,
+ 322
+ ],
+ [
+ 563,
+ 106,
+ 343
+ ]
+ ]
+ ],
+ ".POINTS_PER_SECOND": 60,
+ ".SEGMENT": "CHARACTER",
+ ".VERSION": "1.0",
+ ".X_DIM": 821,
+ ".X_POINTS_PER_INCH": 100,
+ ".Y_DIM": 211,
+ ".Y_POINTS_PER_INCH": 100
+ },
"0x0030": {
".COORD": [
"X",
@@ -11840,5 +11939,114 @@ var unipenData = {
".X_POINTS_PER_INCH": 198,
".Y_DIM": 263,
".Y_POINTS_PER_INCH": 198
+ },
+ "0x1000003": {
+ ".COORD": [
+ "X",
+ "Y",
+ "T"
+ ],
+ ".HIERARCHY": "CHARACTER",
+ ".PEN": [
+ [
+ [
+ 564,
+ 91,
+ 0
+ ],
+ [
+ 563,
+ 91,
+ 13
+ ],
+ [
+ 561,
+ 91,
+ 47
+ ],
+ [
+ 553,
+ 92,
+ 64
+ ],
+ [
+ 542,
+ 93,
+ 82
+ ],
+ [
+ 485,
+ 95,
+ 107
+ ],
+ [
+ 456,
+ 97,
+ 127
+ ],
+ [
+ 426,
+ 98,
+ 152
+ ],
+ [
+ 394,
+ 99,
+ 170
+ ],
+ [
+ 362,
+ 99,
+ 187
+ ],
+ [
+ 303,
+ 99,
+ 207
+ ],
+ [
+ 292,
+ 100,
+ 230
+ ],
+ [
+ 280,
+ 100,
+ 255
+ ],
+ [
+ 270,
+ 100,
+ 272
+ ],
+ [
+ 263,
+ 100,
+ 289
+ ],
+ [
+ 260,
+ 100,
+ 313
+ ],
+ [
+ 255,
+ 100,
+ 341
+ ],
+ [
+ 253,
+ 100,
+ 362
+ ]
+ ]
+ ],
+ ".POINTS_PER_SECOND": 60,
+ ".SEGMENT": "CHARACTER",
+ ".VERSION": "1.0",
+ ".X_DIM": 821,
+ ".X_POINTS_PER_INCH": 100,
+ ".Y_DIM": 211,
+ ".Y_POINTS_PER_INCH": 100
}
}
diff --git a/tests/auto/inputpanel/data/tst_inputpanel.qml b/tests/auto/inputpanel/data/tst_inputpanel.qml
index ecb2b87d..772a1503 100644
--- a/tests/auto/inputpanel/data/tst_inputpanel.qml
+++ b/tests/auto/inputpanel/data/tst_inputpanel.qml
@@ -23,6 +23,7 @@ Rectangle {
id: container
width: 400
height: 400
+ color: "blue"
Component {
id: textInputComp
@@ -30,6 +31,7 @@ Rectangle {
anchors.fill: parent
visible: true
focus: true
+ color: "white"
}
}
@@ -39,14 +41,19 @@ Rectangle {
when: windowShown
property var inputPanel: null
+ property var handwritingInputPanel: null
property var textInput: null
function initTestCase() {
var inputPanelComp = Qt.createComponent("inputpanel/inputpanel.qml")
compare(inputPanelComp.status, Component.Ready, "Failed to create component: "+inputPanelComp.errorString())
- inputPanel = inputPanelComp.createObject(container)
- inputPanel.testcase = testcase
+ inputPanel = inputPanelComp.createObject(container, {"testcase": testcase})
inputPanel.keyboardLayoutsAvailableSpy.wait()
+
+ var handwritingInputPanelComp = Qt.createComponent("inputpanel/handwritinginputpanel.qml")
+ compare(handwritingInputPanelComp.status, Component.Ready, "Failed to create component: "+handwritingInputPanelComp.errorString())
+ handwritingInputPanel = handwritingInputPanelComp.createObject(container, {"testcase": testcase, "inputPanel": inputPanel})
+
textInput = textInputComp.createObject(container)
}
@@ -55,6 +62,8 @@ Rectangle {
textInput.destroy()
if (inputPanel)
inputPanel.destroy()
+ if (handwritingInputPanel)
+ handwritingInputPanel.destroy()
}
function prepareTest(data) {
@@ -69,6 +78,7 @@ Rectangle {
textInput.text = ""
}
textInput.inputMethodHints = data !== undefined && data.hasOwnProperty("initInputMethodHints") ? data.initInputMethodHints : Qt.ImhNone
+ handwritingInputPanel.available = false
textInput.forceActiveFocus()
inputPanel.setHandwritingMode(false)
var locale = data !== undefined && data.hasOwnProperty("initLocale") ? data.initLocale : "en_GB"
@@ -850,5 +860,59 @@ Rectangle {
compare(textInput.text, data.outputText)
}
+
+ function test_hwrFullScreenInputSequence_data() {
+ return [
+ { initInputMethodHints: Qt.ImhNoPredictiveText, toggleShiftCount: 0, inputSequence: "abcdefghij", outputText: "Abcdefghij" },
+ { initInputMethodHints: Qt.ImhNoPredictiveText, toggleShiftCount: 1, inputSequence: "klmnopqrst", outputText: "klmnopqrst" },
+ { initInputMethodHints: Qt.ImhNoPredictiveText, toggleShiftCount: 3, inputSequence: "uvwxyz", outputText: "UVWXYZ" },
+ { initInputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhPreferNumbers, toggleShiftCount: 0, inputSequence: "0123456789", outputText: "0123456789" },
+ ]
+ }
+
+ function test_hwrFullScreenInputSequence(data) {
+ prepareTest(data)
+
+ if (!handwritingInputPanel.enabled)
+ expectFail("", "Handwriting not enabled")
+ verify(handwritingInputPanel.enabled)
+ handwritingInputPanel.available = true
+
+ for (var i = 0; i < data.toggleShiftCount; i++) {
+ inputPanel.toggleShift()
+ }
+ for (var inputIndex in data.inputSequence) {
+ verify(handwritingInputPanel.emulateHandwriting(data.inputSequence[inputIndex], true))
+ }
+
+ if (handwritingInputPanel.wordCandidatePopupListSearchSuggestion(data.outputText)) {
+ handwritingInputPanel.wordCandidatePopupListSelectCurrentItem()
+ }
+
+ Qt.inputMethod.commit()
+ compare(textInput.text, data.outputText)
+ }
+
+ function test_hwrFullScreenGestures_data() {
+ return [
+ { initInputMethodHints: Qt.ImhNoPredictiveText, inputSequence: ["a","b","c",Qt.Key_Backspace,Qt.Key_Space,"c"], outputText: "Ab c" },
+ ]
+ }
+
+ function test_hwrFullScreenGestures(data) {
+ prepareTest(data)
+
+ if (!handwritingInputPanel.enabled)
+ expectFail("", "Handwriting not enabled")
+ verify(handwritingInputPanel.enabled)
+ handwritingInputPanel.available = true
+
+ for (var inputIndex in data.inputSequence) {
+ verify(handwritingInputPanel.emulateHandwriting(data.inputSequence[inputIndex], true))
+ }
+
+ Qt.inputMethod.commit()
+ compare(textInput.text, data.outputText)
+ }
}
}
diff --git a/tests/auto/inputpanel/hwr_test_data/alphanumeric/16777219_100_3.txt b/tests/auto/inputpanel/hwr_test_data/alphanumeric/16777219_100_3.txt
new file mode 100644
index 00000000..0360e3e5
--- /dev/null
+++ b/tests/auto/inputpanel/hwr_test_data/alphanumeric/16777219_100_3.txt
@@ -0,0 +1,29 @@
+.VERSION 1.0
+.HIERARCHY CHARACTER
+.COORD X Y T
+.SEGMENT CHARACTER
+.X_DIM 821
+.Y_DIM 211
+.X_POINTS_PER_INCH 100
+.Y_POINTS_PER_INCH 100
+.POINTS_PER_SECOND 60
+.PEN_DOWN
+564 91 0
+563 91 13
+561 91 47
+553 92 64
+542 93 82
+485 95 107
+456 97 127
+426 98 152
+394 99 170
+362 99 187
+303 99 207
+292 100 230
+280 100 255
+270 100 272
+263 100 289
+260 100 313
+255 100 341
+253 100 362
+.PEN_UP
diff --git a/tests/auto/inputpanel/hwr_test_data/alphanumeric/32_100_3.txt b/tests/auto/inputpanel/hwr_test_data/alphanumeric/32_100_3.txt
new file mode 100644
index 00000000..6bbf727d
--- /dev/null
+++ b/tests/auto/inputpanel/hwr_test_data/alphanumeric/32_100_3.txt
@@ -0,0 +1,27 @@
+.VERSION 1.0
+.HIERARCHY CHARACTER
+.COORD X Y T
+.SEGMENT CHARACTER
+.X_DIM 821
+.Y_DIM 211
+.X_POINTS_PER_INCH 100
+.Y_POINTS_PER_INCH 100
+.POINTS_PER_SECOND 60
+.PEN_DOWN
+268 123 0
+268 122 19
+269 122 47
+271 122 74
+280 121 90
+291 121 111
+318 119 129
+344 118 147
+397 116 183
+424 115 202
+479 112 232
+505 110 254
+516 109 276
+548 107 302
+556 107 322
+563 106 343
+.PEN_UP
diff --git a/tests/auto/inputpanel/hwr_test_data/build_unipen_data.py b/tests/auto/inputpanel/hwr_test_data/build_unipen_data.py
index 2d9504c0..639912b9 100755
--- a/tests/auto/inputpanel/hwr_test_data/build_unipen_data.py
+++ b/tests/auto/inputpanel/hwr_test_data/build_unipen_data.py
@@ -25,7 +25,7 @@ import datetime
import getopt
import re
-unipen_file_pattern = re.compile(r'(^[0-9]{2,4}).*\.txt')
+unipen_file_pattern = re.compile(r'(^[0-9]{2,9}).*\.txt')
def print_header():
print """/******************************************************************************
diff --git a/tests/auto/inputpanel/inputpanel.pro b/tests/auto/inputpanel/inputpanel.pro
index 584fa311..789df15a 100644
--- a/tests/auto/inputpanel/inputpanel.pro
+++ b/tests/auto/inputpanel/inputpanel.pro
@@ -10,4 +10,5 @@ TESTDATA = $$PWD/data/*
OTHER_FILES += \
$$PWD/data/inputpanel/inputpanel.qml \
+ $$PWD/data/inputpanel/handwritinginputpanel.qml \
$$PWD/data/tst_inputpanel.qml \