summaryrefslogtreecommitdiffstats
path: root/tests/auto/integrationtests/macgui
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@nokia.com>2011-10-22 22:38:14 +0200
committerQt by Nokia <qt-info@nokia.com>2011-11-23 14:54:01 +0100
commitbeb72b2fbf17a20b4a9d51d75d79f9c3c69bb357 (patch)
treec972c0a408ea912faaa67d4508ba5d855a1cb582 /tests/auto/integrationtests/macgui
parente739ca0071df28adf767d148ba5095d846e898f3 (diff)
Remove virtual child integers.
This makes the accessibility apis much simpler and less error prone. Disable the itemviews implementation that is in complex widgets. The itemviews will use the new code from itemviews.h/cpp everywhere now. QToolBox was broken before, now at least it simply exposes all its children. The children are the buttons (tabs of the toolbox) and their contents. Change-Id: I45e218f49f02aebbd678ddfe29f94c2a112a2125 Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
Diffstat (limited to 'tests/auto/integrationtests/macgui')
-rw-r--r--tests/auto/integrationtests/macgui/guitest.cpp58
-rw-r--r--tests/auto/integrationtests/macgui/guitest.h32
-rw-r--r--tests/auto/integrationtests/macgui/tst_macgui.cpp14
3 files changed, 43 insertions, 61 deletions
diff --git a/tests/auto/integrationtests/macgui/guitest.cpp b/tests/auto/integrationtests/macgui/guitest.cpp
index ac8b66ba9b..e5245528cb 100644
--- a/tests/auto/integrationtests/macgui/guitest.cpp
+++ b/tests/auto/integrationtests/macgui/guitest.cpp
@@ -58,13 +58,12 @@
class PrintTest : public TestBase
{
public:
- bool operator()(InterfaceChildPair candidate)
+ bool operator()(QAccessibleInterface *candidate)
{
qDebug() << "";
- qDebug() << "Name" << candidate.iface->text(QAccessible::Name, candidate.possibleChild);
- qDebug() << "Pos" << candidate.iface->rect(candidate.possibleChild);
- if (candidate.possibleChild == 0)
- qDebug() << "Number of children" << candidate.iface->childCount();
+ qDebug() << "Name" << candidate->text(QAccessible::Name);
+ qDebug() << "Pos" << candidate->rect();
+ qDebug() << "Number of children" << candidate->childCount();
return false;
}
};
@@ -76,9 +75,9 @@ public:
QString text;
QAccessible::Text textType;
- bool operator()(InterfaceChildPair candidate)
+ bool operator()(QAccessibleInterface *candidate)
{
- return (candidate.iface->text(textType, candidate.possibleChild) == text);
+ return (candidate->text(textType) == text);
}
};
@@ -86,66 +85,63 @@ void WidgetNavigator::printAll(QWidget *widget)
{
QAccessibleInterface * const iface = QAccessible::queryAccessibleInterface(widget);
deleteInDestructor(iface);
- printAll(InterfaceChildPair(iface, 0));
+ printAll(iface);
}
-void WidgetNavigator::printAll(InterfaceChildPair interface)
+void WidgetNavigator::printAll(QAccessibleInterface *interface)
{
PrintTest printTest;
- recursiveSearch(&printTest, interface.iface, interface.possibleChild);
+ recursiveSearch(&printTest, interface);
}
-InterfaceChildPair WidgetNavigator::find(QAccessible::Text textType, const QString &text, QWidget *start)
+QAccessibleInterface *WidgetNavigator::find(QAccessible::Text textType, const QString &text, QWidget *start)
{
- QAccessibleInterface * const iface = QAccessible::queryAccessibleInterface(start);
+ QAccessibleInterface *const iface = QAccessible::queryAccessibleInterface(start);
deleteInDestructor(iface);
return find(textType, text, iface);
}
-InterfaceChildPair WidgetNavigator::find(QAccessible::Text textType, const QString &text, QAccessibleInterface *start)
+QAccessibleInterface *WidgetNavigator::find(QAccessible::Text textType, const QString &text, QAccessibleInterface *start)
{
NameTest nameTest(text, textType);
- return recursiveSearch(&nameTest, start, 0);
+ return recursiveSearch(&nameTest, start);
}
/*
Recursiveley navigates the accessible hiearchy looking for an interface that
passsed the Test (meaning it returns true).
*/
-InterfaceChildPair WidgetNavigator::recursiveSearch(TestBase *test, QAccessibleInterface *iface, int possibleChild)
+QAccessibleInterface *WidgetNavigator::recursiveSearch(TestBase *test, QAccessibleInterface *iface)
{
- QStack<InterfaceChildPair> todoInterfaces;
- todoInterfaces.push(InterfaceChildPair(iface, possibleChild));
+ QStack<QAccessibleInterface *> todoInterfaces;
+ todoInterfaces.push(iface);
while (todoInterfaces.isEmpty() == false) {
- InterfaceChildPair testInterface = todoInterfaces.pop();
+ QAccessibleInterface *testInterface = todoInterfaces.pop();
if ((*test)(testInterface))
return testInterface;
- if (testInterface.possibleChild != 0)
- continue;
-
- const int numChildren = testInterface.iface->childCount();
+ const int numChildren = testInterface->childCount();
for (int i = 0; i < numChildren; ++i) {
- QAccessibleInterface *childInterface = testInterface.iface->child(i);
+ QAccessibleInterface *childInterface = testInterface->child(i);
if (childInterface) {
- todoInterfaces.push(InterfaceChildPair(childInterface, 0));
+ todoInterfaces.push(childInterface);
deleteInDestructor(childInterface);
}
}
}
- return InterfaceChildPair();
+ return 0;
}
-void WidgetNavigator::deleteInDestructor(QAccessibleInterface * interface)
+void WidgetNavigator::deleteInDestructor(QAccessibleInterface *interface)
{
interfaces.insert(interface);
}
-QWidget *WidgetNavigator::getWidget(InterfaceChildPair interface)
+QWidget *WidgetNavigator::getWidget(QAccessibleInterface *interface)
{
- return qobject_cast<QWidget *>(interface.iface->object());
+ return qobject_cast<QWidget *>(interface->object());
}
WidgetNavigator::~WidgetNavigator()
@@ -275,7 +271,7 @@ void DelayedAction::run()
Schedules a mouse click at an interface using a singleShot timer.
Only one click can be scheduled at a time.
*/
-ClickLaterAction::ClickLaterAction(InterfaceChildPair interface, Qt::MouseButtons buttons)
+ClickLaterAction::ClickLaterAction(QAccessibleInterface *interface, Qt::MouseButtons buttons)
{
this->useInterface = true;
this->interface = interface;
@@ -296,7 +292,7 @@ ClickLaterAction::ClickLaterAction(QWidget *widget, Qt::MouseButtons buttons)
void ClickLaterAction::run()
{
if (useInterface) {
- const QPoint globalCenter = interface.iface->rect(interface.possibleChild).center();
+ const QPoint globalCenter = interface->rect().center();
NativeEvents::mouseClick(globalCenter, buttons);
} else { // use widget
const QSize halfSize = widget->size() / 2;
@@ -306,7 +302,7 @@ void ClickLaterAction::run()
DelayedAction::run();
}
-void GuiTester::clickLater(InterfaceChildPair interface, Qt::MouseButtons buttons, int delay)
+void GuiTester::clickLater(QAccessibleInterface *interface, Qt::MouseButtons buttons, int delay)
{
clearSequence();
addToSequence(new ClickLaterAction(interface, buttons), delay);
diff --git a/tests/auto/integrationtests/macgui/guitest.h b/tests/auto/integrationtests/macgui/guitest.h
index 432021c54a..170fc5c19c 100644
--- a/tests/auto/integrationtests/macgui/guitest.h
+++ b/tests/auto/integrationtests/macgui/guitest.h
@@ -54,23 +54,9 @@ QT_USE_NAMESPACE
- Simulating platform mouse and keybord events.
*/
-/*
- InterfaceChildPair specifies an accessibilty interface item.
-*/
-class InterfaceChildPair {
-public:
- InterfaceChildPair() : iface(0), possibleChild(0) {}
- InterfaceChildPair(QAccessibleInterface *iface, int possibleChild)
- :iface(iface), possibleChild(possibleChild)
- { }
-
- QAccessibleInterface *iface;
- int possibleChild;
-};
-
class TestBase {
public:
- virtual bool operator()(InterfaceChildPair candidate) = 0;
+ virtual bool operator()(QAccessibleInterface *candidate) = 0;
virtual ~TestBase() {}
};
@@ -83,15 +69,15 @@ public:
~WidgetNavigator();
void printAll(QWidget *widget);
- void printAll(InterfaceChildPair interface);
+ void printAll(QAccessibleInterface *interface);
- InterfaceChildPair find(QAccessible::Text textType, const QString &text, QWidget *start);
- InterfaceChildPair find(QAccessible::Text textType, const QString &text, QAccessibleInterface *start);
+ QAccessibleInterface *find(QAccessible::Text textType, const QString &text, QWidget *start);
+ QAccessibleInterface *find(QAccessible::Text textType, const QString &text, QAccessibleInterface *start);
- InterfaceChildPair recursiveSearch(TestBase *test, QAccessibleInterface *iface, int possibleChild);
+ QAccessibleInterface *recursiveSearch(TestBase *test, QAccessibleInterface *iface);
void deleteInDestructor(QAccessibleInterface * interface);
- static QWidget *getWidget(InterfaceChildPair interface);
+ static QWidget *getWidget(QAccessibleInterface *interface);
private:
QSet<QAccessibleInterface *> interfaces;
};
@@ -141,13 +127,13 @@ class ClickLaterAction : public DelayedAction
{
Q_OBJECT
public:
- ClickLaterAction(InterfaceChildPair interface, Qt::MouseButtons buttons = Qt::LeftButton);
+ ClickLaterAction(QAccessibleInterface *interface, Qt::MouseButtons buttons = Qt::LeftButton);
ClickLaterAction(QWidget *widget, Qt::MouseButtons buttons = Qt::LeftButton);
protected slots:
void run();
private:
bool useInterface;
- InterfaceChildPair interface;
+ QAccessibleInterface *interface;
QWidget *widget;
Qt::MouseButtons buttons;
};
@@ -168,7 +154,7 @@ public:
protected slots:
void exitLoopSlot();
protected:
- void clickLater(InterfaceChildPair interface, Qt::MouseButtons buttons = Qt::LeftButton, int delay = 300);
+ void clickLater(QAccessibleInterface *interface, Qt::MouseButtons buttons = Qt::LeftButton, int delay = 300);
void clickLater(QWidget *widget, Qt::MouseButtons buttons = Qt::LeftButton, int delay = 300);
void clearSequence();
diff --git a/tests/auto/integrationtests/macgui/tst_macgui.cpp b/tests/auto/integrationtests/macgui/tst_macgui.cpp
index 1552db21ab..9ff2897aa8 100644
--- a/tests/auto/integrationtests/macgui/tst_macgui.cpp
+++ b/tests/auto/integrationtests/macgui/tst_macgui.cpp
@@ -116,8 +116,8 @@ void tst_MacGui::dummy()
box->show();
// Find the "OK" button and schedule a press.
- InterfaceChildPair interface = wn.find(QAccessible::Name, "OK", box);
- QVERIFY(interface.iface);
+ QAccessibleInterface *interface = wn.find(QAccessible::Name, "OK", box);
+ QVERIFY(interface);
const int delay = 1000;
clickLater(interface, Qt::LeftButton, delay);
@@ -142,8 +142,8 @@ void tst_MacGui::splashScreenModality()
box.show();
// Find the "OK" button and schedule a press.
- InterfaceChildPair interface = wn.find(QAccessible::Name, "OK", &box);
- QVERIFY(interface.iface);
+ QAccessibleInterface *interface = wn.find(QAccessible::Name, "OK", &box);
+ QVERIFY(interface);
const int delay = 1000;
clickLater(interface, Qt::LeftButton, delay);
@@ -220,8 +220,8 @@ void tst_MacGui::spinBoxArrowButtons()
const QImage noFocus = grabWindowContents(&colorWidget).toImage();
// Set focus by clicking the less button.
- InterfaceChildPair lessInterface = wn.find(QAccessible::Name, "Less", &spinBox);
- QVERIFY(lessInterface.iface);
+ QAccessibleInterface *lessInterface = wn.find(QAccessible::Name, "Less", &spinBox);
+ QVERIFY(lessInterface);
const int delay = 500;
clickLater(lessInterface, Qt::LeftButton, delay);
const int timeout = 1;
@@ -231,7 +231,7 @@ void tst_MacGui::spinBoxArrowButtons()
const QImage focus = grabWindowContents(&colorWidget).toImage();
// Compare the arrow area of the less button to see if it moved.
- const QRect lessRect = lessInterface.iface->rect(lessInterface.possibleChild);
+ const QRect lessRect = lessInterface->rect();
const QRect lessLocalRect(colorWidget.mapFromGlobal(lessRect.topLeft()), colorWidget.mapFromGlobal(lessRect.bottomRight()));
const QRect compareRect = lessLocalRect.adjusted(5, 3, -5, -7);
QVERIFY(noFocus.copy(compareRect) == focus.copy(compareRect));