aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2016-11-29 16:07:17 +0200
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2017-01-14 10:42:39 +0000
commit0a8c8dfc6d4e2b95195b855fcdd1fbd852fdb679 (patch)
tree998317bb475a05dcc82880afa401440fc43c847f /tests
parent58bdb78952d2c9a238507c0c7ea42505dd24664a (diff)
Add language popup
This change adds language popup as an alternative method for selecting the input language. The language popup is enabled when the active style supports it. This change adds the support for the default style. The popup opens from the change language key with single tap and can be dismissed by tapping anywhere else on the keyboard. The old toggle method for changing the input language is still available and supported (can be enabled easily from keyboard style). Some basic tests are included in this change. [ChangeLog] Added language selection popup for faster selection of input language. Change-Id: Ie3773f1d0cac78dee8237285e8596fe57c8bb5e4 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/inputpanel/data/inputpanel/inputpanel.qml6
-rw-r--r--tests/auto/inputpanel/data/tst_inputpanel.qml85
2 files changed, 90 insertions, 1 deletions
diff --git a/tests/auto/inputpanel/data/inputpanel/inputpanel.qml b/tests/auto/inputpanel/data/inputpanel/inputpanel.qml
index 4d42d941..1fb37d74 100644
--- a/tests/auto/inputpanel/data/inputpanel/inputpanel.qml
+++ b/tests/auto/inputpanel/data/inputpanel/inputpanel.qml
@@ -258,8 +258,12 @@ InputPanel {
return Utils.findChildByProperty(keyboardLayoutLoader, "effectiveAlternativeKeys", key, function(propertyValue, key) { return propertyValue.indexOf(key) !== -1 })
}
+ function findObjectByName(objectName) {
+ return Utils.findChildByProperty(keyboard, "objectName", objectName, null)
+ }
+
function virtualKeyPressOnCurrentLayout(key) {
- var keyObj = findVirtualKey(key)
+ var keyObj = typeof key == "object" && key.hasOwnProperty("key") ? key : findVirtualKey(key)
var alternativeKey = false
if (!keyObj && typeof key == "string") {
keyObj = findVirtualKeyAlternative(key)
diff --git a/tests/auto/inputpanel/data/tst_inputpanel.qml b/tests/auto/inputpanel/data/tst_inputpanel.qml
index ed4f37ef..61363882 100644
--- a/tests/auto/inputpanel/data/tst_inputpanel.qml
+++ b/tests/auto/inputpanel/data/tst_inputpanel.qml
@@ -1461,5 +1461,90 @@ Rectangle {
compare(anchorHandlePointsTo.y, anchorRect.y + anchorRect.height)
}
}
+
+ function test_languagePopupListToggle() {
+ prepareTest()
+ if (inputPanel.availableLocales.length < 2)
+ skip("Input language can not be changed")
+ var changeLanguageKey = inputPanel.findObjectByName("changeLanguageKey")
+ var languagePopupList = inputPanel.findObjectByName("languagePopupList")
+ inputPanel.virtualKeyClick(changeLanguageKey)
+ compare(languagePopupList.visible, true)
+ inputPanel.virtualKeyClick(changeLanguageKey)
+ compare(languagePopupList.visible, false)
+ }
+
+ function test_languagePopupListHideOnFocusChange() {
+ prepareTest()
+ if (inputPanel.availableLocales.length < 2)
+ skip("Input language can not be changed")
+ var changeLanguageKey = inputPanel.findObjectByName("changeLanguageKey")
+ var languagePopupList = inputPanel.findObjectByName("languagePopupList")
+ inputPanel.virtualKeyClick(changeLanguageKey)
+ compare(languagePopupList.visible, true)
+ container.forceActiveFocus()
+ textInput.forceActiveFocus()
+ compare(languagePopupList.visible, false)
+ }
+
+ function test_languagePopupListHideOnKeyboardHide() {
+ prepareTest()
+ if (inputPanel.availableLocales.length < 2)
+ skip("Input language can not be changed")
+ var changeLanguageKey = inputPanel.findObjectByName("changeLanguageKey")
+ var languagePopupList = inputPanel.findObjectByName("languagePopupList")
+ inputPanel.virtualKeyClick(changeLanguageKey)
+ compare(languagePopupList.visible, true)
+ Qt.inputMethod.hide()
+ Qt.inputMethod.show()
+ compare(languagePopupList.visible, false)
+ }
+
+ function test_languagePopupListActiveLocales_data() {
+ return [
+ { activeLocales: ["fi_FI"], initLocale: "fi_FI", languagePopupVisible: false },
+ { activeLocales: ["en_GB", "fi_FI", "ar_AR"], selectLocale: "ar_AR", languagePopupVisible: true },
+ ]
+ }
+
+ function test_languagePopupListActiveLocales(data) {
+ prepareTest(data)
+
+ for (var i = 0; i < data.activeLocales.length; ++i) {
+ if (!inputPanel.isLocaleSupported(data.activeLocales[i])) {
+ expectFail("", "Input locale not available (%1)".arg(data.activeLocales[i]))
+ break
+ }
+ }
+
+ var changeLanguageKey = inputPanel.findObjectByName("changeLanguageKey")
+ var languagePopupList = inputPanel.findObjectByName("languagePopupList")
+ inputPanel.virtualKeyClick(changeLanguageKey)
+
+ compare(languagePopupList.visible, data.languagePopupVisible)
+ if (!data.languagePopupVisible)
+ return
+
+ compare(data.activeLocales.length, languagePopupList.model.count)
+ for (i = 0; i < languagePopupList.model.count; ++i) {
+ verify(data.activeLocales.indexOf(languagePopupList.model.get(i).localeName) !== -1)
+ }
+
+ if (data.hasOwnProperty("selectLocale")) {
+ for (i = 0; i < languagePopupList.model.count; ++i) {
+ if (languagePopupList.model.get(i).localeName === data.selectLocale) {
+ inputPanel.keyboardLayoutLoaderItemSpy.clear()
+ languagePopupList.model.selectItem(i)
+ inputPanel.keyboardLayoutLoaderItemSpy.wait()
+ break
+ }
+ }
+ compare(inputPanel.locale, data.selectLocale, "Language popup select %1".arg(data.selectLocale))
+ } else {
+ inputPanel.virtualKeyClick(changeLanguageKey)
+ }
+
+ compare(languagePopupList.visible, false)
+ }
}
}