summaryrefslogtreecommitdiffstats
path: root/tests/auto/other
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/other')
-rw-r--r--tests/auto/other/compiler/tst_compiler.cpp3
-rw-r--r--tests/auto/other/gestures/BLACKLIST5
-rw-r--r--tests/auto/other/macnativeevents/BLACKLIST2
-rw-r--r--tests/auto/other/macnativeevents/tst_macnativeevents.cpp4
-rw-r--r--tests/auto/other/macplist/macplist.pro2
-rw-r--r--tests/auto/other/modeltest/modeltest.cpp581
-rw-r--r--tests/auto/other/modeltest/modeltest.h82
-rw-r--r--tests/auto/other/modeltest/modeltest.pro5
-rw-r--r--tests/auto/other/modeltest/tst_modeltest.cpp300
-rw-r--r--tests/auto/other/other.pro2
-rw-r--r--tests/auto/other/qabstractitemmodelutils/dynamictreemodel.cpp (renamed from tests/auto/other/modeltest/dynamictreemodel.cpp)0
-rw-r--r--tests/auto/other/qabstractitemmodelutils/dynamictreemodel.h (renamed from tests/auto/other/modeltest/dynamictreemodel.h)0
-rw-r--r--tests/auto/other/qaccessibility/accessiblewidgets.h2
-rw-r--r--tests/auto/other/qaccessibility/qaccessibility.pro5
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp289
-rw-r--r--tests/auto/other/qfocusevent/tst_qfocusevent.cpp4
16 files changed, 89 insertions, 1197 deletions
diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp
index 8b59f2758f..0410856790 100644
--- a/tests/auto/other/compiler/tst_compiler.cpp
+++ b/tests/auto/other/compiler/tst_compiler.cpp
@@ -1266,8 +1266,6 @@ void tst_Compiler::cxx11_rvalue_refs()
QCOMPARE(s3, MoveDefinedQString("Hello"));
}
- // supported by MSVC only from November 2013 CTP, but only check for VC2015:
-# if !defined(Q_CC_MSVC) || defined(Q_CC_INTEL) || _MSC_VER >= 1900 // VS14 == VC2015
// we require automatic generation of move special member functions:
{
struct M { MoveDefinedQString s1, s2; };
@@ -1288,7 +1286,6 @@ void tst_Compiler::cxx11_rvalue_refs()
QCOMPARE(m3.s1, MoveDefinedQString("Hello"));
QCOMPARE(m3.s2, MoveDefinedQString("World"));
}
-# endif // MSVC < 2015
#endif
}
diff --git a/tests/auto/other/gestures/BLACKLIST b/tests/auto/other/gestures/BLACKLIST
index bd43b99d39..1d89178fe5 100644
--- a/tests/auto/other/gestures/BLACKLIST
+++ b/tests/auto/other/gestures/BLACKLIST
@@ -1,7 +1,2 @@
[]
-rhel-7.1
-rhel-7.2
-rhel-7.3
rhel-7.4
-[customGesture]
-opensuse-13.1
diff --git a/tests/auto/other/macnativeevents/BLACKLIST b/tests/auto/other/macnativeevents/BLACKLIST
index 1bc530ecc8..32e0b1d50b 100644
--- a/tests/auto/other/macnativeevents/BLACKLIST
+++ b/tests/auto/other/macnativeevents/BLACKLIST
@@ -7,8 +7,6 @@ osx
osx
[testChildWindowInFrontOfStaysOnTopParentWindow]
osx
-[testModifierCtrlWithDontSwapCtrlAndMeta]
-osx
[testMouseMoveLocation]
osx
[testMouseLeftDoubleClick]
diff --git a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp
index e8970e6f24..18585d1856 100644
--- a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp
+++ b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp
@@ -501,10 +501,10 @@ void tst_MacNativeEvents::testModifierCtrlWithDontSwapCtrlAndMeta()
native.append(new QNativeModifierEvent(Qt::NoModifier));
ExpectedEventList expected(&w);
- expected.append(new QKeyEvent(QEvent::KeyPress, Qt::Key_Meta, Qt::NoModifier));
+ expected.append(new QKeyEvent(QEvent::KeyPress, Qt::Key_Control, Qt::NoModifier));
expected.append(new QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::ControlModifier));
expected.append(new QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ControlModifier));
- expected.append(new QKeyEvent(QEvent::KeyRelease, Qt::Key_Meta, Qt::ControlModifier));
+ expected.append(new QKeyEvent(QEvent::KeyRelease, Qt::Key_Control, Qt::ControlModifier));
native.play();
QVERIFY2(expected.waitForAllEvents(), "the test did not receive all expected events!");
diff --git a/tests/auto/other/macplist/macplist.pro b/tests/auto/other/macplist/macplist.pro
index 3a0e2d43d3..5820793cbc 100644
--- a/tests/auto/other/macplist/macplist.pro
+++ b/tests/auto/other/macplist/macplist.pro
@@ -1,7 +1,7 @@
TEMPLATE = subdirs
+test.depends = app
SUBDIRS = app test
-CONFIG += ordered
diff --git a/tests/auto/other/modeltest/modeltest.cpp b/tests/auto/other/modeltest/modeltest.cpp
deleted file mode 100644
index 611f9e904b..0000000000
--- a/tests/auto/other/modeltest/modeltest.cpp
+++ /dev/null
@@ -1,581 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "modeltest.h"
-
-#include <QtCore/QtCore>
-#include <QtTest/QtTest>
-
-/*!
- Connect to all of the models signals. Whenever anything happens recheck everything.
-*/
-ModelTest::ModelTest(QAbstractItemModel *_model, QObject *parent) : QObject(parent),
- model(_model),
- fetchingMore(false)
-{
- if (!model)
- qFatal("%s: model must not be null", Q_FUNC_INFO);
-
- connect(model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
- this, SLOT(runAllTests()));
- connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
- this, SLOT(runAllTests()));
- connect(model, SIGNAL(columnsInserted(QModelIndex,int,int)),
- this, SLOT(runAllTests()));
- connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)),
- this, SLOT(runAllTests()));
- connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
- this, SLOT(runAllTests()));
- connect(model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
- this, SLOT(runAllTests()));
- connect(model, SIGNAL(layoutAboutToBeChanged()), this, SLOT(runAllTests()));
- connect(model, SIGNAL(layoutChanged()), this, SLOT(runAllTests()));
- connect(model, SIGNAL(modelReset()), this, SLOT(runAllTests()));
- connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
- this, SLOT(runAllTests()));
- connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
- this, SLOT(runAllTests()));
- connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)),
- this, SLOT(runAllTests()));
- connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
- this, SLOT(runAllTests()));
-
- // Special checks for changes
- connect(model, SIGNAL(layoutAboutToBeChanged()),
- this, SLOT(layoutAboutToBeChanged()));
- connect(model, SIGNAL(layoutChanged()),
- this, SLOT(layoutChanged()));
-
- connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
- this, SLOT(rowsAboutToBeInserted(QModelIndex,int,int)));
- connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
- this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int)));
- connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)),
- this, SLOT(rowsInserted(QModelIndex,int,int)));
- connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
- this, SLOT(rowsRemoved(QModelIndex,int,int)));
- connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
- this, SLOT(dataChanged(QModelIndex,QModelIndex)));
- connect(model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
- this, SLOT(headerDataChanged(Qt::Orientation,int,int)));
-
- runAllTests();
-}
-
-void ModelTest::runAllTests()
-{
- if (fetchingMore)
- return;
- nonDestructiveBasicTest();
- rowCount();
- columnCount();
- hasIndex();
- index();
- parent();
- data();
-}
-
-/*!
- nonDestructiveBasicTest tries to call a number of the basic functions (not all)
- to make sure the model doesn't outright segfault, testing the functions that makes sense.
-*/
-void ModelTest::nonDestructiveBasicTest()
-{
- QVERIFY(!model->buddy(QModelIndex()).isValid());
- model->canFetchMore(QModelIndex());
- QVERIFY(model->columnCount(QModelIndex()) >= 0);
- QCOMPARE(model->data(QModelIndex()), QVariant());
- fetchingMore = true;
- model->fetchMore(QModelIndex());
- fetchingMore = false;
- Qt::ItemFlags flags = model->flags(QModelIndex());
- QVERIFY(flags == Qt::ItemIsDropEnabled || flags == 0);
- model->hasChildren(QModelIndex());
- model->hasIndex(0, 0);
- model->headerData(0, Qt::Horizontal);
- model->index(0, 0);
- model->itemData(QModelIndex());
- QVariant cache;
- model->match(QModelIndex(), -1, cache);
- model->mimeTypes();
- QVERIFY(!model->parent(QModelIndex()).isValid());
- QVERIFY(model->rowCount() >= 0);
- QVariant variant;
- model->setData(QModelIndex(), variant, -1);
- model->setHeaderData(-1, Qt::Horizontal, QVariant());
- model->setHeaderData(999999, Qt::Horizontal, QVariant());
- QMap<int, QVariant> roles;
- model->sibling(0, 0, QModelIndex());
- model->span(QModelIndex());
- model->supportedDropActions();
-}
-
-/*!
- Tests model's implementation of QAbstractItemModel::rowCount() and hasChildren()
-
- Models that are dynamically populated are not as fully tested here.
- */
-void ModelTest::rowCount()
-{
-// qDebug() << "rc";
- // check top row
- QModelIndex topIndex = model->index(0, 0, QModelIndex());
- int rows = model->rowCount(topIndex);
- QVERIFY(rows >= 0);
- if (rows > 0)
- QVERIFY(model->hasChildren(topIndex));
-
- QModelIndex secondLevelIndex = model->index(0, 0, topIndex);
- if (secondLevelIndex.isValid()) { // not the top level
- // check a row count where parent is valid
- rows = model->rowCount(secondLevelIndex);
- QVERIFY(rows >= 0);
- if (rows > 0)
- QVERIFY(model->hasChildren(secondLevelIndex));
- }
-
- // The models rowCount() is tested more extensively in checkChildren(),
- // but this catches the big mistakes
-}
-
-/*!
- Tests model's implementation of QAbstractItemModel::columnCount() and hasChildren()
- */
-void ModelTest::columnCount()
-{
- // check top row
- QModelIndex topIndex = model->index(0, 0, QModelIndex());
- QVERIFY(model->columnCount(topIndex) >= 0);
-
- // check a column count where parent is valid
- QModelIndex childIndex = model->index(0, 0, topIndex);
- if (childIndex.isValid())
- QVERIFY(model->columnCount(childIndex) >= 0);
-
- // columnCount() is tested more extensively in checkChildren(),
- // but this catches the big mistakes
-}
-
-/*!
- Tests model's implementation of QAbstractItemModel::hasIndex()
- */
-void ModelTest::hasIndex()
-{
-// qDebug() << "hi";
- // Make sure that invalid values returns an invalid index
- QVERIFY(!model->hasIndex(-2, -2));
- QVERIFY(!model->hasIndex(-2, 0));
- QVERIFY(!model->hasIndex(0, -2));
-
- int rows = model->rowCount();
- int columns = model->columnCount();
-
- // check out of bounds
- QVERIFY(!model->hasIndex(rows, columns));
- QVERIFY(!model->hasIndex(rows + 1, columns + 1));
-
- if (rows > 0)
- QVERIFY(model->hasIndex(0, 0));
-
- // hasIndex() is tested more extensively in checkChildren(),
- // but this catches the big mistakes
-}
-
-/*!
- Tests model's implementation of QAbstractItemModel::index()
- */
-void ModelTest::index()
-{
-// qDebug() << "i";
- // Make sure that invalid values returns an invalid index
- QVERIFY(!model->index(-2, -2).isValid());
- QVERIFY(!model->index(-2, 0).isValid());
- QVERIFY(!model->index(0, -2).isValid());
-
- int rows = model->rowCount();
- int columns = model->columnCount();
-
- if (rows == 0)
- return;
-
- // Catch off by one errors
- QVERIFY(!model->index(rows, columns).isValid());
- QVERIFY(model->index(0, 0).isValid());
-
- // Make sure that the same index is *always* returned
- QModelIndex a = model->index(0, 0);
- QModelIndex b = model->index(0, 0);
- QCOMPARE(a, b);
-
- // index() is tested more extensively in checkChildren(),
- // but this catches the big mistakes
-}
-
-/*!
- Tests model's implementation of QAbstractItemModel::parent()
- */
-void ModelTest::parent()
-{
-// qDebug() << "p";
- // Make sure the model won't crash and will return an invalid QModelIndex
- // when asked for the parent of an invalid index.
- QVERIFY(!model->parent(QModelIndex()).isValid());
-
- if (model->rowCount() == 0)
- return;
-
- // Column 0 | Column 1 |
- // QModelIndex() | |
- // \- topIndex | topIndex1 |
- // \- childIndex | childIndex1 |
-
- // Common error test #1, make sure that a top level index has a parent
- // that is a invalid QModelIndex.
- QModelIndex topIndex = model->index(0, 0, QModelIndex());
- QVERIFY(!model->parent(topIndex).isValid());
-
- // Common error test #2, make sure that a second level index has a parent
- // that is the first level index.
- if (model->rowCount(topIndex) > 0) {
- QModelIndex childIndex = model->index(0, 0, topIndex);
- QCOMPARE(model->parent(childIndex), topIndex);
- }
-
- // Common error test #3, the second column should NOT have the same children
- // as the first column in a row.
- // Usually the second column shouldn't have children.
- QModelIndex topIndex1 = model->index(0, 1, QModelIndex());
- if (model->rowCount(topIndex1) > 0) {
- QModelIndex childIndex = model->index(0, 0, topIndex);
- QModelIndex childIndex1 = model->index(0, 0, topIndex1);
- QVERIFY(childIndex != childIndex1);
- }
-
- // Full test, walk n levels deep through the model making sure that all
- // parent's children correctly specify their parent.
- checkChildren(QModelIndex());
-}
-
-/*!
- Called from the parent() test.
-
- A model that returns an index of parent X should also return X when asking
- for the parent of the index.
-
- This recursive function does pretty extensive testing on the whole model in an
- effort to catch edge cases.
-
- This function assumes that rowCount(), columnCount() and index() already work.
- If they have a bug it will point it out, but the above tests should have already
- found the basic bugs because it is easier to figure out the problem in
- those tests then this one.
- */
-void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth)
-{
- // First just try walking back up the tree.
- QModelIndex p = parent;
- while (p.isValid())
- p = p.parent();
-
- // For models that are dynamically populated
- if (model->canFetchMore(parent)) {
- fetchingMore = true;
- model->fetchMore(parent);
- fetchingMore = false;
- }
-
- int rows = model->rowCount(parent);
- int columns = model->columnCount(parent);
-
- if (rows > 0)
- QVERIFY(model->hasChildren(parent));
-
- // Some further testing against rows(), columns(), and hasChildren()
- QVERIFY(rows >= 0);
- QVERIFY(columns >= 0);
- if (rows > 0)
- QVERIFY(model->hasChildren(parent));
-
- //qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows
- // << "columns:" << columns << "parent column:" << parent.column();
-
- const QModelIndex topLeftChild = model->index(0, 0, parent);
-
- QVERIFY(!model->hasIndex(rows + 1, 0, parent));
- for (int r = 0; r < rows; ++r) {
- if (model->canFetchMore(parent)) {
- fetchingMore = true;
- model->fetchMore(parent);
- fetchingMore = false;
- }
- QVERIFY(!model->hasIndex(r, columns + 1, parent));
- for (int c = 0; c < columns; ++c) {
- QVERIFY(model->hasIndex(r, c, parent));
- QModelIndex index = model->index(r, c, parent);
- // rowCount() and columnCount() said that it existed...
- if (!index.isValid())
- qWarning() << "Got invalid index at row=" << r << "col=" << c << "parent=" << parent;
- QVERIFY(index.isValid());
-
- // index() should always return the same index when called twice in a row
- QModelIndex modifiedIndex = model->index(r, c, parent);
- QCOMPARE(index, modifiedIndex);
-
- // Make sure we get the same index if we request it twice in a row
- QModelIndex a = model->index(r, c, parent);
- QModelIndex b = model->index(r, c, parent);
- QCOMPARE(a, b);
-
- {
- const QModelIndex sibling = model->sibling(r, c, topLeftChild);
- QCOMPARE(index, sibling);
- }
- {
- const QModelIndex sibling = topLeftChild.sibling(r, c);
- QCOMPARE(index, sibling);
- }
-
- // Some basic checking on the index that is returned
- QCOMPARE(index.model(), model);
- QCOMPARE(index.row(), r);
- QCOMPARE(index.column(), c);
- // While you can technically return a QVariant usually this is a sign
- // of a bug in data(). Disable if this really is ok in your model.
-// QVERIFY( model->data ( index, Qt::DisplayRole ).isValid() );
-
- // If the next test fails here is some somewhat useful debug you play with.
-
- if (model->parent(index) != parent) {
- qDebug() << r << c << currentDepth << model->data(index).toString()
- << model->data(parent).toString();
- qDebug() << index << parent << model->parent(index);
-// And a view that you can even use to show the model.
-// QTreeView view;
-// view.setModel(model);
-// view.show();
- }
-
- // Check that we can get back our real parent.
- QCOMPARE(model->parent(index), parent);
-
- // recursively go down the children
- if (model->hasChildren(index) && currentDepth < 10) {
- //qDebug() << r << c << "has children" << model->rowCount(index);
- checkChildren(index, ++currentDepth);
- }/* else { if (currentDepth >= 10) qDebug() << "checked 10 deep"; };*/
-
- // make sure that after testing the children that the index doesn't change.
- QModelIndex newerIndex = model->index(r, c, parent);
- QCOMPARE(index, newerIndex);
- }
- }
-}
-
-/*!
- Tests model's implementation of QAbstractItemModel::data()
- */
-void ModelTest::data()
-{
- // Invalid index should return an invalid qvariant
- QVERIFY(!model->data(QModelIndex()).isValid());
-
- if (model->rowCount() == 0)
- return;
-
- // A valid index should have a valid QVariant data
- QVERIFY(model->index(0, 0).isValid());
-
- // shouldn't be able to set data on an invalid index
- QVERIFY(!model->setData(QModelIndex(), QLatin1String("foo"), Qt::DisplayRole));
-
- // General Purpose roles that should return a QString
- QVariant variant = model->data(model->index(0, 0), Qt::ToolTipRole);
- if (variant.isValid())
- QVERIFY(variant.canConvert<QString>());
- variant = model->data(model->index(0, 0), Qt::StatusTipRole);
- if (variant.isValid())
- QVERIFY(variant.canConvert<QString>());
- variant = model->data(model->index(0, 0), Qt::WhatsThisRole);
- if (variant.isValid())
- QVERIFY(variant.canConvert<QString>());
-
- // General Purpose roles that should return a QSize
- variant = model->data(model->index(0, 0), Qt::SizeHintRole);
- if (variant.isValid())
- QVERIFY(variant.canConvert<QSize>());
-
- // General Purpose roles that should return a QFont
- QVariant fontVariant = model->data(model->index(0, 0), Qt::FontRole);
- if (fontVariant.isValid())
- QVERIFY(fontVariant.canConvert<QFont>());
-
- // Check that the alignment is one we know about
- QVariant textAlignmentVariant = model->data(model->index(0, 0), Qt::TextAlignmentRole);
- if (textAlignmentVariant.isValid()) {
- Qt::Alignment alignment = textAlignmentVariant.value<Qt::Alignment>();
- QCOMPARE(alignment, (alignment & (Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask)));
- }
-
- // General Purpose roles that should return a QColor
- QVariant colorVariant = model->data(model->index(0, 0), Qt::BackgroundColorRole);
- if (colorVariant.isValid())
- QVERIFY(colorVariant.canConvert<QColor>());
-
- colorVariant = model->data(model->index(0, 0), Qt::TextColorRole);
- if (colorVariant.isValid())
- QVERIFY(colorVariant.canConvert<QColor>());
-
- // Check that the "check state" is one we know about.
- QVariant checkStateVariant = model->data(model->index(0, 0), Qt::CheckStateRole);
- if (checkStateVariant.isValid()) {
- int state = checkStateVariant.toInt();
- QVERIFY(state == Qt::Unchecked
- || state == Qt::PartiallyChecked
- || state == Qt::Checked);
- }
-}
-
-/*!
- Store what is about to be inserted to make sure it actually happens
-
- \sa rowsInserted()
- */
-void ModelTest::rowsAboutToBeInserted(const QModelIndex &parent, int start, int /* end */)
-{
-// Q_UNUSED(end);
-// qDebug() << "rowsAboutToBeInserted" << "start=" << start << "end=" << end << "parent=" << model->data ( parent ).toString()
-// << "current count of parent=" << model->rowCount ( parent ); // << "display of last=" << model->data( model->index(start-1, 0, parent) );
-// qDebug() << model->index(start-1, 0, parent) << model->data( model->index(start-1, 0, parent) );
- Changing c;
- c.parent = parent;
- c.oldSize = model->rowCount(parent);
- c.last = model->data(model->index(start - 1, 0, parent));
- c.next = model->data(model->index(start, 0, parent));
- insert.push(c);
-}
-
-/*!
- Confirm that what was said was going to happen actually did
-
- \sa rowsAboutToBeInserted()
- */
-void ModelTest::rowsInserted(const QModelIndex &parent, int start, int end)
-{
- Changing c = insert.pop();
- QCOMPARE(parent, c.parent);
-// qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize
-// << "parent=" << model->data ( parent ).toString() << "current rowcount of parent=" << model->rowCount ( parent );
-
-// for (int ii=start; ii <= end; ii++)
-// {
-// qDebug() << "itemWasInserted:" << ii << model->data ( model->index ( ii, 0, parent ));
-// }
-// qDebug();
-
- QCOMPARE(model->rowCount(parent), c.oldSize + (end - start + 1));
- QCOMPARE(model->data(model->index(start - 1, 0, c.parent)), c.last);
-
- if (c.next != model->data(model->index(end + 1, 0, c.parent))) {
- qDebug() << start << end;
- for (int i = 0; i < model->rowCount(); ++i)
- qDebug() << model->index(i, 0).data().toString();
- qDebug() << c.next << model->data(model->index(end + 1, 0, c.parent));
- }
-
- QCOMPARE(model->data(model->index(end + 1, 0, c.parent)), c.next);
-}
-
-void ModelTest::layoutAboutToBeChanged()
-{
- for (int i = 0; i < qBound(0, model->rowCount(), 100); ++i)
- changing.append(QPersistentModelIndex(model->index(i, 0)));
-}
-
-void ModelTest::layoutChanged()
-{
- for (int i = 0; i < changing.count(); ++i) {
- QPersistentModelIndex p = changing[i];
- QCOMPARE(model->index(p.row(), p.column(), p.parent()), QModelIndex(p));
- }
- changing.clear();
-}
-
-/*!
- Store what is about to be inserted to make sure it actually happens
-
- \sa rowsRemoved()
- */
-void ModelTest::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
-{
- qDebug() << "ratbr" << parent << start << end;
- Changing c;
- c.parent = parent;
- c.oldSize = model->rowCount(parent);
- c.last = model->data(model->index(start - 1, 0, parent));
- c.next = model->data(model->index(end + 1, 0, parent));
- remove.push(c);
-}
-
-/*!
- Confirm that what was said was going to happen actually did
-
- \sa rowsAboutToBeRemoved()
- */
-void ModelTest::rowsRemoved(const QModelIndex &parent, int start, int end)
-{
- qDebug() << "rr" << parent << start << end;
- Changing c = remove.pop();
- QCOMPARE(parent, c.parent);
- QCOMPARE(model->rowCount(parent), c.oldSize - (end - start + 1));
- QCOMPARE(model->data(model->index(start - 1, 0, c.parent)), c.last);
- QCOMPARE(model->data(model->index(start, 0, c.parent)), c.next);
-}
-
-void ModelTest::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
-{
- QVERIFY(topLeft.isValid());
- QVERIFY(bottomRight.isValid());
- QModelIndex commonParent = bottomRight.parent();
- QCOMPARE(topLeft.parent(), commonParent);
- QVERIFY(topLeft.row() <= bottomRight.row());
- QVERIFY(topLeft.column() <= bottomRight.column());
- int rowCount = model->rowCount(commonParent);
- int columnCount = model->columnCount(commonParent);
- QVERIFY(bottomRight.row() < rowCount);
- QVERIFY(bottomRight.column() < columnCount);
-}
-
-void ModelTest::headerDataChanged(Qt::Orientation orientation, int start, int end)
-{
- QVERIFY(start >= 0);
- QVERIFY(end >= 0);
- QVERIFY(start <= end);
- int itemCount = orientation == Qt::Vertical ? model->rowCount() : model->columnCount();
- QVERIFY(start < itemCount);
- QVERIFY(end < itemCount);
-}
diff --git a/tests/auto/other/modeltest/modeltest.h b/tests/auto/other/modeltest/modeltest.h
deleted file mode 100644
index 4676bf4434..0000000000
--- a/tests/auto/other/modeltest/modeltest.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MODELTEST_H
-#define MODELTEST_H
-
-#include <QtCore/QObject>
-#include <QtCore/QAbstractItemModel>
-#include <QtCore/QStack>
-
-class ModelTest : public QObject
-{
- Q_OBJECT
-
-public:
- ModelTest(QAbstractItemModel *model, QObject *parent = 0);
-
-private Q_SLOTS:
- void nonDestructiveBasicTest();
- void rowCount();
- void columnCount();
- void hasIndex();
- void index();
- void parent();
- void data();
-
-protected Q_SLOTS:
- void runAllTests();
- void layoutAboutToBeChanged();
- void layoutChanged();
- void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
- void rowsInserted(const QModelIndex &parent, int start, int end);
- void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
- void rowsRemoved(const QModelIndex &parent, int start, int end);
- void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
- void headerDataChanged(Qt::Orientation orientation, int start, int end);
-
-private:
- void checkChildren(const QModelIndex &parent, int currentDepth = 0);
-
- QAbstractItemModel *model;
-
- struct Changing {
- QModelIndex parent;
- int oldSize;
- QVariant last;
- QVariant next;
- };
- QStack<Changing> insert;
- QStack<Changing> remove;
-
- bool fetchingMore;
-
- QList<QPersistentModelIndex> changing;
-};
-
-#endif
diff --git a/tests/auto/other/modeltest/modeltest.pro b/tests/auto/other/modeltest/modeltest.pro
deleted file mode 100644
index 8e96058449..0000000000
--- a/tests/auto/other/modeltest/modeltest.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG += testcase
-TARGET = tst_modeltest
-QT += widgets testlib
-SOURCES += tst_modeltest.cpp modeltest.cpp dynamictreemodel.cpp
-HEADERS += modeltest.h dynamictreemodel.h
diff --git a/tests/auto/other/modeltest/tst_modeltest.cpp b/tests/auto/other/modeltest/tst_modeltest.cpp
deleted file mode 100644
index e2d002844b..0000000000
--- a/tests/auto/other/modeltest/tst_modeltest.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtGui/QtGui>
-#include <QtWidgets/QtWidgets>
-
-#include "modeltest.h"
-#include "dynamictreemodel.h"
-
-class tst_ModelTest : public QObject
-{
- Q_OBJECT
-
-private slots:
- void stringListModel();
- void treeWidgetModel();
- void standardItemModel();
- void testInsertThroughProxy();
- void moveSourceItems();
- void testResetThroughProxy();
-};
-
-/*
- tests
-*/
-
-void tst_ModelTest::stringListModel()
-{
- QStringListModel model;
- QSortFilterProxyModel proxy;
-
- ModelTest t1(&model);
- ModelTest t2(&proxy);
-
- proxy.setSourceModel(&model);
-
- model.setStringList(QStringList() << "2" << "3" << "1");
- model.setStringList(QStringList() << "a" << "e" << "plop" << "b" << "c");
-
- proxy.setDynamicSortFilter(true);
- proxy.setFilterRegExp(QRegExp("[^b]"));
-}
-
-void tst_ModelTest::treeWidgetModel()
-{
- QTreeWidget widget;
-
- ModelTest t1(widget.model());
-
- QTreeWidgetItem *root = new QTreeWidgetItem(&widget, QStringList("root"));
- for (int i = 0; i < 20; ++i)
- new QTreeWidgetItem(root, QStringList(QString::number(i)));
- QTreeWidgetItem *remove = root->child(2);
- root->removeChild(remove);
- QTreeWidgetItem *parent = new QTreeWidgetItem(&widget, QStringList("parent"));
- new QTreeWidgetItem(parent, QStringList("child"));
- widget.setItemHidden(parent, true);
-
- widget.sortByColumn(0);
-}
-
-void tst_ModelTest::standardItemModel()
-{
- QStandardItemModel model(10, 10);
- QSortFilterProxyModel proxy;
-
- ModelTest t1(&model);
- ModelTest t2(&proxy);
-
- proxy.setSourceModel(&model);
-
- model.insertRows(2, 5);
- model.removeRows(4, 5);
-
- model.insertColumns(2, 5);
- model.removeColumns(4, 5);
-
- model.insertRows(0, 5, model.index(1, 1));
- model.insertColumns(0, 5, model.index(1, 3));
-}
-
-void tst_ModelTest::testInsertThroughProxy()
-{
- DynamicTreeModel *model = new DynamicTreeModel(this);
-
- QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
- proxy->setSourceModel(model);
-
- new ModelTest(proxy, this);
-
- ModelInsertCommand *insertCommand = new ModelInsertCommand(model, this);
- insertCommand->setNumCols(4);
- insertCommand->setStartRow(0);
- insertCommand->setEndRow(9);
- // Parent is QModelIndex()
- insertCommand->doCommand();
-
- insertCommand = new ModelInsertCommand(model, this);
- insertCommand->setNumCols(4);
- insertCommand->setAncestorRowNumbers(QList<int>() << 5);
- insertCommand->setStartRow(0);
- insertCommand->setEndRow(9);
- insertCommand->doCommand();
-
- ModelMoveCommand *moveCommand = new ModelMoveCommand(model, this);
- moveCommand->setNumCols(4);
- moveCommand->setStartRow(0);
- moveCommand->setEndRow(0);
- moveCommand->setDestRow(9);
- moveCommand->setDestAncestors(QList<int>() << 5);
- moveCommand->doCommand();
-}
-
-/**
- Makes the persistent index list publicly accessible
-*/
-class AccessibleProxyModel : public QSortFilterProxyModel
-{
- Q_OBJECT
-public:
- AccessibleProxyModel(QObject *parent = 0) : QSortFilterProxyModel(parent)
- {
- }
-
- QModelIndexList persistent()
- {
- return persistentIndexList();
- }
-};
-
-class ObservingObject : public QObject
-{
- Q_OBJECT
-public:
- ObservingObject(AccessibleProxyModel *proxy, QObject *parent = 0) :
- QObject(parent),
- m_proxy(proxy),
- storePersistentFailureCount(0),
- checkPersistentFailureCount(0)
- {
- connect(m_proxy, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
- SLOT(storePersistent()));
- connect(m_proxy, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
- SLOT(checkPersistent()));
- }
-
-public slots:
-
- void storePersistent(const QModelIndex &parent)
- {
- for (int row = 0; row < m_proxy->rowCount(parent); ++row) {
- QModelIndex proxyIndex = m_proxy->index(row, 0, parent);
- QModelIndex sourceIndex = m_proxy->mapToSource(proxyIndex);
- if (!proxyIndex.isValid()) {
- qWarning("%s: Invalid proxy index", Q_FUNC_INFO);
- ++storePersistentFailureCount;
- }
- if (!sourceIndex.isValid()) {
- qWarning("%s: invalid source index", Q_FUNC_INFO);
- ++storePersistentFailureCount;
- }
- m_persistentSourceIndexes.append(sourceIndex);
- m_persistentProxyIndexes.append(proxyIndex);
- if (m_proxy->hasChildren(proxyIndex))
- storePersistent(proxyIndex);
- }
- }
-
- void storePersistent()
- {
- // This method is called from rowsAboutToBeMoved. Persistent indexes should be valid
- foreach (const QModelIndex &idx, m_persistentProxyIndexes)
- if (!idx.isValid()) {
- qWarning("%s: persistentProxyIndexes contains invalid index", Q_FUNC_INFO);
- ++storePersistentFailureCount;
- }
-
- if (!m_proxy->persistent().isEmpty()) {
- qWarning("%s: proxy should have no persistent indexes when storePersistent called",
- Q_FUNC_INFO);
- ++storePersistentFailureCount;
- }
- storePersistent(QModelIndex());
- if (m_proxy->persistent().isEmpty()) {
- qWarning("%s: proxy should have persistent index after storePersistent called",
- Q_FUNC_INFO);
- ++storePersistentFailureCount;
- }
- }
-
- void checkPersistent()
- {
- for (int row = 0; row < m_persistentProxyIndexes.size(); ++row) {
- m_persistentProxyIndexes.at(row);
- m_persistentSourceIndexes.at(row);
- }
- for (int row = 0; row < m_persistentProxyIndexes.size(); ++row) {
- QModelIndex updatedProxy = m_persistentProxyIndexes.at(row);
- QModelIndex updatedSource = m_persistentSourceIndexes.at(row);
- if (m_proxy->mapToSource(updatedProxy) != updatedSource) {
- qWarning("%s: check failed at row %d", Q_FUNC_INFO, row);
- ++checkPersistentFailureCount;
- }
- }
- m_persistentSourceIndexes.clear();
- m_persistentProxyIndexes.clear();
- }
-
-private:
- AccessibleProxyModel *m_proxy;
- QList<QPersistentModelIndex> m_persistentSourceIndexes;
- QList<QPersistentModelIndex> m_persistentProxyIndexes;
-public:
- int storePersistentFailureCount;
- int checkPersistentFailureCount;
-};
-
-void tst_ModelTest::moveSourceItems()
-{
- DynamicTreeModel *model = new DynamicTreeModel(this);
- AccessibleProxyModel *proxy = new AccessibleProxyModel(this);
- proxy->setSourceModel(model);
-
- ModelInsertCommand *insertCommand = new ModelInsertCommand(model, this);
- insertCommand->setStartRow(0);
- insertCommand->setEndRow(2);
- insertCommand->doCommand();
-
- insertCommand = new ModelInsertCommand(model, this);
- insertCommand->setAncestorRowNumbers(QList<int>() << 1);
- insertCommand->setStartRow(0);
- insertCommand->setEndRow(2);
- insertCommand->doCommand();
-
- ObservingObject observer(proxy);
-
- ModelMoveCommand *moveCommand = new ModelMoveCommand(model, this);
- moveCommand->setStartRow(0);
- moveCommand->setEndRow(0);
- moveCommand->setDestAncestors(QList<int>() << 1);
- moveCommand->setDestRow(0);
- moveCommand->doCommand();
-
- QCOMPARE(observer.storePersistentFailureCount, 0);
- QCOMPARE(observer.checkPersistentFailureCount, 0);
-}
-
-void tst_ModelTest::testResetThroughProxy()
-{
- DynamicTreeModel *model = new DynamicTreeModel(this);
-
- ModelInsertCommand *insertCommand = new ModelInsertCommand(model, this);
- insertCommand->setStartRow(0);
- insertCommand->setEndRow(2);
- insertCommand->doCommand();
-
- QPersistentModelIndex persistent = model->index(0, 0);
-
- AccessibleProxyModel *proxy = new AccessibleProxyModel(this);
- proxy->setSourceModel(model);
-
- ObservingObject observer(proxy);
- observer.storePersistent();
-
- ModelResetCommand *resetCommand = new ModelResetCommand(model, this);
- resetCommand->setNumCols(0);
- resetCommand->doCommand();
-
- QCOMPARE(observer.storePersistentFailureCount, 0);
- QCOMPARE(observer.checkPersistentFailureCount, 0);
-}
-
-QTEST_MAIN(tst_ModelTest)
-#include "tst_modeltest.moc"
diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro
index 0e84b187fa..4119a40279 100644
--- a/tests/auto/other/other.pro
+++ b/tests/auto/other/other.pro
@@ -9,7 +9,6 @@ SUBDIRS=\
macgui \
macnativeevents \
macplist \
- modeltest \
networkselftest \
qaccessibility \
# qaccessibilitylinux \ # QTBUG-44434
@@ -32,7 +31,6 @@ SUBDIRS=\
gestures \
lancelot \
languagechange \
- modeltest \
qaccessibility \
qfocusevent \
qnetworkaccessmanager_and_qprogressdialog \
diff --git a/tests/auto/other/modeltest/dynamictreemodel.cpp b/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.cpp
index fc979bce2d..fc979bce2d 100644
--- a/tests/auto/other/modeltest/dynamictreemodel.cpp
+++ b/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.cpp
diff --git a/tests/auto/other/modeltest/dynamictreemodel.h b/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.h
index 709751dd27..709751dd27 100644
--- a/tests/auto/other/modeltest/dynamictreemodel.h
+++ b/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.h
diff --git a/tests/auto/other/qaccessibility/accessiblewidgets.h b/tests/auto/other/qaccessibility/accessiblewidgets.h
index 0c337a72f4..d436f81d17 100644
--- a/tests/auto/other/qaccessibility/accessiblewidgets.h
+++ b/tests/auto/other/qaccessibility/accessiblewidgets.h
@@ -47,7 +47,7 @@ class QtTestAccessibleWidgetIface: public QAccessibleWidget
{
public:
QtTestAccessibleWidgetIface(QtTestAccessibleWidget *w): QAccessibleWidget(w) {}
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE
+ QString text(QAccessible::Text t) const override
{
if (t == QAccessible::Help)
return QString::fromLatin1("Help yourself");
diff --git a/tests/auto/other/qaccessibility/qaccessibility.pro b/tests/auto/other/qaccessibility/qaccessibility.pro
index bfe652d25a..3587c38e76 100644
--- a/tests/auto/other/qaccessibility/qaccessibility.pro
+++ b/tests/auto/other/qaccessibility/qaccessibility.pro
@@ -8,9 +8,8 @@ HEADERS += accessiblewidgets.h
unix:!darwin:!haiku:!integity: LIBS += -lm
win32 {
- !*g++:!winrt {
- include(../../../../src/3rdparty/iaccessible2/iaccessible2.pri)
- DEFINES += QT_SUPPORTS_IACCESSIBLE2
+ !winrt {
+ QT += windowsuiautomation_support-private
}
LIBS += -luuid -loleacc -loleaut32 -lole32
}
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 29fbffa541..b5d45adadb 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -32,12 +32,10 @@
# include <QtCore/qt_windows.h>
#ifndef Q_OS_WINRT
# include <oleacc.h>
+# include <QtWindowsUIAutomationSupport/private/qwindowsuiawrapper_p.h>
#endif
# include <servprov.h>
# include <winuser.h>
-# ifdef QT_SUPPORTS_IACCESSIBLE2
-# include <ia2_api_all.h>
-# endif
#endif
#include <QtTest/QtTest>
#include <QtGui>
@@ -1697,7 +1695,7 @@ static QRect characterRect(const QTextEdit &edit, int offset)
++it;
QFontMetrics fm(it.fragment().charFormat().font());
QChar ch = edit.document()->characterAt(offset);
- int w = fm.width(ch);
+ int w = fm.horizontalAdvance(ch);
int h = fm.height();
qreal x = line.cursorToX(relativeOffset);
@@ -1768,9 +1766,9 @@ void tst_QAccessibility::textEditTest()
QCOMPARE(endOffset, 31);
QCOMPARE(textIface->characterCount(), 48);
QFontMetrics fm(edit.document()->defaultFont());
- QCOMPARE(textIface->characterRect(0).size(), QSize(fm.width("h"), fm.height()));
- QCOMPARE(textIface->characterRect(5).size(), QSize(fm.width(" "), fm.height()));
- QCOMPARE(textIface->characterRect(6).size(), QSize(fm.width("w"), fm.height()));
+ QCOMPARE(textIface->characterRect(0).size(), QSize(fm.horizontalAdvance("h"), fm.height()));
+ QCOMPARE(textIface->characterRect(5).size(), QSize(fm.horizontalAdvance(" "), fm.height()));
+ QCOMPARE(textIface->characterRect(6).size(), QSize(fm.horizontalAdvance("w"), fm.height()));
int offset = 10;
QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("d"));
@@ -3738,7 +3736,7 @@ void tst_QAccessibility::bridgeTest()
// For now this is a simple test to see if the bridge is working at all.
// Ideally it should be extended to test all aspects of the bridge.
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
- // First, test MSAA part of bridge
+
QWidget window;
QVBoxLayout *lay = new QVBoxLayout(&window);
QPushButton *button = new QPushButton(tr("Push me"), &window);
@@ -3775,10 +3773,7 @@ void tst_QAccessibility::bridgeTest()
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
-
- /**************************************************
- * QPushButton
- **************************************************/
+ // Validate button position through the accessible interface.
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(button);
QPoint buttonPos = button->mapToGlobal(QPoint(0,0));
QRect buttonRect = iface->rect();
@@ -3787,231 +3782,113 @@ void tst_QAccessibility::bridgeTest()
// All set, now test the bridge.
const QPoint nativePos = QHighDpi::toNativePixels(buttonRect.center(), window.windowHandle());
POINT pt{nativePos.x(), nativePos.y()};
- IAccessible *iaccButton;
- VARIANT varChild;
- HRESULT hr = ::AccessibleObjectFromPoint(pt, &iaccButton, &varChild);
+ // Initialize COM stuff.
+ HRESULT hr = CoInitialize(nullptr);
QVERIFY(SUCCEEDED(hr));
- VARIANT varSELF;
- varSELF.vt = VT_I4;
- varSELF.lVal = 0;
- // **** Test get_accRole ****
- VARIANT varRole;
- hr = iaccButton->get_accRole(varSELF, &varRole);
+ // Get UI Automation interface.
+ IUIAutomation *automation = nullptr;
+ hr = CoCreateInstance(CLSID_CUIAutomation, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&automation));
QVERIFY(SUCCEEDED(hr));
- QCOMPARE(varRole.vt, (VARTYPE)VT_I4);
- QCOMPARE(varRole.lVal, (LONG)ROLE_SYSTEM_PUSHBUTTON);
-
- // **** Test accLocation ****
- long x, y, w, h;
- // Do not crash on insane arguments.
- varChild.lVal = 999;
- hr = iaccButton->accLocation(&x, &y, &w, &h, varChild);
- QCOMPARE(SUCCEEDED(hr), false);
-
- hr = iaccButton->accLocation(&x, &y, &w, &h, varSELF);
- QCOMPARE(buttonRect, QHighDpi::fromNativePixels(QRect(x, y, w, h), window.windowHandle()));
-
-#ifdef QT_SUPPORTS_IACCESSIBLE2
- // Test IAccessible2 part of bridge
- if (IAccessible2 *ia2Button = (IAccessible2*)queryIA2(iaccButton, IID_IAccessible2)) {
- // The control supports IAccessible2.
- // ia2Button is the reference to the accessible object's IAccessible2 interface.
-
- /***** Test IAccessibleComponent *****/
- IAccessibleComponent *ia2Component = 0;
- hr = ia2Button->QueryInterface(IID_IAccessibleComponent, (void**)&ia2Component);
- QVERIFY(SUCCEEDED(hr));
- long x, y;
- hr = ia2Component->get_locationInParent(&x, &y);
- QVERIFY(SUCCEEDED(hr));
- QCOMPARE(button->pos(), QHighDpi::fromNativePixels(QPoint(x, y), window.windowHandle()));
- ia2Component->Release();
-
- /***** Test IAccessibleAction *****/
- IAccessibleAction *ia2Action = 0;
- hr = ia2Button->QueryInterface(IID_IAccessibleAction, (void**)&ia2Action);
- QVERIFY(SUCCEEDED(hr));
- QVERIFY(ia2Action);
- long nActions;
- ia2Action->nActions(&nActions);
- QVERIFY(nActions >= 1); // "Press" and "SetFocus"
- BSTR actionName;
- ia2Action->get_name(0, &actionName);
- QString name((QChar*)actionName);
- ::SysFreeString(actionName);
- QCOMPARE(name, QAccessibleActionInterface::pressAction());
- ia2Action->Release();
-
- /***** Test IAccessibleRelation *****/
- long nRelations = 0;
- hr = ia2Button->get_nRelations(&nRelations);
- QVERIFY(SUCCEEDED(hr));
- QCOMPARE(nRelations, (long)1);
-
- IAccessibleRelation **relations = (IAccessibleRelation **)::CoTaskMemAlloc(sizeof(IAccessibleRelation *) * 4);
- hr = ia2Button->get_relations(4, relations, &nRelations);
- QVERIFY(SUCCEEDED(hr));
- QCOMPARE(nRelations, (long)1);
-
- IAccessibleRelation *relation = relations[0];
- BSTR relType;
- hr = relation->get_relationType(&relType);
- QCOMPARE(QString::fromWCharArray(relType), QLatin1String("labelFor"));
- ::SysFreeString(relType);
-
- long nTargets;
- relation->get_nTargets(&nTargets);
- QCOMPARE(nTargets, (long)1);
- IAccessible *target; // target is the label
- hr = relation->get_target(0, (IUnknown**)&target);
- QVERIFY(SUCCEEDED(hr));
-
- VARIANT varRole;
- hr = target->get_accRole(varSELF, &varRole);
- QVERIFY(SUCCEEDED(hr));
- Q_ASSERT(varRole.vt == (VARTYPE)VT_I4);
- QCOMPARE(varRole.lVal, (LONG)ROLE_SYSTEM_STATICTEXT);
+ // Get button element from UI Automation using point.
+ IUIAutomationElement *buttonElement = nullptr;
+ hr = automation->ElementFromPoint(pt, &buttonElement);
+ QVERIFY(SUCCEEDED(hr));
- BSTR buttonName;
- hr = target->get_accName(varSELF, &buttonName);
- QVERIFY(SUCCEEDED(hr));
+ // Check that it has a button control type ID.
+ CONTROLTYPEID controlTypeId;
+ hr = buttonElement->get_CurrentControlType(&controlTypeId);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(controlTypeId, UIA_ButtonControlTypeId);
- QCOMPARE(QString::fromWCharArray(buttonName), QLatin1String("Push my buddy"));
- ::SysFreeString(buttonName);
- ::CoTaskMemFree(relations);
+ // Test the bounding rectangle.
+ RECT rect;
+ hr = buttonElement->get_CurrentBoundingRectangle(&rect);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(buttonRect, QRect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top));
- // Done testing
- ia2Button->Release();
- }
-#endif
- iaccButton->Release();
+ buttonElement->Release();
- /**************************************************
- * QWidget
- **************************************************/
+ // Get native window handle.
QWindow *windowHandle = window.windowHandle();
+ QVERIFY(windowHandle != 0);
QPlatformNativeInterface *platform = QGuiApplication::platformNativeInterface();
+ QVERIFY(platform != 0);
HWND hWnd = (HWND)platform->nativeResourceForWindow("handle", windowHandle);
+ QVERIFY(hWnd != 0);
- IAccessible *iaccWindow;
- hr = ::AccessibleObjectFromWindow(hWnd, OBJID_CLIENT, IID_IAccessible, (void**)&iaccWindow);
+ // Get automation element for the window from handle.
+ IUIAutomationElement *windowElement = nullptr;
+ hr = automation->ElementFromHandle(hWnd, &windowElement);
QVERIFY(SUCCEEDED(hr));
- hr = iaccWindow->get_accRole(varSELF, &varRole);
+ QVERIFY(windowElement != 0);
+
+ // Validate that the top-level widget is reported as a window.
+ hr = windowElement->get_CurrentControlType(&controlTypeId);
QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(controlTypeId, UIA_WindowControlTypeId);
- QCOMPARE(varRole.vt, (VARTYPE)VT_I4);
- QCOMPARE(varRole.lVal, (LONG)ROLE_SYSTEM_CLIENT);
+ // Get a tree walker to walk over elements.
+ IUIAutomationTreeWalker *controlWalker = nullptr;
+ IUIAutomationElement *node = nullptr;
+ QList<IUIAutomationElement *> nodeList;
- long nChildren;
- hr = iaccWindow->get_accChildCount(&nChildren);
+ hr = automation->get_ControlViewWalker(&controlWalker);
QVERIFY(SUCCEEDED(hr));
- QCOMPARE(nChildren, (long)4);
-
- /**************************************************
- * QTextEdit
- **************************************************/
- // Get the second child (the accessible interface for the text edit)
- varChild.vt = VT_I4;
- varChild.lVal = 2;
- QVERIFY(iaccWindow);
- IAccessible *iaccTextEdit;
- hr = iaccWindow->get_accChild(varChild, (IDispatch**)&iaccTextEdit);
- QVERIFY(SUCCEEDED(hr));
- QVERIFY(iaccTextEdit);
- hr = iaccTextEdit->get_accRole(varSELF, &varRole);
- QVERIFY(SUCCEEDED(hr));
-
- QCOMPARE(varRole.vt, (VARTYPE)VT_I4);
- QCOMPARE(varRole.lVal, (LONG)ROLE_SYSTEM_TEXT);
+ QVERIFY(controlWalker != 0);
+ hr = controlWalker->GetFirstChildElement(windowElement, &node);
+ QVERIFY(SUCCEEDED(hr));
+ QVERIFY(node != 0);
+ int numElements = 5; // Title bar + 4 widgets
-#ifdef QT_SUPPORTS_IACCESSIBLE2
- if (IAccessibleEditableText *ia2TextEdit = (IAccessibleEditableText*)queryIA2(iaccTextEdit, IID_IAccessibleEditableText)) {
- ia2TextEdit->copyText(6, 11);
- QCOMPARE(QApplication::clipboard()->text(), QLatin1String("world"));
- ia2TextEdit->cutText(12, 16);
- QCOMPARE(QApplication::clipboard()->text(), QLatin1String("how "));
- ia2TextEdit->Release();
- }
- if (IAccessibleText *ia2Text = (IAccessibleText*)queryIA2(iaccTextEdit, IID_IAccessibleText)) {
- BSTR txt;
- hr = ia2Text->get_text(12, 15, &txt);
+ while (node) {
+ nodeList.append(node);
+ QVERIFY(nodeList.size() <= numElements);
+ IUIAutomationElement *next = nullptr;
+ hr = controlWalker->GetNextSiblingElement(node, &next);
QVERIFY(SUCCEEDED(hr));
- QCOMPARE(QString((QChar*)txt), QLatin1String("are"));
- ia2Text->Release();
+ node = next;
}
-#endif
- iaccTextEdit->Release();
+ QCOMPARE(nodeList.size(), numElements);
+ // Title bar
+ hr = nodeList.at(0)->get_CurrentControlType(&controlTypeId);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(controlTypeId, UIA_TitleBarControlTypeId);
- /**************************************************
- * QTableWidget
- **************************************************/
- {
- // Get the second child (the accessible interface for the table widget)
- varChild.vt = VT_I4;
- varChild.lVal = 3;
- QVERIFY(iaccWindow);
- IAccessible *iaccTable = 0;
- hr = iaccWindow->get_accChild(varChild, (IDispatch**)&iaccTable);
- QVERIFY(SUCCEEDED(hr));
- QVERIFY(iaccTable);
- hr = iaccTable->get_accRole(varSELF, &varRole);
- QVERIFY(SUCCEEDED(hr));
-
- QCOMPARE(varRole.vt, (VARTYPE)VT_I4);
- QCOMPARE(varRole.lVal, (LONG)ROLE_SYSTEM_TABLE);
-
+ // Button
+ hr = nodeList.at(1)->get_CurrentControlType(&controlTypeId);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(controlTypeId, UIA_ButtonControlTypeId);
-#ifdef QT_SUPPORTS_IACCESSIBLE2
- IAccessibleTable2 *ia2Table = (IAccessibleTable2*)queryIA2(iaccTable, IID_IAccessibleTable2);
- QVERIFY(ia2Table);
- BSTR bstrDescription;
- hr = ia2Table->get_columnDescription(0, &bstrDescription);
- QVERIFY(SUCCEEDED(hr));
- QCOMPARE(QString::fromWCharArray(bstrDescription), QLatin1String("h1"));
- ::SysFreeString(bstrDescription);
+ // Edit
+ hr = nodeList.at(2)->get_CurrentControlType(&controlTypeId);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(controlTypeId, UIA_EditControlTypeId);
- hr = ia2Table->get_rowDescription(1, &bstrDescription);
- QVERIFY(SUCCEEDED(hr));
- QCOMPARE(QString::fromWCharArray(bstrDescription), QLatin1String("v2"));
- ::SysFreeString(bstrDescription);
+ // Table
+ hr = nodeList.at(3)->get_CurrentControlType(&controlTypeId);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(controlTypeId, UIA_TableControlTypeId);
- IAccessible *accTableCell = 0;
- hr = ia2Table->get_cellAt(1, 2, (IUnknown**)&accTableCell);
- QVERIFY(SUCCEEDED(hr));
- QVERIFY(accTableCell);
- IAccessibleTableCell *ia2TableCell = (IAccessibleTableCell *)queryIA2(accTableCell, IID_IAccessibleTableCell);
- QVERIFY(ia2TableCell);
- LONG index;
- ia2TableCell->get_rowIndex(&index);
- QCOMPARE(index, (LONG)1);
- ia2TableCell->get_columnIndex(&index);
- QCOMPARE(index, (LONG)2);
-
- IAccessible *iaccTableCell = 0;
- hr = ia2TableCell->QueryInterface(IID_IAccessible, (void**)&iaccTableCell);
- QVERIFY(SUCCEEDED(hr));
- QVERIFY(iaccTableCell);
- BSTR bstrCellName;
- hr = iaccTableCell->get_accName(varSELF, &bstrCellName);
- QVERIFY(SUCCEEDED(hr));
- QString cellName((QChar*)bstrCellName);
- QCOMPARE(cellName, QLatin1String("1.2"));
+ // Label
+ hr = nodeList.at(4)->get_CurrentControlType(&controlTypeId);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(controlTypeId, UIA_EditControlTypeId);
- accTableCell->Release();
- iaccTableCell->Release();
- ia2TableCell->Release();
- ia2Table->Release();
-#endif
- iaccTable->Release();
+ for (auto nd : nodeList) {
+ nd->Release();
}
- iaccWindow->Release();
+ controlWalker->Release();
+ windowElement->Release();
+ automation->Release();
+ CoUninitialize();
+
QTestAccessibility::clearEvents();
#endif
}
diff --git a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
index 35441010f7..70e696e703 100644
--- a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
+++ b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
@@ -346,10 +346,6 @@ void tst_QFocusEvent::checkReason_ActiveWindow()
d->hide();
QTest::qWait(100);
-#if defined(Q_OS_IRIX)
- QEXPECT_FAIL("", "IRIX requires explicit activateWindow(), so this test does not make any sense.", Abort);
-#endif
-
if (!QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive)
|| !QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive)) {
// Activate window of testFocusWidget, focus in that window goes to childFocusWidgetOne