summaryrefslogtreecommitdiff
path: root/tests/auto/activeFocusOnTab
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@digia.com>2013-05-07 14:21:12 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-15 10:01:38 +0200
commit795b9fdc52993e0199f462add398b5de8e4d75c4 (patch)
tree91e4e7b3748d384ce4e8fa96c8104b106c7556c1 /tests/auto/activeFocusOnTab
parent72232a9ba0fa0ac328d60f1a1c8965cb303f4a48 (diff)
downloadqtquickcontrols-795b9fdc52993e0199f462add398b5de8e4d75c4.tar.gz
Mac: respect the system settings in Full Keyboard Access
Because we use TableView as ListView, then only SpinBox, TextField, TextAre and TableView could be selected. Change-Id: I65ca106e60a57d86e029647653ae110fd81edaa4 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'tests/auto/activeFocusOnTab')
-rw-r--r--tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml8
-rw-r--r--tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp128
2 files changed, 132 insertions, 4 deletions
diff --git a/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml b/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml
index 5955b61e..20f1a77f 100644
--- a/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml
+++ b/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml
@@ -44,8 +44,8 @@ import QtQuick.Controls 1.0
Item {
id: main
objectName: "main"
- width: 800
- height: 600
+ width: 400
+ height: 800
focus: true
Component.onCompleted: button1.focus = true
Column {
@@ -197,6 +197,10 @@ Item {
objectName: "textfield"
text: "abc"
}
+ TableView {
+ id: tableview
+ objectName: "tableview"
+ }
TextArea {
id: textarea
objectName: "textarea"
diff --git a/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp b/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp
index 19d0d194..6278149e 100644
--- a/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp
+++ b/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp
@@ -45,6 +45,8 @@
#include <QtQml/qqmlcontext.h>
#include <QtQuick/qquickview.h>
#include <QtQuick/private/qquickitem_p.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformtheme.h>
#include "../shared/util.h"
#include "../shared/visualtestutil.h"
@@ -61,8 +63,14 @@ private slots:
void cleanup();
void activeFocusOnTab();
+ void activeFocusOnTab2();
private:
QQmlEngine engine;
+ bool qt_tab_all_widgets() {
+ if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
+ return theme->themeHint(QPlatformTheme::TabAllWidgets).toBool();
+ return true;
+ }
};
tst_activeFocusOnTab::tst_activeFocusOnTab()
@@ -80,6 +88,9 @@ void tst_activeFocusOnTab::cleanup()
void tst_activeFocusOnTab::activeFocusOnTab()
{
+ if (!qt_tab_all_widgets())
+ QSKIP("This function doesn't support NOT iterating all.");
+
QQuickView *window = new QQuickView(0);
window->setBaseSize(QSize(800,600));
@@ -215,7 +226,16 @@ void tst_activeFocusOnTab::activeFocusOnTab()
QVERIFY(item);
QVERIFY(item->hasActiveFocus());
- // Tab: textfield->textarea
+ // Tab: textfield->tableview
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "tableview");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: tableview->textarea
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
QGuiApplication::sendEvent(window, &key);
QVERIFY(key.isAccepted());
@@ -224,7 +244,16 @@ void tst_activeFocusOnTab::activeFocusOnTab()
QVERIFY(item);
QVERIFY(item->hasActiveFocus());
- // BackTab: textarea->textfield
+ // BackTab: textarea->tableview
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "tableview");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: tableview->textfield
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
QGuiApplication::sendEvent(window, &key);
QVERIFY(key.isAccepted());
@@ -422,6 +451,101 @@ void tst_activeFocusOnTab::activeFocusOnTab()
delete window;
}
+void tst_activeFocusOnTab::activeFocusOnTab2()
+{
+ if (qt_tab_all_widgets())
+ QSKIP("This function doesn't support iterating all.");
+
+ QQuickView *window = new QQuickView(0);
+ window->setBaseSize(QSize(800,600));
+
+ window->setSource(testFileUrl("activeFocusOnTab.qml"));
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+ QVERIFY(QGuiApplication::focusWindow() == window);
+
+ // original: spinbox
+ QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "spinbox");
+ QVERIFY(item);
+ item->forceActiveFocus();
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: spinbox->textfield
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "textfield");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: textfield->tableview
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "tableview");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: tableview->textarea
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "textarea");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: textarea->tableview
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "tableview");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: tableview->textfield
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "textfield");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: textfield->spinbox
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "spinbox");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: spinbox->textarea
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "textarea");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: textarea->tableview
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "tableview");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ delete window;
+}
+
QTEST_MAIN(tst_activeFocusOnTab)
#include "tst_activeFocusOnTab.moc"