From: Frederik Gladhorn Date: Fri, 13 Jan 2012 10:47:48 +0000 (+0100) Subject: Move accessibility test to QtQuick 2. X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=2df5c4b9c260a81c585a9e607961c497c6b6a750;p=konrad%2Fqtdeclarative.git Move accessibility test to QtQuick 2. The test now only depends on Quick 2 and no longer a mix of widgets, Quick 1 and 2. Change-Id: I3120e11dadb8bb7d7635e6baa1cb905d917353ea Reviewed-by: Jan-Arve Sæther --- diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index f5ff636..6780a87 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -27,7 +27,6 @@ PUBLICTESTS += \ qmlplugindump PRIVATETESTS += \ - qdeclarativeaccessibility \ qdeclarativebinding \ qdeclarativechangeset \ qdeclarativeconnection \ diff --git a/tests/auto/declarative/qdeclarativeaccessibility/data/checkbuttons.qml b/tests/auto/qtquick2/qquickaccessible/data/checkbuttons.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeaccessibility/data/checkbuttons.qml rename to tests/auto/qtquick2/qquickaccessible/data/checkbuttons.qml diff --git a/tests/auto/declarative/qdeclarativeaccessibility/data/hittest.qml b/tests/auto/qtquick2/qquickaccessible/data/hittest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeaccessibility/data/hittest.qml rename to tests/auto/qtquick2/qquickaccessible/data/hittest.qml diff --git a/tests/auto/declarative/qdeclarativeaccessibility/data/pushbutton.qml b/tests/auto/qtquick2/qquickaccessible/data/pushbutton.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeaccessibility/data/pushbutton.qml rename to tests/auto/qtquick2/qquickaccessible/data/pushbutton.qml diff --git a/tests/auto/declarative/qdeclarativeaccessibility/data/statictext.qml b/tests/auto/qtquick2/qquickaccessible/data/statictext.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeaccessibility/data/statictext.qml rename to tests/auto/qtquick2/qquickaccessible/data/statictext.qml diff --git a/tests/auto/declarative/qdeclarativeaccessibility/data/widgets/TextRect.qml b/tests/auto/qtquick2/qquickaccessible/data/widgets/TextRect.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeaccessibility/data/widgets/TextRect.qml rename to tests/auto/qtquick2/qquickaccessible/data/widgets/TextRect.qml diff --git a/tests/auto/declarative/qdeclarativeaccessibility/qdeclarativeaccessibility.pro b/tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro similarity index 53% rename from tests/auto/declarative/qdeclarativeaccessibility/qdeclarativeaccessibility.pro rename to tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro index ee93c10..dc32316 100644 --- a/tests/auto/declarative/qdeclarativeaccessibility/qdeclarativeaccessibility.pro +++ b/tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro @@ -1,23 +1,19 @@ CONFIG += testcase -TARGET = tst_qdeclarativeaccessibility -QT += declarative-private network qtquick1-private testlib +TARGET = tst_qquickaccessible +QT += declarative-private network quick-private testlib macx:CONFIG -= app_bundle -SOURCES += tst_qdeclarativeaccessibility.cpp +SOURCES += tst_qquickaccessible.cpp include (../../shared/util.pri) +OTHER_FILES += data/checkbuttons.qml +OTHER_FILES += data/hittest.qml OTHER_FILES += data/pushbutton.qml OTHER_FILES += data/statictext.qml -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +DEFINES += SRCDIR=\\\"$$PWD\\\" CONFIG += parallel_test @@ -27,6 +23,3 @@ wince*: { DEPLOYMENT += accessneeded } - - - diff --git a/tests/auto/declarative/qdeclarativeaccessibility/tst_qdeclarativeaccessibility.cpp b/tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp similarity index 71% rename from tests/auto/declarative/qdeclarativeaccessibility/tst_qdeclarativeaccessibility.cpp rename to tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp index 0688edf..c633c82 100644 --- a/tests/auto/declarative/qdeclarativeaccessibility/tst_qdeclarativeaccessibility.cpp +++ b/tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp @@ -45,100 +45,18 @@ #include -#include #include #include #include #include -#include +#include #include "../../shared/util.h" typedef QSharedPointer QAI; - -static inline bool verifyChild(QWidget *child, QAccessibleInterface *iface, - int index, const QRect &domain) -{ - if (!child) { - qWarning("tst_QAccessibility::verifyChild: null pointer to child."); - return false; - } - - if (!iface) { - qWarning("tst_QAccessibility::verifyChild: null pointer to interface."); - return false; - } - - // Verify that we get a valid QAccessibleInterface for the child. - QAccessibleInterface *childInterface = QAccessible::queryAccessibleInterface(child); - if (!childInterface) { - qWarning("tst_QAccessibility::verifyChild: Failed to retrieve interface for child."); - return false; - } - - // QAccessibleInterface::indexOfChild(): - // Verify that indexOfChild() returns an index equal to the index passed in - int indexFromIndexOfChild = iface->indexOfChild(childInterface); - delete childInterface; - if (indexFromIndexOfChild != index) { - qWarning("tst_QAccessibility::verifyChild (indexOfChild()):"); - qWarning() << "Expected:" << index; - qWarning() << "Actual: " << indexFromIndexOfChild; - return false; - } - - // Navigate to child, compare its object and role with the interface from queryAccessibleInterface(child). - QAccessibleInterface *navigatedChildInterface = iface->child(index - 1); - if (navigatedChildInterface == 0) - return false; - - const QRect rectFromInterface = navigatedChildInterface->rect(); - delete navigatedChildInterface; - - // QAccessibleInterface::childAt(): - // Calculate global child position and check that the interface - // returns the correct index for that position. - QPoint globalChildPos = child->mapToGlobal(QPoint(0, 0)); - QAccessibleInterface *childAtInterface = iface->childAt(globalChildPos.x(), globalChildPos.y()); - if (!childAtInterface) { - qWarning("tst_QAccessibility::verifyChild (childAt()):"); - qWarning() << "Expected:" << childInterface; - qWarning() << "Actual: no child"; - return false; - } - if (childAtInterface->object() != childInterface->object()) { - qWarning("tst_QAccessibility::verifyChild (childAt()):"); - qWarning() << "Expected:" << childInterface; - qWarning() << "Actual: " << childAtInterface; - return false; - } - delete childInterface; - delete childAtInterface; - - // Verify that the child is within its domain. - if (!domain.contains(rectFromInterface)) { - qWarning("tst_QAccessibility::verifyChild: Child is not within its domain."); - return false; - } - - return true; -} - -static inline int indexOfChild(QAccessibleInterface *parentInterface, QWidget *childWidget) -{ - if (!parentInterface || !childWidget) - return -1; - QAccessibleInterface *childInterface = QAccessible::queryAccessibleInterface(childWidget); - if (!childInterface) - return -1; - int index = parentInterface->indexOfChild(childInterface); - delete childInterface; - return index; -} - #define EXPECT(cond) \ do { \ if (!errorAt && !(cond)) { \ @@ -166,15 +84,6 @@ static int verifyHierarchy(QAccessibleInterface *iface) EXPECT(iface->object() == parent->object()); delete parent; - // navigate Sibling... -// if (middleChild) { -// entry = if2->navigate(QAccessible::Sibling, middle, &if3); -// EXPECT(entry == 0 && if3->object() == middleChild->object()); -// if (entry == 0) -// delete if3; -// EXPECT(iface->indexOfChild(middleChild) == middle); -// } - // verify children... if (!errorAt) errorAt = verifyHierarchy(if2); @@ -189,12 +98,12 @@ static int verifyHierarchy(QAccessibleInterface *iface) //TESTED_FILES= -class tst_QDeclarativeAccessibility : public QDeclarativeDataTest +class tst_QQuickAccessible : public QDeclarativeDataTest { Q_OBJECT public: - tst_QDeclarativeAccessibility(); - virtual ~tst_QDeclarativeAccessibility(); + tst_QQuickAccessible(); + virtual ~tst_QQuickAccessible(); private slots: void commonTests_data(); @@ -206,17 +115,17 @@ private slots: void checkableTest(); }; -tst_QDeclarativeAccessibility::tst_QDeclarativeAccessibility() +tst_QQuickAccessible::tst_QQuickAccessible() { } -tst_QDeclarativeAccessibility::~tst_QDeclarativeAccessibility() +tst_QQuickAccessible::~tst_QQuickAccessible() { } -void tst_QDeclarativeAccessibility::commonTests_data() +void tst_QQuickAccessible::commonTests_data() { QTest::addColumn("accessibleRoleFileName"); @@ -224,7 +133,7 @@ void tst_QDeclarativeAccessibility::commonTests_data() QTest::newRow("PushButton") << SRCDIR "/data/pushbutton.qml"; } -void tst_QDeclarativeAccessibility::commonTests() +void tst_QQuickAccessible::commonTests() { QFETCH(QString, accessibleRoleFileName); @@ -288,17 +197,17 @@ QString eventName(const int ev) } } -void tst_QDeclarativeAccessibility::declarativeAttachedProperties() +void tst_QQuickAccessible::declarativeAttachedProperties() { { QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.1\nItem {\n" + component.setData("import QtQuick 2.0\nItem {\n" "}", QUrl()); QObject *object = component.create(); QVERIFY(object != 0); - QObject *attachedObject = QDeclarativeAccessibleAttached::attachedProperties(object); + QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object); QCOMPARE(attachedObject, static_cast(0)); delete object; } @@ -306,20 +215,20 @@ void tst_QDeclarativeAccessibility::declarativeAttachedProperties() // Attached property { QObject parent; - QDeclarativeAccessibleAttached *attachedObj = new QDeclarativeAccessibleAttached(&parent); + QQuickAccessibleAttached *attachedObj = new QQuickAccessibleAttached(&parent); attachedObj->name(); QVariant pp = attachedObj->property("name"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.1\nItem {\n" + component.setData("import QtQuick 2.0\nItem {\n" "Accessible.role: Accessible.Button\n" "}", QUrl()); QObject *object = component.create(); QVERIFY(object != 0); - QObject *attachedObject = QDeclarativeAccessibleAttached::attachedProperties(object); + QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object); QVERIFY(attachedObject); if (attachedObject) { QVariant p = attachedObject->property("role"); @@ -337,7 +246,7 @@ void tst_QDeclarativeAccessibility::declarativeAttachedProperties() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.1\nItem {\n" + component.setData("import QtQuick 2.0\nItem {\n" "Accessible.role: Accessible.Button\n" "Accessible.name: \"Donald\"\n" "Accessible.description: \"Duck\"\n" @@ -345,7 +254,7 @@ void tst_QDeclarativeAccessibility::declarativeAttachedProperties() QObject *object = component.create(); QVERIFY(object != 0); - QObject *attachedObject = QDeclarativeAccessibleAttached::attachedProperties(object); + QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object); QVERIFY(attachedObject); if (attachedObject) { QVariant p = attachedObject->property("role"); @@ -363,7 +272,7 @@ void tst_QDeclarativeAccessibility::declarativeAttachedProperties() } -void tst_QDeclarativeAccessibility::basicPropertiesTest() +void tst_QQuickAccessible::basicPropertiesTest() { QAI app = QAI(QAccessible::queryAccessibleInterface(qApp)); QCOMPARE(app->childCount(), 0); @@ -425,7 +334,7 @@ QAI topLevelChildAt(QAccessibleInterface *iface, int x, int y) return child; } -void tst_QDeclarativeAccessibility::hitTest() +void tst_QQuickAccessible::hitTest() { QQuickView *canvas = new QQuickView; canvas->setSource(testFileUrl("hittest.qml")); @@ -471,7 +380,7 @@ void tst_QDeclarativeAccessibility::hitTest() delete canvas; } -void tst_QDeclarativeAccessibility::checkableTest() +void tst_QQuickAccessible::checkableTest() { QQuickView *canvas = new QQuickView(); canvas->setSource(testFileUrl("checkbuttons.qml")); @@ -496,6 +405,6 @@ void tst_QDeclarativeAccessibility::checkableTest() QVERIFY(!(checkBox2->state().checked)); } -QTEST_MAIN(tst_QDeclarativeAccessibility) +QTEST_MAIN(tst_QQuickAccessible) -#include "tst_qdeclarativeaccessibility.moc" +#include "tst_qquickaccessible.moc" diff --git a/tests/auto/qtquick2/qtquick2.pro b/tests/auto/qtquick2/qtquick2.pro index 0756ddf..8b8c5c9 100644 --- a/tests/auto/qtquick2/qtquick2.pro +++ b/tests/auto/qtquick2/qtquick2.pro @@ -24,6 +24,7 @@ PRIVATETESTS += \ !contains(QT_CONFIG,xmlpatterns):PRIVATETESTS -= qdeclarativexmllistmodel QUICKTESTS = \ + qquickaccessible \ qquickanchors \ qquickanimatedimage \ qquickborderimage \