summaryrefslogtreecommitdiffstats
path: root/old/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'old/plugins')
-rw-r--r--old/plugins/plugins.pro4
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/hbwidgets.pro49
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbabstractbutton.cpp85
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbabstractbutton.h76
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbabstractitemview.cpp282
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbabstractitemview.h188
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbabstractviewitem.cpp71
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbabstractviewitem.h77
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbcombobox.cpp175
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbcombobox.h98
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbfactory.cpp123
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbfactory.h64
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbinputmethod.cpp71
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbinputmethod.h72
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhblabel.cpp72
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhblabel.h78
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhblineedit.cpp91
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhblineedit.h77
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbmainwindow.cpp69
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbmainwindow.h69
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbpushbutton.cpp66
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbpushbutton.h73
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbwidget.cpp121
-rw-r--r--old/plugins/qtuitest_widgets/hbwidgets/testhbwidget.h83
-rw-r--r--old/plugins/qtuitest_widgets/qgraphicsviewwidgets/qgraphicsviewwidgets.pro38
-rw-r--r--old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsitem.cpp132
-rw-r--r--old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsitem.h85
-rw-r--r--old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsproxywidget.cpp256
-rw-r--r--old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsproxywidget.h105
-rw-r--r--old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicstextitem.cpp66
-rw-r--r--old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicstextitem.h74
-rw-r--r--old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsview.cpp69
-rw-r--r--old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsview.h69
-rw-r--r--old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsviewfactory.cpp109
-rw-r--r--old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsviewfactory.h66
-rw-r--r--old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicswidget.cpp55
-rw-r--r--old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicswidget.h64
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/qmlwidgets.pro50
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativefactory.cpp107
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativefactory.h62
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeitem.cpp299
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeitem.h122
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativelistview.cpp188
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativelistview.h89
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativemousearea.cpp60
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativemousearea.h64
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetext.cpp79
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetext.h72
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetextinput.cpp91
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetextinput.h69
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeview.cpp58
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeview.h65
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativewebview.cpp209
-rw-r--r--old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativewebview.h88
-rw-r--r--old/plugins/qtuitest_widgets/qtuitest_widgets.pro10
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/DESCRIPTION1
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/qtwidgets.pro95
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testabstractbutton.cpp195
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testabstractbutton.h91
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testabstractitemview.cpp475
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testabstractitemview.h185
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testabstractspinbox.cpp125
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testabstractspinbox.h68
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testcalendarwidget.cpp185
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testcalendarwidget.h77
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testcheckbox.cpp93
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testcheckbox.h69
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testcombobox.cpp252
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testcombobox.h94
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testdateedit.cpp78
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testdateedit.h71
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testdatetimeedit.cpp477
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testdatetimeedit.h84
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testdockwidget.cpp99
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testdockwidget.h75
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testfactory.cpp183
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testfactory.h65
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testgenericcheckwidget.cpp87
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testgenericcheckwidget.h68
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testgenericinputmethod.cpp74
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testgenericinputmethod.h72
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testgenerictextwidget.cpp105
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testgenerictextwidget.h71
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testgroupbox.cpp132
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testgroupbox.h84
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testheaderview.cpp84
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testheaderview.h74
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testignore.cpp59
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testignore.h64
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testlabel.cpp121
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testlabel.h78
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testlineedit.cpp146
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testlineedit.h76
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testlistview.cpp96
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testlistview.h69
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testmenu.cpp398
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testmenu.h108
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testmenubar.cpp391
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testmenubar.h107
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testpushbutton.cpp114
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testpushbutton.h78
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testtabbar.cpp231
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testtabbar.h93
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testtext.cpp116
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testtext.h139
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testtextedit.cpp298
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testtextedit.h106
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testtimeedit.cpp78
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testtimeedit.h72
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testtoolbar.cpp116
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testtoolbar.h93
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testtreeview.cpp193
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testtreeview.h76
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testtreewidget.cpp212
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testtreewidget.h78
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testwebview.cpp188
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testwebview.h94
-rw-r--r--old/plugins/qtuitest_widgets/qtwidgets/testwidgetslog.h85
-rw-r--r--old/plugins/styles/qtuitest/qtuitest.pro42
-rw-r--r--old/plugins/styles/qtuitest/style.cpp241
-rw-r--r--old/plugins/styles/qtuitest/style.h62
-rw-r--r--old/plugins/styles/styles.pro3
122 files changed, 13713 insertions, 0 deletions
diff --git a/old/plugins/plugins.pro b/old/plugins/plugins.pro
new file mode 100644
index 0000000..84960fd
--- /dev/null
+++ b/old/plugins/plugins.pro
@@ -0,0 +1,4 @@
+TEMPLATE=subdirs
+SUBDIRS=\
+ qtuitest_widgets \
+ styles
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/hbwidgets.pro b/old/plugins/qtuitest_widgets/hbwidgets/hbwidgets.pro
new file mode 100644
index 0000000..ff5dd3a
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/hbwidgets.pro
@@ -0,0 +1,49 @@
+SOURCES += \
+ testhbmainwindow.cpp \
+ testhblabel.cpp \
+ testhblineedit.cpp \
+ testhbcombobox.cpp \
+ testhbwidget.cpp \
+ testhbabstractitemview.cpp \
+ testhbabstractviewitem.cpp \
+ testhbabstractbutton.cpp \
+ testhbpushbutton.cpp \
+ testhbinputmethod.cpp \
+ testhbfactory.cpp
+
+HEADERS += \
+ testhbmainwindow.h \
+ testhblabel.h \
+ testhblineedit.h \
+ testhbcombobox.h \
+ testhbwidget.h \
+ testhbabstractitemview.h \
+ testhbabstractviewitem.h \
+ testhbabstractbutton.h \
+ testhbpushbutton.h \
+ testhbinputmethod.h \
+ testhbfactory.h
+
+TEMPLATE=lib
+CONFIG+=plugin hb hb_install
+VPATH+=$$PWD
+INCLUDEPATH+=$$PWD
+TARGET=hbwidgets
+TARGET=$$qtLibraryTarget($$TARGET)
+
+include($$SRCROOT/libqtuitest/libqtuitest.pri)
+
+target.path=$$[QT_INSTALL_PLUGINS]/qtuitest_widgets
+
+unix:!symbian {
+ MOC_DIR=$$OUT_PWD/.moc
+ OBJECTS_DIR=$$OUT_PWD/.obj
+}
+
+symbian {
+ TARGET.EPOCALLOWDLLDATA=1
+ MOC_DIR=$$OUT_PWD/moc
+ OBJECTS_DIR=$$OUT_PWD/obj
+}
+
+INSTALLS+=target
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractbutton.cpp b/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractbutton.cpp
new file mode 100644
index 0000000..b097501
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractbutton.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testhbabstractbutton.h"
+
+#include <HbAbstractButton>
+#include <HbMainWindow>
+
+namespace QtUiTest {
+
+TestHbAbstractButton::TestHbAbstractButton(QObject *_q)
+ : TestHbWidget(_q), q(qobject_cast<HbAbstractButton*>(_q))
+{
+}
+
+Qt::CheckState TestHbAbstractButton::checkState() const
+{ return q->isChecked() ? Qt::Checked : Qt::Unchecked; }
+
+bool TestHbAbstractButton::setCheckState(Qt::CheckState state)
+{
+ if (state == checkState()) return true;
+ if (!q->isCheckable()) {
+ QtUiTest::setErrorString("This abstract button is not checkable.");
+ return false;
+ }
+ bool ret = activate();
+
+ if (ret && (state != checkState()) && !QtUiTest::waitForSignal(q, SIGNAL(toggled(bool)))) {
+ QtUiTest::setErrorString("Successfully activated button, but check state did not change "
+ "to expected value.");
+ return false;
+ }
+ return ret;
+}
+
+bool TestHbAbstractButton::activate()
+{
+ HbMainWindow *mw = q->mainWindow();
+ QtUiTest::mouseClick(mw->mapToGlobal(mw->mapFromScene(q->mapToScene(q->boundingRect().center()))));
+ QtUiTest::wait(500);
+ return true;
+}
+
+bool TestHbAbstractButton::canWrap(QObject *o)
+{ return qobject_cast<HbAbstractButton*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractbutton.h b/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractbutton.h
new file mode 100644
index 0000000..e880906
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractbutton.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTHBABSTRACTBUTTON_H
+#define TESTHBABSTRACTBUTTON_H
+
+#include "testhbwidget.h"
+
+class HbAbstractButton;
+
+namespace QtUiTest {
+
+class TestHbAbstractButton : public TestHbWidget,
+ public QtUiTest::CheckWidget,
+ public QtUiTest::ActivateWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::CheckWidget
+ QtUiTest::ActivateWidget)
+
+public:
+ TestHbAbstractButton(QObject*);
+
+ virtual Qt::CheckState checkState() const;
+ virtual bool setCheckState(Qt::CheckState);
+ virtual bool activate();
+
+ static bool canWrap(QObject*);
+
+private:
+ HbAbstractButton *q;
+
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractitemview.cpp b/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractitemview.cpp
new file mode 100644
index 0000000..543b12e
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractitemview.cpp
@@ -0,0 +1,282 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testhbabstractitemview.h"
+//#include "testwidgetslog.h"
+
+//#include <QListView>
+//#include <QTimer>
+//#include <QScrollBar>
+//#include <QComboBox>
+#include <HbAbstractViewItem>
+
+#include <QDebug>
+#include <qtuitestnamespace.h>
+
+namespace QtUiTest {
+
+TestHbAbstractItemView::TestHbAbstractItemView(QObject *_q)
+ : TestHbWidget(_q), q(qobject_cast<HbAbstractItemView*>(_q))
+{
+}
+
+QString TestHbAbstractItemView::selectedText() const
+{
+ return q->currentIndex().data().toString();
+}
+
+QString TestHbAbstractItemView::text() const
+{
+ return list().join("\n");
+}
+
+QStringList TestHbAbstractItemView::list() const
+{
+ class HbModelListGetter : public HbModelViewIterator<HbAbstractItemView>
+ {
+ public:
+ HbModelListGetter(HbAbstractItemView *view)
+ : HbModelViewIterator<HbAbstractItemView>(view) {};
+
+ QStringList getList() {
+ list.clear();
+ iterate(view()->rootIndex());
+ return list;
+ }
+ protected:
+ virtual void visit(QModelIndex const &index)
+ { list << itemForIndex(index); }
+
+ QStringList list;
+ };
+
+ return HbModelListGetter(q).getList();
+}
+
+QModelIndex TestHbAbstractItemView::indexForItem(QString const &item) const
+{
+ QModelIndex ret;
+
+ class HbModelIndexGetter : public HbModelViewIterator<HbAbstractItemView>
+ {
+ public:
+ HbModelIndexGetter(HbAbstractItemView *view, QString const &item)
+ : HbModelViewIterator<HbAbstractItemView>(view), matches(0), m_item(item) {};
+ QModelIndex index;
+ int matches;
+
+ protected:
+ void visit(QModelIndex const &idx) {
+
+ if (itemForIndex(idx) == m_item) {
+ ++matches;
+ index = idx;
+ }
+ }
+ private:
+ QString m_item;
+ };
+
+ HbModelIndexGetter indexGetter(q, item);
+ indexGetter.iterate(q->rootIndex());
+
+ // No matching item
+ if (!indexGetter.matches) {
+// TestWidgetsLog() << "no matching item for" << item;
+ }
+
+ // More than one matching item
+ else if (indexGetter.matches > 1) {
+ qWarning("QtUitest: more than one item matches '%s' in item view", qPrintable(item));
+// TestWidgetsLog() << indexGetter.matches << "matches for" << item;
+ }
+
+ else
+ ret = indexGetter.index;
+
+ return ret;
+}
+
+QModelIndex TestHbAbstractItemView::indexFromList(QVariantList const &list) const
+{
+ QVariantList indexList = list;
+ QModelIndex ret;
+ if (list.size() > 1) {
+ int column = indexList.takeLast().toInt();
+ int row = indexList.takeLast().toInt();
+ ret = q->model()->index(row, column, indexFromList(indexList));
+ }
+ return ret;
+}
+
+
+QVariantList TestHbAbstractItemView::listFromIndex(QModelIndex const &index) const
+{
+ QVariantList ret;
+ if (index.parent().isValid()) {
+ ret << listFromIndex(index.parent());
+ }
+ if (index.isValid()) {
+ ret << index.row() << index.column();
+ }
+
+ return ret;
+}
+
+QRect TestHbAbstractItemView::visualRect(QString const &item) const
+{
+ QRect ret;
+
+ QModelIndex index = indexForItem(item);
+
+ if (index.isValid()) {
+ HbAbstractViewItem *vItem = q->itemByIndex(index);
+ if (vItem) {
+ ret = vItem->boundingRect().toRect();
+// ret.moveTopLeft(vItem->mapToScene(QPoint()));
+ }
+ }
+
+ return ret;
+}
+
+bool TestHbAbstractItemView::isMultiSelection() const
+{ return (q->selectionMode() > HbAbstractItemView::SingleSelection); }
+
+bool TestHbAbstractItemView::canSelect(QString const &item) const
+{
+ if (q->selectionMode() == HbAbstractItemView::NoSelection)
+ return false;
+
+ return list().contains(item);
+}
+
+bool TestHbAbstractItemView::canSelectMulti(QStringList const &items) const
+{
+ if (!isMultiSelection())
+ return false;
+
+ QSet<QString> itemSet = items.toSet();
+ return ((itemSet & list().toSet()) == itemSet);
+}
+
+bool TestHbAbstractItemView::select(QString const &item)
+{
+ if (!canSelect(item)) {
+// TestWidgetsLog() << "can't select" << item;
+ return false;
+ }
+
+ if (!QtUiTest::mousePreferred() && (!setFocus() || !hasFocus())) {
+ QtUiTest::setErrorString("Couldn't give focus to item view");
+ return false;
+ }
+
+ return select(indexForItem(item));
+}
+
+bool TestHbAbstractItemView::select(QModelIndex const &index)
+{
+ if (QtUiTest::mousePreferred()) {
+ if (!ensureVisible(index)) {
+ return false;
+ }
+ HbAbstractViewItem *item = q->itemByIndex(index);
+ QtUiTest::ActivateWidget* aw = qtuitest_cast<QtUiTest::ActivateWidget*>(item);
+
+ if (aw) {
+ return aw->activate();
+ }
+ }
+
+ return false;
+}
+
+bool TestHbAbstractItemView::selectMulti(QStringList const &items)
+{
+ return false;
+}
+
+bool TestHbAbstractItemView::selectIndex(QVariantList const &indexList)
+{
+ QModelIndex idx = indexFromList(indexList);
+ if (idx.isValid()) {
+ return select(idx);
+ }
+ else {
+ QtUiTest::setErrorString("Invalid index");
+ return false;
+ }
+}
+
+QVariantList TestHbAbstractItemView::selectedIndex() const
+{
+ return listFromIndex(q->currentIndex());
+}
+
+bool TestHbAbstractItemView::ensureVisible(QString const &item)
+{
+ return ensureVisible(indexForItem(item));
+}
+
+bool TestHbAbstractItemView::ensureVisible(QModelIndex const &index)
+{
+ //FIXME: QtUiTest should simulate the input events required to scroll the view
+ q->scrollTo(index);
+ return true;
+}
+
+bool TestHbAbstractItemView::canEnter(QVariant const& item) const
+{
+ bool ret = false;
+ return ret;
+}
+
+bool TestHbAbstractItemView::enter(QVariant const& item, bool noCommit)
+{
+ bool ret = false;
+ return ret;
+}
+
+bool TestHbAbstractItemView::canWrap(QObject* o)
+{ return qobject_cast<HbAbstractItemView*>(o); }
+
+}
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractitemview.h b/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractitemview.h
new file mode 100644
index 0000000..ec25ff5
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractitemview.h
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTHBABSTRACTITEMVIEW_H
+#define TESTHBABSTRACTITEMVIEW_H
+
+#include "testhbwidget.h"
+#include <HbAbstractItemView>
+
+const int QTUITEST_MAX_LIST=15000;
+
+namespace QtUiTest {
+
+class TestHbAbstractItemView : public TestHbWidget,
+ public QtUiTest::TextWidget,
+ public QtUiTest::ListWidget,
+ public QtUiTest::SelectWidget,
+ public QtUiTest::IndexedWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::TextWidget
+ QtUiTest::ListWidget
+ QtUiTest::SelectWidget
+ QtUiTest::IndexedWidget)
+
+public:
+ TestHbAbstractItemView(QObject*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+ virtual bool ensureVisible(QString const&);
+
+ virtual bool canEnter(QVariant const&) const;
+ virtual bool enter(QVariant const&,bool);
+
+ virtual bool isMultiSelection() const;
+ virtual bool canSelect(QString const&) const;
+ virtual bool canSelectMulti(QStringList const&) const;
+ virtual bool select(QString const&);
+ virtual bool selectMulti(QStringList const&);
+
+ virtual bool selectIndex(QVariantList const&);
+ virtual QVariantList selectedIndex() const;
+
+ static bool canWrap(QObject*);
+
+protected:
+ virtual QModelIndex indexForItem(QString const&) const;
+ virtual QModelIndex indexFromList(QVariantList const&) const;
+ virtual QVariantList listFromIndex(QModelIndex const&) const;
+ virtual bool ensureVisible(QModelIndex const&);
+ virtual bool select(QModelIndex const&);
+
+signals:
+ void selected(const QString&);
+
+private slots:
+ void on_activated(QModelIndex const&);
+
+private:
+ HbAbstractItemView *q;
+};
+
+template <typename T>
+class HbModelViewIterator
+{
+public:
+ HbModelViewIterator(T* view)
+ : m_view(view), count(0)
+ {}
+
+ virtual ~HbModelViewIterator()
+ {}
+
+ virtual void iterate(QModelIndex rootIndex = QModelIndex(), bool recurse=true)
+ {
+ QModelIndexList seen;
+ iterate(rootIndex, &seen, recurse, true);
+ }
+
+protected:
+ T* view() const
+ { return m_view; }
+ QAbstractItemModel* model() const
+ { return m_view->model(); }
+
+ virtual void visit(QModelIndex const&) = 0;
+ virtual void overFlow()
+ {
+ QtUiTest::setErrorString("Maximum number of items exceeded");
+ }
+ virtual bool isRowHidden(int, const QModelIndex&)
+ {
+ return false;
+ }
+ virtual QString itemForIndex(QModelIndex const& idx) const
+ {
+ if (idx.data().canConvert(QVariant::String)) {
+ return idx.data().toString();
+ } else if (idx.data().canConvert(QVariant::StringList)) {
+ return idx.data().toStringList().join(",");
+ }
+ return QString();
+ }
+
+private:
+ void iterate(QModelIndex const &index, QModelIndexList *seen, bool recurse, bool isRoot=false)
+ {
+ if (++count > QTUITEST_MAX_LIST) {
+ overFlow();
+ return;
+ }
+
+ if (index.isValid()) {
+ visit(index);
+ (*seen) << index;
+ }
+
+ for (int i = 0, max_i = model()->rowCount(index); i < max_i && count <= QTUITEST_MAX_LIST; ++i) {
+ if (isRowHidden(i, index)) {
+ continue;
+ }
+ for (int j = 0, max_j = model()->columnCount(index);
+ j < max_j && count <= QTUITEST_MAX_LIST; ++j) {
+ QModelIndex child;
+ if (model()->hasIndex(i, j, index)) {
+ child = model()->index(i, j, index);
+ }
+ if (child.isValid() && !seen->contains(child) && (isRoot || recurse)) {
+#if 0
+ /* Very verbose! */
+ qDebug() << "child at (" << i << "," << j << ")" << child.data();
+#endif
+ iterate(child, seen, recurse);
+ }
+ }
+ }
+ }
+
+ T *m_view;
+ int count;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractviewitem.cpp b/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractviewitem.cpp
new file mode 100644
index 0000000..b266594
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractviewitem.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testhbabstractviewitem.h"
+
+#include <HbAbstractViewItem>
+#include <HbMainWindow>
+
+namespace QtUiTest {
+
+TestHbAbstractViewItem::TestHbAbstractViewItem(QObject *_q)
+ : TestHbWidget(_q), q(qobject_cast<HbAbstractViewItem*>(_q))
+{
+}
+
+bool TestHbAbstractViewItem::activate()
+{
+ HbMainWindow *mw = q->mainWindow();
+ QtUiTest::mouseClick(mw->mapToGlobal(mw->mapFromScene(q->mapToScene(q->boundingRect().center()))));
+ QtUiTest::wait(500);
+ return true;
+}
+
+QString TestHbAbstractViewItem::text() const
+{
+ QString ret;
+ return ret;
+}
+
+bool TestHbAbstractViewItem::canWrap(QObject *o)
+{ return qobject_cast<HbAbstractViewItem*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractviewitem.h b/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractviewitem.h
new file mode 100644
index 0000000..dc74664
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbabstractviewitem.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTHBABSTRACTVIEWITEM_H
+#define TESTHBABSTRACTVIEWITEM_H
+
+#include "testhbwidget.h"
+class HbAbstractViewItem;
+
+namespace QtUiTest {
+
+class TestHbAbstractViewItem : public TestHbWidget,
+ public QtUiTest::ActivateWidget,
+ public QtUiTest::TextWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::ActivateWidget
+ QtUiTest::TextWidget)
+
+public:
+ TestHbAbstractViewItem(QObject*);
+
+ virtual bool activate();
+ virtual QString text() const;
+
+ static bool canWrap(QObject*);
+
+protected:
+ bool activate(QtUiTest::InputOption);
+
+private:
+ HbAbstractViewItem *q;
+// bool m_pressed;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbcombobox.cpp b/old/plugins/qtuitest_widgets/hbwidgets/testhbcombobox.cpp
new file mode 100644
index 0000000..7096314
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbcombobox.cpp
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testhbcombobox.h"
+
+#include <qtuitestnamespace.h>
+
+#include <HbComboBox>
+#include <HbListView>
+#include <HbMainWindow>
+#include <HbInputMethod>
+
+#include <QDebug>
+
+namespace QtUiTest {
+
+TestHbComboBox::TestHbComboBox(QObject *_q)
+ : TestHbWidget(_q), q(qobject_cast<HbComboBox*>(_q))
+{
+}
+
+QString TestHbComboBox::text() const
+{
+ return list().join("\n");
+}
+
+QString TestHbComboBox::selectedText() const
+{
+ return q->currentText();
+}
+
+QStringList TestHbComboBox::list() const
+{
+ return q->items();
+}
+
+QRect TestHbComboBox::visualRect(QString const &item) const
+{
+ QRect ret;
+ return ret;
+}
+
+QString TestHbComboBox::labelText() const
+{
+ QString ret = selectedText();
+ return ret;
+}
+
+QObject* TestHbComboBox::buddy() const
+{
+ return q;
+}
+
+bool TestHbComboBox::canSelect(QString const &item) const
+{ return list().contains(item); }
+
+bool TestHbComboBox::select(QString const &item)
+{
+ HbListView *lv = listView();
+ if (!lv || !lv->QGraphicsItem::isVisible()) {
+ // need to activate list view
+ QGraphicsItem *button = q->primitive(HbStyle::P_ComboBoxButton_toucharea);
+ HbMainWindow *mw = q->mainWindow();
+ if (button && mw) {
+ QtUiTest::mouseClick(mw->mapToGlobal(mw->mapFromScene(button->mapToScene(button->boundingRect().center()))));
+ QtUiTest::wait(500);
+ } else {
+ // Something wrong here...
+ return false;
+ }
+ if (!lv) lv = listView();
+ // TODO: The click may not have activated the dropdown - eg, if another combobox had its
+ // dropdown active. Need to fix this.
+ }
+
+ // At this point, the HbListView should be visible, should now call select on
+ // the listview...
+ QtUiTest::SelectWidget *sView = qtuitest_cast<QtUiTest::SelectWidget*>(lv);
+ return sView->select(item);
+}
+
+bool TestHbComboBox::canEnter(QVariant const& item) const
+{
+ if (q->isEditable()) {
+ if (!item.canConvert<QString>()) return false;
+ return true;
+/*
+ int dontcare = 0;
+ QString text = item.toString();
+ const HbValidator *validator = q->validator();
+ if (validator) {
+ return (QValidator::Acceptable==validator->validate(text, dontcare));
+ } else {
+ return true;
+ }
+*/
+ } else {
+ return canSelect(item.toString());
+ }
+}
+
+bool TestHbComboBox::enter(QVariant const& item, bool noCommit)
+{
+ if (q->isEditable()) {
+ HbMainWindow *mw = q->mainWindow();
+ QtUiTest::mouseClick(mw->mapToGlobal(mw->mapFromScene(q->mapToScene(q->boundingRect().center()))));
+ QtUiTest::wait(1000);
+ q->clear();
+ HbInputMethod::activeInputMethod()->receiveText(item.toString());
+ QtUiTest::wait(1000);
+ QtUiTest::mouseClick(mw->mapToGlobal(mw->mapFromScene(q->mapToScene(QPoint(-2, 0)))));
+ return true;
+ } else {
+ return select(item.toString());
+ }
+}
+
+bool TestHbComboBox::canWrap(QObject *o)
+{ return qobject_cast<HbComboBox*>(o); }
+
+HbListView *TestHbComboBox::listView()
+{
+ HbListView *ret = 0;
+ HbMainWindow *mw = q->mainWindow();
+ if (mw) {
+ foreach(QGraphicsItem *child, mw->items()) {
+ HbListView *lv = qgraphicsitem_cast<HbListView*>(child);
+ if (lv && lv->model() == q->model()) {
+ ret = lv;
+ break;
+ }
+ }
+ }
+ return ret;
+}
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbcombobox.h b/old/plugins/qtuitest_widgets/hbwidgets/testhbcombobox.h
new file mode 100644
index 0000000..a75fab0
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbcombobox.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTHBCOMBOBOX_H
+#define TESTHBCOMBOBOX_H
+
+#include "testhbwidget.h"
+
+class HbComboBox;
+class HbListView;
+
+namespace QtUiTest {
+
+class TestHbComboBox : public TestHbWidget,
+ public QtUiTest::TextWidget,
+ public QtUiTest::ListWidget,
+ public QtUiTest::LabelWidget,
+ public QtUiTest::InputWidget,
+ public QtUiTest::SelectWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::TextWidget
+ QtUiTest::ListWidget
+ QtUiTest::LabelWidget
+ QtUiTest::InputWidget
+ QtUiTest::SelectWidget)
+public:
+ TestHbComboBox(QObject*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+
+ virtual QString labelText() const;
+ virtual QObject* buddy() const;
+
+ virtual bool canSelect(QString const&) const;
+ virtual bool select(QString const&);
+
+ virtual bool canEnter(QVariant const&) const;
+ virtual bool enter(QVariant const&,bool);
+
+ static bool canWrap(QObject*);
+
+signals:
+ void selected(QString const&);
+
+private:
+ bool selectWithKeys(QString const&);
+ HbListView *listView();
+
+ HbComboBox *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbfactory.cpp b/old/plugins/qtuitest_widgets/hbwidgets/testhbfactory.cpp
new file mode 100644
index 0000000..9642b91
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbfactory.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testhbfactory.h"
+
+#include "testhbmainwindow.h"
+#include "testhbwidget.h"
+#include "testhbabstractbutton.h"
+#include "testhbpushbutton.h"
+#include "testhbabstractitemview.h"
+#include "testhblabel.h"
+#include "testhblineedit.h"
+#include "testhbcombobox.h"
+#include "testhbinputmethod.h"
+#include "testhbabstractviewitem.h"
+
+#include <QApplication>
+#include <HbInputMethod>
+
+namespace QtUiTest {
+
+TestHbFactory::TestHbFactory()
+{
+}
+
+QObject* TestHbFactory::find(QtUiTest::WidgetType type)
+{
+ if (type == InputMethod) {
+ return HbInputMethod::activeInputMethod();
+ }
+
+ return 0;
+}
+
+
+QObject* TestHbFactory::create(QObject* o)
+{
+ QObject* ret = 0;
+
+#define TRY(Klass) \
+ if (Klass::canWrap(o)) { \
+ ret = new Klass(o); \
+ break; \
+ }
+
+ /* Order is important here; classes should be listed in order of
+ * most to least derived. */
+
+ do {
+ TRY(TestHbComboBox);
+ TRY(TestHbLineEdit);
+ TRY(TestHbPushButton);
+ TRY(TestHbLabel);
+ TRY(TestHbAbstractItemView);
+ TRY(TestHbAbstractViewItem);
+ TRY(TestHbAbstractButton);
+ TRY(TestHbWidget);
+ TRY(TestHbInputMethod);
+ TRY(TestHbMainWindow);
+ } while(0);
+
+ return ret;
+}
+
+QStringList TestHbFactory::keys() const
+{
+ /* Order doesn't matter here. */
+ return QStringList()
+ << "HbMainWindow"
+ << "HbWidget"
+ << "HbLabel"
+ << "HbComboBox"
+ << "HbLineEdit"
+ << "HbAbstractItemView"
+ << "HbAbstractViewItem"
+ << "HbAbstractButton"
+ << "HbPushButton"
+ << "HbInputMethod"
+ ;
+}
+
+}
+#include <qplugin.h>
+Q_EXPORT_PLUGIN2(hbwidgets, QtUiTest::TestHbFactory)
+
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbfactory.h b/old/plugins/qtuitest_widgets/hbwidgets/testhbfactory.h
new file mode 100644
index 0000000..4e7ee48
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbfactory.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTHBFACTORY_H
+#define TESTHBFACTORY_H
+
+#include <QObject>
+#include <qtuitestwidgetinterface.h>
+
+namespace QtUiTest {
+
+class TestHbFactory : public QObject, public QtUiTest::WidgetFactory
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::WidgetFactory)
+
+public:
+ TestHbFactory();
+
+ virtual QObject* find(QtUiTest::WidgetType);
+ virtual QObject* create(QObject*);
+ virtual QStringList keys() const;
+};
+
+}
+#endif \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbinputmethod.cpp b/old/plugins/qtuitest_widgets/hbwidgets/testhbinputmethod.cpp
new file mode 100644
index 0000000..3632564
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbinputmethod.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testhbinputmethod.h"
+
+#include <qtuitestnamespace.h>
+#include <HbInputMethod>
+
+#include <QDebug>
+
+namespace QtUiTest {
+
+TestHbInputMethod::TestHbInputMethod(QObject *_q)
+ : q(qobject_cast<HbInputMethod*>(_q))
+{
+}
+
+bool TestHbInputMethod::canEnter(QVariant const& item) const
+{
+ return true;
+}
+
+bool TestHbInputMethod::enter(QVariant const& item, bool noCommit)
+{
+ q->receiveText(item.toString());
+ q->setFocusWidget(0);
+ return true;
+}
+
+bool TestHbInputMethod::canWrap(QObject *o)
+{ return qobject_cast<HbInputMethod*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbinputmethod.h b/old/plugins/qtuitest_widgets/hbwidgets/testhbinputmethod.h
new file mode 100644
index 0000000..71c144a
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbinputmethod.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTHBINPUTMETHOD_H
+#define TESTHBINPUTMETHOD_H
+
+#include "testhbwidget.h"
+
+class HbInputMethod;
+
+namespace QtUiTest {
+
+class TestHbInputMethod : public QObject,
+ QtUiTest::InputWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::InputWidget)
+
+public:
+ TestHbInputMethod(QObject*);
+
+ virtual bool canEnter(QVariant const&) const;
+ virtual bool enter(QVariant const&,bool);
+
+ static bool canWrap(QObject*);
+
+private:
+ HbInputMethod *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhblabel.cpp b/old/plugins/qtuitest_widgets/hbwidgets/testhblabel.cpp
new file mode 100644
index 0000000..5c8b4fc
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhblabel.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testhblabel.h"
+//#include "testwidgetslog.h"
+
+#include <HbLabel>
+//#include <QGroupBox>
+
+namespace QtUiTest {
+
+TestHbLabel::TestHbLabel(QObject* _q)
+ : TestHbWidget(_q), q(qobject_cast<HbLabel*>(_q))
+{}
+
+QString TestHbLabel::text() const
+{
+ return q->plainText();
+}
+
+QString TestHbLabel::labelText() const
+{
+ return text();
+}
+
+QObject* TestHbLabel::buddy() const
+{
+return 0;// return q->buddy();
+}
+
+bool TestHbLabel::canWrap(QObject *o)
+{ return qobject_cast<HbLabel*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhblabel.h b/old/plugins/qtuitest_widgets/hbwidgets/testhblabel.h
new file mode 100644
index 0000000..ef3f73d
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhblabel.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTHBLABEL_H
+#define TESTHBLABEL_H
+
+#include "testhbwidget.h"
+
+class HbLabel;
+
+namespace QtUiTest {
+
+class TestHbLabel : public TestHbWidget,
+ public QtUiTest::LabelWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::LabelWidget)
+
+public:
+ TestHbLabel(QObject*);
+
+ virtual bool ignoreScan() const { return true; }
+
+ virtual QString text() const;
+
+ virtual QString labelText() const;
+ virtual QObject* buddy() const;
+
+ static bool canWrap(QObject*);
+
+private:
+ static QString convertToPlainText(QString const&);
+ QString groupBoxName() const;
+
+ HbLabel *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhblineedit.cpp b/old/plugins/qtuitest_widgets/hbwidgets/testhblineedit.cpp
new file mode 100644
index 0000000..42d5aea
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhblineedit.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testhblineedit.h"
+
+#include <qtuitestnamespace.h>
+
+#include <HbLineEdit>
+#include <HbMainWindow>
+#include <HbInputMethod>
+
+#include <QDebug>
+
+namespace QtUiTest {
+
+TestHbLineEdit::TestHbLineEdit(QObject *_q)
+ : TestHbWidget(_q), q(qobject_cast<HbLineEdit*>(_q))
+{
+}
+
+QString TestHbLineEdit::text() const
+{
+ return q->text();
+}
+
+QString TestHbLineEdit::selectedText() const
+{
+ return q->selectedText();
+}
+
+bool TestHbLineEdit::canEnter(QVariant const& item) const
+{
+ //TODO
+ return true;
+}
+
+bool TestHbLineEdit::enter(QVariant const& item, bool noCommit)
+{
+ HbMainWindow *mw = q->mainWindow();
+ QtUiTest::mouseClick(mw->mapToGlobal(mw->mapFromScene(q->mapToScene(q->boundingRect().center()))));
+ QtUiTest::wait(1000);
+ //FIXME
+ q->setText(QString());
+ HbInputMethod::activeInputMethod()->receiveText(item.toString());
+ QtUiTest::wait(1000);
+ QtUiTest::mouseClick(mw->mapToGlobal(mw->mapFromScene(q->mapToScene(QPoint(-2, 0)))));
+ return true;
+}
+
+bool TestHbLineEdit::canWrap(QObject *o)
+{ return qobject_cast<HbLineEdit*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhblineedit.h b/old/plugins/qtuitest_widgets/hbwidgets/testhblineedit.h
new file mode 100644
index 0000000..f19505a
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhblineedit.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTHBLINEEDIT_H
+#define TESTHBLINEEDIT_H
+
+#include "testhbwidget.h"
+
+class HbLineEdit;
+
+namespace QtUiTest {
+
+class TestHbLineEdit : public TestHbWidget,
+ public QtUiTest::TextWidget,
+ public QtUiTest::InputWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::TextWidget
+ QtUiTest::InputWidget)
+
+public:
+ TestHbLineEdit(QObject*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+
+ virtual bool canEnter(QVariant const&) const;
+ virtual bool enter(QVariant const&,bool);
+
+ static bool canWrap(QObject*);
+
+private:
+ HbLineEdit *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbmainwindow.cpp b/old/plugins/qtuitest_widgets/hbwidgets/testhbmainwindow.cpp
new file mode 100644
index 0000000..d0de71f
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbmainwindow.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testhbmainwindow.h"
+
+#include <HbMainWindow>
+#include <HbInputMethod>
+
+namespace QtUiTest {
+
+TestHbMainWindow::TestHbMainWindow(QObject* _q)
+ : TestWidget(_q), q(qobject_cast<HbMainWindow*>(_q))
+{}
+
+QObjectList const& TestHbMainWindow::children() const
+{
+ m_children.clear();
+ foreach(QGraphicsItem *child, q->items()) {
+ QObject *obj = qgraphicsitem_cast<QGraphicsObject*>(child);
+ if (obj) {
+ m_children << obj;
+ }
+ }
+
+ return m_children;
+}
+
+bool TestHbMainWindow::canWrap(QObject *o)
+{ return qobject_cast<HbMainWindow*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbmainwindow.h b/old/plugins/qtuitest_widgets/hbwidgets/testhbmainwindow.h
new file mode 100644
index 0000000..05daa3a
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbmainwindow.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTHBMAINWINDOW_H
+#define TESTHBMAINWINDOW_H
+
+#include <testwidget.h>
+
+class HbMainWindow;
+
+namespace QtUiTest {
+
+class TestHbMainWindow : public TestWidget
+{
+ Q_OBJECT
+
+public:
+ TestHbMainWindow(QObject*);
+ static bool canWrap(QObject*);
+
+ virtual QObjectList const& children() const;
+
+private:
+ HbMainWindow* q;
+
+ mutable QObjectList m_children;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbpushbutton.cpp b/old/plugins/qtuitest_widgets/hbwidgets/testhbpushbutton.cpp
new file mode 100644
index 0000000..7b8138c
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbpushbutton.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testhbpushbutton.h"
+
+#include <HbPushButton>
+
+namespace QtUiTest {
+
+TestHbPushButton::TestHbPushButton(QObject *_q)
+ : TestHbAbstractButton(_q), q(qobject_cast<HbPushButton*>(_q))
+{
+}
+
+QString TestHbPushButton::labelText() const
+{
+ return q->text();
+}
+
+QObject* TestHbPushButton::buddy() const
+{
+ return q;
+}
+
+bool TestHbPushButton::canWrap(QObject *o)
+{ return qobject_cast<HbPushButton*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbpushbutton.h b/old/plugins/qtuitest_widgets/hbwidgets/testhbpushbutton.h
new file mode 100644
index 0000000..0f6ffce
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbpushbutton.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTHBPUSHBUTTON_H
+#define TESTHBPUSHBUTTON_H
+
+#include "testhbabstractbutton.h"
+
+class HbPushButton;
+
+namespace QtUiTest {
+
+class TestHbPushButton : public TestHbAbstractButton,
+ public QtUiTest::LabelWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::LabelWidget)
+
+public:
+ TestHbPushButton(QObject*);
+
+ virtual QString labelText() const;
+ virtual QObject* buddy() const;
+
+ static bool canWrap(QObject*);
+
+private:
+ HbPushButton *q;
+
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbwidget.cpp b/old/plugins/qtuitest_widgets/hbwidgets/testhbwidget.cpp
new file mode 100644
index 0000000..26354cf
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbwidget.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testhbwidget.h"
+
+#include <qgraphicsview.h>
+#include <QDebug>
+
+namespace QtUiTest {
+
+TestHbWidget::TestHbWidget(QObject* _q)
+ : q(qobject_cast<HbWidget*>(_q))
+{
+}
+
+// As the item may be transformed (eg, rotated relative to view) the
+// area of the bounding rect may be considerably larger than that of the item.
+const QRect& TestHbWidget::geometry() const
+{
+ QGraphicsView *view = q->scene()->views().first();
+ m_geometry = view->mapFromScene(q->sceneBoundingRect()).boundingRect();
+
+ return m_geometry;
+}
+
+bool TestHbWidget::isVisible() const
+{
+ return q->isVisibleTo(0);
+}
+
+QRegion TestHbWidget::visibleRegion() const
+{
+ //FIXME
+
+ QRegion ret;
+
+ if (isVisible()) {
+ ret = q->boundingRegion(QTransform());
+ }
+
+ return ret;
+}
+
+const QObjectList& TestHbWidget::children() const
+{
+ return q->children();
+}
+
+QObject* TestHbWidget::parent() const
+{
+ return q->scene()->views().first();
+}
+
+QPoint TestHbWidget::mapToGlobal(const QPoint& pos) const
+{
+ QPointF posf(pos);
+ QGraphicsView *view = q->scene()->views().first();
+ return view->mapToGlobal(view->mapFromScene(q->mapToScene(posf)));
+}
+
+QPoint TestHbWidget::mapFromGlobal(const QPoint& pos) const
+{
+ QGraphicsView *view = q->scene()->views().first();
+ return q->mapFromScene(view->mapToScene(pos)).toPoint();
+}
+
+bool TestHbWidget::ensureVisibleRegion(const QRegion&)
+{ return true; }
+
+bool TestHbWidget::hasFocus() const
+{ return q->hasFocus(); }
+
+bool TestHbWidget::grabPixmap(QPixmap &pixmap) const
+{
+ QGraphicsView *view = q->scene()->views().first();
+ pixmap = QPixmap::grabWidget( view, geometry() );
+ return true;
+}
+
+bool TestHbWidget::canWrap(QObject *o)
+{
+ return qobject_cast<HbWidget*>(o); }
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/hbwidgets/testhbwidget.h b/old/plugins/qtuitest_widgets/hbwidgets/testhbwidget.h
new file mode 100644
index 0000000..f1c225f
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/hbwidgets/testhbwidget.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTHBWIDGET_H
+#define TESTHBWIDGET_H
+
+#include <HbWidget>
+#include <QRect>
+#include <qtuitestwidgetinterface.h>
+
+namespace QtUiTest {
+
+class TestHbWidget : public QObject,
+ public QtUiTest::Widget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::Widget)
+
+public:
+ TestHbWidget(QObject*);
+
+ virtual const QRect& geometry() const;
+ virtual bool isVisible() const;
+ virtual QRegion visibleRegion() const;
+ virtual const QObjectList &children() const;
+ virtual QObject* parent() const;
+ virtual QPoint mapToGlobal(const QPoint&) const;
+ virtual QPoint mapFromGlobal(const QPoint&) const;
+ virtual bool ensureVisibleRegion(const QRegion&);
+ virtual bool hasFocus() const;
+ virtual bool grabPixmap(QPixmap &pixmap) const;
+
+ static bool canWrap(QObject*);
+
+private:
+ HbWidget* q;
+
+protected:
+ mutable QObjectList m_children;
+ mutable QRect m_geometry;
+};
+
+}
+#endif \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/qgraphicsviewwidgets.pro b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/qgraphicsviewwidgets.pro
new file mode 100644
index 0000000..9b0e7bc
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/qgraphicsviewwidgets.pro
@@ -0,0 +1,38 @@
+SOURCES += \
+ testgraphicsitem.cpp \
+ testgraphicsproxywidget.cpp \
+ testgraphicstextitem.cpp \
+ testgraphicswidget.cpp \
+ testgraphicsview.cpp \
+ testgraphicsviewfactory.cpp
+
+HEADERS += \
+ testgraphicsitem.h \
+ testgraphicsproxywidget.h \
+ testgraphicstextitem.h \
+ testgraphicswidget.h \
+ testgraphicsview.h \
+ testgraphicsviewfactory.h
+
+TEMPLATE=lib
+CONFIG+=plugin
+VPATH+=$$PWD
+INCLUDEPATH+=$$PWD
+TARGET=qgraphicsviewwidgets
+TARGET=$$qtLibraryTarget($$TARGET)
+
+include($$SRCROOT/libqtuitest/libqtuitest.pri)
+
+target.path=$$[QT_INSTALL_PLUGINS]/qtuitest_widgets
+
+unix:!symbian {
+ MOC_DIR=$$OUT_PWD/.moc
+ OBJECTS_DIR=$$OUT_PWD/.obj
+}
+
+symbian {
+ TARGET.EPOCALLOWDLLDATA=1
+ MOC_DIR=$$OUT_PWD/moc
+ OBJECTS_DIR=$$OUT_PWD/obj
+}
+INSTALLS += target
diff --git a/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsitem.cpp b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsitem.cpp
new file mode 100644
index 0000000..f518c05
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsitem.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testgraphicsitem.h"
+#include "testgraphicsviewfactory.h"
+#include <qgraphicsview.h>
+#include <QDebug>
+
+namespace QtUiTest {
+
+TestGraphicsItem::TestGraphicsItem(QGraphicsItem* _q)
+ : q(_q)
+{}
+
+// As the item may be transformed (eg, rotated relative to view) the
+// area of the bounding rect may be considerably larger than that of the item.
+const QRect& TestGraphicsItem::geometry() const
+{
+ QGraphicsView *view = q->scene()->views().first();
+ m_geometry = view->mapFromScene(q->sceneBoundingRect()).boundingRect();
+
+ return m_geometry;
+}
+
+bool TestGraphicsItem::isVisible() const
+{
+ return q->isVisibleTo(0);
+}
+
+QRegion TestGraphicsItem::visibleRegion() const
+{
+ //FIXME
+
+ QRegion ret;
+
+ if (isVisible()) {
+ ret = q->boundingRegion(QTransform());
+ }
+
+ return ret;
+}
+
+const QObjectList& TestGraphicsItem::children() const
+{
+ m_children.clear();
+ foreach(QGraphicsItem *child, q->childItems()) {
+ QObject *obj = TestGraphicsViewFactory::supportedGraphicsItem(child);
+ if (obj)
+ m_children << obj;
+ }
+ return m_children;
+}
+
+QObject* TestGraphicsItem::parent() const
+{
+// return QObject::parent();
+ return q->scene()->views().first();
+}
+
+QPoint TestGraphicsItem::mapToGlobal(const QPoint& pos) const
+{
+ QPointF posf(pos);
+ QGraphicsView *view = q->scene()->views().first();
+ return view->mapToGlobal(view->mapFromScene(q->mapToScene(posf)));
+}
+
+QPoint TestGraphicsItem::mapFromGlobal(const QPoint& pos) const
+{
+ QGraphicsView *view = q->scene()->views().first();
+ return q->mapFromScene(view->mapToScene(pos)).toPoint();
+}
+
+bool TestGraphicsItem::ensureVisibleRegion(const QRegion&)
+{ return true; }
+
+bool TestGraphicsItem::hasFocus() const
+{ return q->hasFocus(); }
+
+#ifdef Q_WS_QWS
+bool TestGraphicsItem::hasEditFocus() const
+{ return hasFocus(); }
+
+bool TestGraphicsItem::setEditFocus(bool)
+{ return false; }
+#endif
+
+bool TestGraphicsItem::grabPixmap(QPixmap &pixmap) const
+{
+ QGraphicsView *view = q->scene()->views().first();
+ pixmap = QPixmap::grabWidget( view, geometry() );
+ return true;
+}
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsitem.h b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsitem.h
new file mode 100644
index 0000000..309d907
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsitem.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTGRAPHICSITEM_H
+#define TESTGRAPHICSITEM_H
+
+#include <QGraphicsItem>
+#include <QRect>
+#include <qtuitestwidgetinterface.h>
+
+namespace QtUiTest {
+
+class TestGraphicsItem : public QObject,
+ public QtUiTest::Widget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::Widget)
+
+public:
+ TestGraphicsItem(QGraphicsItem*);
+
+ virtual const QRect& geometry() const;
+ virtual bool isVisible() const;
+ virtual QRegion visibleRegion() const;
+ virtual const QObjectList &children() const;
+ virtual QObject* parent() const;
+ virtual QPoint mapToGlobal(const QPoint&) const;
+ virtual QPoint mapFromGlobal(const QPoint&) const;
+ virtual bool ensureVisibleRegion(const QRegion&);
+ virtual bool hasFocus() const;
+#ifdef Q_WS_QWS
+ virtual bool hasEditFocus() const;
+ virtual bool setEditFocus(bool);
+#endif
+ virtual bool grabPixmap(QPixmap &pixmap) const;
+
+private:
+ QGraphicsItem* q;
+
+protected:
+ mutable QObjectList m_children;
+ mutable QRect m_geometry;
+};
+
+}
+#endif \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsproxywidget.cpp b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsproxywidget.cpp
new file mode 100644
index 0000000..d442269
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsproxywidget.cpp
@@ -0,0 +1,256 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGraphicsProxyWidget>
+#include "testgraphicsproxywidget.h"
+#include <QWidget>
+
+namespace QtUiTest {
+
+TestGraphicsProxyWidget::TestGraphicsProxyWidget(QObject* _q)
+ : TestGraphicsItem(static_cast<QGraphicsProxyWidget*>(_q))
+ , q(static_cast<QGraphicsProxyWidget*>(_q))
+{}
+
+const QObjectList& TestGraphicsProxyWidget::children() const
+{
+ m_children.clear();
+ m_children << qobject_cast<QObject*>(q->widget());
+ return m_children;
+}
+
+bool TestGraphicsProxyWidget::canWrap(QObject *o)
+{ return qobject_cast<QGraphicsProxyWidget*>(o); }
+/*
+static const uint qt_meta_data_TestGraphicsProxyWidget[] = {
+
+ // content:
+ 1, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 0, 0, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_TestGraphicsProxyWidget[] = {
+ "TestFxItem\0"
+};
+
+const QMetaObject TestGraphicsProxyWidget::staticMetaObject = {
+ { &TestGraphicsItem::staticMetaObject, qt_meta_stringdata_TestGraphicsProxyWidget,
+ qt_meta_data_TestGraphicsProxyWidget, 0 }
+};
+
+const QMetaObject *TestGraphicsProxyWidget::metaObject() const
+{
+ return &staticMetaObject;
+}
+
+void *TestGraphicsProxyWidget::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+
+ void* ret = 0;
+
+ do {
+#define DO(Type,String) \
+ if (!strcmp(_clname,#String) && qtuitest_cast<Type*>(q->widget())) { \
+ ret = static_cast<Type*>(this); \
+ break; \
+ }
+ // No need for Widget - TestGfxCanvasItem already handles it.
+ //DO(QtUiTest::Widget, QtUiTest::Widget);
+ //DO(QtUiTest::Widget, com.nokia.qt.QtUiTest.Widget/1.0);
+ DO(QtUiTest::CheckWidget, QtUiTest::CheckWidget);
+ DO(QtUiTest::CheckWidget, com.nokia.qt.QtUiTest.CheckWidget/1.0);
+ DO(QtUiTest::ActivateWidget, QtUiTest::ActivateWidget);
+ DO(QtUiTest::ActivateWidget, com.nokia.qt.QtUiTest.ActivateWidget/1.0);
+ DO(QtUiTest::LabelWidget, QtUiTest::LabelWidget);
+ DO(QtUiTest::LabelWidget, com.nokia.qt.QtUiTest.LabelWidget/1.0);
+ DO(QtUiTest::TextWidget, QtUiTest::TextWidget);
+ DO(QtUiTest::TextWidget, com.nokia.qt.QtUiTest.TextWidget/1.0);
+ DO(QtUiTest::ListWidget, QtUiTest::ListWidget);
+ DO(QtUiTest::ListWidget, com.nokia.qt.QtUiTest.ListWidget/1.0);
+ DO(QtUiTest::InputWidget, QtUiTest::InputWidget);
+ DO(QtUiTest::InputWidget, com.nokia.qt.QtUiTest.InputWidget/1.0);
+ DO(QtUiTest::SelectWidget, QtUiTest::SelectWidget);
+ DO(QtUiTest::SelectWidget, com.nokia.qt.QtUiTest.SelectWidget/1.0);
+#undef DO
+ } while(0);
+
+ if (!ret) ret = TestGraphicsItem::qt_metacast(_clname);
+
+ return ret;
+}
+
+bool TestGraphicsProxyWidget::activate()
+{
+ QtUiTest::ActivateWidget *w = qtuitest_cast<QtUiTest::ActivateWidget*>(q->widget());
+ if (w) return w->activate();
+ return false;
+}
+
+QString TestGraphicsProxyWidget::labelText() const
+{
+ QtUiTest::LabelWidget *w = qtuitest_cast<QtUiTest::LabelWidget*>(q->widget());
+ if (w) return w->labelText();
+ return QString();
+}
+
+QObject* TestGraphicsProxyWidget::buddy() const
+{
+ QObject *ret = 0;
+ QtUiTest::LabelWidget *w = qtuitest_cast<QtUiTest::LabelWidget*>(q->widget());
+ if (w) ret = w->buddy();
+ if (ret == q->widget()) ret = q;
+ return ret;
+}
+
+bool TestGraphicsProxyWidget::isTristate() const
+{
+ QtUiTest::CheckWidget *w = qtuitest_cast<QtUiTest::CheckWidget*>(q->widget());
+ if (w) return w->isTristate();
+ return false;
+}
+
+Qt::CheckState TestGraphicsProxyWidget::checkState() const
+{
+ QtUiTest::CheckWidget *w = qtuitest_cast<QtUiTest::CheckWidget*>(q->widget());
+ if (w) return w->checkState();
+ return Qt::CheckState(0);
+}
+
+bool TestGraphicsProxyWidget::setCheckState(Qt::CheckState state)
+{
+ QtUiTest::CheckWidget *w = qtuitest_cast<QtUiTest::CheckWidget*>(q->widget());
+ if (w) return w->setCheckState(state);
+ return false;
+}
+
+QString TestGraphicsProxyWidget::selectedText() const
+{
+ QtUiTest::TextWidget *w = qtuitest_cast<QtUiTest::TextWidget*>(q->widget());
+ if (w) return w->selectedText();
+ return QString();
+}
+
+QString TestGraphicsProxyWidget::text() const
+{
+ QtUiTest::TextWidget *w = qtuitest_cast<QtUiTest::TextWidget*>(q->widget());
+ if (w) return w->text();
+ return QString();
+}
+
+QStringList TestGraphicsProxyWidget::list() const
+{
+ QtUiTest::ListWidget *w = qtuitest_cast<QtUiTest::ListWidget*>(q->widget());
+ if (w) return w->list();
+ return QStringList();
+}
+
+QRect TestGraphicsProxyWidget::visualRect(const QString& item) const
+{
+ QtUiTest::ListWidget *w = qtuitest_cast<QtUiTest::ListWidget*>(q->widget());
+ if (w) return w->visualRect(item);
+ return QRect();
+}
+
+bool TestGraphicsProxyWidget::ensureVisible(const QString& item)
+{
+ QtUiTest::ListWidget *w = qtuitest_cast<QtUiTest::ListWidget*>(q->widget());
+ if (w) return w->ensureVisible(item);
+ return false;
+}
+
+bool TestGraphicsProxyWidget::canEnter(const QVariant& value) const
+{
+ QtUiTest::InputWidget *w = qtuitest_cast<QtUiTest::InputWidget*>(q->widget());
+ if (w) return w->canEnter(value);
+ return false;
+}
+
+bool TestGraphicsProxyWidget::enter(const QVariant& value, bool noCommit)
+{
+ QtUiTest::InputWidget *w = qtuitest_cast<QtUiTest::InputWidget*>(q->widget());
+ if (w) return w->enter(value, noCommit);
+ return false;
+}
+
+bool TestGraphicsProxyWidget::isMultiSelection() const
+{
+ QtUiTest::SelectWidget *w = qtuitest_cast<QtUiTest::SelectWidget*>(q->widget());
+ if (w) return w->isMultiSelection();
+ return false;
+}
+
+bool TestGraphicsProxyWidget::canSelect(const QString& item) const
+{
+ QtUiTest::SelectWidget *w = qtuitest_cast<QtUiTest::SelectWidget*>(q->widget());
+ if (w) return w->canSelect(item);
+ return false;
+}
+
+bool TestGraphicsProxyWidget::canSelectMulti(const QStringList& items) const
+{
+ QtUiTest::SelectWidget *w = qtuitest_cast<QtUiTest::SelectWidget*>(q->widget());
+ if (w) return w->canSelectMulti(items);
+ return false;
+}
+
+bool TestGraphicsProxyWidget::select(const QString& item)
+{
+ QtUiTest::SelectWidget *w = qtuitest_cast<QtUiTest::SelectWidget*>(q->widget());
+ if (w) return w->select(item);
+ return false;
+}
+
+bool TestGraphicsProxyWidget::selectMulti(const QStringList& items)
+{
+ QtUiTest::SelectWidget *w = qtuitest_cast<QtUiTest::SelectWidget*>(q->widget());
+ if (w) return w->selectMulti(items);
+ return false;
+}
+*/
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsproxywidget.h b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsproxywidget.h
new file mode 100644
index 0000000..9c11d9b
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsproxywidget.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTGRAPHICSPROXYWIDGET_H
+#define TESTGRAPHICSPROXYWIDGET_H
+
+#include "testgraphicsitem.h"
+#include <QGraphicsProxyWidget>
+
+namespace QtUiTest {
+
+class TestGraphicsProxyWidget : public TestGraphicsItem
+/*,
+ public QtUiTest::ActivateWidget,
+ public QtUiTest::LabelWidget,
+ public QtUiTest::CheckWidget,
+ public QtUiTest::TextWidget,
+ public QtUiTest::ListWidget,
+ public QtUiTest::InputWidget,
+ public QtUiTest::SelectWidget
+*/
+{
+ Q_OBJECT//_CHECK
+
+public:
+/* static const QMetaObject staticMetaObject;
+ virtual const QMetaObject *metaObject() const;
+ virtual void *qt_metacast(const char *);
+*/
+ TestGraphicsProxyWidget(QObject*);
+
+ virtual const QObjectList &children() const;
+
+ static bool canWrap(QObject*);
+/*
+ virtual bool activate();
+
+ virtual QString labelText() const;
+ virtual QObject* buddy() const;
+
+ virtual bool isTristate() const;
+ virtual Qt::CheckState checkState() const;
+ virtual bool setCheckState(Qt::CheckState);
+
+ virtual QString selectedText() const;
+ virtual QString text() const;
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(const QString&) const;
+ virtual bool ensureVisible(const QString&);
+
+ virtual bool canEnter(const QVariant&) const;
+ virtual bool enter(const QVariant&,bool);
+
+ virtual bool isMultiSelection() const;
+
+ virtual bool canSelect(const QString&) const;
+ virtual bool canSelectMulti(const QStringList&) const;
+ virtual bool select(const QString&);
+ virtual bool selectMulti(const QStringList&);
+*/
+private:
+ QGraphicsProxyWidget* q;
+};
+
+}
+#endif \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicstextitem.cpp b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicstextitem.cpp
new file mode 100644
index 0000000..7070968
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicstextitem.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGraphicsTextItem>
+#include "testgraphicstextitem.h"
+
+namespace QtUiTest {
+
+TestGraphicsTextItem::TestGraphicsTextItem(QObject* _q)
+ : TestGraphicsItem(static_cast<QGraphicsTextItem*>(_q))
+ , q(static_cast<QGraphicsTextItem*>(_q))
+{}
+
+QString TestGraphicsTextItem::text() const
+{ return q->toPlainText(); }
+
+QString TestGraphicsTextItem::labelText() const
+{ return text(); }
+
+QObject* TestGraphicsTextItem::buddy() const
+{
+ return q;
+}
+
+bool TestGraphicsTextItem::canWrap(QObject *o)
+{ return qobject_cast<QGraphicsTextItem*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicstextitem.h b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicstextitem.h
new file mode 100644
index 0000000..48b1639
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicstextitem.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTGRAPHICSTEXTITEM_H
+#define TESTGRAPHICSTEXTITEM_H
+
+#include "testgraphicsitem.h"
+
+class QGraphicsTextItem;
+
+namespace QtUiTest {
+
+class TestGraphicsTextItem : public TestGraphicsItem,
+ public QtUiTest::TextWidget,
+ public QtUiTest::LabelWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::TextWidget)
+ Q_INTERFACES(QtUiTest::LabelWidget)
+
+public:
+ TestGraphicsTextItem(QObject*);
+
+ virtual QString text() const;
+
+ virtual QString labelText() const;
+ virtual QObject* buddy() const;
+
+ static bool canWrap(QObject*);
+
+private:
+ QGraphicsTextItem* q;
+};
+
+}
+#endif \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsview.cpp b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsview.cpp
new file mode 100644
index 0000000..2bc1da1
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsview.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testgraphicsview.h"
+#include "testgraphicsviewfactory.h"
+
+#include <qgraphicsitem.h>
+#include <qgraphicsview.h>
+
+namespace QtUiTest {
+
+TestGraphicsView::TestGraphicsView(QObject* _q)
+ : TestWidget(_q), q(qobject_cast<QGraphicsView*>(_q))
+{}
+
+QObjectList const& TestGraphicsView::children() const
+{
+ m_children.clear();
+ foreach(QGraphicsItem *child, q->items()) {
+// if (child->parentItem()) continue;
+ QObject *obj = TestGraphicsViewFactory::supportedGraphicsItem(child);
+ if (obj)
+ m_children << obj;
+ }
+ return m_children;
+}
+
+bool TestGraphicsView::canWrap(QObject *o)
+{ return qobject_cast<QGraphicsView*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsview.h b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsview.h
new file mode 100644
index 0000000..0f98689
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsview.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTGRAPHICSVIEW_H
+#define TESTGRAPHICSVIEW_H
+
+#include <testwidget.h>
+
+class QGraphicsView;
+
+namespace QtUiTest {
+
+class TestGraphicsView : public TestWidget
+{
+ Q_OBJECT
+
+public:
+ TestGraphicsView(QObject*);
+ static bool canWrap(QObject*);
+
+ virtual QObjectList const& children() const;
+
+private:
+ QGraphicsView* q;
+
+ mutable QObjectList m_children;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsviewfactory.cpp b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsviewfactory.cpp
new file mode 100644
index 0000000..6aaeb79
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsviewfactory.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testgraphicsviewfactory.h"
+
+#include "testgraphicsproxywidget.h"
+#include "testgraphicstextitem.h"
+#include "testgraphicsview.h"
+#include "testgraphicswidget.h"
+
+//#include "testwidgetslog.h"
+
+#include <QApplication>
+
+namespace QtUiTest {
+
+TestGraphicsViewFactory::TestGraphicsViewFactory()
+{
+}
+
+QObject* TestGraphicsViewFactory::create(QObject* o)
+{
+ QObject* ret = 0;
+
+#define TRY(Klass) \
+ if (Klass::canWrap(o)) { \
+ ret = new Klass(o); \
+ break; \
+ }
+
+ /* Order is important here; classes should be listed in order of
+ * most to least derived. */
+
+ do {
+ /* Qt Graphics View items */
+ TRY(TestGraphicsTextItem);
+ TRY(TestGraphicsProxyWidget);
+ TRY(TestGraphicsWidget);
+ TRY(TestGraphicsView);
+// TRY(TestGraphicsItem);
+ } while(0);
+
+// TestWidgetsLog() << o << ret;
+
+ return ret;
+}
+
+QStringList TestGraphicsViewFactory::keys() const
+{
+ /* Order doesn't matter here. */
+ return QStringList()
+ << "QGraphicsTextItem"
+ << "QGraphicsProxyWidget"
+ << "QGraphicsView"
+ << "QGraphicsWidget"
+ ;
+}
+
+QObject* TestGraphicsViewFactory::supportedGraphicsItem(QGraphicsItem* item)
+{
+ QObject *ret = 0;
+ if ( (ret = qgraphicsitem_cast<QGraphicsTextItem*>(item)) ) {return ret;}
+ if ( (ret = qobject_cast<QObject*>(qgraphicsitem_cast<QGraphicsProxyWidget*>(item))) ) {return ret;}
+ if ( (ret = qgraphicsitem_cast<QGraphicsWidget*>(item)) ) {return ret;}
+ return ret;
+}
+
+}
+#include <qplugin.h>
+Q_EXPORT_PLUGIN2(qtgraphicsviewwidgets, QtUiTest::TestGraphicsViewFactory)
+
diff --git a/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsviewfactory.h b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsviewfactory.h
new file mode 100644
index 0000000..f91c3e1
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicsviewfactory.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTGRAPHICSVIEWFACTORY_H
+#define TESTGRAPHICSVIEWFACTORY_H
+
+#include <QObject>
+#include <QGraphicsItem>
+#include <qtuitestwidgetinterface.h>
+
+namespace QtUiTest {
+
+class TestGraphicsViewFactory : public QObject, public QtUiTest::WidgetFactory
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::WidgetFactory)
+
+public:
+ TestGraphicsViewFactory();
+
+ virtual QObject* create(QObject*);
+ virtual QStringList keys() const;
+
+ static QObject* supportedGraphicsItem(QGraphicsItem*);
+};
+
+}
+#endif \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicswidget.cpp b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicswidget.cpp
new file mode 100644
index 0000000..342f013
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicswidget.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGraphicsWidget>
+#include "testgraphicswidget.h"
+
+namespace QtUiTest {
+
+TestGraphicsWidget::TestGraphicsWidget(QObject* _q)
+ : TestGraphicsItem(static_cast<QGraphicsWidget*>(_q))
+ , q(static_cast<QGraphicsWidget*>(_q))
+{}
+
+bool TestGraphicsWidget::canWrap(QObject *o)
+{ return qobject_cast<QGraphicsWidget*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicswidget.h b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicswidget.h
new file mode 100644
index 0000000..ae63052
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qgraphicsviewwidgets/testgraphicswidget.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTGRAPHICSWIDGET_H
+#define TESTGRAPHICSWIDGET_H
+
+#include "testgraphicsitem.h"
+
+class QGraphicsWidget;
+
+namespace QtUiTest {
+
+class TestGraphicsWidget : public TestGraphicsItem
+{
+ Q_OBJECT
+
+public:
+ TestGraphicsWidget(QObject*);
+ static bool canWrap(QObject*);
+
+private:
+ QGraphicsWidget* q;
+};
+
+}
+#endif \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/qmlwidgets.pro b/old/plugins/qtuitest_widgets/qmlwidgets/qmlwidgets.pro
new file mode 100644
index 0000000..1b2707f
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/qmlwidgets.pro
@@ -0,0 +1,50 @@
+SOURCES += \
+ testdeclarativefactory.cpp \
+ testdeclarativeitem.cpp \
+ testdeclarativelistview.cpp \
+ testdeclarativetext.cpp \
+ testdeclarativetextinput.cpp \
+ testdeclarativeview.cpp \
+ testdeclarativemousearea.cpp
+
+HEADERS += \
+ testdeclarativefactory.h \
+ testdeclarativeitem.h \
+ testdeclarativelistview.h \
+ testdeclarativetext.h \
+ testdeclarativetextinput.h \
+ testdeclarativeview.h \
+ testdeclarativemousearea.h
+
+TEMPLATE=lib
+CONFIG+=plugin
+
+MOC_DIR=$$OUT_PWD/.moc
+OBJECTS_DIR=$$OUT_PWD/.obj
+VPATH+=$$PWD
+INCLUDEPATH+=$$PWD
+INCLUDEPATH+=$$SRCROOT/libqtwidgets
+QT+=declarative script opengl
+TARGET=qmlwidgets
+INCLUDEPATH+=$(HOME)/opengles2/SDKPackage/Builds/OGLES2/Include
+
+include($$SRCROOT/libqtuitest/libqtuitest.pri)
+
+unix:!symbian {
+ MOC_DIR=$$OUT_PWD/.moc
+ OBJECTS_DIR=$$OUT_PWD/.obj
+ target.path=$$[QT_INSTALL_PLUGINS]/qtuitest_widgets
+ INSTALLS+=target
+}
+
+win32 {
+ target.path=$$[QT_INSTALL_PLUGINS]/qtuitest_widgets
+ INSTALLS+=target
+}
+
+contains(QT_CONFIG, webkit) {
+ QT+=webkit
+ SOURCES+=testdeclarativewebview.cpp
+ HEADERS+=testdeclarativewebview.h
+}
+
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativefactory.cpp b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativefactory.cpp
new file mode 100644
index 0000000..2a4495e
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativefactory.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testdeclarativefactory.h"
+#include "testdeclarativeitem.h"
+#include "testdeclarativetext.h"
+#include "testdeclarativetextinput.h"
+#include "testdeclarativemousearea.h"
+#include "testdeclarativelistview.h"
+#include "testdeclarativewebview.h"
+#include "testdeclarativeview.h"
+
+#include <QDebug>
+
+#include <QDeclarativeView>
+#include <QDeclarativeItem>
+#include <private/qdeclarativelistview_p.h>
+#include <private/qdeclarativetext_p.h>
+#include <private/qdeclarativetextinput_p.h>
+#include <private/qdeclarativemousearea_p.h>
+
+#if !defined(QT_NO_WEBKIT)
+# include <private/qdeclarativewebview_p.h>
+#endif
+
+TestQmlFactory::TestQmlFactory()
+{
+}
+
+QObject* TestQmlFactory::create(QObject* o)
+{
+ QObject* ret = 0;
+
+#define TRY(Type,TestType) while (!ret) { \
+ Type* thing = qobject_cast<Type*>(o); \
+ if (thing) ret = new TestType(thing); \
+ break; \
+}
+
+ TRY(QDeclarativeView, TestDeclarativeView);
+#if !defined(QT_NO_WEBKIT)
+ TRY(QDeclarativeWebView, TestDeclarativeWebView);
+#endif
+ TRY(QDeclarativeListView, TestDeclarativeListView);
+ TRY(QDeclarativeTextInput, TestDeclarativeTextInput);
+ TRY(QDeclarativeText, TestDeclarativeText);
+ TRY(QDeclarativeMouseArea, TestDeclarativeMouseArea);
+ TRY(QDeclarativeItem, TestDeclarativeItem);
+
+ return ret;
+}
+
+QStringList TestQmlFactory::keys() const
+{
+ return QStringList()
+ << "QDeclarativeItem"
+ << "QDeclarativeView"
+ << "QDeclarativeListView"
+ << "QDeclarativeMouseArea"
+ << "QDeclarativeText"
+ << "QDeclarativeTextInput"
+#if !defined(QT_NO_WEBKIT)
+ << "QDeclarativeWebView"
+#endif
+ ;
+}
+
+#include <qplugin.h>
+Q_EXPORT_PLUGIN2(qmlwidgets, TestQmlFactory)
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativefactory.h b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativefactory.h
new file mode 100644
index 0000000..85a022b
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativefactory.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEST_DECLARATIVE_FACTORY_H
+#define TEST_DECLARATIVE_FACTORY_H
+
+#include <QObject>
+
+#include <qtuitestwidgetinterface.h>
+
+class TestQmlFactory : public QObject, public QtUiTest::WidgetFactory
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::WidgetFactory)
+
+public:
+ TestQmlFactory();
+
+ virtual QObject* create(QObject*);
+ virtual QStringList keys() const;
+};
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeitem.cpp b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeitem.cpp
new file mode 100644
index 0000000..09b593e
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeitem.cpp
@@ -0,0 +1,299 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testdeclarativeitem.h"
+
+#include <QDeclarativeItem>
+#include <QDeclarativeEngine>
+#include <QDeclarativeContext>
+#include <QDeclarativeListProperty>
+#include <QScriptValue>
+#include <QMetaObject>
+#include <QMetaProperty>
+#include <private/qdeclarativemetatype_p.h>
+#include <QDebug>
+
+TestDeclarativeItem::TestDeclarativeItem(QDeclarativeItem* _q)
+ : QtUiTest::TestGraphicsItem(_q),
+ q(_q),
+ m_childActivate(false)
+{
+}
+
+const QObjectList& TestDeclarativeItem::children() const
+{
+ m_children.clear();
+
+ foreach (QObject *child, q->children()) {
+ if (qobject_cast<QDeclarativeItem*>(child))
+ m_children << child;
+ }
+
+ return m_children;
+}
+
+bool TestDeclarativeItem::implements(char const* interface) const
+{
+ if (interface == QLatin1String("ActivateWidget")) {
+ m_childActivate = 0;
+ foreach (QObject *child, children()) {
+ if (qtuitest_cast<QtUiTest::ActivateWidget*>(child)) {
+ m_childActivate = child;
+ return true;
+ }
+ }
+ return false;
+ }
+ return (interface == QLatin1String("Widget"));
+}
+
+static const uint qt_meta_data_TestDeclarativeItem[] = {
+
+ // content:
+ 1, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 0, 0, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+
+ 0 // eodinherits
+};
+
+static const char qt_meta_stringdata_TestDeclarativeItem[] = {
+ "TestDeclarativeItem\0"
+};
+
+const QMetaObject TestDeclarativeItem::staticMetaObject = {
+ { &QObject::staticMetaObject, qt_meta_stringdata_TestDeclarativeItem,
+ qt_meta_data_TestDeclarativeItem, 0 }
+};
+
+const QMetaObject *TestDeclarativeItem::metaObject() const
+{
+ return &staticMetaObject;
+}
+
+void *TestDeclarativeItem::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+
+ void* ret = 0;
+
+ do {
+#define DO(Type,String) \
+ if (!strcmp(_clname,#String) && implements(static_cast<Type*>(0)->_q_interfaceName())) { \
+ ret = static_cast<Type*>(this); \
+ break; \
+ }
+
+ DO(QtUiTest::Widget, QtUiTest::Widget);
+ DO(QtUiTest::Widget, com.nokia.qt.QtUiTest.Widget/1.0);
+ DO(QtUiTest::CheckWidget, QtUiTest::CheckWidget);
+ DO(QtUiTest::CheckWidget, com.nokia.qt.QtUiTest.CheckWidget/1.0);
+ DO(QtUiTest::ActivateWidget, QtUiTest::ActivateWidget);
+ DO(QtUiTest::ActivateWidget, com.nokia.qt.QtUiTest.ActivateWidget/1.0);
+ DO(QtUiTest::LabelWidget, QtUiTest::LabelWidget);
+ DO(QtUiTest::LabelWidget, com.nokia.qt.QtUiTest.LabelWidget/1.0);
+ DO(QtUiTest::TextWidget, QtUiTest::TextWidget);
+ DO(QtUiTest::TextWidget, com.nokia.qt.QtUiTest.TextWidget/1.0);
+ DO(QtUiTest::ListWidget, QtUiTest::ListWidget);
+ DO(QtUiTest::ListWidget, com.nokia.qt.QtUiTest.ListWidget/1.0);
+ DO(QtUiTest::InputWidget, QtUiTest::InputWidget);
+ DO(QtUiTest::InputWidget, com.nokia.qt.QtUiTest.InputWidget/1.0);
+ DO(QtUiTest::SelectWidget, QtUiTest::SelectWidget);
+ DO(QtUiTest::SelectWidget, com.nokia.qt.QtUiTest.SelectWidget/1.0);
+#undef DO
+ } while(0);
+
+ if (!ret) ret = QObject::qt_metacast(_clname);
+
+ return ret;
+}
+
+/*************************************************************************************************/
+
+static const QString TestDeclarativeItemSubclassError(
+ "Internal error: TestDeclarativeItem::%1() called. Either %2::implements() is wrong or %2 forgot to override %1."
+);
+
+#define SETERROR() \
+ QtUiTest::setErrorString(TestDeclarativeItemSubclassError.arg(__FUNCTION__).arg(metaObject()->className()))
+
+bool TestDeclarativeItem::activate()
+{
+ if (QtUiTest::ActivateWidget *aw = qtuitest_cast<QtUiTest::ActivateWidget*>(m_childActivate)) {
+ return aw->activate();
+ }
+
+ return false;
+}
+
+QString TestDeclarativeItem::labelText() const
+{ SETERROR(); return QString(); }
+bool TestDeclarativeItem::isTristate() const
+{ SETERROR(); return false; }
+Qt::CheckState TestDeclarativeItem::checkState() const
+{ SETERROR(); return Qt::CheckState(0); }
+bool TestDeclarativeItem::setCheckState(Qt::CheckState)
+{ SETERROR(); return false; }
+QString TestDeclarativeItem::selectedText() const
+{ SETERROR(); return QString(); }
+QString TestDeclarativeItem::text() const
+{ SETERROR(); return QString(); }
+QStringList TestDeclarativeItem::list() const
+{ SETERROR(); return QStringList(); }
+QRect TestDeclarativeItem::visualRect(const QString&) const
+{ SETERROR(); return QRect(); }
+bool TestDeclarativeItem::ensureVisible(const QString&)
+{ SETERROR(); return false; }
+bool TestDeclarativeItem::canEnter(const QVariant&) const
+{ SETERROR(); return false; }
+bool TestDeclarativeItem::enter(const QVariant&,bool)
+{ SETERROR(); return false; }
+bool TestDeclarativeItem::isMultiSelection() const
+{ SETERROR(); return false; }
+bool TestDeclarativeItem::canSelect(const QString&) const
+{ SETERROR(); return false; }
+bool TestDeclarativeItem::canSelectMulti(const QStringList&) const
+{ SETERROR(); return false; }
+bool TestDeclarativeItem::select(const QString&)
+{ SETERROR(); return false; }
+bool TestDeclarativeItem::selectMulti(const QStringList&)
+{ SETERROR(); return false; }
+
+
+
+///////
+
+bool TestDeclarativeItem::isVisible() const
+{
+ return q->isVisible();
+}
+
+QObject* TestDeclarativeItem::parent() const
+{ return q->parentItem() ? q->parentItem() : TestGraphicsItem::parent(); }
+
+bool TestDeclarativeItem::ensureVisibleRegion(const QRegion&)
+{ return true; }
+
+bool TestDeclarativeItem::hasFocus() const
+{ return q->hasFocus(); }
+
+QString unSlash(const QString &text)
+{
+ int lastSlash = text.lastIndexOf(QLatin1Char('/'));
+ if (lastSlash != -1)
+ return text.mid(lastSlash+1);
+ else
+ return text;
+}
+
+QVariant TestDeclarativeItem::getProperty(const QString& name) const
+{
+ QVariant ret;
+
+ if (name.toUpper() == "QMLTYPE") {
+ QString typeName;
+ QDeclarativeType *type = QDeclarativeMetaType::qmlType(q->metaObject());
+ if (type) {
+ typeName = QLatin1String(type->qmlTypeName());
+ } else {
+ typeName = QString::fromUtf8(q->metaObject()->className());
+ int marker = typeName.indexOf(QLatin1String("_QMLTYPE_"));
+ if (marker != -1)
+ typeName = typeName.left(marker);
+ else {
+ marker = typeName.indexOf(QLatin1String("_QML_"));
+ if (marker != -1)
+ typeName = typeName.left(marker);
+
+ foreach (QDeclarativeType* type, QDeclarativeMetaType::qmlTypes()) {
+ if (type->typeName() == typeName) {
+ typeName = QLatin1String(type->qmlTypeName());
+ break;
+ }
+ }
+ }
+ }
+
+ if (!typeName.isNull()) {
+ int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
+ if (lastSlash != -1)
+ typeName = typeName.mid(lastSlash+1);
+
+ return typeName;
+ }
+ } else if (name.contains('.')) {
+ // This is an attached property
+ int dot = name.indexOf('.');
+ QString attachTypeName = name.left(dot);
+ QDeclarativeType *attachType = 0;
+ foreach (QDeclarativeType* type, QDeclarativeMetaType::qmlTypes()) {
+ if (unSlash(type->qmlTypeName()) == attachTypeName) {
+ attachType = type;
+ break;
+ }
+ }
+ if (attachType) {
+ QDeclarativeAttachedPropertiesFunc func = attachType->attachedPropertiesFunction();
+ if (func) {
+ QObject *attached = func(q);
+ if (attached) {
+ ret = attached->property(name.mid(dot+1).toLatin1());
+ }
+ }
+ }
+ } else {
+ ret = q->property(name.toLatin1());
+ }
+
+ if (ret.type() == QVariant::UserType) {
+ bool ok;
+ QObject *obj = QDeclarativeMetaType::toQObject(ret, &ok);
+ if (ok) {
+ return QVariant::fromValue(obj);
+ }
+ return QVariant();
+ }
+
+ return ret;
+}
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeitem.h b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeitem.h
new file mode 100644
index 0000000..292918a
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeitem.h
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEST_DECLARATIVE_ITEM_H
+#define TEST_DECLARATIVE_ITEM_H
+
+#include "../qgraphicsviewwidgets/testgraphicsitem.h"
+
+class QDeclarativeItem;
+
+class TestDeclarativeItem :
+ public QtUiTest::TestGraphicsItem,
+ public QtUiTest::ActivateWidget,
+ public QtUiTest::LabelWidget,
+ public QtUiTest::CheckWidget,
+ public QtUiTest::TextWidget,
+ public QtUiTest::ListWidget,
+ public QtUiTest::InputWidget,
+ public QtUiTest::SelectWidget
+{
+public:
+ Q_OBJECT_CHECK
+ Q_INTERFACES(
+ QtUiTest::Widget
+ QtUiTest::ActivateWidget
+ QtUiTest::LabelWidget
+ QtUiTest::CheckWidget
+ QtUiTest::TextWidget
+ QtUiTest::ListWidget
+ QtUiTest::InputlWidget
+ QtUiTest::SelectWidget)
+
+ static const QMetaObject staticMetaObject;
+ virtual const QMetaObject *metaObject() const;
+ virtual void *qt_metacast(const char *);
+
+ TestDeclarativeItem(QDeclarativeItem*);
+
+ const QObjectList& children() const;
+ QString id() const;
+
+ virtual bool activate();
+
+ virtual QString labelText() const;
+
+ virtual bool isTristate() const;
+ virtual Qt::CheckState checkState() const;
+ virtual bool setCheckState(Qt::CheckState);
+
+ virtual QString selectedText() const;
+ virtual QString text() const;
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(const QString&) const;
+ virtual bool ensureVisible(const QString&);
+
+ virtual bool canEnter(const QVariant&) const;
+ virtual bool enter(const QVariant&,bool);
+
+ virtual bool isMultiSelection() const;
+
+ virtual bool canSelect(const QString&) const;
+ virtual bool canSelectMulti(const QStringList&) const;
+ virtual bool select(const QString&);
+ virtual bool selectMulti(const QStringList&);
+
+ virtual bool isVisible() const;
+ virtual QObject* parent() const;
+ virtual bool ensureVisibleRegion(const QRegion&);
+ virtual bool hasFocus() const;
+ virtual QVariant getProperty(const QString&) const;
+
+protected:
+ virtual bool implements(const char*) const;
+
+private:
+ QDeclarativeItem* q;
+
+ mutable QObjectList m_children;
+ mutable QObject *m_childActivate;
+};
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativelistview.cpp b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativelistview.cpp
new file mode 100644
index 0000000..33129fb
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativelistview.cpp
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testdeclarativelistview.h"
+#include <private/qdeclarativelistview_p.h>
+#include <private/qlistmodelinterface_p.h>
+
+
+TestDeclarativeListView::TestDeclarativeListView(QDeclarativeListView *_q)
+ : TestDeclarativeItem(_q)
+ , q(_q)
+{}
+
+QString TestDeclarativeListView::selectedText() const
+{
+// waitForModelUpdate(q->model());
+ return getData(q->currentIndex());
+}
+
+
+QString TestDeclarativeListView::getData(int index) const
+{
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(q->model().value<QObject*>());
+// QListModelInterface *model = qobject_cast<QListModelInterface*>(q->model());
+ if (model) {
+ QStringList sl;
+ QList<int> roles = model->roles();
+ QHash<int,QVariant> data = model->data(index, roles);
+ foreach (QVariant value, data)
+ sl << value.toString();
+ return sl.join(" ");
+ }
+ return QString();
+}
+
+QString TestDeclarativeListView::text() const
+{
+ return list().join("\n");
+}
+
+QStringList TestDeclarativeListView::list() const
+{
+ QStringList ret;
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(q->model().value<QObject*>());
+// QListModelInterface *model = qobject_cast<QListModelInterface*>(q->model());
+
+ for (int i = 0; i < model->count(); i++) {
+ ret << getData(i);
+ }
+
+ return ret;
+}
+
+QRect TestDeclarativeListView::visualRect(QString const &item) const
+{
+ using namespace QtUiTest;
+
+ QRect ret;
+/*
+ // Allow testwidgets to make decisions based on the view associated with this item.
+// QVariant view = QVariant::fromValue((QObject*)q);
+// q->model()->setProperty("_q_qtuitest_itemview", view);
+ ListWidget* lw = qtuitest_cast<ListWidget*>(q->model());
+ if (!lw) {
+ QString model;
+ QDebug(&model) << q->model();
+ setErrorString("Could not find a ListWidget interface for model " + model);
+ } else {
+ ret = lw->visualRect(item);
+ }
+*/
+ return ret;
+}
+
+bool TestDeclarativeListView::isMultiSelection() const
+{
+ return false;
+}
+
+bool TestDeclarativeListView::canSelect(QString const &item) const
+{
+ return (list().contains(item));
+}
+
+bool TestDeclarativeListView::canSelectMulti(QStringList const &items) const
+{
+ return false;
+}
+
+bool TestDeclarativeListView::select(QString const &item)
+{
+ if (!canSelect(item)) {
+ return false;
+ }
+
+ // FIXME: Shouldn't set focus this way...
+ q->setFocus(true);
+/*
+
+ //FIXME: Should support both mouse and keyboard
+
+ // Consume pending key events, if any.
+ while (QtUiTest::waitForEvent(q, QEvent::KeyRelease, 200, Qt::QueuedConnection))
+ {}
+
+ QStringList allItems = list();
+
+ const int maxtries = 100;
+ int desiredIndex = allItems.indexOf(item);
+ int currentIndex = q->currentIndex();
+
+ // Move vertically
+ Qt::Key key;
+ if (desiredIndex > currentIndex)
+ key = (q->orientation() == Qt::Vertical) ? Qt::Key_Down : Qt::Key_Right;
+ else
+ key = (q->orientation() == Qt::Vertical) ? Qt::Key_Up : Qt::Key_Left;
+
+ for (int i = 0; i < maxtries && selectedText() != item; ++i) {
+ if (!QtUiTest::keyClick(q->canvas(), key)) return false;
+QtUiTest::wait(200);
+ }
+ QString selected = selectedText();
+ qDebug() << "selectedText() now" << selected;
+ if (selected != item) {
+ QtUiTest::setErrorString(QString(
+ "Up/down keys should have caused item %1 to become selected, but item %2 "
+ "is selected instead.").arg(item).arg(selected));
+ return false;
+ }
+ return true;
+*/
+
+ return false;
+
+}
+
+bool TestDeclarativeListView::selectMulti(QStringList const &items)
+{
+ return false;
+}
+
+bool TestDeclarativeListView::ensureVisible(QString const &item)
+{
+ return true;
+}
+
+bool TestDeclarativeListView::canWrap(QObject* o)
+{ return qobject_cast<QDeclarativeListView*>(o); }
+
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativelistview.h b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativelistview.h
new file mode 100644
index 0000000..6aefbbe
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativelistview.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEST_DECLARATIVE_LISTVIEW_H
+#define TEST_DECLARATIVE_LISTVIEW_H
+
+#include "testdeclarativeitem.h"
+
+
+class QDeclarativeListView;
+
+class TestDeclarativeListView : public TestDeclarativeItem
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::TextWidget
+ QtUiTest::ListWidget
+ QtUiTest::SelectWidget)
+
+public:
+ TestDeclarativeListView(QDeclarativeListView*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+ virtual bool ensureVisible(QString const&);
+
+ virtual bool isMultiSelection() const;
+
+ virtual bool canSelect(QString const&) const;
+ virtual bool canSelectMulti(QStringList const&) const;
+ virtual bool select(QString const&);
+ virtual bool selectMulti(QStringList const&);
+
+ static bool canWrap(QObject*);
+
+signals:
+ void selected(const QString&);
+
+protected:
+ QString getData(int) const;
+
+private:
+ QDeclarativeListView *q;
+
+};
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativemousearea.cpp b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativemousearea.cpp
new file mode 100644
index 0000000..721f55e
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativemousearea.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testdeclarativemousearea.h"
+
+#include <private/qdeclarativemousearea_p.h>
+
+TestDeclarativeMouseArea::TestDeclarativeMouseArea(QDeclarativeMouseArea* _q)
+ : TestDeclarativeItem(_q)
+ , q(_q)
+{}
+
+bool TestDeclarativeMouseArea::activate()
+{
+ QPoint p;
+ p = visibleRegion().boundingRect().center();
+ ensureVisiblePoint(p);
+ QtUiTest::mouseClick(mapToGlobal(p), Qt::LeftButton);
+ QtUiTest::waitForSignal(q, SIGNAL(clicked(QDeclarativeMouseEvent*)));
+ return true;
+}
+
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativemousearea.h b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativemousearea.h
new file mode 100644
index 0000000..21dc282
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativemousearea.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEST_DECLARATIVE_MOUSEAREA_H
+#define TEST_DECLARATIVE_MOUSEAREA_H
+
+#include "testdeclarativeitem.h"
+
+class QDeclarativeMouseArea;
+
+class TestDeclarativeMouseArea : public TestDeclarativeItem
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::ActivateWidget)
+
+public:
+ TestDeclarativeMouseArea(QDeclarativeMouseArea*);
+
+ virtual bool activate();
+
+private:
+ QDeclarativeMouseArea* q;
+};
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetext.cpp b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetext.cpp
new file mode 100644
index 0000000..6a5776d
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetext.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testdeclarativetext.h"
+
+#include <private/qdeclarativetext_p.h>
+
+TestDeclarativeText::TestDeclarativeText(QDeclarativeText* _q)
+ : TestDeclarativeItem(_q)
+ , q(_q)
+{}
+
+QString TestDeclarativeText::text() const
+{ return q->text(); }
+
+QString TestDeclarativeText::selectedText() const
+{ return text(); }
+
+QString TestDeclarativeText::labelText() const
+{ return text(); }
+
+bool TestDeclarativeText::isLabel() const
+{ return true; }
+
+// For QML items, assume that the text is a label for the parent.
+QObject* TestDeclarativeText::buddy() const
+{
+ QObject *parent = TestDeclarativeItem::parent();
+ QtUiTest::Widget *pw = qtuitest_cast<Widget*>(parent);
+ if (pw)
+ return parent;
+ else
+ return 0;
+}
+
+bool TestDeclarativeText::implements(char const* interface) const
+{
+ if (interface == QLatin1String("LabelWidget")) return isLabel();
+ return TestDeclarativeItem::implements(interface);
+}
+
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetext.h b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetext.h
new file mode 100644
index 0000000..fe707d2
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetext.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEST_DECLARATIVE_TEXT_H
+#define TEST_DECLARATIVE_TEXT_H
+
+#include "testdeclarativeitem.h"
+
+class QDeclarativeText;
+
+class TestDeclarativeText : public TestDeclarativeItem
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::TextWidget)
+
+public:
+ TestDeclarativeText(QDeclarativeText*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+ virtual QString labelText() const;
+ virtual QObject* buddy() const;
+
+protected:
+ virtual bool implements(char const*) const;
+
+private:
+ bool isLabel() const;
+
+ QDeclarativeText* q;
+};
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetextinput.cpp b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetextinput.cpp
new file mode 100644
index 0000000..dffe2e7
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetextinput.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testdeclarativetextinput.h"
+
+#include <private/qdeclarativetextinput_p.h>
+
+TestDeclarativeTextInput::TestDeclarativeTextInput(QDeclarativeTextInput* _q)
+ : TestDeclarativeItem(_q)
+ , q(_q)
+{}
+
+QString TestDeclarativeTextInput::text() const
+{ return q->text(); }
+
+QString TestDeclarativeTextInput::selectedText() const
+{ return text(); }
+
+bool TestDeclarativeTextInput::canEnter(QVariant const& item) const
+{
+ if (!item.canConvert<QString>()) return false;
+ if (!q->validator()) return true;
+
+ int dontcare = 0;
+ QString text = item.toString();
+ return (QValidator::Acceptable==q->validator()->validate(text, dontcare));
+}
+
+bool TestDeclarativeTextInput::enter(QVariant const& item, bool noCommit)
+{
+ if (!canEnter(item)) return false;
+ QString itemString = item.toString();
+ using namespace QtUiTest;
+
+ if (!q->hasFocus()) {
+ QPoint p = visibleRegion().boundingRect().center();
+ ensureVisiblePoint(p);
+ QtUiTest::mouseClick(mapToGlobal(p), Qt::LeftButton);
+ QtUiTest::waitForSignal(q, SIGNAL(focusChanged()));
+ if (!q->hasFocus()) {
+ QtUiTest::setErrorString("Couldn't give focus to TextInput");
+ return false;
+ }
+ }
+
+ foreach (QChar const& c, itemString) {
+ if (!keyClick(q, SIGNAL(textChanged()), asciiToKey(c.toLatin1()), asciiToModifiers(c.toLatin1()) ))
+ return false;
+ }
+ if (!noCommit) QtUiTest::keyClick(QtUiTest::Key_Activate);
+
+ return true;
+}
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetextinput.h b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetextinput.h
new file mode 100644
index 0000000..f2a3d82
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativetextinput.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEST_DECLARATIVE_TEXTINPUT_H
+#define TEST_DECLARATIVE_TEXTINPUT_H
+
+#include "testdeclarativeitem.h"
+
+class QDeclarativeTextInput;
+
+class TestDeclarativeTextInput : public TestDeclarativeItem
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::TextWidget)
+ Q_INTERFACES(QtUiTest::InputWidget)
+
+public:
+ TestDeclarativeTextInput(QDeclarativeTextInput*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+
+ virtual bool canEnter(QVariant const&) const;
+ virtual bool enter(QVariant const&,bool);
+
+protected:
+ QDeclarativeTextInput* q;
+};
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeview.cpp b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeview.cpp
new file mode 100644
index 0000000..deafdd6
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeview.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testdeclarativeview.h"
+#include <QDebug>
+#include <QDeclarativeView>
+#include <QDeclarativeItem>
+
+TestDeclarativeView::TestDeclarativeView(QDeclarativeView* _q)
+ : TestGraphicsView(_q), q(_q)
+{}
+
+QObjectList const& TestDeclarativeView::children() const
+{
+ m_children = QObjectList();
+ if (q->rootObject()) m_children << q->rootObject();
+ m_children << q->children();
+ return m_children;
+}
+
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeview.h b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeview.h
new file mode 100644
index 0000000..9611aea
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativeview.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEST_DECLARATIVE_VIEW_H
+#define TEST_DECLARATIVE_VIEW_H
+
+#include "../qgraphicsviewwidgets/testgraphicsview.h"
+
+class QDeclarativeView;
+
+class TestDeclarativeView : public QtUiTest::TestGraphicsView
+{
+ Q_OBJECT
+
+public:
+ TestDeclarativeView(QDeclarativeView*);
+
+ virtual QObjectList const& children() const;
+
+private:
+ QDeclarativeView* q;
+
+ mutable QObjectList m_children;
+};
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativewebview.cpp b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativewebview.cpp
new file mode 100644
index 0000000..9262404
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativewebview.cpp
@@ -0,0 +1,209 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testdeclarativewebview.h"
+
+#include <private/qdeclarativewebview_p.h>
+#include <private/qdeclarativeflickable_p.h>
+
+#include <QWebPage>
+#include <QWebFrame>
+#include <QWebElementCollection>
+
+TestDeclarativeWebView::TestDeclarativeWebView(QDeclarativeWebView *_q)
+ : TestDeclarativeItem(_q), q(_q)
+{
+}
+
+QString TestDeclarativeWebView::text() const
+{
+ QWebPage *page = q->page();
+ if (page && page->mainFrame()) {
+ return page->mainFrame()->toPlainText();
+ }
+ return QString();
+}
+
+QString TestDeclarativeWebView::selectedText() const
+{
+ return text();
+}
+
+QStringList TestDeclarativeWebView::list() const
+{
+ QStringList ret;
+
+ QWebPage *page = q->page();
+ if (page && page->mainFrame()) {
+ QWebElementCollection links = page->mainFrame()->findAllElements("a[href]");
+ foreach (QWebElement el, links) {
+ QString str = el.toPlainText();
+ if (!str.isEmpty()) ret << str;
+ }
+ }
+ return ret;
+}
+
+QWebElement TestDeclarativeWebView::elementForItem(QString const &item) const
+{
+ QWebElement ret;
+ QWebPage *page = q->page();
+ if (page && page->mainFrame()) {
+ QWebElementCollection links = page->mainFrame()->findAllElements("a[href]");
+ foreach (QWebElement el, links) {
+ if (el.toPlainText() == item) {
+ ret = el;
+ break;
+ }
+ }
+ }
+ return ret;
+}
+
+QRect TestDeclarativeWebView::visualRect(QString const &item) const
+{
+ return visualRect(elementForItem(item));
+}
+
+QRect TestDeclarativeWebView::visualRect(QWebElement const &el) const
+{
+ if (!el.isNull()) {
+ QRect geo = el.geometry();
+ qreal scale = q->contentsScale();
+ return QRect(geo.x() * scale, geo.y() * scale, geo.width() * scale, geo.height() * scale);
+ }
+ return QRect();
+}
+
+bool TestDeclarativeWebView::canSelect(QString const &item) const
+{ return list().contains(item); }
+
+bool TestDeclarativeWebView::select(QString const &item)
+{
+ QWebElement el(elementForItem(item));
+ if (el.isNull()) return false;
+
+ QRect rect = visualRect(el);
+ QPoint pos = rect.center();
+
+ if (q->parentItem()) {
+ QDeclarativeFlickable *flick = qobject_cast<QDeclarativeFlickable*>(q->parentItem()->parentItem());
+
+/*
+ qDebug() << "Viewport X " << flick->viewportX();
+ qDebug() << "Viewport Y " << flick->viewportY();
+ qDebug() << "Viewport Width " << flick->viewportWidth();
+ qDebug() << "Viewport Height" << flick->viewportHeight();
+ qDebug() << "Bottom " << flick->viewportY() + flick->height() + q->y();
+ qDebug() << "Item at " << pos;
+*/
+ if (flick && (flick->contentY() + q->y() > pos.y() ||
+ flick->contentY() + flick->height() + q->y() < pos.y())) {
+ // qDebug() << " *** MOVING VIEWPORT ***";
+ flick->setContentY(pos.y() - flick->height()/2);
+ }
+ }
+
+// qDebug() << "Select:" << item << "by clicking at" << pos << mapToGlobal(pos);
+
+ QtUiTest::mouseClick(mapToGlobal(pos), Qt::LeftButton);
+
+ return true;
+}
+
+bool TestDeclarativeWebView::canEnter(QVariant const& item) const
+{
+ // Accept everything for now...
+ return true;
+}
+
+bool TestDeclarativeWebView::enter(QVariant const& item, bool noCommit)
+{
+ QString itemString = item.toString();
+ foreach (QChar const& c, itemString) {
+ QtUiTest::keyClick(QtUiTest::asciiToKey(c.toLatin1()), QtUiTest::asciiToModifiers(c.toLatin1()));
+ }
+ if (!noCommit) QtUiTest::keyClick(QtUiTest::Key_Activate);
+
+ return true;
+}
+
+bool TestDeclarativeWebView::selectIndex(QVariantList const &indexList)
+{
+ QWebElement el;
+ QWebPage *page = q->page();
+ if (page && page->mainFrame()) {
+ if (indexList.size() > 1) {
+ bool ok;
+ int elIndex = indexList[1].toInt(&ok);
+ if (!ok) {
+ QtUiTest::setErrorString("Element index must be an integer");
+ return false;
+ }
+ QWebElementCollection els = page->mainFrame()->findAllElements(indexList[0].toString());
+ if (els.count() < (elIndex-1)) {
+ QtUiTest::setErrorString("Element index out of range");
+ return false;
+ }
+ el = els[elIndex];
+ } else if (indexList.size() == 1) {
+ el = page->mainFrame()->findFirstElement(indexList[0].toString());
+ } else return false;
+ }
+
+ if (el.isNull()) return false;
+
+ QRect rect = visualRect(el);
+ QPoint pos = rect.center();
+
+ if (q->parentItem()) {
+ QDeclarativeFlickable *flick = qobject_cast<QDeclarativeFlickable*>(q->parentItem()->parentItem());
+
+ if (flick && (flick->contentY() + q->y() > pos.y() ||
+ flick->contentY() + flick->height() + q->y() < pos.y())) {
+ flick->setContentY(pos.y() - flick->height()/2);
+ }
+ }
+
+ QtUiTest::mouseClick(mapToGlobal(pos), Qt::LeftButton);
+
+ return true;
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativewebview.h b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativewebview.h
new file mode 100644
index 0000000..cb81b3b
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qmlwidgets/testdeclarativewebview.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEST_DECLARATIVE_WEBVIEW_H
+#define TEST_DECLARATIVE_WEBVIEW_H
+
+#include "testdeclarativeitem.h"
+
+class QDeclarativeWebView;
+class QWebElement;
+
+class TestDeclarativeWebView : public TestDeclarativeItem,
+ public QtUiTest::IndexedWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::TextWidget
+ QtUiTest::ListWidget
+ QtUiTest::SelectWidget
+ QtUiTest::InputWidget
+ QtUiTest::IndexedWidget)
+
+public:
+ TestDeclarativeWebView(QDeclarativeWebView*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+
+ virtual bool canSelect(QString const&) const;
+ virtual bool select(QString const&);
+
+ virtual bool canEnter(QVariant const&) const;
+ virtual bool enter(QVariant const&,bool);
+
+ virtual bool selectIndex(QVariantList const&);
+
+
+protected:
+ QWebElement elementForItem(QString const&) const;
+ virtual QRect visualRect(QWebElement const&) const;
+
+private:
+ QDeclarativeWebView *q;
+};
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtuitest_widgets.pro b/old/plugins/qtuitest_widgets/qtuitest_widgets.pro
new file mode 100644
index 0000000..734a268
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtuitest_widgets.pro
@@ -0,0 +1,10 @@
+TEMPLATE=subdirs
+SUBDIRS +=\
+ qtwidgets
+
+!symbian:SUBDIRS +=qgraphicsviewwidgets
+
+enable_hbwidgets:SUBDIRS += hbwidgets
+
+# QtVersion >= 4.7?
+#SUBDIRS += qmlwidgets
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/DESCRIPTION b/old/plugins/qtuitest_widgets/qtwidgets/DESCRIPTION
new file mode 100644
index 0000000..5735373
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/DESCRIPTION
@@ -0,0 +1 @@
+QtUitest plugin containing logic for interacting with Qt widgets.
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/qtwidgets.pro b/old/plugins/qtuitest_widgets/qtwidgets/qtwidgets.pro
new file mode 100644
index 0000000..986f04e
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/qtwidgets.pro
@@ -0,0 +1,95 @@
+SOURCES += \
+ testabstractbutton.cpp \
+ testabstractitemview.cpp \
+ testabstractspinbox.cpp \
+ testcalendarwidget.cpp \
+ testcheckbox.cpp \
+ testcombobox.cpp \
+ testdateedit.cpp \
+ testdatetimeedit.cpp \
+ testdockwidget.cpp \
+ testfactory.cpp \
+ testgenericcheckwidget.cpp \
+ testgenerictextwidget.cpp \
+ testgroupbox.cpp \
+ testheaderview.cpp \
+ testignore.cpp \
+ testlabel.cpp \
+ testlineedit.cpp \
+ testlistview.cpp \
+ testmenu.cpp \
+ testmenubar.cpp \
+ testpushbutton.cpp \
+ testtabbar.cpp \
+ testtext.cpp \
+ testtextedit.cpp \
+ testtimeedit.cpp \
+ testtoolbar.cpp \
+ testtreeview.cpp \
+ testtreewidget.cpp \
+ testgenericinputmethod.cpp
+
+HEADERS += \
+ testabstractbutton.h \
+ testabstractitemview.h \
+ testabstractspinbox.h \
+ testcalendarwidget.h \
+ testcheckbox.h \
+ testcombobox.h \
+ testdateedit.h \
+ testdatetimeedit.h \
+ testdockwidget.h \
+ testfactory.h \
+ testgenericcheckwidget.h \
+ testgenerictextwidget.h \
+ testgroupbox.h \
+ testheaderview.h \
+ testignore.h \
+ testlabel.h \
+ testlineedit.h \
+ testlistview.h \
+ testwidgetslog.h \
+ testmenu.h \
+ testmenubar.h \
+ testpushbutton.h \
+ testtabbar.h \
+ testtext.h \
+ testtextedit.h \
+ testtimeedit.h \
+ testtoolbar.h \
+ testtreeview.h \
+ testtreewidget.h \
+ testgenericinputmethod.h
+
+TEMPLATE=lib
+CONFIG+=plugin
+VPATH+=$$PWD
+INCLUDEPATH+=$$PWD
+TARGET=qtwidgets
+TARGET=$$qtLibraryTarget($$TARGET)
+
+include($$SRCROOT/libqtuitest/libqtuitest.pri)
+
+
+target.path=$$[QT_INSTALL_PLUGINS]/qtuitest_widgets
+unix:!symbian {
+ MOC_DIR=$$OUT_PWD/.moc
+ OBJECTS_DIR=$$OUT_PWD/.obj
+}
+
+symbian {
+ TARGET.EPOCALLOWDLLDATA=1
+ TARGET.CAPABILITY += AllFiles ReadDeviceData ReadUserData SwEvent WriteUserData NetworkServices
+ MOC_DIR=$$OUT_PWD/moc
+ OBJECTS_DIR=$$OUT_PWD/obj
+ LIBS+= -lws32 -leuser -lcone
+}
+INSTALLS += target
+
+contains(QT_CONFIG, webkit) {
+ QT+=webkit
+ SOURCES+=testwebview.cpp
+ HEADERS+=testwebview.h
+}
+
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testabstractbutton.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testabstractbutton.cpp
new file mode 100644
index 0000000..379f92d
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testabstractbutton.cpp
@@ -0,0 +1,195 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testabstractbutton.h"
+#include "testwidgetslog.h"
+
+#include <QAbstractButton>
+#include <QTimer>
+#include <QTime>
+#include <QPointer>
+#include <QStyleOptionButton>
+
+namespace QtUiTest {
+
+TestAbstractButton::TestAbstractButton(QObject *_q)
+ : TestGenericTextWidget(_q), q(qobject_cast<QAbstractButton*>(_q)),
+ m_pressed(false)
+{
+ if (!QtUiTest::connectFirst(q, SIGNAL(pressed()), this, SIGNAL(activated())))
+ Q_ASSERT(false);
+ if (!connect(q, SIGNAL(toggled(bool)), this, SLOT(on_toggled(bool))))
+ Q_ASSERT(false);
+}
+
+void TestAbstractButton::on_toggled(bool state)
+{ emit stateChanged(state); }
+
+Qt::CheckState TestAbstractButton::checkState() const
+{ return q->isChecked() ? Qt::Checked : Qt::Unchecked; }
+
+bool TestAbstractButton::setCheckState(Qt::CheckState state)
+{
+ if (state == checkState()) return true;
+ if (!q->isCheckable()) {
+ QtUiTest::setErrorString("This abstract button is not checkable.");
+ return false;
+ }
+ bool ret = activate(QtUiTest::NoOptions);
+ TestWidgetsLog() << "activated:" << ret;
+ if (ret && (state != checkState()) && !QtUiTest::waitForSignal(q, SIGNAL(toggled(bool)))) {
+ QtUiTest::setErrorString("Successfully activated button, but check state did not change "
+ "to expected value.");
+ return false;
+ }
+ TestWidgetsLog() << "state:" << ret;
+ return ret;
+}
+
+bool TestAbstractButton::activate()
+{
+ return activate((QtUiTest::InputOption)0);
+}
+
+bool TestAbstractButton::activate(QtUiTest::InputOption opt)
+{
+ if (QtUiTest::mousePreferred()) {
+ int t;
+ m_pressed = false;
+
+ QPoint pos;
+ if (q->isCheckable()) {
+ QStyle const* style = q->style();
+ QStyleOptionButton opt;
+ opt.initFrom(q);
+ QRect rect = style->subElementRect( QStyle::SE_CheckBoxIndicator, &opt, q);
+ pos = rect.center();
+ } else {
+ pos = q->rect().center();
+ }
+
+ QRegion region = QRegion(pos.x()-1, pos.y()-1, 3, 3);
+ for (t = 0; t < 2; ++t) {
+ ensureVisibleRegion(region);
+ QtUiTest::mousePress(mapToGlobal(pos), Qt::LeftButton, opt);
+ QtUiTest::waitForSignal(q, SIGNAL(pressed()));
+ if (q->isDown())
+ break;
+ }
+ if (!q->isDown()) {
+ qWarning("Button did not react to mouse press.");
+ QtUiTest::mouseRelease(mapToGlobal(pos), Qt::LeftButton, opt);
+ return false;
+ }
+ if (t > 0)
+ qWarning("Button did not react to mouse press on first try.");
+
+ QtUiTest::mouseRelease(mapToGlobal(pos), Qt::LeftButton, opt);
+ return true;
+ } else {
+ Qt::Key key = Qt::Key(QtUiTest::Key_ActivateButton);
+ Qt::KeyboardModifiers mod = 0;
+
+ if (q->focusPolicy() == Qt::NoFocus) {
+ /* Handle buttons which need to be activated by a shortcut */
+ QKeySequence ks = q->shortcut();
+ TestWidgetsLog() << "Can't give focus to button; need to use shortcut"
+ << ks.toString();
+ if (ks.isEmpty()) {
+ QtUiTest::setErrorString("Button has NoFocus policy set and does not appear "
+ "to have any shortcut set. Therefore, it is impossible to activate "
+ "using only the keyboard.");
+ return false;
+ }
+
+ int key_and_mod = ks[0];
+ mod = QFlag(key_and_mod & (0xfe000000));
+ key = Qt::Key(key_and_mod & (0x01ffffff));
+ }
+ else {
+ if (!hasFocus()) setFocus();
+ if (!hasFocus()) return false;
+ }
+
+ QPointer<QObject> safeQ(q);
+
+ if (!QtUiTest::keyClick(q, SIGNAL(pressed()), key, mod, opt))
+ return false;
+
+ if (safeQ && q->isDown() && !QtUiTest::waitForSignal(q, SIGNAL(released()))) {
+ QtUiTest::setErrorString("Button did not become released after key click");
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+QString TestAbstractButton::labelText() const
+{
+ QString ret = text();
+ if (ret.isEmpty())
+ return ret;
+
+ QObject *w = parent();
+ while (w) {
+ QtUiTest::Widget *qw = qtuitest_cast<QtUiTest::Widget*>(w);
+ QtUiTest::LabelWidget *lw = qtuitest_cast<QtUiTest::LabelWidget*>(w);
+ if (lw) {
+ if (!lw->labelText().isEmpty()) {
+ ret.prepend(lw->labelText() + "/");
+ break;
+ }
+ }
+ w = qw->parent();
+ }
+ return ret;
+}
+
+QObject* TestAbstractButton::buddy() const
+{
+ return q;
+}
+
+bool TestAbstractButton::canWrap(QObject *o)
+{ return qobject_cast<QAbstractButton*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testabstractbutton.h b/old/plugins/qtuitest_widgets/qtwidgets/testabstractbutton.h
new file mode 100644
index 0000000..687c56e
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testabstractbutton.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTABSTRACTBUTTON_H
+#define TESTABSTRACTBUTTON_H
+
+#include "testgenerictextwidget.h"
+
+class QAbstractButton;
+
+namespace QtUiTest {
+
+class TestAbstractButton : public TestGenericTextWidget,
+ public QtUiTest::CheckWidget,
+ public QtUiTest::ActivateWidget,
+ public QtUiTest::LabelWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::CheckWidget
+ QtUiTest::ActivateWidget
+ QtUiTest::LabelWidget)
+
+public:
+ TestAbstractButton(QObject*);
+
+ virtual Qt::CheckState checkState() const;
+ virtual bool setCheckState(Qt::CheckState);
+ virtual bool activate();
+
+ virtual QString labelText() const;
+ virtual QObject* buddy() const;
+
+ static bool canWrap(QObject*);
+
+protected:
+ bool activate(QtUiTest::InputOption);
+
+signals:
+ void stateChanged(int);
+ void activated();
+
+private slots:
+ void on_toggled(bool);
+
+private:
+ QAbstractButton *q;
+ bool m_pressed;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testabstractitemview.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testabstractitemview.cpp
new file mode 100644
index 0000000..ccb1371
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testabstractitemview.cpp
@@ -0,0 +1,475 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testabstractitemview.h"
+#include "testwidgetslog.h"
+
+#include <QListView>
+#include <QTimer>
+#include <QScrollBar>
+#include <QComboBox>
+#include <QGraphicsProxyWidget>
+#include <QGraphicsView>
+
+#include <qtuitestnamespace.h>
+
+namespace QtUiTest {
+
+TestAbstractItemView::TestAbstractItemView(QObject *_q)
+ : TestWidget(_q), q(qobject_cast<QAbstractItemView*>(_q))
+{
+ if (q && q->parent() && qobject_cast<QComboBox*>(q->parent()->parent())) {
+ // The test object of the combobox will handle recording
+ return;
+ }
+
+ QtUiTest::connectFirst(q, SIGNAL(activated(QModelIndex)),
+ this, SLOT(on_activated(QModelIndex)));
+ QtUiTest::connectFirst(q, SIGNAL(pressed(QModelIndex)),
+ this, SLOT(on_activated(QModelIndex)));
+}
+
+void TestAbstractItemView::on_activated(QModelIndex const& ind)
+{
+ // Timer discourages duplicate signal emission.
+ if (m_lastActivatedTimer.elapsed() > 500 || m_lastActivatedTimer.elapsed() < 0) {
+ TestWidgetsLog() << "emit selected" << ind.data().toString();
+ emit selected(printable(ind.data().toString()));
+ m_lastActivatedTimer.start();
+ } else {
+ TestWidgetsLog() << "Would emit selected" << ind.data().toString()
+ << "except we have already done that recently.";
+ }
+}
+
+QString TestAbstractItemView::selectedText() const
+{
+ TestWidgetsLog();
+ return printable(q->currentIndex().data().toString());
+}
+
+QString TestAbstractItemView::text() const
+{
+ TestWidgetsLog();
+ return list().join("\n");
+}
+
+QStringList TestAbstractItemView::list() const
+{
+ class QModelListGetter : public QModelViewIterator<QAbstractItemView>
+ {
+ public:
+ QModelListGetter(QAbstractItemView *view)
+ : QModelViewIterator<QAbstractItemView>(view) {};
+
+ QStringList getList() {
+ list.clear();
+ iterate(view()->rootIndex());
+ return list;
+ }
+ protected:
+ virtual void visit(QModelIndex const &index)
+ { list << itemForIndex(index); }
+
+ QStringList list;
+ };
+
+ return QModelListGetter(q).getList();
+}
+
+QModelIndex TestAbstractItemView::indexForItem(QString const &item) const
+{
+ QModelIndex ret;
+
+ class QModelIndexGetter : public QModelViewIterator<QAbstractItemView>
+ {
+ public:
+ QModelIndexGetter(QAbstractItemView *view, QString const &item)
+ : QModelViewIterator<QAbstractItemView>(view), matches(0), m_item(item) {};
+ QModelIndex index;
+ int matches;
+
+ protected:
+ void visit(QModelIndex const &idx) {
+
+ if (itemForIndex(idx) == m_item) {
+ ++matches;
+ index = idx;
+ }
+ }
+ private:
+ QString m_item;
+ };
+
+ QModelIndexGetter indexGetter(q, item);
+ indexGetter.iterate(q->rootIndex());
+
+ // No matching item
+ if (!indexGetter.matches) {
+ TestWidgetsLog() << "no matching item for" << item;
+ }
+
+ // More than one matching item
+ else if (indexGetter.matches > 1) {
+ qWarning("QtUitest: more than one item matches '%s' in item view", qPrintable(item));
+ TestWidgetsLog() << indexGetter.matches << "matches for" << item;
+ }
+
+ else
+ ret = indexGetter.index;
+
+ return ret;
+}
+
+QModelIndex TestAbstractItemView::indexFromList(QVariantList const &list) const
+{
+ QVariantList indexList = list;
+ QModelIndex ret;
+ if (list.size() > 1) {
+ int column = indexList.takeLast().toInt();
+ int row = indexList.takeLast().toInt();
+ ret = q->model()->index(row, column, indexFromList(indexList));
+ }
+ return ret;
+}
+
+
+QVariantList TestAbstractItemView::listFromIndex(QModelIndex const &index) const
+{
+ QVariantList ret;
+ if (index.parent().isValid()) {
+ ret << listFromIndex(index.parent());
+ }
+ if (index.isValid()) {
+ ret << index.row() << index.column();
+ }
+
+ return ret;
+}
+
+QRect TestAbstractItemView::visualRect(QString const &item) const
+{
+ QRect ret;
+
+ QModelIndex index = indexForItem(item);
+
+ if (index.isValid()) {
+ ret = q->visualRect(index);
+ ret.moveTopLeft(q->mapFromGlobal(q->viewport()->mapToGlobal(ret.topLeft())));
+ }
+
+ return ret;
+}
+
+bool TestAbstractItemView::isMultiSelection() const
+{ return (q->selectionMode() > QAbstractItemView::SingleSelection); }
+
+bool TestAbstractItemView::canSelect(QString const &item) const
+{
+ if (q->selectionMode() == QAbstractItemView::NoSelection)
+ return false;
+
+ return list().contains(item);
+}
+
+bool TestAbstractItemView::canSelectMulti(QStringList const &items) const
+{
+ if (!isMultiSelection())
+ return false;
+
+ QSet<QString> itemSet = items.toSet();
+ return ((itemSet & list().toSet()) == itemSet);
+}
+
+bool TestAbstractItemView::select(QString const &item)
+{
+ TestWidgetsLog() << item;
+
+ if (!canSelect(item)) {
+ TestWidgetsLog() << "can't select" << item;
+ return false;
+ }
+
+ if (!QtUiTest::mousePreferred() && (!setFocus() || !hasFocus())) {
+ QtUiTest::setErrorString("Couldn't give focus to item view");
+ return false;
+ }
+
+ return select(indexForItem(item));
+}
+
+bool TestAbstractItemView::select(QModelIndex const &index)
+{
+ if (QtUiTest::mousePreferred()) {
+ if (!ensureVisible(index)) {
+ TestWidgetsLog() << "couldn't make item visible";
+ return false;
+ }
+ QPoint pos = q->visualRect(index).center();
+ TestWidgetsLog() << "after ensureVisible, item is at" << pos;
+
+ while (q->parentWidget()) {
+ // Workaround to allow selection from QComboBoxes embedded in a QGraphicsView
+ QGraphicsProxyWidget *gpw = q->parentWidget()->graphicsProxyWidget();
+ if (!gpw) break;
+ QGraphicsScene *scene = gpw->scene();
+ if (!scene) break;
+ QGraphicsView *view = scene->views().first();
+ if (!view) break;
+ QtUiTest::mouseClick(view->mapToGlobal(view->mapFromScene(gpw->mapToScene(pos))), Qt::LeftButton);
+ return true;
+ }
+
+ QtUiTest::mouseClick(q->viewport()->mapToGlobal(pos), Qt::LeftButton);
+ return true;
+
+ } else {
+ // Consume pending key events, if any.
+ while (QtUiTest::waitForEvent(q, QEvent::KeyRelease, 200, Qt::QueuedConnection))
+ {}
+
+ const int maxtries = 100;
+
+ // Move vertically
+ int desiredY = q->visualRect(index).center().y();
+ int currentY = q->visualRect(q->currentIndex()).center().y();
+
+ for (int i = 0; i < maxtries && desiredY != currentY; ++i) {
+ Qt::Key key;
+ if (desiredY < currentY) {
+ key = Qt::Key_Up;
+ TestWidgetsLog() << "Up (desired=" << desiredY << ", current=" << currentY << ")";
+ } else {
+ key = Qt::Key_Down;
+ TestWidgetsLog() << "Down (desired=" << desiredY << ", current=" << currentY << ")";
+ }
+ if (!QtUiTest::keyClick(q, key)) return false;
+ desiredY = q->visualRect(index).center().y();
+ currentY = q->visualRect(q->currentIndex()).center().y();
+ }
+ if (desiredY != currentY) {
+ QtUiTest::setErrorString(QString(
+ "Up/down keys failed to move highlight vertically; desired position %1, "
+ "current position %2").arg(desiredY).arg(currentY));
+ return false;
+ }
+
+ // Move horizontally
+ int desiredX = q->visualRect(index).center().x();
+ int currentX = q->visualRect(q->currentIndex()).center().x();
+
+ for (int i = 0; i < maxtries && desiredX != currentX; ++i) {
+ Qt::Key key;
+ if (desiredX < currentX) {
+ key = Qt::Key_Left;
+ TestWidgetsLog() << "Left (desired=" << desiredX << ", current=" << currentX << ")";
+ } else {
+ key = Qt::Key_Right;
+ TestWidgetsLog() << "Right (desired=" << desiredX << ", current=" << currentX << ")";
+ }
+ if (!QtUiTest::keyClick(q, key)) return false;
+ desiredX = q->visualRect(index).center().x();
+ currentX = q->visualRect(q->currentIndex()).center().x();
+ }
+ if (desiredX != currentX) {
+ QtUiTest::setErrorString(QString(
+ "Left/right keys failed to move highlight horizontally; desired position %1, "
+ "current position %2").arg(desiredX).arg(currentX));
+ return false;
+ }
+
+ TestWidgetsLog() << "hit activate key";
+ if (!QtUiTest::keyClick(q, QtUiTest::Key_Activate)) return false;
+ return true;
+ }
+
+ return false;
+}
+
+bool TestAbstractItemView::selectMulti(QStringList const &items)
+{
+ if (!canSelectMulti(items)) return false;
+
+ TestWidgetsLog() << items;
+
+ return false;
+}
+
+bool TestAbstractItemView::selectIndex(QVariantList const &indexList)
+{
+ QModelIndex idx = indexFromList(indexList);
+ if (idx.isValid()) {
+ return select(idx);
+ }
+ else {
+ QtUiTest::setErrorString("Invalid index");
+ return false;
+ }
+}
+
+QVariantList TestAbstractItemView::selectedIndex() const
+{
+ return listFromIndex(q->currentIndex());
+}
+
+bool TestAbstractItemView::ensureVisible(QString const &item)
+{
+ return ensureVisible(indexForItem(item));
+}
+
+bool TestAbstractItemView::ensureVisible(QModelIndex const &index)
+{
+ QPoint p = q->visualRect(index).center();
+
+ if (q->viewport()->rect().contains(p)) {
+ TestWidgetsLog() << "item is already visible";
+ return true;
+ }
+
+ if (!QtUiTest::mousePreferred())
+ return false;
+
+ /* Figure out the points to click for scrolling in each direction */
+ QScrollBar *vbar = q->verticalScrollBar();
+ QScrollBar *hbar = q->horizontalScrollBar();
+ QPoint up = vbar->mapToGlobal(QPoint(vbar->width()/2,5));
+ QPoint down = vbar->mapToGlobal(QPoint(vbar->width()/2,vbar->height()-5));
+ QPoint left = hbar->mapToGlobal(QPoint(5, hbar->height()/2));
+ QPoint right = hbar->mapToGlobal(QPoint(hbar->width()-5,hbar->height()/2));
+
+ // While p is above rect...
+ while (p.y() < q->viewport()->rect().top()) {
+ if (!vbar->isVisible()) return false;
+ TestWidgetsLog() << "up" << "\nrect:" << rect() << "p:" << p;
+ QtUiTest::mouseClick(up);
+ waitForSignal(vbar, SIGNAL(valueChanged(int)));
+ p = q->visualRect(index).center();
+ }
+ // While p is below rect...
+ while (p.y() > q->viewport()->rect().bottom()) {
+ if (!vbar->isVisible()) return false;
+ TestWidgetsLog() << "down" << "\nrect:" << rect() << "p:" << p;
+ QtUiTest::mouseClick(down);
+ waitForSignal(vbar, SIGNAL(valueChanged(int)));
+ p = q->visualRect(index).center();
+ }
+ // While p is left of rect...
+ while (p.x() < q->viewport()->rect().left()) {
+ if (!hbar->isVisible()) return false;
+ TestWidgetsLog() << "left" << "\nrect:" << rect() << "p:" << p;
+ QtUiTest::mouseClick(left);
+ waitForSignal(hbar, SIGNAL(valueChanged(int)));
+ p = q->visualRect(index).center();
+ }
+ // While p is right of rect...
+ while (p.x() > q->viewport()->rect().right()) {
+ if (!hbar->isVisible()) return false;
+ TestWidgetsLog() << "right" << "\nrect:" << rect() << "p:" << p;
+ QtUiTest::mouseClick(right);
+ waitForSignal(hbar, SIGNAL(valueChanged(int)));
+ p = q->visualRect(index).center();
+ }
+
+ if (!q->viewport()->rect().contains(p)) {
+ TestWidgetsLog() << "failed" << "\nrect:" << q->viewport()->rect() << "p:" << p;
+ return false;
+ }
+
+ return true;
+}
+
+bool TestAbstractItemView::canEnter(QVariant const& item) const
+{
+ bool ret = false;
+ QModelIndex ci = q->currentIndex();
+ if (ci.isValid() && q->selectionMode() != QAbstractItemView::NoSelection && ci.flags() & Qt::ItemIsEditable) {
+ QWidget *indexWidget = q->indexWidget(ci);
+ if (!indexWidget) {
+ // FIXME: Should simulate correct events to enter edit mode
+ q->edit(ci);
+ indexWidget = q->indexWidget(ci);
+ }
+ InputWidget* iw = qtuitest_cast<InputWidget*>(indexWidget);
+ if (iw) {
+ ret = iw->canEnter(item);
+ // FIXME: Should simulate correct events to leave edit mode
+ q->setFocus();
+ } else {
+ SelectWidget* sw = qtuitest_cast<SelectWidget*>(indexWidget);
+ if (sw) {
+ ret = sw->canSelect(item.toString());
+ q->setFocus();
+ }
+ }
+ }
+ return ret;
+}
+
+bool TestAbstractItemView::enter(QVariant const& item, bool noCommit)
+{
+ bool ret = false;
+ QModelIndex ci = q->currentIndex();
+ if (ci.isValid() && q->selectionMode() != QAbstractItemView::NoSelection && ci.flags() & Qt::ItemIsEditable) {
+ QWidget *indexWidget = q->indexWidget(ci);
+ if (!indexWidget) {
+ // FIXME: Should simulate correct events to enter edit mode
+ q->edit(ci);
+ indexWidget = q->indexWidget(ci);
+ }
+ InputWidget* iw = qtuitest_cast<InputWidget*>(indexWidget);
+ if (iw) {
+ ret = iw->enter(item, noCommit);
+ // FIXME: Should simulate correct events to leave edit mode
+ q->setFocus();
+ } else {
+ SelectWidget* sw = qtuitest_cast<SelectWidget*>(indexWidget);
+ ret = sw->select(item.toString());
+ q->setFocus();
+ }
+ }
+
+ return ret;
+}
+
+bool TestAbstractItemView::canWrap(QObject* o)
+{ return qobject_cast<QAbstractItemView*>(o); }
+
+}
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testabstractitemview.h b/old/plugins/qtuitest_widgets/qtwidgets/testabstractitemview.h
new file mode 100644
index 0000000..b6a5ddb
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testabstractitemview.h
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTABSTRACTITEMVIEW_H
+#define TESTABSTRACTITEMVIEW_H
+
+#include <testwidget.h>
+#include <QAbstractItemView>
+#include <QTime>
+
+const int QTUITEST_MAX_LIST=15000;
+
+namespace QtUiTest {
+
+class TestAbstractItemView : public TestWidget,
+ public QtUiTest::TextWidget,
+ public QtUiTest::ListWidget,
+ public QtUiTest::SelectWidget,
+ public QtUiTest::IndexedWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::TextWidget
+ QtUiTest::ListWidget
+ QtUiTest::SelectWidget
+ QtUiTest::IndexedWidget)
+
+public:
+ TestAbstractItemView(QObject*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+ virtual bool ensureVisible(QString const&);
+
+ virtual bool canEnter(QVariant const&) const;
+ virtual bool enter(QVariant const&,bool);
+
+ virtual bool isMultiSelection() const;
+ virtual bool canSelect(QString const&) const;
+ virtual bool canSelectMulti(QStringList const&) const;
+ virtual bool select(QString const&);
+ virtual bool selectMulti(QStringList const&);
+
+ virtual bool selectIndex(QVariantList const&);
+ virtual QVariantList selectedIndex() const;
+
+ static bool canWrap(QObject*);
+
+protected:
+ virtual QModelIndex indexForItem(QString const&) const;
+ virtual QModelIndex indexFromList(QVariantList const&) const;
+ virtual QVariantList listFromIndex(QModelIndex const&) const;
+ virtual bool ensureVisible(QModelIndex const&);
+ virtual bool select(QModelIndex const&);
+
+signals:
+ void selected(const QString&);
+
+private slots:
+ void on_activated(QModelIndex const&);
+
+private:
+ QAbstractItemView *q;
+ QTime m_lastActivatedTimer;
+};
+
+template <typename T>
+class QModelViewIterator
+{
+public:
+ QModelViewIterator(T* view)
+ : m_view(view), count(0)
+ {}
+
+ virtual ~QModelViewIterator()
+ {}
+
+ virtual void iterate(QModelIndex rootIndex = QModelIndex(), bool recurse=true)
+ {
+ QModelIndexList seen;
+ iterate(rootIndex, &seen, recurse, true);
+ }
+
+protected:
+ T* view() const
+ { return m_view; }
+ QAbstractItemModel* model() const
+ { return m_view->model(); }
+
+ virtual void visit(QModelIndex const&) = 0;
+ virtual void overFlow()
+ {
+ QtUiTest::setErrorString("Maximum number of items exceeded");
+ }
+ virtual bool isRowHidden(int, const QModelIndex&)
+ {
+ return false;
+ }
+ virtual QString itemForIndex(QModelIndex const& idx) const
+ {
+ return TestWidget::printable(idx.data().toString());
+ }
+
+private:
+ void iterate(QModelIndex const &index, QModelIndexList *seen, bool recurse, bool isRoot=false)
+ {
+ if (++count > QTUITEST_MAX_LIST) {
+ overFlow();
+ return;
+ }
+
+ if (index.isValid()) {
+ visit(index);
+ (*seen) << index;
+ }
+
+ for (int i = 0, max_i = model()->rowCount(index); i < max_i && count <= QTUITEST_MAX_LIST; ++i) {
+ if (isRowHidden(i, index)) {
+ continue;
+ }
+ for (int j = 0, max_j = model()->columnCount(index);
+ j < max_j && count <= QTUITEST_MAX_LIST; ++j) {
+ QModelIndex child;
+ if (model()->hasIndex(i, j, index)) {
+ child = model()->index(i, j, index);
+ }
+ if (child.isValid() && !seen->contains(child) && (isRoot || recurse)) {
+#if 0
+ /* Very verbose! */
+ qDebug() << "child at (" << i << "," << j << ")" << child.data();
+#endif
+ iterate(child, seen, recurse);
+ }
+ }
+ }
+ }
+
+ T *m_view;
+ int count;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testabstractspinbox.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testabstractspinbox.cpp
new file mode 100644
index 0000000..3469667
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testabstractspinbox.cpp
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testabstractspinbox.h"
+#include "testwidgetslog.h"
+
+#include <QPointer>
+#include <QSpinBox>
+#include <QValidator>
+#include <QVariant>
+
+namespace QtUiTest {
+
+TestAbstractSpinBox::TestAbstractSpinBox(QObject *_q)
+ : TestGenericTextWidget(_q), q(qobject_cast<QAbstractSpinBox*>(_q))
+{
+//TestWidgetsLog();
+}
+
+bool TestAbstractSpinBox::canEnter(QVariant const& item) const
+{
+ if (!item.canConvert<QString>()) return false;
+
+ int dontcare = 0;
+ QString text = item.toString();
+ return (QValidator::Acceptable==q->validate(text, dontcare));
+}
+
+bool TestAbstractSpinBox::enter(QVariant const& item, bool noCommit)
+{
+ if (!canEnter(item)) return false;
+ if (!hasFocus() && !setFocus()) return false;
+
+ using namespace QtUiTest;
+
+ QPointer<QObject> safeThis = this;
+ if (!safeThis) {
+ setErrorString("Widget was destroyed while entering text.");
+ return false;
+ }
+
+ InputWidget* iw = qtuitest_cast<InputWidget*>(inputProxy());
+ TestWidgetsLog() << iw;
+
+ //FIXME: This shouldn't be necessary
+ bool kt = q->keyboardTracking();
+ q->setKeyboardTracking(true);
+
+ //FIXME: Doesn't use mouse events...
+ bool ret = true;
+
+ /* Use input method if available... */
+ if (iw) {
+ ret = iw->canEnter(item) && iw->enter(item, noCommit);
+ } else {
+ //FIXME: Should clear existing text using keyClicks, not API
+ q->clear();
+ /* ...otherwise, generate key clicks ourself */
+ foreach (QChar c, item.toString()) {
+ TestWidgetsLog() << asciiToModifiers(c.toLatin1());
+ keyClick( asciiToKey(c.toLatin1()), asciiToModifiers(c.toLatin1()) );
+ }
+ }
+
+ waitForSignal(q, SIGNAL(valueChanged(int)));
+ q->setKeyboardTracking(kt);
+
+ if (!safeThis) {
+ setErrorString("Widget was destroyed while entering text.");
+ return false;
+ }
+
+ if (mousePreferred()) {
+ return ret;
+ }
+
+ if (!noCommit) {
+ keyClick(QtUiTest::Key_Activate);
+ }
+
+ return ret;
+}
+
+bool TestAbstractSpinBox::canWrap(QObject *o)
+{ return qobject_cast<QAbstractSpinBox*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testabstractspinbox.h b/old/plugins/qtuitest_widgets/qtwidgets/testabstractspinbox.h
new file mode 100644
index 0000000..1f3444e
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testabstractspinbox.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTABSTRACTSPINBOX_H
+#define TESTABSTRACTSPINBOX_H
+
+#include "testgenerictextwidget.h"
+
+class QAbstractSpinBox;
+
+namespace QtUiTest {
+
+class TestAbstractSpinBox : public TestGenericTextWidget
+{
+ Q_OBJECT
+
+public:
+ TestAbstractSpinBox(QObject*);
+
+ virtual bool canEnter(QVariant const&) const;
+ virtual bool enter(QVariant const&,bool);
+
+ static bool canWrap(QObject*);
+
+private:
+ QAbstractSpinBox *q;
+};
+
+}
+#endif
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testcalendarwidget.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testcalendarwidget.cpp
new file mode 100644
index 0000000..68897c6
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testcalendarwidget.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testcalendarwidget.h"
+#include "testwidgetslog.h"
+
+#include <qtuitestnamespace.h>
+
+#include <QAbstractItemView>
+#include <QCalendarWidget>
+#include <QMenu>
+#include <QSpinBox>
+#include <QToolButton>
+
+namespace QtUiTest {
+
+/* FIXME replace this with canSelect */
+QString const GetListRegExp = QString("QTUITEST_REGEX_");
+
+TestCalendarWidget::TestCalendarWidget(QObject *_q)
+ : TestWidget(_q), q(qobject_cast<QCalendarWidget*>(_q))
+{}
+
+QStringList TestCalendarWidget::list() const
+{
+ QStringList ret;
+ QtUiTest::ListWidget *calendarView
+ = qtuitest_cast<QtUiTest::ListWidget*>(
+ q->findChild<QAbstractItemView*>());
+
+ if (!calendarView) {
+ return ret;
+ }
+
+ ret = calendarView->list();
+
+ /* Append months */
+ QStringList months;
+ for (int i = 1; i <= 12; ++i) {
+ months << QDate::longMonthName(i);
+ }
+ ret << months;
+
+ /* Append years */
+ /* FIXME replace this with canSelect() */
+ ret << (GetListRegExp + "[0-9]{4}");
+
+ return ret;
+}
+
+/* FIXME make this less of a hack. */
+QRect TestCalendarWidget::visualRect(QString const &item) const
+{
+ TestWidgetsLog() << item << "my geometry is" << geometry();
+
+ QRect ret;
+
+ QAbstractItemView *view = q->findChild<QAbstractItemView*>();
+ QtUiTest::ListWidget *calendarView
+ = qtuitest_cast<QtUiTest::ListWidget*>(view);
+
+ if (!calendarView) {
+ return ret;
+ }
+
+ ret = calendarView->visualRect(item);
+ if (!ret.isNull()) {
+ ret.moveTopLeft( q->mapFromGlobal( view->mapToGlobal(ret.topLeft()) ) );
+ TestWidgetsLog() << item << "is a visible day at" << ret;
+ return ret;
+ }
+
+ QToolButton *yearButton = 0;
+ QToolButton *monthButton = 0;
+ QSpinBox *yearSpin = q->findChild<QSpinBox*>();
+ QMenu *monthMenu = 0;
+
+ QList<QToolButton*> blist = q->findChildren<QToolButton*>();
+ foreach(QToolButton *b, blist) {
+ if (!monthButton && (monthMenu = b->menu())) {
+ monthButton = b;
+ }
+ if (!b->menu()) {
+ yearButton = b;
+ }
+ }
+ TestWidgetsLog() << "monthButton" << monthButton << "yearButton" << yearButton;
+ TestWidgetsLog() << "item" << item << "monthMenu" << monthMenu;
+
+ if (yearButton && yearButton->isVisible() && yearButton->text() == item) {
+ QPoint p = q->mapFromGlobal( yearButton->mapToGlobal(QPoint(yearButton->width()+5, yearButton->height()/2)) );
+ ret = QRect(p.x() - 2, p.y() - 2, 5, 5);
+ TestWidgetsLog() << "click near yearbutton";
+ } else if (yearSpin && yearSpin->isVisible() && yearSpin->value() == item.toInt()) {
+ TestWidgetsLog() << "confirm spinbox";
+ QPoint p = q->mapFromGlobal( yearSpin->mapToGlobal(QPoint(yearSpin->width()+5, yearSpin->height()/2)) );
+ ret = QRect(p.x() - 2, p.y() - 2, 5, 5);
+ } else if (monthButton && monthButton->isVisible() && monthButton->text() == item) {
+ QPoint p = q->mapFromGlobal( monthButton->mapToGlobal(QPoint(-5, monthButton->height()/2)) );
+ ret = QRect(p.x() - 2, p.y() - 2, 5, 5);
+ TestWidgetsLog() << "click near monthbutton";
+ } else if (monthMenu && monthMenu->isVisible()
+ && qtuitest_cast<QtUiTest::ListWidget*>(monthMenu)
+ && qtuitest_cast<QtUiTest::ListWidget*>(monthMenu)->list().contains(item)) {
+ ret = qtuitest_cast<QtUiTest::ListWidget*>(monthMenu)->visualRect(item);
+ ret.moveTopLeft( q->mapFromGlobal( monthMenu->mapToGlobal(ret.topLeft()) ) );
+ TestWidgetsLog() << "click on monthmenu";
+ } else {
+ do {
+ QStringList items = list();
+ if (items.contains(item)) {
+ ret = QRect(-1, -1, 1, 1);
+ ret.moveTopLeft( q->mapFromGlobal(QPoint(-1,-1)) );
+ break;
+ }
+ foreach (QString s, items) {
+ if (!s.startsWith(GetListRegExp)) continue;
+ QRegExp re(s.mid(GetListRegExp.length()));
+ if (re.exactMatch(item)) {
+ ret = QRect(-1, -1, 1, 1);
+ ret.moveTopLeft( q->mapFromGlobal(QPoint(-1,-1)) );
+ break;
+ }
+ }
+ if (!ret.isNull()) break;
+ } while(0);
+ }
+
+ TestWidgetsLog() << "returning rect" << ret;
+
+ return ret;
+}
+
+/* FIXME implement these. */
+bool TestCalendarWidget::canSelect(QString const&) const
+{ return false; }
+
+bool TestCalendarWidget::select(QString const&)
+{ return false; }
+
+bool TestCalendarWidget::ensureVisible(QString const&)
+{ return false; }
+
+bool TestCalendarWidget::canWrap(QObject *o)
+{ return qobject_cast<QCalendarWidget*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testcalendarwidget.h b/old/plugins/qtuitest_widgets/qtwidgets/testcalendarwidget.h
new file mode 100644
index 0000000..5846a95
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testcalendarwidget.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTCALENDARWIDGET_H
+#define TESTCALENDARWIDGET_H
+
+#include <testwidget.h>
+
+class QCalendarWidget;
+
+namespace QtUiTest {
+
+class TestCalendarWidget : public TestWidget, public QtUiTest::ListWidget,
+ public QtUiTest::SelectWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::ListWidget
+ QtUiTest::SelectWidget)
+
+public:
+ TestCalendarWidget(QObject*);
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+ virtual bool ensureVisible(QString const&);
+
+ virtual bool canSelect(QString const&) const;
+ virtual bool select(QString const&);
+
+ static bool canWrap(QObject*);
+
+private:
+ QCalendarWidget *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testcheckbox.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testcheckbox.cpp
new file mode 100644
index 0000000..cb7c5ee
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testcheckbox.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testcheckbox.h"
+#include "testwidgetslog.h"
+
+#include <QCheckBox>
+
+namespace QtUiTest {
+
+TestCheckBox::TestCheckBox(QObject *_q)
+ : TestAbstractButton(_q), q(qobject_cast<QCheckBox*>(_q))
+{ TestWidgetsLog(); }
+
+bool TestCheckBox::isTristate() const
+{ TestWidgetsLog(); return q->isTristate(); }
+
+Qt::CheckState TestCheckBox::checkState() const
+{ TestWidgetsLog(); return q->checkState(); }
+
+bool TestCheckBox::setCheckState(Qt::CheckState state)
+{
+ Qt::CheckState initState = checkState();
+ if (state == initState) return true;
+
+ bool ret = activate(QtUiTest::NoOptions);
+ TestWidgetsLog() << "activated:" << ret;
+
+ if (ret && (state == initState) && !QtUiTest::waitForSignal(q, SIGNAL(stateChanged(int)))) {
+ QtUiTest::setErrorString("Successfully activated button, but check state did not change "
+ "to expected value.");
+ return false;
+ }
+
+ // Give application time to respond to first activation
+ QtUiTest::wait(20);
+
+ if (state != checkState()) {
+ ret = activate(QtUiTest::NoOptions);
+ TestWidgetsLog() << "activated:" << ret;
+ }
+
+ if (ret && (state != checkState()) && !QtUiTest::waitForSignal(q, SIGNAL(stateChanged(int)))) {
+ QtUiTest::setErrorString("Successfully activated button, but check state did not change "
+ "to expected value.");
+ return false;
+ }
+ TestWidgetsLog() << "state:" << ret;
+ return ret;
+}
+
+bool TestCheckBox::canWrap(QObject *o)
+{ return qobject_cast<QCheckBox*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testcheckbox.h b/old/plugins/qtuitest_widgets/qtwidgets/testcheckbox.h
new file mode 100644
index 0000000..2698ce7
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testcheckbox.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTCHECKBOX_H
+#define TESTCHECKBOX_H
+
+#include "testabstractbutton.h"
+
+class QCheckBox;
+
+namespace QtUiTest {
+
+class TestCheckBox : public TestAbstractButton
+{
+ Q_OBJECT
+public:
+ TestCheckBox(QObject*);
+
+ virtual bool isTristate() const;
+ virtual Qt::CheckState checkState() const;
+ virtual bool setCheckState(Qt::CheckState);
+
+ static bool canWrap(QObject*);
+
+private:
+ QCheckBox *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testcombobox.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testcombobox.cpp
new file mode 100644
index 0000000..0def518
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testcombobox.cpp
@@ -0,0 +1,252 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testcombobox.h"
+#include "testwidgetslog.h"
+
+#include <qtuitestnamespace.h>
+
+#include <QComboBox>
+#include <QAbstractItemView>
+
+namespace QtUiTest {
+
+TestComboBox::TestComboBox(QObject *_q)
+ : TestWidget(_q), q(qobject_cast<QComboBox*>(_q))
+{
+ TestWidgetsLog();
+ connect(q, SIGNAL(activated(QString)), this, SIGNAL(selected(QString)));
+}
+
+QString TestComboBox::text() const
+{ TestWidgetsLog(); return list().join("\n"); }
+
+QString TestComboBox::selectedText() const
+{ TestWidgetsLog(); return q->currentText(); }
+
+QStringList TestComboBox::list() const
+{
+ QStringList ret;
+ for (int i = 0, max = q->count(); i < max; ++i) {
+ ret << q->itemText(i);
+ }
+ TestWidgetsLog() << ret;
+ return ret;
+}
+
+QRect TestComboBox::visualRect(QString const &item) const
+{
+ TestWidgetsLog();
+ QRect ret;
+ QtUiTest::ListWidget *viewList
+ = qtuitest_cast<QtUiTest::ListWidget*>(q->view());
+ if (viewList) {
+ ret = viewList->visualRect(item);
+ }
+ return ret;
+}
+
+QString TestComboBox::labelText() const
+{
+ QString ret = selectedText();
+ if (ret.isEmpty())
+ return ret;
+
+ QObject *w = parent();
+ while (w) {
+ QtUiTest::Widget *qw = qtuitest_cast<QtUiTest::Widget*>(w);
+ QtUiTest::LabelWidget *lw = qtuitest_cast<QtUiTest::LabelWidget*>(w);
+ if (lw) {
+ if (!lw->labelText().isEmpty()) {
+ ret.prepend(lw->labelText() + "/");
+ break;
+ }
+ }
+ w = qw->parent();
+ }
+ return ret;
+}
+
+QObject* TestComboBox::buddy() const
+{
+ return q;
+}
+
+bool TestComboBox::canSelect(QString const &item) const
+{ return list().contains(item); }
+
+bool TestComboBox::select(QString const &item)
+{
+ TestWidgetsLog() << item;
+ if (!canSelect(item)) return false;
+ if (selectedText() == item) return true;
+
+ QtUiTest::Widget *wView
+ = qtuitest_cast<QtUiTest::Widget*>(q->view());
+ QtUiTest::SelectWidget *sView
+ = qtuitest_cast<QtUiTest::SelectWidget*>(q->view());
+ if (!wView || !sView) {
+ QtUiTest::setErrorString("Can't find a pointer to the item view for this combobox.");
+ return false;
+ }
+
+ TestWidgetsLog() << "view isVisible()" << wView->isVisible();
+
+ /* Open the view if it is not currently open. */
+ if (!wView->isVisible()) {
+ if (QtUiTest::mousePreferred()) {
+ QStyle const* style = q->style();
+ QStyleOptionComboBox opt;
+ opt.initFrom(q);
+ QRect rect = style->subControlRect( QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow, q);
+ QPoint pos = rect.center();
+ TestWidgetsLog() << "local pos" << pos;
+ pos = mapToGlobal(pos);
+ /* May take more than one click. */
+ for (int i = 0; i < 2 && !wView->isVisible(); ++i) {
+ TestWidgetsLog() << "global pos" << pos;
+ TestWidgetsLog() << "Going to click at" << pos << "to open the view";
+ QtUiTest::mouseClick(pos, Qt::LeftButton);
+ QtUiTest::waitForSignal(q, SIGNAL(highlighted(int)));
+ }
+ // Combo box tries to detect and ignore "accidental" double clicks,
+ // so wait for a bit to ensure any subsequent clicks aren't
+ // ignored.
+ QtUiTest::wait( qApp->doubleClickInterval() );
+ } else {
+ TestWidgetsLog() << "Going to give myself focus";
+ if (!setFocus()) {
+ QtUiTest::setErrorString("Could not give focus to combobox");
+ return false;
+ }
+ if (q->isEditable()) {
+ return selectWithKeys(item);
+ } else {
+ //FIXME: This doesn't work if the combobox is editable
+ QtUiTest::keyClick(QtUiTest::Key_Select);
+ if (!q->view()->hasFocus() && !QtUiTest::waitForEvent( q->view(), QEvent::FocusIn)) {
+ QtUiTest::setErrorString("Could not give focus to combobox popup.");
+ return false;
+ }
+ }
+ }
+ }
+
+ /* Select the desired item from the view. */
+ TestWidgetsLog() << "Calling select() on the view";
+ bool ret = sView->select(item);
+
+ // Wait up to 1 second for the view to disappear after selection.
+ for (int i = 0; i < 1000 && wView->isVisible(); i+=100, QtUiTest::wait(100))
+ {}
+
+ if (!ret && QtUiTest::errorString().isEmpty()) {
+ QtUiTest::setErrorString(
+ "Selecting from embedded item view in combo box failed for an unknown reason.");
+ }
+
+ return ret;
+}
+
+bool TestComboBox::selectWithKeys(QString const &item)
+{
+ QStringList allItems = list();
+
+ const int maxtries = 100;
+ int desiredIndex = allItems.indexOf(item);
+
+ if (-1 == desiredIndex)
+ return false;
+
+ int currentIndex = q->currentIndex();
+
+ // Move vertically
+ Qt::Key key;
+ if (desiredIndex > currentIndex)
+ key = Qt::Key_Down;
+ else
+ key = Qt::Key_Up;
+
+ for (int i = 0; i < maxtries && selectedText() != item; ++i) {
+ TestWidgetsLog() << "keyClick" << (key==Qt::Key_Down ? "Down" : "Up");
+ if (!QtUiTest::keyClick(q, key)) return false;
+ }
+ QString selected = selectedText();
+ TestWidgetsLog() << "selectedText() now" << selected;
+ if (selected != item) {
+ QtUiTest::setErrorString(QString(
+ "Up/down keys should have caused item %1 to become selected, but item %2 "
+ "is selected instead.").arg(item).arg(selected));
+ return false;
+ }
+ return true;
+}
+
+bool TestComboBox::canEnter(QVariant const& item) const
+{
+ if (q->isEditable()) {
+ if (!item.canConvert<QString>()) return false;
+ int dontcare = 0;
+ QString text = item.toString();
+ const QValidator *validator = q->validator();
+ if (validator) {
+ return (QValidator::Acceptable==validator->validate(text, dontcare));
+ } else {
+ return true;
+ }
+ } else {
+ return canSelect(item.toString());
+ }
+}
+
+bool TestComboBox::enter(QVariant const& item, bool noCommit)
+{
+ if (q->isEditable()) {
+ return TestWidget::enter(item, noCommit);
+ } else {
+ return select(item.toString());
+ }
+}
+
+bool TestComboBox::canWrap(QObject *o)
+{ return qobject_cast<QComboBox*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testcombobox.h b/old/plugins/qtuitest_widgets/qtwidgets/testcombobox.h
new file mode 100644
index 0000000..c8e72dd
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testcombobox.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTCOMBOBOX_H
+#define TESTCOMBOBOX_H
+
+#include <testwidget.h>
+
+class QComboBox;
+
+namespace QtUiTest {
+
+class TestComboBox : public TestWidget,
+ public QtUiTest::TextWidget,
+ public QtUiTest::ListWidget,
+ public QtUiTest::LabelWidget,
+ public QtUiTest::SelectWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::TextWidget
+ QtUiTest::ListWidget
+ QtUiTest::LabelWidget
+ QtUiTest::SelectWidget)
+public:
+ TestComboBox(QObject*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+
+ virtual QString labelText() const;
+ virtual QObject* buddy() const;
+
+ virtual bool canSelect(QString const&) const;
+ virtual bool select(QString const&);
+
+ virtual bool canEnter(QVariant const&) const;
+ virtual bool enter(QVariant const&,bool);
+
+ static bool canWrap(QObject*);
+
+signals:
+ void selected(QString const&);
+
+private:
+ bool selectWithKeys(QString const&);
+
+ QComboBox *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testdateedit.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testdateedit.cpp
new file mode 100644
index 0000000..a14622f
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testdateedit.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testdateedit.h"
+#include "testwidgetslog.h"
+
+#include <QDateEdit>
+
+namespace QtUiTest {
+
+TestDateEdit::TestDateEdit(QObject* _q)
+ : TestDateTimeEdit(_q), q(qobject_cast<QDateEdit*>(_q))
+{
+ TestWidgetsLog();
+
+ disconnect(q, SIGNAL(dateTimeChanged(QDateTime)), this, 0);
+ connect(q, SIGNAL(dateTimeChanged(QDateTime)),
+ this, SLOT(onDateTimeChanged(QDateTime)));
+}
+
+void TestDateEdit::onDateTimeChanged(QDateTime const& dt)
+{
+ emit entered(dt.date());
+}
+
+QString TestDateEdit::text() const
+{
+ TestWidgetsLog();
+ return q->date().toString(q->displayFormat());
+}
+
+QVariant TestDateEdit::value() const
+{
+ return q->date();
+}
+
+bool TestDateEdit::canWrap(QObject *o)
+{ return qobject_cast<QDateEdit*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testdateedit.h b/old/plugins/qtuitest_widgets/qtwidgets/testdateedit.h
new file mode 100644
index 0000000..3494e14
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testdateedit.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTDATEEDIT_H
+#define TESTDATEEDIT_H
+
+#include "testdatetimeedit.h"
+
+class QDateEdit;
+
+namespace QtUiTest {
+
+class TestDateEdit : public TestDateTimeEdit
+{
+ Q_OBJECT
+public:
+ TestDateEdit(QObject*);
+
+ virtual QString text() const;
+ virtual QVariant value() const;
+
+ static bool canWrap(QObject*);
+
+private slots:
+ void onDateTimeChanged(QDateTime const&);
+
+private:
+ QDateEdit *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testdatetimeedit.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testdatetimeedit.cpp
new file mode 100644
index 0000000..4ce47dc
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testdatetimeedit.cpp
@@ -0,0 +1,477 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testdatetimeedit.h"
+#include "testwidgetslog.h"
+
+#include <QLayout>
+#include <QLineEdit>
+#include <QStyleOptionSpinBox>
+
+namespace QtUiTest {
+
+TestDateTimeEdit::TestDateTimeEdit(QObject* _q)
+ : TestGenericTextWidget(_q), q(qobject_cast<QDateTimeEdit*>(_q))
+{
+ TestWidgetsLog();
+ connect(q, SIGNAL(dateTimeChanged(QDateTime)),
+ this, SLOT(onDateTimeChanged(QDateTime)));
+}
+
+void TestDateTimeEdit::onDateTimeChanged(const QDateTime& dt)
+{ emit entered(dt); }
+
+QString TestDateTimeEdit::text() const
+{
+ TestWidgetsLog();
+ return q->dateTime().toString();
+}
+
+QVariant TestDateTimeEdit::value() const
+{
+ return q->dateTime();
+}
+
+QRegExp dateFormatToRegExp(const QString& format)
+{
+ QString re;
+ QString fmt = format;
+
+#define REPLACE_TOK(A,B) \
+ if (fmt.startsWith(A)) { \
+ re += B; \
+ fmt.remove(0, qstrlen(A)); \
+ continue; \
+ }
+ while (!fmt.isEmpty()) {
+ REPLACE_TOK("yyyy", "(\\d{4})");
+ REPLACE_TOK("yy", "(\\d{2})");
+
+ REPLACE_TOK("MMMM", "(\\w+)");
+ REPLACE_TOK("MMM", "(\\w+)");
+ REPLACE_TOK("MM", "([01]\\d)");
+ REPLACE_TOK("M", "(\\d\\d?)");
+
+ REPLACE_TOK("dddd", "(\\w+)");
+ REPLACE_TOK("ddd", "(\\w+)");
+ REPLACE_TOK("dd", "([0123]\\d)");
+ REPLACE_TOK("d", "(\\d{1,2})");
+
+ REPLACE_TOK("hh", "([012]\\d)");
+ REPLACE_TOK("h", "(\\d{1,2})");
+
+ REPLACE_TOK("HH", "([012]\\d)");
+ REPLACE_TOK("H", "(\\d{1,2})");
+
+ REPLACE_TOK("mm", "([0-5]\\d)");
+ REPLACE_TOK("m", "(\\d{1,2})");
+
+ REPLACE_TOK("ss", "([0-5]\\d)");
+ REPLACE_TOK("s", "(\\d{1,2})");
+
+ REPLACE_TOK("zzz", "(\\d{3})");
+ REPLACE_TOK("z", "(\\d{0,3})");
+
+ REPLACE_TOK("AP", "(AM|PM)");
+ REPLACE_TOK("ap", "(am|pm)");
+ REPLACE_TOK("A", "(AM|PM)");
+ REPLACE_TOK("a", "(am|pm)");
+
+ re += QString("\\x%1").arg(fmt.at(0).unicode(), 4, 16, QChar('0'));
+ fmt.remove(0,1);
+ }
+#undef REPLACE_TOK
+
+ TestWidgetsLog() << format << "resulted in" << re;
+
+ return QRegExp(re);
+}
+
+bool TestDateTimeEdit::canEnter(const QVariant& item) const
+{
+ QString text;
+ if (item.canConvert<QDateTime>()) {
+ text = item.value<QDateTime>().toString( q->displayFormat() );
+ } else if (item.canConvert<QDate>()) {
+ text = item.value<QDate>().toString( q->displayFormat() );
+ } else if (item.canConvert<QTime>()) {
+ text = item.value<QTime>().toString( q->displayFormat() );
+ } else {
+ text = item.toString();
+ }
+ int dont_care = 0;
+ TestWidgetsLog() << text << "format:" << q->displayFormat();
+ bool ret = (QValidator::Acceptable ==
+ static_cast<QAbstractSpinBox*>(q)->validate(text, dont_care));
+ if (ret) {
+ TestWidgetsLog() << "Can enter" << item;
+ } else {
+ TestWidgetsLog() << "Can't enter" << item;
+ }
+ return ret;
+}
+
+QPoint TestDateTimeEdit::nextClick( const QStringList& cap,
+ QMap<QDateTimeEdit::Section,int> const& capMap,
+ bool *final, bool *ok)
+{
+ if (ok) *ok = false;
+ if (final) *final = false;
+
+ QPoint ret;
+
+ int activeSection = -1;
+ int moveUpDown = 0;
+ int sectionsNeedingChanges = 0;
+ bool ampm = q->displayedSections() & QDateTimeEdit::AmPmSection;
+
+ /* Sections, from most to least significant.
+ * It is necessary to edit most significant first because that can affect
+ * the allowed values from less significant fields (e.g., can't select
+ * '30' in days if '02' is selected for month).
+ */
+ static const QDateTimeEdit::Section sections[] = {
+ QDateTimeEdit::YearSection,
+ QDateTimeEdit::MonthSection,
+ QDateTimeEdit::DaySection,
+ QDateTimeEdit::HourSection,
+ QDateTimeEdit::MinuteSection,
+ QDateTimeEdit::SecondSection,
+ QDateTimeEdit::MSecSection,
+ QDateTimeEdit::AmPmSection,
+ (QDateTimeEdit::Section)0
+ };
+
+ {
+ int i = 0;
+ for (QDateTimeEdit::Section section = sections[i];
+ section;
+ section = sections[++i]) {
+ if (!(q->displayedSections() & section)) continue;
+ QString text = q->sectionText(section);
+ int cap_i = capMap.value(section);
+ TestWidgetsLog() << "i" << i << "text" << text << "cap_i" << cap_i
+ << "cap" << cap.at(cap_i);
+ if (text != cap.at(cap_i)) {
+ ++sectionsNeedingChanges;
+ if (-1 == activeSection) {
+ bool is_int = false;
+ int src = text.toInt(&is_int);
+ int dest = cap.at(cap_i).toInt(&is_int);
+ if (!is_int && section == QDateTimeEdit::MonthSection) {
+ if (q->displayFormat().contains("MMMM")) {
+ moveUpDown = QDate::fromString(cap.at(cap_i), "MMMM").month() - QDate::fromString(text, "MMMM").month();
+ } else if (q->displayFormat().contains("MMM")) {
+ moveUpDown = QDate::fromString(cap.at(cap_i), "MMM").month() - QDate::fromString(text, "MMM").month();
+ }
+ } else if (section == QDateTimeEdit::AmPmSection) {
+ if (text.toUpper() == "PM")
+ moveUpDown = -1;
+ else
+ moveUpDown = 1;
+ } else if (section == QDateTimeEdit::HourSection && ampm && (dest == 12 || src == 12)) {
+ moveUpDown = (src - dest);
+ } else {
+ moveUpDown = (dest - src);
+ }
+ activeSection = cap_i;
+ }
+ }
+ }
+ }
+
+ /* If there is only one section that requires a change,
+ * AND that section is off the desired value by one,
+ * AND that section already has focus,
+ * then this should be the last necessary click. */
+ if (final && (1 == sectionsNeedingChanges) && (1 == qAbs(moveUpDown)) && q->currentSectionIndex() == activeSection)
+ *final = true;
+
+ TestWidgetsLog() << "activeSection" << activeSection << "currentSectionIndex" << q->currentSectionIndex();
+
+ if (-1 == activeSection) {
+ /* No clicking required; already at target value */
+ if (final) *final = true;
+ } else if (q->currentSectionIndex() != activeSection) {
+ /* Clicking required; need to move cursor to correct section */
+ int begin = -1, end = -1;
+ {
+ QString text = q->text();
+ for (int i = 0; i < activeSection; ++i) {
+ QString sec = q->sectionText(q->sectionAt(i));
+ text.replace(text.indexOf(sec), sec.length(), QString(sec.length(), '_'));
+ }
+ QString sec = q->sectionText(q->sectionAt(activeSection));
+ begin = text.indexOf(sec);
+ end = begin + sec.length();
+ TestWidgetsLog() << "sec" << sec << "lies from" << begin << "to" << end << "in" << text;
+ }
+ QPoint pos(0, q->height()/2);
+ QLineEdit* le = q->findChild<QLineEdit*>();
+ QPoint clickPos;
+ while (le->rect().contains(pos) && clickPos.isNull()) {
+ int cursor = le->cursorPositionAt(pos);
+ if (cursor >= begin && cursor < end) {
+ clickPos = q->mapFromGlobal(le->mapToGlobal(pos));
+ }
+ pos.setX(pos.x() + 2);
+ }
+ ret = clickPos;
+ if (ret.isNull()) {
+ if (ok) *ok = false;
+ QtUiTest::setErrorString(QString("Could not determine where to click in "
+ "date edit to move cursor between position %1 and %2").arg(begin).arg(end));
+ return ret;
+ }
+ } else if (moveUpDown != 0) {
+ /* Clicking required; need to move up */
+ QStyle const* style = q->style();
+ QStyleOptionSpinBox opt;
+ opt.initFrom(q);
+ QRect rect = style->subControlRect(QStyle::CC_SpinBox, &opt,
+ (moveUpDown > 0) ? QStyle::SC_SpinBoxUp : QStyle::SC_SpinBoxDown,
+ q);
+ TestWidgetsLog() << "move " << ((moveUpDown > 0) ? "up" : "down") << rect;
+ ret = rect.center();
+ }
+
+ if (ok) *ok = true;
+ return ret;
+}
+
+bool TestDateTimeEdit::enterByMouse(const QString& format, const QDateTime& dt)
+{
+ bool final = false;
+ bool ok = true;
+
+ QRegExp re( dateFormatToRegExp(format) );
+ if (-1 == re.indexIn( dt.toString(format) )) {
+ TestWidgetsLog() << "regex didn't match, re:" << re << "date:" << dt.toString(format);
+ return false;
+ }
+
+ QStringList cap = re.capturedTexts();
+ cap.removeFirst();
+
+ TestWidgetsLog() << "cap" << cap << "text" << q->text();
+
+ /* Mapping from section to index in cap.
+ * Wouldn't be necessary if QDateTimeEdit had the inverse of sectionAt().
+ */
+ QMap<QDateTimeEdit::Section,int> capMap;
+ for (int i = 0; i < q->sectionCount(); ++i) {
+ capMap.insert( q->sectionAt(i), i );
+ }
+
+ do {
+ QPoint nc = nextClick(cap, capMap, &final, &ok);
+ if (ok) {
+ if (!ensureVisiblePoint(nc)) return false;
+ QtUiTest::mouseClick(q->mapToGlobal(nc));
+// On some platforms, this takes too long
+#ifndef Q_OS_MAC
+ QtUiTest::waitForSignal(q, SIGNAL(dateTimeChanged(QDateTime)));
+#endif
+ }
+ } while (!final && ok);
+
+ return ok;
+}
+
+bool TestDateTimeEdit::enterByKeys(const QString& format, const QDateTime& dt, bool noCommit)
+{
+ if (!hasEditFocus() && !setEditFocus(true)) return false;
+ TestWidgetsLog() << "got focus";
+
+ for (int i = 0, m = q->sectionCount(); i < m; ++i) {
+ if (!enterSectionByKeys(q->sectionAt(i), format, dt))
+ return false;
+ }
+
+ if (noCommit) return true;
+
+ return setEditFocus(false);
+}
+
+bool TestDateTimeEdit::enter(const QVariant& item, bool noCommit)
+{
+ QString text;
+ QDateTime dt;
+ QString format = q->displayFormat();
+ TestWidgetsLog() << "Format: " << format;
+ if (item.canConvert<QDateTime>()) {
+ dt = item.value<QDateTime>();
+ text = dt.toString( format );
+ TestWidgetsLog() << "QDateTime";
+ } else if (item.canConvert<QDate>()) {
+ dt = QDateTime(item.value<QDate>(), QTime());
+ text = dt.toString( format );
+ TestWidgetsLog() << "QDate";
+ } else if (item.canConvert<QTime>()) {
+ dt = QDateTime(QDate(1970,1,1), item.value<QTime>());
+ text = dt.toString( format );
+ TestWidgetsLog() << "QTime";
+ } else {
+ text = item.toString();
+ dt = QDateTime::fromString(text, format);
+ TestWidgetsLog() << "String";
+ }
+ int dont_care = 0;
+ if (QValidator::Acceptable !=
+ static_cast<QAbstractSpinBox*>(q)->validate(text, dont_care)) {
+ TestWidgetsLog() << "Can't enter" << item << "(text:" << text << ")";
+ return false;
+ }
+
+ if (text == q->text()) return true;
+
+ if (QtUiTest::mousePreferred()) {
+ return enterByMouse(format, dt);
+ } else {
+ return enterByKeys(format, dt, noCommit);
+ }
+
+ return false;
+}
+
+bool TestDateTimeEdit::enterSectionByKeys(QDateTimeEdit::Section section,
+ const QString& fmt, const QDateTime& dt)
+{
+ using namespace QtUiTest;
+
+ if (fmt.isEmpty() || !dt.isValid()) return false;
+
+#define TRY(str) if (fmt.contains(str)) { \
+ text = dt.toString(str); \
+}
+
+ QString text;
+ switch (section) {
+ case QDateTimeEdit::YearSection:
+ TRY("yyyy")
+ else TRY("yy");
+ break;
+ case QDateTimeEdit::MonthSection:
+ TRY("MMMM")
+ else TRY("MMM")
+ else TRY("MM")
+ else TRY("M");
+ break;
+ case QDateTimeEdit::DaySection:
+ TRY("dddd")
+ else TRY("ddd")
+ else TRY("dd")
+ else TRY("d");
+ break;
+ case QDateTimeEdit::HourSection:
+ TRY("hh")
+ else TRY("h")
+ else TRY("HH")
+ else TRY("H");
+ if (fmt.contains("AP") || fmt.contains("ap")) {
+ // Need to use 12 hour format
+ if (fmt.contains("hh")) {
+ text = dt.toString("hh ap");
+ text = text.left(text.indexOf(' '));
+ }
+ else if (fmt.contains("h")) {
+ text = dt.toString("h ap");
+ text = text.left(text.indexOf(' '));
+ }
+ }
+ break;
+ case QDateTimeEdit::MinuteSection:
+ TRY("mm")
+ else TRY("m");
+ break;
+ case QDateTimeEdit::SecondSection:
+ TRY("ss")
+ else TRY("s");
+ break;
+ case QDateTimeEdit::MSecSection:
+ TRY("zzz")
+ else TRY("z");
+ break;
+ case QDateTimeEdit::AmPmSection:
+ TRY("AP")
+ else TRY("ap");
+ break;
+ default:
+ return false;
+ }
+#undef TRY
+
+ if (text.isEmpty()) return false;
+
+ QMap<int,int> sectionMap;
+ for (int i = 0; i < q->sectionCount(); ++i) {
+ sectionMap.insert(q->sectionAt(i), i);
+ }
+
+ int i = 0;
+ while (q->currentSection() != section && ++i < 100) {
+ Qt::KeyboardModifiers mod = (q->currentSectionIndex() < sectionMap[section]) ? Qt::KeyboardModifiers(0) : Qt::ShiftModifier;
+ TestWidgetsLog() << "Entering extra key click (before " + text + ") to move to prev/next section";
+ if (!keyClick(q, Qt::Key_Tab)) {
+ setErrorString("Key click did not go to the expected widget.");
+ return false;
+ }
+ }
+ if (q->currentSection() != section) {
+ setErrorString("Could not move focus to desired section.");
+ return false;
+ }
+
+ TestWidgetsLog() << "Going to enter" << text << "in section" << section;
+
+ foreach (const QChar& c, text) {
+ if (!keyClick(q, asciiToKey(c.toLatin1()))) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool TestDateTimeEdit::canWrap(QObject *o)
+{ return qobject_cast<QDateTimeEdit*>(o); }
+
+}
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testdatetimeedit.h b/old/plugins/qtuitest_widgets/qtwidgets/testdatetimeedit.h
new file mode 100644
index 0000000..204446d
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testdatetimeedit.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTDATETIMEEDIT_H
+#define TESTDATETIMEEDIT_H
+
+#include "testgenerictextwidget.h"
+#include <QDateTimeEdit>
+
+namespace QtUiTest {
+
+class TestDateTimeEdit : public TestGenericTextWidget
+{
+ Q_OBJECT
+public:
+ TestDateTimeEdit(QObject*);
+
+ virtual QString text() const;
+ virtual QVariant value() const;
+
+ virtual bool canEnter(QVariant const&) const;
+ virtual bool enter(QVariant const&,bool);
+
+ static bool canWrap(QObject*);
+
+protected:
+ bool enterByKeys(QString const&,QDateTime const&,bool);
+ bool enterByMouse(QString const&,QDateTime const&);
+ bool enterSectionByKeys(QDateTimeEdit::Section,QString const&,
+ QDateTime const&);
+ QPoint nextClick(QStringList const&,
+ QMap<QDateTimeEdit::Section,int> const&,bool*,bool*);
+
+private slots:
+ void onDateTimeChanged(QDateTime const&);
+
+signals:
+ void entered(QVariant const&);
+
+private:
+ QDateTimeEdit *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testdockwidget.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testdockwidget.cpp
new file mode 100644
index 0000000..9b24e13
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testdockwidget.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testdockwidget.h"
+#include "testwidgetslog.h"
+
+#include <QDockWidget>
+
+namespace QtUiTest {
+
+TestDockWidget::TestDockWidget(QObject* _q)
+ : TestGenericTextWidget(_q), q(qobject_cast<QDockWidget*>(_q))
+{ TestWidgetsLog(); }
+
+QString TestDockWidget::text() const
+{
+ TestWidgetsLog();
+ return windowTitle();
+}
+
+QString TestDockWidget::labelText() const
+{
+ QString ret = text();
+ if (ret.isEmpty())
+ return ret;
+
+ QObject *w = parent();
+ while (w) {
+ QtUiTest::Widget *qw = qtuitest_cast<QtUiTest::Widget*>(w);
+ QtUiTest::LabelWidget *lw = qtuitest_cast<QtUiTest::LabelWidget*>(w);
+ if (lw) {
+ if (!lw->labelText().isEmpty()) {
+ ret.prepend(lw->labelText() + "/");
+ break;
+ }
+ }
+ w = qw->parent();
+ }
+ return ret;
+}
+
+QObject* TestDockWidget::buddy() const
+{
+ return q->widget();
+}
+
+bool TestDockWidget::canWrap(QObject *o)
+{ return qobject_cast<QDockWidget*>(o); }
+
+QString TestDockWidget::convertToPlainText(QString const &richText)
+{
+ static QRegExp rxBr("<br */?>");
+ static QRegExp rxHtml("<[^>]+>");
+
+ QString ret(richText);
+ ret.replace(rxBr, "\n");
+ ret.replace(rxHtml, QString());
+ return ret;
+}
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testdockwidget.h b/old/plugins/qtuitest_widgets/qtwidgets/testdockwidget.h
new file mode 100644
index 0000000..d77840c
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testdockwidget.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTDOCKWIDGET_H
+#define TESTDOCKWIDGET_H
+
+#include "testgenerictextwidget.h"
+
+class QDockWidget;
+
+namespace QtUiTest {
+
+class TestDockWidget : public TestGenericTextWidget,
+ public QtUiTest::LabelWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::LabelWidget)
+
+public:
+ TestDockWidget(QObject*);
+
+ virtual QString text() const;
+
+ virtual QString labelText() const;
+ virtual QObject* buddy() const;
+
+ static bool canWrap(QObject*);
+
+private:
+ static QString convertToPlainText(QString const&);
+
+ QDockWidget *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testfactory.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testfactory.cpp
new file mode 100644
index 0000000..3a4182c
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testfactory.cpp
@@ -0,0 +1,183 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testfactory.h"
+
+#include "testabstractbutton.h"
+#include "testabstractitemview.h"
+#include "testabstractspinbox.h"
+#include "testcalendarwidget.h"
+#include "testcheckbox.h"
+#include "testcombobox.h"
+#include "testdateedit.h"
+#include "testdatetimeedit.h"
+#include "testdockwidget.h"
+#include "testgenericcheckwidget.h"
+#include "testgenerictextwidget.h"
+#include "testgroupbox.h"
+#include "testheaderview.h"
+#include "testignore.h"
+#include "testlabel.h"
+#include "testlineedit.h"
+#include "testlistview.h"
+#include "testmenu.h"
+#include "testmenubar.h"
+#include "testpushbutton.h"
+#include "testtabbar.h"
+#include "testtextedit.h"
+#include "testtimeedit.h"
+#include "testtoolbar.h"
+#include "testtreeview.h"
+#include "testtreewidget.h"
+#include "testgenericinputmethod.h"
+
+#if !defined(QT_NO_WEBKIT)
+# include "testwebview.h"
+#endif
+
+#include <testwidget.h>
+#include "testwidgetslog.h"
+#include <QApplication>
+
+namespace QtUiTest {
+
+TestWidgetsFactory::TestWidgetsFactory()
+{
+}
+
+QObject* TestWidgetsFactory::create(QObject* o)
+{
+ QObject* ret = 0;
+
+#define TRY(Klass) \
+ if (Klass::canWrap(o)) { \
+ ret = new Klass(o); \
+ break; \
+ }
+
+ /* Order is important here; classes should be listed in order of
+ * most to least derived. */
+
+ do {
+ /* Qt widgets */
+ TRY(TestDateEdit);
+ TRY(TestTimeEdit);
+ TRY(TestDateTimeEdit);
+ TRY(TestCalendarWidget);
+ TRY(TestDateTimeEdit);
+ TRY(TestHeaderView);
+ TRY(TestTreeWidget);
+ TRY(TestTreeView);
+ TRY(TestListView);
+ TRY(TestAbstractItemView);
+ TRY(TestTabBar);
+ TRY(TestMenuBar);
+ TRY(TestToolBar);
+ TRY(TestMenu);
+ TRY(TestDockWidget);
+#if !defined(QT_NO_WEBKIT)
+ TRY(TestWebView);
+#endif
+ TRY(TestLabel);
+ TRY(TestAbstractSpinBox);
+ TRY(TestGroupBox);
+ TRY(TestCheckBox);
+ TRY(TestComboBox);
+ TRY(TestLineEdit);
+ TRY(TestTextEdit);
+ TRY(TestPushButton);
+ TRY(TestAbstractButton);
+ TRY(TestGenericCheckWidget);
+ TRY(TestGenericTextWidget);
+ TRY(TestIgnore);
+ TRY(TestWidget);
+ TRY(TestGenericInputMethod);
+ } while(0);
+
+ TestWidgetsLog() << o << ret;
+
+ return ret;
+}
+
+QStringList TestWidgetsFactory::keys() const
+{
+ /* Order doesn't matter here. */
+ return QStringList()
+ << "QAbstractButton"
+ << "QAbstractItemView"
+ << "QAbstractSlider"
+ << "QAbstractSpinBox"
+ << "QCalendarWidget"
+ << "QCheckBox"
+ << "QComboBox"
+ << "QDateEdit"
+ << "QDateTimeEdit"
+ << "QDockWidget"
+ << "QFrame"
+ << "QGroupBox"
+ << "QHeaderView"
+ << "QLCDNumber"
+ << "QLabel"
+ << "QLineEdit"
+ << "QListView"
+ << "QMenu"
+ << "QMenuBar"
+ << "QMessageBox"
+ << "QProgressBar"
+ << "QPushButton"
+ << "QStackedWidget"
+ << "QTabBar"
+ << "QTextEdit"
+ << "QTimeEdit"
+ << "QToolBar"
+ << "QTreeView"
+ << "QTreeWidget"
+#if !defined(QT_NO_WEBKIT)
+ << "QWebView"
+#endif
+ << "QWidget"
+ << "QInputContext"
+ ;
+}
+
+}
+#include <qplugin.h>
+Q_EXPORT_PLUGIN2(qttestwidgets, QtUiTest::TestWidgetsFactory)
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testfactory.h b/old/plugins/qtuitest_widgets/qtwidgets/testfactory.h
new file mode 100644
index 0000000..af62e70
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testfactory.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTFACTORY_H
+#define TESTFACTORY_H
+
+#include <QObject>
+
+#include <qtuitestwidgetinterface.h>
+
+namespace QtUiTest {
+
+class TestWidgetsFactory : public QObject, public QtUiTest::WidgetFactory
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::WidgetFactory)
+
+public:
+ TestWidgetsFactory();
+
+ virtual QObject* create(QObject*);
+ virtual QStringList keys() const;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testgenericcheckwidget.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testgenericcheckwidget.cpp
new file mode 100644
index 0000000..b35d939
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testgenericcheckwidget.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testgenericcheckwidget.h"
+#include "testwidgetslog.h"
+
+#include <QWidget>
+#include <QVariant>
+
+namespace QtUiTest {
+
+QList<QByteArray> TestGenericCheckWidget::checkProperties = QList<QByteArray>()
+ << "checked"
+;
+
+TestGenericCheckWidget::TestGenericCheckWidget(QObject* _q)
+ : TestWidget(_q), q(qobject_cast<QWidget*>(_q))
+{
+ TestWidgetsLog();
+ foreach (QByteArray property, checkProperties) {
+ if (-1 != q->metaObject()->indexOfProperty(property)) {
+ checkProperty = property;
+ break;
+ }
+ }
+}
+
+Qt::CheckState TestGenericCheckWidget::checkState() const
+{
+ TestWidgetsLog();
+ return q->property(checkProperty).toBool()
+ ? Qt::Checked
+ : Qt::Unchecked;
+}
+
+bool TestGenericCheckWidget::canWrap(QObject *o)
+{
+ QWidget *w;
+ if (!(w = qobject_cast<QWidget*>(o)))
+ return false;
+
+ foreach (QByteArray property, checkProperties)
+ if (-1 != o->metaObject()->indexOfProperty(property))
+ return true;
+
+ return false;
+}
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testgenericcheckwidget.h b/old/plugins/qtuitest_widgets/qtwidgets/testgenericcheckwidget.h
new file mode 100644
index 0000000..759b1d3
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testgenericcheckwidget.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTGENERICCHECKWIDGET_H
+#define TESTGENERICCHECKWIDGET_H
+
+#include <testwidget.h>
+
+namespace QtUiTest {
+
+class TestGenericCheckWidget : public TestWidget, public QtUiTest::CheckWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::CheckWidget)
+public:
+ TestGenericCheckWidget(QObject*);
+
+ virtual Qt::CheckState checkState() const;
+
+ static bool canWrap(QObject*);
+
+private:
+ QWidget *q;
+ QByteArray checkProperty;
+ static QList<QByteArray> checkProperties;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testgenericinputmethod.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testgenericinputmethod.cpp
new file mode 100644
index 0000000..8b01697
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testgenericinputmethod.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testgenericinputmethod.h"
+
+#include <qtuitestnamespace.h>
+#include <QInputContext>
+#include <QInputMethodEvent>
+#include <QDebug>
+
+namespace QtUiTest {
+
+TestGenericInputMethod::TestGenericInputMethod(QObject *_q)
+ : q(qobject_cast<QInputContext*>(_q))
+{
+}
+
+bool TestGenericInputMethod::canEnter(QVariant const& item) const
+{
+ return true;
+}
+
+bool TestGenericInputMethod::enter(QVariant const& item, bool noCommit)
+{
+ QInputMethodEvent event;
+ event.setCommitString(item.toString());
+ q->sendEvent(event);
+ return true;
+}
+
+bool TestGenericInputMethod::canWrap(QObject *o)
+{
+ return qobject_cast<QInputContext*>(o);
+}
+
+}
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testgenericinputmethod.h b/old/plugins/qtuitest_widgets/qtwidgets/testgenericinputmethod.h
new file mode 100644
index 0000000..c8f6dca
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testgenericinputmethod.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTGENERICINPUTMETHOD_H
+#define TESTGENERICINPUTMETHOD_H
+
+#include "testwidget.h"
+
+class QInputContext;
+
+namespace QtUiTest {
+
+class TestGenericInputMethod : public QObject,
+ QtUiTest::InputWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::InputWidget)
+
+public:
+ TestGenericInputMethod(QObject*);
+
+ virtual bool canEnter(QVariant const&) const;
+ virtual bool enter(QVariant const&,bool);
+
+ static bool canWrap(QObject*);
+
+private:
+ QInputContext *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testgenerictextwidget.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testgenerictextwidget.cpp
new file mode 100644
index 0000000..a8719cc
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testgenerictextwidget.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testgenerictextwidget.h"
+#include "testwidgetslog.h"
+
+#include <QWidget>
+#include <QVariant>
+
+namespace QtUiTest {
+
+QList<QByteArray> TestGenericTextWidget::textProperties = QList<QByteArray>()
+ << "text"
+ << "plainText"
+ << "value"
+ << "title"
+;
+QList<QByteArray> TestGenericTextWidget::selectedTextProperties = QList<QByteArray>()
+ << "selectedText"
+;
+
+TestGenericTextWidget::TestGenericTextWidget(QObject* _q)
+ : TestWidget(_q), q(qobject_cast<QWidget*>(_q))
+{
+ TestWidgetsLog() << _q;
+ foreach (QByteArray property, textProperties) {
+ if (-1 != q->metaObject()->indexOfProperty(property)) {
+ textProperty = property;
+ break;
+ }
+ }
+ foreach (QByteArray property, selectedTextProperties) {
+ if (-1 != q->metaObject()->indexOfProperty(property)) {
+ selectedTextProperty = property;
+ break;
+ }
+ }
+}
+
+QString TestGenericTextWidget::text() const
+{ TestWidgetsLog(); return q->property(textProperty).toString(); }
+
+QString TestGenericTextWidget::selectedText() const
+{
+ TestWidgetsLog();
+ QString ret;
+ if (!selectedTextProperty.isEmpty())
+ ret = q->property(selectedTextProperty).toString();
+ if (ret.isEmpty())
+ ret = text();
+ return ret;
+}
+
+bool TestGenericTextWidget::canWrap(QObject *o)
+{
+ QWidget *w;
+ if (!(w = qobject_cast<QWidget*>(o)))
+ return false;
+
+ foreach (QByteArray property, textProperties)
+ if (-1 != o->metaObject()->indexOfProperty(property))
+ return true;
+
+ return false;
+}
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testgenerictextwidget.h b/old/plugins/qtuitest_widgets/qtwidgets/testgenerictextwidget.h
new file mode 100644
index 0000000..baad629
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testgenerictextwidget.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTGENERICTEXTWIDGET_H
+#define TESTGENERICTEXTWIDGET_H
+
+#include <testwidget.h>
+
+namespace QtUiTest {
+
+class TestGenericTextWidget : public TestWidget, public QtUiTest::TextWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::TextWidget)
+public:
+ TestGenericTextWidget(QObject*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+
+ static bool canWrap(QObject*);
+
+private:
+ QWidget *q;
+ QByteArray textProperty;
+ QByteArray selectedTextProperty;
+ static QList<QByteArray> textProperties;
+ static QList<QByteArray> selectedTextProperties;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testgroupbox.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testgroupbox.cpp
new file mode 100644
index 0000000..d33a9e7
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testgroupbox.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testgroupbox.h"
+#include "testwidgetslog.h"
+
+#include <QGroupBox>
+#include <QStyleOptionGroupBox>
+
+namespace QtUiTest {
+
+TestGroupBox::TestGroupBox(QObject *_q)
+ : TestGenericTextWidget(_q), q(qobject_cast<QGroupBox*>(_q))
+{
+ connect(q, SIGNAL(toggled(bool)), this, SLOT(on_toggled(bool)));
+}
+
+void TestGroupBox::on_toggled(bool state)
+{ emit stateChanged(state); }
+
+Qt::CheckState TestGroupBox::checkState() const
+{ return q->isChecked() ? Qt::Checked : Qt::Unchecked; }
+
+bool TestGroupBox::setCheckState(Qt::CheckState state)
+{
+ TestWidgetsLog() << state << checkState() << q->isCheckable();
+ if (state == checkState()) return true;
+ if (!q->isCheckable()) return false;
+
+ if (QtUiTest::mousePreferred()) {
+ QStyle const* style = q->style();
+ QStyleOptionGroupBox opt;
+ opt.initFrom(q);
+ QRect rect = style->subControlRect(QStyle::CC_GroupBox, &opt, QStyle::SC_GroupBoxCheckBox, q);
+ QPoint p = rect.center();
+ if (!ensureVisiblePoint(p)) return false;
+ if (!QtUiTest::mouseClick(q, SIGNAL(toggled(bool)), mapToGlobal( p ) )) return false;
+ } else {
+ if (!setFocus()) {
+ QtUiTest::setErrorString("Couldn't toggle group box check state: couldn't give "
+ "focus to group box.");
+ return false;
+ }
+ if (!QtUiTest::keyClick(q, SIGNAL(toggled(bool)), QtUiTest::Key_ActivateButton )) return false;
+ }
+
+ return state == checkState();
+}
+
+QString TestGroupBox::labelText() const
+{
+ QString ret = text();
+ if (ret.isEmpty())
+ return ret;
+
+ QObject *w = parent();
+ while (w) {
+ QtUiTest::Widget *qw = qtuitest_cast<QtUiTest::Widget*>(w);
+ QtUiTest::LabelWidget *lw = qtuitest_cast<QtUiTest::LabelWidget*>(w);
+ if (lw) {
+ if (!lw->labelText().isEmpty()) {
+ ret.prepend(lw->labelText() + "/");
+ break;
+ }
+ }
+ w = qw->parent();
+ }
+ return ret;
+}
+
+QObject* TestGroupBox::buddy() const
+{
+ QObject *buddy = q;
+
+ if (!q->isCheckable()) {
+ // If the widget is a QGroupBox, and it has exactly one focusable child widget,
+ // consider that child widget the buddy
+ QList<QWidget*> focusableWidgets;
+ foreach (QWidget* fw, q->findChildren<QWidget*>()) {
+ if (fw->focusPolicy() != Qt::NoFocus)
+ focusableWidgets << fw;
+ }
+ if (focusableWidgets.count() == 1) {
+ buddy = focusableWidgets[0];
+ }
+ }
+
+ return buddy;
+}
+
+bool TestGroupBox::canWrap(QObject *o)
+{ return qobject_cast<QGroupBox*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testgroupbox.h b/old/plugins/qtuitest_widgets/qtwidgets/testgroupbox.h
new file mode 100644
index 0000000..08fa82e
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testgroupbox.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTGROUPBOX_H
+#define TESTGROUPBOX_H
+
+#include "testgenerictextwidget.h"
+
+class QGroupBox;
+
+namespace QtUiTest {
+
+class TestGroupBox : public TestGenericTextWidget,
+ public QtUiTest::CheckWidget,
+ public QtUiTest::LabelWidget
+
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::CheckWidget
+ QtUiTest::LabelWidget)
+
+public:
+ TestGroupBox(QObject*);
+
+ virtual Qt::CheckState checkState() const;
+ virtual bool setCheckState(Qt::CheckState);
+
+ virtual QString labelText() const;
+ virtual QObject* buddy() const;
+
+ static bool canWrap(QObject*);
+
+signals:
+ void stateChanged(int);
+
+private slots:
+ void on_toggled(bool);
+
+private:
+ QGroupBox *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testheaderview.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testheaderview.cpp
new file mode 100644
index 0000000..c8f2b8f
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testheaderview.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testheaderview.h"
+#include "testwidgetslog.h"
+
+#include <QListView>
+#include <QTimer>
+#include <QScrollBar>
+#include <QComboBox>
+
+#include <qtuitestnamespace.h>
+
+namespace QtUiTest {
+
+TestHeaderView::TestHeaderView(QObject *_q)
+ : TestWidget(_q), q(static_cast<QHeaderView*>(_q))
+{
+}
+
+QStringList TestHeaderView::list() const
+{
+ QStringList ret;
+
+ for (int i=0; i<q->count(); ++i) {
+ ret << (q->model()->headerData(i, q->orientation())).toString();
+ }
+
+ return ret;
+}
+
+QRect TestHeaderView::visualRect(QString const &item) const
+{
+ int index = list().indexOf(item);
+ QPoint zero;
+ int sectionSize = q->sectionSize(index);
+ int sectionPos = q->sectionPosition(index);
+ return q->orientation() == Qt::Horizontal
+ ? QRect(zero.x() + sectionPos, zero.y(), sectionSize, q->height())
+ : QRect(zero.x(), zero.y() + sectionPos, q->width(), sectionSize);
+}
+
+bool TestHeaderView::canWrap(QObject* o)
+{ return qobject_cast<QHeaderView*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testheaderview.h b/old/plugins/qtuitest_widgets/qtwidgets/testheaderview.h
new file mode 100644
index 0000000..5970dd1
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testheaderview.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTHEADERVIEW_H
+#define TESTHEADERVIEW_H
+
+#include <testwidget.h>
+
+#include <QHeaderView>
+
+namespace QtUiTest {
+
+class TestHeaderView : public TestWidget,
+ public QtUiTest::ListWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::ListWidget)
+
+public:
+ TestHeaderView(QObject*);
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+
+ static bool canWrap(QObject*);
+
+signals:
+ void selected(const QString&);
+
+private:
+ QHeaderView *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testignore.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testignore.cpp
new file mode 100644
index 0000000..cd63018
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testignore.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testignore.h"
+#include "testwidgetslog.h"
+
+namespace QtUiTest {
+
+TestIgnore::TestIgnore(QObject* _q)
+ : TestWidget(_q), q(_q)
+{ TestWidgetsLog(); }
+
+bool TestIgnore::canWrap(QObject *o)
+{
+ QString cn = o->metaObject()->className();
+ return (cn == "QStackedWidget" ||
+ cn == "QFrame" ||
+ cn == "QWidget");
+}
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testignore.h b/old/plugins/qtuitest_widgets/qtwidgets/testignore.h
new file mode 100644
index 0000000..db0ae98
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testignore.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTIGNORE_H
+#define TESTIGNORE_H
+
+#include <testwidget.h>
+
+namespace QtUiTest {
+
+class TestIgnore : public TestWidget
+{
+ Q_OBJECT
+public:
+ TestIgnore(QObject*);
+ virtual bool ignoreScan() const { return true; }
+
+ static bool canWrap(QObject*);
+
+private:
+ QObject *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testlabel.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testlabel.cpp
new file mode 100644
index 0000000..b5ce0cc
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testlabel.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testlabel.h"
+#include "testwidgetslog.h"
+
+#include <QLabel>
+#include <QGroupBox>
+
+namespace QtUiTest {
+
+TestLabel::TestLabel(QObject* _q)
+ : TestGenericTextWidget(_q), q(qobject_cast<QLabel*>(_q))
+{ TestWidgetsLog(); }
+
+QString TestLabel::text() const
+{
+ TestWidgetsLog();
+ QString text = TestGenericTextWidget::text();
+ if (q->textFormat() != Qt::PlainText)
+ text = convertToPlainText(text);
+
+ return text;
+}
+
+QString TestLabel::labelText() const
+{
+ QString ret = text();
+ if (ret.isEmpty())
+ return ret;
+
+ QObject *w = parent();
+ while (w) {
+ QtUiTest::Widget *qw = qtuitest_cast<QtUiTest::Widget*>(w);
+ QtUiTest::LabelWidget *lw = qtuitest_cast<QtUiTest::LabelWidget*>(w);
+ if (lw) {
+ if (!lw->labelText().isEmpty()) {
+ ret.prepend(lw->labelText() + "/");
+ break;
+ }
+ }
+ w = qw->parent();
+ }
+ return ret;
+}
+
+QObject* TestLabel::buddy() const
+{
+ return q->buddy();
+}
+
+bool TestLabel::canWrap(QObject *o)
+{ return qobject_cast<QLabel*>(o); }
+
+QString TestLabel::convertToPlainText(QString const &richText)
+{
+ static QRegExp rxBr("<br */?>");
+ static QRegExp rxHtml("<[^>]+>");
+
+ QString ret(richText);
+ ret.replace(rxBr, "\n");
+ ret.replace(rxHtml, QString());
+ return ret;
+}
+
+// Returns a groupbox prefix for widgets that are owned by a groupbox
+QString TestLabel::groupBoxName() const
+{
+ QWidget *parent = q;
+ QGroupBox *gb;
+ QString ret;
+ do {
+ parent = qobject_cast<QWidget*>(parent->parent());
+ gb = qobject_cast<QGroupBox*>(parent);
+ if (gb && !gb->title().isEmpty())
+ ret += gb->title() + "/";
+ } while (parent);
+
+ ret.chop(1);
+ return ret;
+}
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testlabel.h b/old/plugins/qtuitest_widgets/qtwidgets/testlabel.h
new file mode 100644
index 0000000..dbca3b4
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testlabel.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTLABEL_H
+#define TESTLABEL_H
+
+#include "testgenerictextwidget.h"
+
+class QLabel;
+
+namespace QtUiTest {
+
+class TestLabel : public TestGenericTextWidget,
+ public QtUiTest::LabelWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::LabelWidget)
+
+public:
+ TestLabel(QObject*);
+
+ virtual bool ignoreScan() const { return true; }
+
+ virtual QString text() const;
+
+ virtual QString labelText() const;
+ virtual QObject* buddy() const;
+
+ static bool canWrap(QObject*);
+
+private:
+ static QString convertToPlainText(QString const&);
+ QString groupBoxName() const;
+
+ QLabel *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testlineedit.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testlineedit.cpp
new file mode 100644
index 0000000..4f24e5c
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testlineedit.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testlineedit.h"
+#include "testtext.h"
+#include "testwidgetslog.h"
+
+#include <QDesktopWidget>
+#include <QLayout>
+#include <QLineEdit>
+#include <QPointer>
+#include <QValidator>
+#include <QVariant>
+#include <QDateTimeEdit>
+
+namespace QtUiTest {
+
+TestLineEdit::TestLineEdit(QObject *_q)
+ : TestGenericTextWidget(_q), q(qobject_cast<QLineEdit*>(_q))
+{
+ if (q && qobject_cast<QDateTimeEdit*>(q->parent())) {
+ // The test object of the parent will handle recording
+ return;
+ }
+
+ connect(q, SIGNAL(textEdited(QString)), this, SLOT(onTextEdited(QString)));
+}
+
+void TestLineEdit::onTextEdited(QString const& item)
+{ emit entered(item); }
+
+bool TestLineEdit::canEnter(QVariant const& item) const
+{
+ if (!item.canConvert<QString>()) return false;
+ if (!q->validator()) return true;
+
+ int dontcare = 0;
+ QString text = item.toString();
+ return (QValidator::Acceptable==q->validator()->validate(text, dontcare));
+}
+
+bool TestLineEdit::enter(QVariant const& item, bool noCommit)
+{
+ if (!canEnter(item)) return false;
+
+ bool hadEditFocus = false;
+
+ if (!hadEditFocus && !setEditFocus(true)) return false;
+
+ using namespace QtUiTest;
+
+ QPointer<QObject> safeThis = this;
+
+ if (!safeThis) {
+ setErrorString("Widget was destroyed while entering text.");
+ return false;
+ }
+
+ QString oldText = text();
+ QString selectedText = q->selectedText();
+ QString itemString = item.toString();
+
+ QString expectedText = oldText;
+ if (selectedText == "") {
+ expectedText.insert(q->cursorPosition(), itemString);
+ // If there's text currently in the field, and we don't already have
+ // edit focus, then erase it first.
+ if (!oldText.isEmpty() && !hadEditFocus) {
+ if (!TestText::eraseTextByKeys(q)) return false;
+ expectedText = itemString;
+ }
+ } else {
+ expectedText.replace(selectedText, itemString);
+ }
+
+ InputWidget *iw = qtuitest_cast<InputWidget*>(inputProxy());
+
+ if (!safeThis) {
+ setErrorString("Widget was destroyed while entering text.");
+ return false;
+ }
+
+ TestWidgetsLog() << iw;
+
+ if (iw) {
+ if (!TestText::enterTextByProxy(iw, q, itemString, expectedText, !noCommit)) return false;
+ } else {
+ if (!TestText::enterText(q, itemString, expectedText, !noCommit)) return false;
+ }
+
+ if (!safeThis) {
+ setErrorString("Widget was destroyed while entering text.");
+ return false;
+ }
+
+ if (!noCommit && hasEditFocus()) {
+ if (!setEditFocus(false)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool TestLineEdit::canWrap(QObject *o)
+{ return qobject_cast<QLineEdit*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testlineedit.h b/old/plugins/qtuitest_widgets/qtwidgets/testlineedit.h
new file mode 100644
index 0000000..ec94ae7
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testlineedit.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTLINEEDIT_H
+#define TESTLINEEDIT_H
+
+#include "testgenerictextwidget.h"
+
+class QLineEdit;
+
+namespace QtUiTest {
+
+class TestLineEdit : public TestGenericTextWidget
+{
+ Q_OBJECT
+
+
+public:
+ TestLineEdit(QObject*);
+
+ virtual bool canEnter(QVariant const&) const;
+ virtual bool enter(QVariant const&,bool);
+
+ static bool canWrap(QObject*);
+
+private slots:
+ void onTextEdited(QString const&);
+
+signals:
+ void entered(QVariant const&);
+
+private:
+ QLineEdit *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testlistview.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testlistview.cpp
new file mode 100644
index 0000000..96507e2
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testlistview.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testlistview.h"
+#include "testwidgetslog.h"
+
+#include <QListView>
+
+#include <qtuitestnamespace.h>
+
+namespace QtUiTest {
+
+TestListView::TestListView(QObject *_q)
+ : TestAbstractItemView(_q), q(qobject_cast<QListView*>(_q))
+{}
+
+QStringList TestListView::list() const
+{
+ QStringList list;
+
+ QAbstractItemModel *model = q->model();
+ QModelIndex index = q->rootIndex();
+ int count = 0;
+
+ for (int i = 0, max_i = model->rowCount(index); i < max_i && count <= QTUITEST_MAX_LIST; ++i) {
+ if (model->hasIndex(i, q->modelColumn(), index)) {
+ list << model->data(model->index(i, q->modelColumn(), index)).toString();
+ }
+ }
+
+ return list;
+}
+
+QModelIndex TestListView::indexForItem(QString const &item) const
+{
+ QModelIndex ret;
+
+ QStringList list;
+
+ QAbstractItemModel *model = q->model();
+ QModelIndex index = q->rootIndex();
+ int count = 0;
+
+ for (int i = 0, max_i = model->rowCount(index); i < max_i && count <= QTUITEST_MAX_LIST; ++i) {
+ int j = q->modelColumn();
+ QModelIndex child;
+ if (model->hasIndex(i, j, index) && model->data(model->index(i, j, index)).toString() == item) {
+ ret = model->index(i, j, index);
+ }
+ }
+
+ return ret;
+}
+
+bool TestListView::canWrap(QObject* o)
+{ return qobject_cast<QListView*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testlistview.h b/old/plugins/qtuitest_widgets/qtwidgets/testlistview.h
new file mode 100644
index 0000000..3a3dea9
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testlistview.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTLISTVIEW_H
+#define TESTLISTVIEW_H
+
+#include "testabstractitemview.h"
+
+#include <QListView>
+
+namespace QtUiTest {
+
+class TestListView : public TestAbstractItemView
+{
+ Q_OBJECT
+
+public:
+ TestListView(QObject*);
+ virtual QStringList list() const;
+ static bool canWrap(QObject*);
+
+protected:
+ virtual QModelIndex indexForItem(QString const&) const;
+
+private:
+ QListView *q;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testmenu.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testmenu.cpp
new file mode 100644
index 0000000..66e1e58
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testmenu.cpp
@@ -0,0 +1,398 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testmenu.h"
+#include "testwidgetslog.h"
+
+#include <QMenu>
+#include <QAction>
+
+namespace QtUiTest {
+
+TestMenu::TestMenu(QObject *_q)
+ : TestWidget(_q), q(qobject_cast<QMenu*>(_q)), lastAction(0)
+{
+ // For accurate ordering of events recording, these connections
+ // must come before all others.
+ QtUiTest::connectFirst(q, SIGNAL(hovered(QAction*)),
+ this, SLOT(on_hovered(QAction*)));
+}
+
+void TestMenu::on_hovered(QAction* a)
+{
+ if (lastAction)
+ QtUiTest::disconnectFirst(lastAction, 0, this, 0);
+ lastAction = a;
+ if (lastAction) {
+ QtUiTest::connectFirst(lastAction, SIGNAL(toggled(bool)),
+ this, SLOT(on_toggled(bool)));
+ QtUiTest::connectFirst(lastAction, SIGNAL(triggered(bool)),
+ this, SLOT(on_triggered(bool)));
+ }
+}
+
+void TestMenu::on_toggled(bool state)
+{ emit stateChanged(state); }
+
+QString textForAction(QMenu* m, QAction* a)
+{
+ QString ret;
+ foreach (QAction* child, m->actions()) {
+ if (child == a) {
+ ret = a->text();
+ ret.replace("/","\\/");
+ } else if (child->menu()) {
+ ret = textForAction(child->menu(), a);
+ if (!ret.isEmpty())
+ ret.prepend(child->menu()->title().replace("/","\\/") + "/");
+ }
+ if (!ret.isEmpty())
+ break;
+ }
+ return ret;
+}
+
+void TestMenu::on_triggered(bool)
+{
+ /*
+ Both the top level and submenus emit the triggered() signal.
+ We only want to emit selected() if we are the top level menu.
+ */
+ bool top_level = true;
+ if (q->menuAction()) {
+ foreach (QWidget* w, q->menuAction()->associatedWidgets()) {
+ if (qobject_cast<QMenu*>(w)) {
+ top_level = false;
+ break;
+ }
+ }
+ }
+
+ if (!top_level) return;
+
+ emit selected(textForAction(q,lastAction));
+}
+
+QString TestMenu::text() const
+{
+ return list().join("\n");
+}
+
+QString TestMenu::selectedText() const
+{
+ QString ret;
+
+ QAction *active = q->activeAction();
+ if (!active) return ret;
+
+ QMenu *child = active->menu();
+ if (!child || !child->activeAction())
+ return active->text().replace("/", "\\/");
+
+ return active->text().replace("/", "\\/") + "/" + qtuitest_cast<QtUiTest::TextWidget*>(child)->selectedText();
+}
+
+QStringList TestMenu::list() const
+{
+ QStringList ret;
+
+ /* Iterate through every action */
+ foreach( QAction *a, q->actions() ) {
+ if (!a->isEnabled() || a->isSeparator())
+ continue;
+ QString t = a->text();
+ t.replace("/","\\/");
+ if (!t.isEmpty()) ret << t;
+ if (a->menu() && a->menu() != q) {
+ QStringList sub = qtuitest_cast<QtUiTest::ListWidget*>(a->menu())->list();
+ foreach (QString s, sub) {
+ if (!s.isEmpty()) ret << t + "/" + s;
+ }
+ }
+ }
+
+ return ret;
+}
+
+QRect TestMenu::visualRect(QString const &item) const
+{
+ TestWidgetsLog() << item;
+ static QRegExp slashRe("[^\\\\]/");
+ QRect ret;
+
+ int ind;
+ if (0 != (ind = item.indexOf(slashRe)+1)) {
+ QString top(item.left(ind));
+ QString rest(item.mid(ind+1));
+
+ QAction *a(q->activeAction());
+ QString t = a->text();
+ t.replace("/","\\/");
+ if (!a || t != top || !a->menu()) {
+ TestWidgetsLog() << "The desired submenu" << item << "is not visible";
+ return ret;
+ }
+
+ ret = qtuitest_cast<QtUiTest::ListWidget*>(a->menu())->visualRect(rest);
+ ret.moveTopLeft( q->mapFromGlobal( a->menu()->mapToGlobal( ret.topLeft() ) ) );
+ return ret;
+ }
+
+ QAction *a = actionForItem(item);
+ if (a) ret = q->actionGeometry(a);
+
+ return ret;
+}
+
+QAction *TestMenu::actionForItem(QString const &item) const
+{
+ static QRegExp amperRe("&(.)");
+ QAction *ret = 0;
+ foreach( QAction *a, q->actions() ) {
+ QString t = a->text();
+ t.replace("/","\\/");
+ if (t == item) {
+ ret = a;
+ break;
+ } else {
+ t.replace(amperRe, "\\1");
+ if (t == item) {
+ ret = a;
+ }
+ }
+ }
+
+ if (!ret) {
+ setErrorString("Item \"" + item + "\" is not available");
+ } else if (!ret->isEnabled()) {
+ setErrorString("Item \"" + item + "\" is not enabled");
+ ret = 0;
+ }
+
+ return ret;
+}
+
+Qt::CheckState TestMenu::checkState() const
+{
+ QAction *active = q->activeAction();
+ return (active && active->isChecked()) ? Qt::Checked : Qt::Unchecked;
+}
+
+bool TestMenu::ensureVisible(QString const&)
+{ return false; }
+
+bool TestMenu::canSelect(QString const &item) const
+{
+ QStringList l = list();
+ return l.contains(item) || l.contains(labelText(item));
+}
+
+bool TestMenu::select(QString const &item)
+{
+ if (!isVisible()) {
+ setErrorString("Can't select \"" + item + "\" because menu is not visible");
+ return false;
+ }
+
+ TestWidgetsLog() << item;
+ static QRegExp slashRe("[^\\\\]/");
+
+ QString topItem = item;
+ QString rest;
+
+ int ind;
+ if (0 != (ind = item.indexOf(slashRe)+1)) {
+ topItem = item.left(ind);
+ rest = item.mid(ind+1);
+ }
+
+ QRect r = visualRect(topItem);
+ if (r.isNull()) {
+ if (errorString().isEmpty()) {
+ setErrorString("Can't find visual rect for item \"" + topItem + "\" in menu");
+ }
+ return false;
+ }
+
+ QPoint pos = r.center();
+
+ bool useMouse = mousePreferred();
+ if (useMouse) {
+ while (!rect().contains(pos)) {
+ QRect visibleRect = visibleRegion().boundingRect();
+ QPoint globalPos = mapToGlobal(visibleRect.topLeft());
+ if (pos.y() < globalPos.y()) {
+ TestWidgetsLog() << "click to scroll up";
+ mouseClick(QPoint(globalPos.x() + visibleRect.width() / 2, globalPos.y() + 8));
+ QtUiTest::wait(200);
+ } else {
+ TestWidgetsLog() << "click to scroll down";
+ mouseClick(QPoint(globalPos.x() + visibleRect.width() / 2, globalPos.y() + visibleRect.height() - 8));
+ QtUiTest::wait(200);
+ }
+
+ pos = visualRect(topItem).center();
+ }
+ TestWidgetsLog() << "click on item";
+ if (!mouseClick(q, mapToGlobal(pos)))
+ return false;
+// waitForSignal(q, SIGNAL(triggered(QAction*)));
+ } else {
+ Qt::Key key;
+ if ( pos.y() > q->actionGeometry(q->activeAction()).center().y() )
+ key = Qt::Key_Down;
+ else
+ key = Qt::Key_Up;
+
+ while ( selectedText() != topItem ) {
+ TestWidgetsLog() << "key" << ((key == Qt::Key_Down) ? "down" : "up");
+ if (!keyClick(q, key)) return false;
+ }
+
+ TestWidgetsLog() << "select key";
+ // If this is the last item, it should be trigged...
+ if (item == topItem) {
+ if (!keyClick(q->activeAction(), SIGNAL(triggered(bool)), QtUiTest::Key_Activate))
+ return false;
+ }
+ // ...but if it has a submenu, it won't be; rather, its menu will be shown.
+ else if (q->activeAction() && q->activeAction()->menu()) {
+ if (!keyClick(q->activeAction()->menu(), QtUiTest::Key_Activate))
+ return false;
+ }
+
+ // And if it doesn't have a submenu and isn't the final item... well, that shouldn't
+ // happen, but that will be caught below.
+ }
+
+ if (topItem != item) {
+ QAction *a(q->activeAction());
+ if (!a || !a->menu()) {
+ setErrorString("Failed to select \"" + item + "\" because " +
+ (!a ? "focus could not be given to a parent item."
+ : "an item was expected to have a submenu, but didn't."));
+ return false;
+ }
+
+ // Wait until the menu is visible
+ if (!a->menu()->isVisible() && !waitForEvent(a->menu(), QEvent::Show)) {
+ setErrorString("Failed to select \"" + item + "\" because a submenu did not become "
+ "visible when it should have.");
+ return false;
+ }
+
+ TestWidgetsLog() << "calling select() on child";
+ return qtuitest_cast<SelectWidget*>(a->menu())->select(rest);
+ }
+ return true;
+}
+
+bool TestMenu::isCheckable(const QString &item)
+{
+ static QRegExp slashRe("[^\\\\]/");
+ bool ret = false;
+ int ind;
+ if (0 != (ind = item.indexOf(slashRe)+1)) {
+ QString top(item.left(ind));
+ QString rest(item.mid(ind+1));
+
+ QAction *a = actionForItem(top);
+ if (!a || !a->menu()) {
+ TestWidgetsLog() << "The desired submenu" << item << "is not valid";
+ return ret;
+ }
+
+ return qtuitest_cast<QtUiTest::CheckItemWidget*>(a->menu())->isCheckable(rest);
+ }
+
+ QAction *a = actionForItem(item);
+ if (a) ret = a->isCheckable();
+
+ return ret;
+}
+
+bool TestMenu::isChecked(const QString &item) const
+{
+ static QRegExp slashRe("[^\\\\]/");
+
+ bool ret = false;
+ int ind;
+ if (0 != (ind = item.indexOf(slashRe)+1)) {
+ QString top(item.left(ind));
+ QString rest(item.mid(ind+1));
+
+ QAction *a = actionForItem(top);
+ if (!a || !a->menu()) {
+ TestWidgetsLog() << "The desired submenu" << item << "is not valid";
+ return ret;
+ }
+
+ return qtuitest_cast<QtUiTest::CheckItemWidget*>(a->menu())->isChecked(rest);
+ }
+
+ QAction *a = actionForItem(item);
+ if (a) {
+ ret = a->isChecked();
+ } else {
+ setErrorString("Cannot get check status for item \"" + item + "\"");
+ }
+
+ return ret;
+}
+
+bool TestMenu::setChecked(const QString &item, bool value)
+{
+ if (isChecked(item) == value) {
+ return true;
+ }
+
+ return select(item);
+}
+
+bool TestMenu::hasFocus() const
+{
+ return !q->isHidden();
+}
+
+bool TestMenu::canWrap(QObject *o)
+{ return qobject_cast<QMenu*>(o); }
+
+}
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testmenu.h b/old/plugins/qtuitest_widgets/qtwidgets/testmenu.h
new file mode 100644
index 0000000..17a45aa
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testmenu.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTMENU_H
+#define TESTMENU_H
+
+#include <testwidget.h>
+
+#include <QtGlobal>
+
+class QMenu;
+class QAction;
+
+namespace QtUiTest {
+
+class TestMenu : public TestWidget, public QtUiTest::TextWidget,
+ public QtUiTest::ListWidget, public QtUiTest::CheckWidget,
+ public QtUiTest::SelectWidget, public QtUiTest::CheckItemWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::TextWidget
+ QtUiTest::ListWidget
+ QtUiTest::CheckWidget
+ QtUiTest::CheckItemWidget
+ QtUiTest::SelectWidget)
+
+public:
+ TestMenu(QObject*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+ virtual bool ensureVisible(QString const&);
+
+ virtual Qt::CheckState checkState() const;
+
+ virtual bool canSelect(const QString&) const;
+ virtual bool select(const QString&);
+
+ virtual bool isCheckable(const QString&);
+ virtual bool isChecked(const QString&) const;
+ virtual bool setChecked(const QString&, bool);
+
+ virtual bool hasFocus() const;
+
+ static bool canWrap(QObject*);
+
+signals:
+ void stateChanged(int);
+ void selected(const QString&);
+
+private slots:
+ void on_hovered(QAction*);
+ void on_triggered(bool);
+ void on_toggled(bool);
+
+private:
+ QMenu *q;
+ QAction *lastAction;
+
+ QAction *actionForItem(QString const&) const;
+};
+
+}
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testmenubar.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testmenubar.cpp
new file mode 100644
index 0000000..095b5d4
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testmenubar.cpp
@@ -0,0 +1,391 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testmenubar.h"
+#include "testwidgetslog.h"
+
+#include <QMenuBar>
+#include <QMenu>
+#include <QAction>
+
+namespace QtUiTest {
+
+TestMenuBar::TestMenuBar(QObject *_q)
+ : TestWidget(_q), q(qobject_cast<QMenuBar*>(_q)), lastAction(0)
+{
+ // For accurate ordering of events recording, these connections
+ // must come before all others.
+// QtUiTest::connectFirst(q, SIGNAL(hovered(QAction*)),
+// this, SLOT(on_hovered(QAction*)));
+}
+/*
+void TestMenuBar::on_hovered(QAction* a)
+{
+ if (lastAction)
+ QtUiTest::disconnectFirst(lastAction, 0, this, 0);
+ lastAction = a;
+ if (lastAction) {
+ QtUiTest::connectFirst(lastAction, SIGNAL(toggled(bool)),
+ this, SLOT(on_toggled(bool)));
+ QtUiTest::connectFirst(lastAction, SIGNAL(triggered(bool)),
+ this, SLOT(on_triggered(bool)));
+ }
+}
+
+void TestMenuBar::on_toggled(bool state)
+{ emit stateChanged(state); }
+*/
+/*
+QString textForAction(QMenu* m, QAction* a)
+{
+ QString ret;
+ foreach (QAction* child, m->actions()) {
+ if (child == a) {
+ ret = a->text();
+ ret.replace("/","\\/");
+ } else if (child->menu()) {
+ ret = textForAction(child->menu(), a);
+ if (!ret.isEmpty())
+ ret.prepend(child->menu()->title().replace("/","\\/") + "/");
+ }
+ if (!ret.isEmpty())
+ break;
+ }
+ return ret;
+}
+*/
+/*
+void TestMenuBar::on_triggered(bool)
+{
+ // Both the top level and submenus emit the triggered() signal.
+ // We only want to emit selected() if we are the top level menu.
+
+ bool top_level = true;
+ if (q->menuAction()) {
+ foreach (QWidget* w, q->menuAction()->associatedWidgets()) {
+ if (qobject_cast<QMenu*>(w)) {
+ top_level = false;
+ break;
+ }
+ }
+ }
+
+ if (!top_level) return;
+
+ emit selected(textForAction(q,lastAction));
+// }
+*/
+QString TestMenuBar::text() const
+{
+ return list().join("\n");
+}
+
+QString TestMenuBar::selectedText() const
+{
+ QString ret;
+
+ QAction *active = q->activeAction();
+ if (!active) return ret;
+
+ QMenu *child = active->menu();
+ if (!child || !child->activeAction())
+ return active->text().replace("/", "\\/");
+
+ return active->text().replace("/", "\\/") + "/" + qtuitest_cast<QtUiTest::TextWidget*>(child)->selectedText();
+}
+
+QStringList TestMenuBar::list() const
+{
+ QStringList ret;
+
+ /* Iterate through every action */
+ foreach( QAction *a, q->actions() ) {
+ if (!a->isEnabled())
+ continue;
+ QString t = a->text();
+ t.replace("/","\\/");
+ if (!t.isEmpty()) ret << t;
+ if (a->menu()) {
+ QStringList sub = qtuitest_cast<QtUiTest::ListWidget*>(a->menu())->list();
+ foreach (QString s, sub) {
+ if (!s.isEmpty()) ret << t + "/" + s;
+ }
+ }
+ }
+
+ return ret;
+}
+
+QRect TestMenuBar::visualRect(QString const &item) const
+{
+ TestWidgetsLog() << item;
+ static QRegExp slashRe("[^\\\\]/");
+ static QRegExp amperRe("&(.)");
+ QRect ret;
+
+ int ind;
+ if (0 != (ind = item.indexOf(slashRe)+1)) {
+ QString top(item.left(ind));
+ QString rest(item.mid(ind+1));
+
+ QAction *a(q->activeAction());
+ QString t = a->text();
+ t.replace("/","\\/");
+ if (!a || t != top || !a->menu()) {
+ TestWidgetsLog() << "The desired submenu" << item << "is not visible";
+ return ret;
+ }
+
+ ret = qtuitest_cast<QtUiTest::ListWidget*>(a->menu())->visualRect(rest);
+ ret.moveTopLeft( q->mapFromGlobal( a->menu()->mapToGlobal( ret.topLeft() ) ) );
+ return ret;
+ }
+
+ QAction *a = actionForItem(item);
+ if (a) ret = q->actionGeometry(a);
+
+ return ret;
+}
+
+QAction *TestMenuBar::actionForItem(QString const &item) const
+{
+ static QRegExp amperRe("&(.)");
+ QAction *ret = 0;
+ foreach( QAction *a, q->actions() ) {
+ QString t = a->text();
+ t.replace("/","\\/");
+ if (t == item) {
+ ret = a;
+ break;
+ } else {
+ t.replace(amperRe, "\\1");
+ if (t == item) {
+ ret = a;
+ }
+ }
+ }
+
+ if (!ret) {
+ setErrorString("Item \"" + item + "\" is not available");
+ } else if (!ret->isEnabled()) {
+ setErrorString("Item \"" + item + "\" is not enabled");
+ ret = 0;
+ }
+
+ return ret;
+}
+
+Qt::CheckState TestMenuBar::checkState() const
+{
+ QAction *active = q->activeAction();
+ return (active && active->isChecked()) ? Qt::Checked : Qt::Unchecked;
+}
+
+bool TestMenuBar::ensureVisible(QString const&)
+{ return false; }
+
+bool TestMenuBar::canSelect(QString const &item) const
+{
+ return list().contains(item);
+}
+
+bool TestMenuBar::select(QString const &item)
+{
+ if (!isVisible()) {
+ setErrorString("Can't select \"" + item + "\" because menu is not visible");
+ return false;
+ }
+
+ TestWidgetsLog() << item;
+ static QRegExp slashRe("[^\\\\]/");
+
+ QString topItem = item;
+ QString rest;
+
+ int ind;
+ if (0 != (ind = item.indexOf(slashRe)+1)) {
+ topItem = item.left(ind);
+ rest = item.mid(ind+1);
+ }
+
+ QAction *action = actionForItem(topItem);
+
+ QRect r = visualRect(topItem);
+ if (r.isNull()) {
+ if (errorString().isEmpty()) {
+ setErrorString("Can't find visual rect for item \"" + topItem + "\" in menu");
+ }
+ return false;
+ }
+
+ QPoint pos = r.center();
+
+ if (mousePreferred()) {
+ while (!rect().contains(pos)) {
+ QRect visibleRect = visibleRegion().boundingRect();
+ QPoint globalPos = mapToGlobal(visibleRect.topLeft());
+ if (pos.y() < globalPos.y()) {
+ TestWidgetsLog() << "click to scroll up";
+ mouseClick(QPoint(globalPos.x() + visibleRect.width() / 2, globalPos.y() + 8));
+ QtUiTest::wait(200);
+ } else {
+ TestWidgetsLog() << "click to scroll down";
+ mouseClick(QPoint(globalPos.x() + visibleRect.width() / 2, globalPos.y() + visibleRect.height() - 8));
+ QtUiTest::wait(200);
+ }
+
+ pos = visualRect(topItem).center();
+ }
+
+ if (!mouseClick(action->menu(), SIGNAL(aboutToShow()), mapToGlobal(pos)))
+ return false;
+ } else {
+ Qt::Key key;
+ if ( pos.y() > q->actionGeometry(q->activeAction()).center().y() )
+ key = Qt::Key_Down;
+ else
+ key = Qt::Key_Up;
+
+ while ( selectedText() != topItem ) {
+ TestWidgetsLog() << "key" << ((key == Qt::Key_Down) ? "down" : "up");
+ if (!keyClick(q, key)) return false;
+ }
+
+ TestWidgetsLog() << "select key";
+ // If this is the last item, it should be trigged...
+ if (item == topItem) {
+ if (!keyClick(q->activeAction(), SIGNAL(triggered(bool)), QtUiTest::Key_Select))
+ return false;
+ }
+ // ...but if it has a submenu, it won't be; rather, its menu will be shown.
+ else if (q->activeAction() && q->activeAction()->menu()) {
+ if (!keyClick(q->activeAction()->menu(), QtUiTest::Key_Select))
+ return false;
+ }
+
+ // And if it doesn't have a submenu and isn't the final item... well, that shouldn't
+ // happen, but that will be caught below.
+ }
+
+ if (topItem != item) {
+
+ if (!action->menu()->isVisible() && !waitForEvent(action->menu(), QEvent::Show)) {
+ setErrorString("Failed to select \"" + item + "\" because a submenu did not become "
+ "visible when it should have.");
+ return false;
+ }
+
+ TestWidgetsLog() << "calling select() on child";
+ return qtuitest_cast<SelectWidget*>(action->menu())->select(rest);
+ }
+
+ return true;
+}
+
+bool TestMenuBar::isCheckable(const QString &item)
+{
+ static QRegExp slashRe("[^\\\\]/");
+
+ bool ret = false;
+ int ind;
+ if (0 != (ind = item.indexOf(slashRe)+1)) {
+ QString top(item.left(ind));
+ QString rest(item.mid(ind+1));
+
+ QAction *a = actionForItem(top);
+ if (!a || !a->menu()) {
+ TestWidgetsLog() << "The desired submenu" << item << "is not valid";
+ return ret;
+ }
+
+ return qtuitest_cast<QtUiTest::CheckItemWidget*>(a->menu())->isCheckable(rest);
+ }
+
+ QAction *a = actionForItem(item);
+ if (a) ret = a->isCheckable();
+
+ return ret;
+}
+
+bool TestMenuBar::isChecked(const QString &item) const
+{
+ static QRegExp slashRe("[^\\\\]/");
+
+ bool ret = false;
+ int ind;
+ if (0 != (ind = item.indexOf(slashRe)+1)) {
+ QString top(item.left(ind));
+ QString rest(item.mid(ind+1));
+
+ QAction *a = actionForItem(top);
+
+ if (!a || !a->menu()) {
+ TestWidgetsLog() << "The desired submenu" << item << "is not valid";
+ return ret;
+ }
+
+ return qtuitest_cast<QtUiTest::CheckItemWidget*>(a->menu())->isChecked(rest);
+ }
+
+ QAction *a = actionForItem(item);
+ if (a) ret = a->isChecked();
+
+ return ret;
+}
+
+bool TestMenuBar::setChecked(const QString &item, bool value)
+{
+ if (isChecked(item) == value) {
+ return true;
+ }
+
+ return select(item);
+}
+
+bool TestMenuBar::hasFocus() const
+{
+ return !q->isHidden();
+}
+
+bool TestMenuBar::canWrap(QObject *o)
+{ return qobject_cast<QMenuBar*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testmenubar.h b/old/plugins/qtuitest_widgets/qtwidgets/testmenubar.h
new file mode 100644
index 0000000..229e4f7
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testmenubar.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTMENUBAR_H
+#define TESTMENUBAR_H
+
+#include <testwidget.h>
+
+#include <QtGlobal>
+
+class QMenuBar;
+class QAction;
+
+namespace QtUiTest {
+
+class TestMenuBar : public TestWidget, public QtUiTest::TextWidget,
+ public QtUiTest::ListWidget, public QtUiTest::CheckWidget,
+ public QtUiTest::SelectWidget, public CheckItemWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::TextWidget
+ QtUiTest::ListWidget
+ QtUiTest::CheckWidget
+ QtUiTest::CheckItemWidget
+ QtUiTest::SelectWidget)
+
+public:
+ TestMenuBar(QObject*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+ virtual bool ensureVisible(QString const&);
+
+ virtual Qt::CheckState checkState() const;
+
+ virtual bool canSelect(const QString&) const;
+ virtual bool select(const QString&);
+
+ virtual bool isCheckable(const QString&);
+ virtual bool isChecked(const QString&) const;
+ virtual bool setChecked(const QString&, bool);
+
+ virtual bool hasFocus() const;
+
+ static bool canWrap(QObject*);
+
+signals:
+ void stateChanged(int);
+ void selected(const QString&);
+
+//private slots:
+// void on_hovered(QAction*);
+// void on_triggered(bool);
+// void on_toggled(bool);
+
+private:
+ QMenuBar *q;
+ QAction *lastAction;
+
+ QAction *actionForItem(QString const&) const;
+};
+
+}
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testpushbutton.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testpushbutton.cpp
new file mode 100644
index 0000000..6d3bd35
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testpushbutton.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testpushbutton.h"
+#include "testwidgetslog.h"
+
+#include <QMenu>
+#include <QPushButton>
+
+namespace QtUiTest {
+
+TestPushButton::TestPushButton(QObject *_q)
+ : TestAbstractButton(_q), q(qobject_cast<QPushButton*>(_q))
+{}
+
+QStringList TestPushButton::list() const
+{
+ QStringList ret;
+
+ QtUiTest::ListWidget *menu
+ = qtuitest_cast<QtUiTest::ListWidget*>(q->menu());
+
+ if (menu)
+ ret = menu->list();
+
+ return ret;
+}
+
+QRect TestPushButton::visualRect(QString const &item) const
+{
+ TestWidgetsLog();
+ QRect ret;
+ QtUiTest::ListWidget *lMenu
+ = qtuitest_cast<QtUiTest::ListWidget*>(q->menu());
+
+ if (lMenu)
+ ret = lMenu->visualRect(item);
+ return ret;
+}
+
+bool TestPushButton::ensureVisible(QString const& item)
+{
+ bool ret = false;
+
+ QtUiTest::ListWidget *menu
+ = qtuitest_cast<QtUiTest::ListWidget*>(q->menu());
+
+ if (menu)
+ ret = menu->ensureVisible(item);
+
+ return ret;
+}
+
+bool TestPushButton::canSelect(QString const &item) const
+{ return list().contains(item); }
+
+bool TestPushButton::select(QString const &item)
+{
+ bool ret = false;
+
+ QtUiTest::SelectWidget *menu
+ = qtuitest_cast<QtUiTest::SelectWidget*>(q->menu());
+
+ if (menu)
+ {
+ activate();
+ ret = menu->select(item);
+ }
+
+ return ret;
+}
+
+bool TestPushButton::canWrap(QObject *o)
+{ return qobject_cast<QPushButton*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testpushbutton.h b/old/plugins/qtuitest_widgets/qtwidgets/testpushbutton.h
new file mode 100644
index 0000000..5a3f420
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testpushbutton.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTPUSHBUTTON_H
+#define TESTPUSHBUTTON_H
+
+#include "testabstractbutton.h"
+
+class QPushButton;
+
+namespace QtUiTest {
+
+class TestPushButton : public TestAbstractButton,
+ public QtUiTest::ListWidget, public QtUiTest::SelectWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::ListWidget
+ QtUiTest::SelectWidget)
+
+public:
+ TestPushButton(QObject*);
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+ virtual bool ensureVisible(QString const&);
+
+ virtual bool canSelect(const QString&) const;
+ virtual bool select(const QString&);
+
+ static bool canWrap(QObject*);
+
+private:
+ QPushButton *q;
+};
+
+}
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testtabbar.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testtabbar.cpp
new file mode 100644
index 0000000..4a7bd8a
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testtabbar.cpp
@@ -0,0 +1,231 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testtabbar.h"
+
+#include "testwidgetslog.h"
+
+#include <QTabBar>
+#include <QTabWidget>
+#include <QToolButton>
+
+namespace QtUiTest {
+
+TestTabBar::TestTabBar(QObject *_q)
+ : TestWidget(_q), q(qobject_cast<QTabBar*>(_q))
+{
+ connect(q, SIGNAL(currentChanged(int)),
+ this, SLOT(on_currentChanged(int)));
+}
+
+void TestTabBar::on_currentChanged(int index)
+{ emit selected(q->tabText(index)); }
+
+QString TestTabBar::text() const
+{ return list().join("\n"); }
+
+QString TestTabBar::selectedText() const
+{ return q->tabText(q->currentIndex()); }
+
+QStringList TestTabBar::list() const
+{
+ QStringList ret;
+ for (int i = 0, max = q->count(); i < max; ++i)
+ ret << q->tabText(i);
+ return ret;
+}
+
+QRect TestTabBar::visualRect(QString const &item) const
+{
+ int index = indexForItem(item);
+ if (index != -1)
+ return q->visibleRegion().subtracted(q->childrenRegion()).intersected(QRegion(q->tabRect(index))).boundingRect();
+ else
+ return QRect();
+}
+
+bool TestTabBar::ensureVisible(QString const& item)
+{
+ /* First, find desired index. */
+ int desired = indexForItem(item);
+ if (-1 == desired) return false;
+
+ QToolButton* leftB = 0;
+ QToolButton* rightB = 0;
+
+ QList<QToolButton*> buttons = q->findChildren<QToolButton*>();
+ QRegion buttonRegion;
+ foreach (QToolButton* b, buttons) {
+ if (b->arrowType() == Qt::LeftArrow) {
+ leftB = b;
+ buttonRegion |= b->geometry();
+ } else if (b->arrowType() == Qt::RightArrow) {
+ rightB = b;
+ buttonRegion |= b->geometry();
+ }
+ }
+ QRect buttonRect = buttonRegion.boundingRect();
+
+ int clicks = 0;
+ /* While desired tab isn't visible... */
+ while (q->visibleRegion().subtracted(buttonRect).intersected( q->tabRect(desired) ).isEmpty()
+ && clicks < 50) {
+
+ TestWidgetsLog() << "visible:" << q->visibleRegion().boundingRect() << "buttons:" << buttonRect << "tab:" << q->tabRect(desired);
+
+ QObject* button = 0;
+
+ /* Shall we go to the left or the right? */
+ if (q->tabRect(desired).left() >= q->visibleRegion().subtracted(buttonRect).boundingRect().right())
+ button = rightB;
+ else
+ button = leftB;
+
+ QtUiTest::ActivateWidget* aw
+ = qtuitest_cast<QtUiTest::ActivateWidget*>(button);
+ if (!aw) return false;
+ aw->activate();
+
+ ++clicks;
+ }
+
+ return !q->visibleRegion().subtracted(buttonRect).intersected( q->tabRect(desired) ).isEmpty();
+}
+
+bool TestTabBar::canSelect(QString const& item) const
+{
+ return indexForItem(item) != -1;
+}
+
+bool isAncestor(QObject* parent, QObject* child)
+{
+ bool ret = false;
+ QObject* p = child;
+ while (p && !ret) {
+ ret = (p == parent);
+ p = p->parent();
+ }
+ return ret;
+}
+
+bool TestTabBar::select(QString const& item)
+{
+ using namespace QtUiTest;
+
+ QStringList allTabs;
+ int desired = -1;
+ desired = indexForItem(item);
+ for (int i = 0, max = q->count(); i < max && -1 == desired; ++i) {
+ if (q->tabText(i) == item)
+ desired = i;
+ allTabs << q->tabText(i);
+ }
+ if (-1 == desired) {
+ setErrorString(
+ "Could not select tab '" + item + "' because there is no tab with that text");
+ return false;
+ }
+ if (q->currentIndex() == desired) return true;
+
+ QString originalTab = q->tabText(q->currentIndex());
+
+ if (mousePreferred()) {
+ if (!ensureVisible(item)) return false;
+ QPoint p = visualRect(item).center();
+ if (!ensureVisiblePoint(p)) return false;
+ mouseClick(mapToGlobal(p));
+ QtUiTest::waitForSignal(q, SIGNAL(currentChanged(int)));
+ if (q->currentIndex() != desired) {
+ setErrorString(
+ "Clicked on tab '" + item + "' but it did not appear to become selected.\n"
+ "Selected tab is: " + selectedText());
+ return false;
+ }
+ return true;
+ }
+
+ if (!setFocus()) return false;
+
+ Qt::Key key;
+ int diff = 0;
+ if (desired < q->currentIndex()) {
+ key = Qt::Key_Left;
+ diff = q->currentIndex() - desired;
+ }
+ else {
+ key = Qt::Key_Right;
+ diff = desired - q->currentIndex();
+ }
+ for (int i = 0; i < diff; ++i) {
+ if (!setFocus()) return false;
+ if (!keyClick(q, SIGNAL(currentChanged(int)), key))
+ return false;
+ }
+
+ if (q->currentIndex() == desired) return true;
+ setErrorString(
+ QString("Can't change tabs: pressed the %1 key %2 times which should have "
+ "moved from '%3' to '%4', but the current tab ended up as '%5'.")
+ .arg((key == Qt::Key_Right) ? "Right" : "Left")
+ .arg(diff)
+ .arg(originalTab)
+ .arg(item)
+ .arg(q->tabText(q->currentIndex()))
+ );
+ return false;
+}
+
+int TestTabBar::indexForItem(QString const& item) const
+{
+ for (int i = 0, max = q->count(); i < max; ++i) {
+ if (q->tabText(i) == item || labelText(q->tabText(i)) == item)
+ return i;
+ }
+ return -1;
+}
+
+bool TestTabBar::inherits(QtUiTest::WidgetType type) const
+{ return (QtUiTest::TabBar == type); }
+
+bool TestTabBar::canWrap(QObject *o)
+{ return qobject_cast<QTabBar*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testtabbar.h b/old/plugins/qtuitest_widgets/qtwidgets/testtabbar.h
new file mode 100644
index 0000000..b636bec
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testtabbar.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTTABBAR_H
+#define TESTTABBAR_H
+
+#include <testwidget.h>
+
+class QTabBar;
+
+namespace QtUiTest {
+
+class TestTabBar : public TestWidget,
+ public QtUiTest::TextWidget,
+ public QtUiTest::ListWidget,
+ public QtUiTest::SelectWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::TextWidget
+ QtUiTest::ListWidget
+ QtUiTest::SelectWidget)
+
+public:
+ TestTabBar(QObject*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+ virtual bool ensureVisible(QString const&);
+
+ virtual bool canSelect(QString const&) const;
+ virtual bool select(QString const&);
+
+ virtual bool inherits(QtUiTest::WidgetType) const;
+
+ static bool canWrap(QObject*);
+
+signals:
+ void selected(const QString&);
+
+private slots:
+ void on_currentChanged(int);
+
+private:
+ int indexForItem(QString const&) const;
+ QTabBar *q;
+};
+
+}
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testtext.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testtext.cpp
new file mode 100644
index 0000000..e62cc27
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testtext.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testtext.h"
+#include "testwidgetslog.h"
+
+#include <QPointer>
+#include <QVariant>
+
+using namespace QtUiTest;
+
+bool TestText::enterText(QObject* q, QString const& item, QString const& expectedText, bool commit)
+{
+ QByteArray textChanged = textChangedSignal(q);
+ TextWidget* tw = qtuitest_cast<TextWidget*>(q);
+
+ foreach (QChar const& c, item) {
+ TestWidgetsLog() << asciiToModifiers(c.toLatin1());
+ if (!keyClick(q, textChanged, asciiToKey(c.toLatin1()), asciiToModifiers(c.toLatin1()) ))
+ return false;
+ }
+
+ QString newText = tw->text();
+ if (newText != expectedText) {
+ setErrorString(QString("After entering text, expected text of:\n%1\nBut text was:\n%2")
+ .arg(expectedText)
+ .arg(newText));
+ return false;
+ }
+
+ if (commit) {
+#ifdef Q_OS_SYMBIAN
+ keyClick(Qt::Key_Select);
+#else
+ QtUiTest::Widget* w = qtuitest_cast<QtUiTest::Widget*>(q);
+ if (w) return w->setEditFocus(false);
+#endif
+ }
+
+ return true;
+}
+
+bool TestText::enterTextByProxy(QtUiTest::InputWidget* proxy, QObject* q, QString const& item, QString const& expectedText, bool commit)
+{
+ TextWidget* tw = qtuitest_cast<TextWidget*>(q);
+ QByteArray textChanged = textChangedSignal(q);
+ QPointer<QObject> safeQ(q);
+
+ if (!proxy->enter(item, !commit)) return false;
+
+ QString newText;
+
+ for (int i = expectedText.length(); i != 0; --i) {
+ if (!safeQ) {
+ setErrorString("Widget was destroyed while entering text.");
+ return false;
+ }
+ newText = tw->text();
+ if (newText == expectedText) {
+ break;
+ }
+ if (!waitForSignal(q, textChanged)) {
+ setErrorString("Text did not change on focused widget due to key clicks");
+ return false;
+ }
+ }
+
+ if (newText != expectedText) newText = tw->text();
+ if (newText != expectedText) {
+ setErrorString(QString("After entering text, expected text of:\n%1\nBut text was:\n%2")
+ .arg(expectedText)
+ .arg(newText));
+ return false;
+ }
+
+ return true;
+}
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testtext.h b/old/plugins/qtuitest_widgets/qtwidgets/testtext.h
new file mode 100644
index 0000000..6168c1e
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testtext.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTTEXT_H
+#define TESTTEXT_H
+
+#include <qtuitestnamespace.h>
+#include <qrect.h>
+#include <qpoint.h>
+#include "testwidgetslog.h"
+
+namespace QtUiTest {
+
+namespace TestText {
+
+ inline
+ QByteArray textChangedSignal(QObject* q)
+ {
+ QByteArray textChangedSignal("textChanged(QString)");
+ if (-1 == q->metaObject()->indexOfSignal(textChangedSignal)) {
+ textChangedSignal = "textChanged()";
+ }
+ textChangedSignal.prepend(QSIGNAL_CODE);
+ return textChangedSignal;
+ }
+
+ // Erase the text in the widget q by using key clicks
+ template <typename T> inline
+ bool eraseTextByKeys(T* q)
+ {
+ using namespace QtUiTest;
+
+ if (!q->hasFocus()) {
+ setErrorString("Cannot erase text from unfocused widget.");
+ return false;
+ }
+
+ Widget* w = qtuitest_cast<Widget*>(q);
+ bool hadEditFocus = w->hasEditFocus();
+ if (!w->setEditFocus(true)) {
+ setErrorString("Couldn't erase text from widget: couldn't give edit focus to widget.");
+ return false;
+ }
+
+ const int MAX = q->text().length()+1;
+ int i = 0;
+
+ int pos = q->cursorPosition();
+ int oldPos = -1;
+ TestWidgetsLog() << "pos" << pos << "MAX" << MAX;
+
+ while (oldPos != pos && (++i < MAX) && (pos < MAX-1)) {
+ keyClick(q, SIGNAL(cursorPositionChanged(int,int)), Qt::Key_Right);
+ oldPos = pos;
+ pos = q->cursorPosition();
+ }
+
+ if (i >= MAX) {
+ setErrorString("Could not move cursor to rightmost position in widget.");
+ return false;
+ }
+
+ QByteArray textChanged = textChangedSignal(q);
+ i = 0;
+ do {
+ if (!keyClick(q, textChanged, Qt::Key_Backspace))
+ return false;
+ } while (q->cursorPosition() != 0 && (++i < MAX));
+
+ if (i >= MAX || !q->text().isEmpty()) {
+ setErrorString("Could not erase all text by pressing backspace.");
+ return false;
+ }
+
+ if (!w->setEditFocus(hadEditFocus)) {
+ setErrorString("Couldn't return widget to original edit focus state.");
+ return false;
+ }
+
+ return true;
+ }
+
+ template <typename T> inline
+ bool eraseTextByMouse(T* q)
+ {
+// QtUiTest::setErrorString("Erasing text by mouse is not implemented.");
+// return false;
+
+ //FIXME: For now, erase text using keys. Not sure if erasing text using
+ // the mouse makes sense in Qt.
+ return eraseTextByKeys(q);
+ }
+
+ bool enterText(QObject* q, QString const& item, QString const& expectedText, bool commit = true);
+ bool enterTextByProxy(QtUiTest::InputWidget* proxy, QObject* q, QString const& item, QString const& expectedText, bool commit = true);
+};
+
+}
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testtextedit.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testtextedit.cpp
new file mode 100644
index 0000000..9e43324
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testtextedit.cpp
@@ -0,0 +1,298 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testtext.h"
+#include "testtextedit.h"
+#include "testwidgetslog.h"
+
+#include <QLayout>
+#include <QPointer>
+#include <QTextDocumentFragment>
+#include <QTextEdit>
+#include <QTextBlock>
+#include <QTextFragment>
+#include <QScrollBar>
+
+namespace QtUiTest {
+
+TestTextEdit::TestTextEdit(QObject *_q)
+ : TestWidget(_q)
+ , lastEntered()
+ , lastCursorPosition(-1)
+ , committed(false)
+ , q(qobject_cast<QTextEdit*>(_q))
+{
+ lastCursorPosition = cursorPosition();
+ connect(q, SIGNAL(textChanged()), this, SLOT(onTextChanged()));
+ connect(q, SIGNAL(textChanged()), this, SIGNAL(textChanged()));
+ connect(q, SIGNAL(cursorPositionChanged()), this, SLOT(onCursorPositionChanged()));
+}
+
+QString TestTextEdit::text() const
+{ return q->toPlainText(); }
+
+QString TestTextEdit::selectedText() const
+{ return q->textCursor().selection().toPlainText(); }
+
+QStringList TestTextEdit::list() const
+{
+ QStringList ret;
+ QTextDocument *doc = q->document();
+
+ for (int i = 0, blockCount = doc->blockCount(); i < blockCount; ++i) {
+ QTextBlock block = doc->findBlockByNumber(i);
+ QTextBlock::iterator it;
+ for (it = block.begin(); !(it.atEnd()); ++it) {
+ QTextFragment fragment = it.fragment();
+ if (fragment.isValid() && fragment.charFormat().isAnchor()) {
+ ret << fragment.text();
+ }
+ }
+ }
+
+ return ret;
+}
+
+QTextFragment TestTextEdit::fragmentForItem(QString const &item) const
+{
+ QTextFragment ret;
+ QTextDocument *doc = q->document();
+
+ for (int i = 0, blockCount = doc->blockCount(); i < blockCount; ++i) {
+ QTextBlock block = doc->findBlockByNumber(i);
+ QTextBlock::iterator it;
+ for (it = block.begin(); !(it.atEnd()); ++it) {
+ QTextFragment fragment = it.fragment();
+ if (fragment.isValid() && fragment.charFormat().isAnchor() &&
+ fragment.text() == item) {
+ return fragment;
+ }
+ }
+ }
+
+ return ret;
+}
+
+QRect TestTextEdit::visualRect(QString const &item) const
+{
+ return visualRect(fragmentForItem(item));
+}
+
+QRect TestTextEdit::visualRect(QTextFragment const &fragment) const
+{
+ QRect ret;
+
+ if (fragment.isValid()) {
+ QTextCursor cursor(q->document());
+ cursor.setPosition(fragment.position()+1);
+ ret = q->cursorRect(cursor);
+ }
+
+ return ret;
+}
+
+bool TestTextEdit::canEnter(QVariant const& item) const
+{
+ return item.canConvert<QString>();
+}
+
+bool TestTextEdit::enter(QVariant const& item, bool noCommit)
+{
+ if (!canEnter(item)) return false;
+
+ bool hadEditFocus = hasEditFocus();
+
+ if (!hadEditFocus && !setEditFocus(true)) return false;
+
+ using namespace QtUiTest;
+
+ QPointer<QObject> safeThis = this;
+ if (!safeThis) {
+ setErrorString("Widget was destroyed while entering text.");
+ return false;
+ }
+
+ QString oldText = text();
+ QString itemString = item.toString();
+ QString expectedText = oldText;
+ expectedText.insert(q->textCursor().position(), itemString);
+
+ /* If there's text currently in the field, and we committed it,
+ then erase it first. */
+ if (!oldText.isEmpty() && committed) {
+ if (QtUiTest::mousePreferred()) {
+ if (!TestText::eraseTextByMouse(this)) return false;
+ } else {
+ if (!TestText::eraseTextByKeys(this)) return false;
+ }
+ expectedText = itemString;
+ }
+
+ InputWidget* iw = qtuitest_cast<InputWidget*>(inputProxy());
+
+ if (!safeThis) {
+ setErrorString("Widget was destroyed while entering text.");
+ return false;
+ }
+
+ TestWidgetsLog() << iw;
+
+ if (iw) {
+ if (!TestText::enterTextByProxy(iw, q, itemString, expectedText, !noCommit)) return false;
+ } else {
+ if (!TestText::enterText(q, itemString, expectedText, !noCommit)) return false;
+ }
+
+ if (!safeThis) {
+ setErrorString("Widget was destroyed while entering text.");
+ return false;
+ }
+
+ if (!noCommit && hasEditFocus()) {
+ if (!setEditFocus(false)) {
+ return false;
+ }
+ }
+
+ committed = !noCommit;
+
+ return true;
+}
+
+bool TestTextEdit::canSelect(QString const &item) const
+{ return list().contains(item); }
+
+bool TestTextEdit::ensureVisible(QTextFragment const &item)
+{
+ QPoint p = visualRect(item).center();
+
+ if (q->viewport()->rect().contains(p)) {
+ TestWidgetsLog() << "item is already visible";
+ return true;
+ }
+
+ if (!QtUiTest::mousePreferred())
+ return false;
+
+ /* Figure out the points to click for scrolling in each direction */
+ QScrollBar *vbar = q->verticalScrollBar();
+ QScrollBar *hbar = q->horizontalScrollBar();
+ QPoint up = vbar->mapToGlobal(QPoint(vbar->width()/2,5));
+ QPoint down = vbar->mapToGlobal(QPoint(vbar->width()/2,vbar->height()-5));
+ QPoint left = hbar->mapToGlobal(QPoint(5, hbar->height()/2));
+ QPoint right = hbar->mapToGlobal(QPoint(hbar->width()-5,hbar->height()/2));
+
+ // While p is above rect...
+ while (p.y() < q->viewport()->rect().top()) {
+ if (!vbar->isVisible()) return false;
+ TestWidgetsLog() << "up" << "\nrect:" << rect() << "p:" << p;
+ QtUiTest::mouseClick(up);
+ waitForSignal(vbar, SIGNAL(valueChanged(int)));
+ p = visualRect(item).center();
+ }
+ // While p is below rect...
+ while (p.y() > q->viewport()->rect().bottom()) {
+ if (!vbar->isVisible()) return false;
+ TestWidgetsLog() << "down" << "\nrect:" << rect() << "p:" << p;
+ QtUiTest::mouseClick(down);
+ waitForSignal(vbar, SIGNAL(valueChanged(int)));
+ p = visualRect(item).center();
+ }
+ // While p is left of rect...
+ while (p.x() < q->viewport()->rect().left()) {
+ if (!hbar->isVisible()) return false;
+ TestWidgetsLog() << "left" << "\nrect:" << rect() << "p:" << p;
+ QtUiTest::mouseClick(left);
+ waitForSignal(hbar, SIGNAL(valueChanged(int)));
+ p = visualRect(item).center();
+ }
+ // While p is right of rect...
+ while (p.x() > q->viewport()->rect().right()) {
+ if (!hbar->isVisible()) return false;
+ TestWidgetsLog() << "right" << "\nrect:" << rect() << "p:" << p;
+ QtUiTest::mouseClick(right);
+ waitForSignal(hbar, SIGNAL(valueChanged(int)));
+ p = visualRect(item).center();
+ }
+
+ if (!q->viewport()->rect().contains(p)) {
+ TestWidgetsLog() << "failed" << "\nrect:" << q->viewport()->rect() << "p:" << p;
+ return false;
+ }
+
+ return true;
+}
+
+bool TestTextEdit::select(QString const &item)
+{
+ QTextFragment fragment = fragmentForItem(item);
+ if (!fragment.isValid()) return false;
+ ensureVisible(fragment);
+ QPoint pos = visualRect(item).center();
+ QtUiTest::mouseClick(q->viewport()->mapToGlobal(pos), Qt::LeftButton);
+ return true;
+
+}
+
+bool TestTextEdit::canWrap(QObject *o)
+{ return qobject_cast<QTextEdit*>(o); }
+
+int TestTextEdit::cursorPosition() const
+{
+ return q->textCursor().position();
+}
+
+void TestTextEdit::onTextChanged()
+{
+ if (!hasFocus() || !isVisible()) return;
+ if (q->toPlainText() == lastEntered) return;
+ lastEntered = q->toPlainText();
+ emit entered(lastEntered);
+}
+
+void TestTextEdit::onCursorPositionChanged()
+{
+ int prev = lastCursorPosition;
+ lastCursorPosition = cursorPosition();
+ emit cursorPositionChanged(prev, lastCursorPosition);
+}
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testtextedit.h b/old/plugins/qtuitest_widgets/qtwidgets/testtextedit.h
new file mode 100644
index 0000000..0795baf
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testtextedit.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTTEXTEDIT_H
+#define TESTTEXTEDIT_H
+
+#include <testwidget.h>
+
+class QTextEdit;
+class QTextFragment;
+
+namespace QtUiTest {
+
+class TestTextEdit : public TestWidget,
+ public QtUiTest::TextWidget,
+ public QtUiTest::ListWidget,
+ public QtUiTest::SelectWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::TextWidget
+ QtUiTest::ListWidget
+ QtUiTest::SelectWidget)
+
+public:
+ TestTextEdit(QObject*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+
+ virtual bool canEnter(QVariant const&) const;
+ virtual bool enter(QVariant const&,bool);
+
+ virtual bool canSelect(QString const&) const;
+ virtual bool select(QString const&);
+
+ static bool canWrap(QObject*);
+
+ int cursorPosition() const;
+
+signals:
+ void cursorPositionChanged(int,int);
+ void textChanged();
+ void entered(QVariant const&);
+
+protected:
+ QTextFragment fragmentForItem(QString const&) const;
+ virtual QRect visualRect(QTextFragment const&) const;
+ virtual bool ensureVisible(QTextFragment const&);
+
+private slots:
+ void onTextChanged();
+ void onCursorPositionChanged();
+
+private:
+ QString lastEntered;
+ int lastCursorPosition;
+ bool committed;
+ QTextEdit *q;
+};
+
+}
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testtimeedit.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testtimeedit.cpp
new file mode 100644
index 0000000..99fb9b4
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testtimeedit.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testtimeedit.h"
+#include "testwidgetslog.h"
+
+#include <QTimeEdit>
+
+namespace QtUiTest {
+
+TestTimeEdit::TestTimeEdit(QObject* _q)
+ : TestDateTimeEdit(_q), q(qobject_cast<QTimeEdit*>(_q))
+{
+ TestWidgetsLog();
+
+ disconnect(q, SIGNAL(dateTimeChanged(QDateTime)), this, 0);
+ connect(q, SIGNAL(dateTimeChanged(QDateTime)),
+ this, SLOT(onDateTimeChanged(QDateTime)));
+}
+
+void TestTimeEdit::onDateTimeChanged(QDateTime const& dt)
+{
+ emit entered(dt.time());
+}
+
+QString TestTimeEdit::text() const
+{
+ TestWidgetsLog();
+ return q->time().toString(q->displayFormat());
+}
+
+QVariant TestTimeEdit::value() const
+{
+ return q->time();
+}
+
+bool TestTimeEdit::canWrap(QObject *o)
+{ return qobject_cast<QTimeEdit*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testtimeedit.h b/old/plugins/qtuitest_widgets/qtwidgets/testtimeedit.h
new file mode 100644
index 0000000..d110958
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testtimeedit.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTTIMEEDIT_H
+#define TESTTIMEEDIT_H
+
+#include "testdatetimeedit.h"
+
+class QTimeEdit;
+
+namespace QtUiTest {
+
+class TestTimeEdit : public TestDateTimeEdit
+{
+ Q_OBJECT
+public:
+ TestTimeEdit(QObject*);
+
+ virtual QString text() const;
+ virtual QVariant value() const;
+
+ static bool canWrap(QObject*);
+
+private slots:
+ void onDateTimeChanged(QDateTime const&);
+
+private:
+ QTimeEdit *q;
+};
+
+}
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testtoolbar.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testtoolbar.cpp
new file mode 100644
index 0000000..390ad00
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testtoolbar.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testtoolbar.h"
+#include "testwidgetslog.h"
+
+#include <QToolBar>
+#include <QAction>
+
+namespace QtUiTest {
+
+TestToolBar::TestToolBar(QObject *_q)
+ : TestWidget(_q), q(qobject_cast<QToolBar*>(_q)), lastAction(0)
+{
+ // For accurate ordering of events recording, these connections
+ // must come before all others.
+// QtUiTest::connectFirst(q, SIGNAL(hovered(QAction*)),
+// this, SLOT(on_hovered(QAction*)));
+}
+
+QStringList TestToolBar::list() const
+{
+ QStringList ret;
+
+ /* Iterate through every action */
+ foreach( QAction *a, q->actions() ) {
+ if (!a->isVisible())
+ continue;
+ QString t = a->text();
+ t.replace("/","\\/");
+ if (!t.isEmpty()) ret << t;
+ }
+
+ return ret;
+}
+
+QRect TestToolBar::visualRect(QString const &item) const
+{
+//FIXME: Implement me
+ Q_UNUSED(item);
+ QRect ret;
+ return ret;
+}
+
+bool TestToolBar::ensureVisible(QString const&)
+{ return false; }
+
+QString TestToolBar::labelText() const
+{
+ return q->windowTitle();
+}
+
+QObject* TestToolBar::buddy() const
+{
+ return q;
+}
+
+bool TestToolBar::canSelect(QString const &item) const
+{
+ return list().contains(item);
+}
+
+bool TestToolBar::select(QString const &item)
+{
+//FIXME: Implement me
+ Q_UNUSED(item);
+ return false;
+}
+
+bool TestToolBar::hasFocus() const
+{
+ return q->hasFocus();
+}
+
+bool TestToolBar::canWrap(QObject *o)
+{ return qobject_cast<QToolBar*>(o); }
+
+}
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testtoolbar.h b/old/plugins/qtuitest_widgets/qtwidgets/testtoolbar.h
new file mode 100644
index 0000000..817b36e
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testtoolbar.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTTOOLBAR_H
+#define TESTTOOLBAR_H
+
+#include <testwidget.h>
+
+#include <QtGlobal>
+
+class QToolBar;
+class QAction;
+
+namespace QtUiTest {
+
+class TestToolBar : public TestWidget,
+ public QtUiTest::ListWidget, public QtUiTest::LabelWidget,
+ public QtUiTest::SelectWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::ListWidget
+ QtUiTest::LabelWidget
+ QtUiTest::SelectWidget)
+
+public:
+ TestToolBar(QObject*);
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+ virtual bool ensureVisible(QString const&);
+
+ virtual QString labelText() const;
+ virtual QObject* buddy() const;
+
+ virtual bool canSelect(const QString&) const;
+ virtual bool select(const QString&);
+
+ virtual bool hasFocus() const;
+
+ static bool canWrap(QObject*);
+
+signals:
+ void stateChanged(int);
+ void selected(const QString&);
+
+private:
+ QToolBar *q;
+ QAction *lastAction;
+};
+
+}
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testtreeview.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testtreeview.cpp
new file mode 100644
index 0000000..9fc41b2
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testtreeview.cpp
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testtreeview.h"
+#include "testwidgetslog.h"
+
+#include <QTreeView>
+
+#include <qtuitestnamespace.h>
+
+namespace QtUiTest {
+
+TestTreeView::TestTreeView(QObject *_q)
+ : TestAbstractItemView(_q), q(static_cast<QTreeView*>(_q))
+{
+}
+
+QString TestTreeView::selectedText() const
+{
+ TestWidgetsLog();
+
+ if (q->allColumnsShowFocus()) {
+ return selectedValue().toStringList().join(",");
+ }
+
+ return TestAbstractItemView::selectedText();
+}
+
+QVariant TestTreeView::selectedValue() const
+{
+ TestWidgetsLog();
+
+ if (q->allColumnsShowFocus()) {
+ QStringList columnText;
+ QModelIndex selectedIndex = q->currentIndex();
+
+ for (int i = 0, max_i = q->model()->columnCount(selectedIndex.parent()); i < max_i; ++i) {
+ if (q->isColumnHidden(i)) continue;
+ QModelIndex sibling(selectedIndex.sibling(selectedIndex.row(), i));
+ columnText << TestWidget::printable(sibling.data().toString());
+ }
+
+ return columnText;
+ }
+
+ return TestAbstractItemView::selectedText();
+}
+
+QStringList TestTreeView::list() const
+{
+ class QModelListGetter : public QModelViewIterator<QTreeView>
+ {
+ public:
+ QModelListGetter(QTreeView *view)
+ : QModelViewIterator<QTreeView>(view) {};
+
+ QStringList getList() {
+ list.clear();
+ iterate(view()->rootIndex(), view()->itemsExpandable());
+ return list;
+ }
+ protected:
+ virtual void visit(QModelIndex const &index)
+ {
+ if (index == view()->rootIndex() && !view()->rootIsDecorated()) {
+ return;
+ } else if (view()->isColumnHidden(index.column())) {
+ return;
+ }
+ list << itemForIndex(index);
+ }
+
+ virtual bool isRowHidden(int row, const QModelIndex& index)
+ {
+ return view()->isRowHidden(row, index);
+ }
+
+ virtual QString itemForIndex(QModelIndex const& index) const
+ {
+ QString ret = TestWidget::printable(index.data().toString());
+ ret.replace("/","\\\\/");
+
+ QModelIndex rootIndex = view()->rootIndex();
+ if (index.parent() != rootIndex) {
+ ret = itemForIndex(index.parent()) + "/" + ret;
+ }
+ return ret;
+ }
+ QStringList list;
+ };
+
+ return QModelListGetter(q).getList();
+}
+
+QModelIndex TestTreeView::indexForItem(QString const &item) const
+{
+ return indexForItem(q->rootIndex(), item);
+}
+
+QModelIndex TestTreeView::indexForItem(QModelIndex const &index, QString const &item) const
+{
+ QModelIndex ret;
+ static QRegExp slashRe("[^\\\\]/");
+
+ int ind;
+ if (0 != (ind = item.indexOf(slashRe)+1)) {
+ return indexForItem(indexForItem(index, item.left(ind)), item.mid(ind+1));
+ }
+
+ QString itemUnescaped(item);
+ itemUnescaped.replace("\\/", "/");
+
+ QAbstractItemModel *model = q->model();
+ int count = 0;
+
+ for (int i = 0, max_i = model->rowCount(index); i < max_i && count <= QTUITEST_MAX_LIST; ++i) {
+ if (q->isRowHidden(i, index)) continue;
+ for (int j = 0, max_j = model->columnCount(index); j < max_j && count <= QTUITEST_MAX_LIST; ++j) {
+ if (q->isColumnHidden(j)) continue;
+ if (model->hasIndex(i, j, index) && model->data(model->index(i, j, index)).toString() == itemUnescaped) {
+ if (ret.isValid()) {
+ qWarning("QtUitest: more than one item matches '%s' in item view", qPrintable(item));
+ return ret;
+ } else {
+ ret = model->index(i, j, index);
+ }
+ }
+ }
+ }
+
+ return ret;
+}
+
+bool TestTreeView::ensureVisible(QModelIndex const &index)
+{
+ if (!index.isValid()) return false;
+
+ if (q->itemsExpandable() && !q->isExpanded(index.parent())) {
+ ensureVisible(index.parent());
+ //FIXME: Should expand using mouse/key clicks
+ q->setExpanded(index.parent(), true);
+ }
+
+ return TestAbstractItemView::ensureVisible(index);
+}
+
+bool TestTreeView::canSelect(QString const &item) const
+{
+ return indexForItem(item).isValid();
+}
+
+bool TestTreeView::canWrap(QObject* o)
+{ return qobject_cast<QTreeView*>(o); }
+
+}
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testtreeview.h b/old/plugins/qtuitest_widgets/qtwidgets/testtreeview.h
new file mode 100644
index 0000000..fd6632a
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testtreeview.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTTREEVIEW_H
+#define TESTTREEVIEW_H
+
+#include "testabstractitemview.h"
+
+class QTreeView;
+
+namespace QtUiTest {
+
+class TestTreeView : public TestAbstractItemView
+{
+ Q_OBJECT
+
+public:
+ TestTreeView(QObject*);
+
+ virtual QString selectedText() const;
+ virtual QVariant selectedValue() const;
+ virtual QStringList list() const;
+ virtual bool canSelect(QString const&) const;
+ static bool canWrap(QObject*);
+
+protected:
+ virtual QModelIndex indexForItem(QString const&) const;
+ QModelIndex indexForItem(QModelIndex const&, QString const&) const;
+ virtual bool ensureVisible(QModelIndex const&);
+
+private:
+ QTreeView *q;
+};
+
+}
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testtreewidget.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testtreewidget.cpp
new file mode 100644
index 0000000..e011b0a
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testtreewidget.cpp
@@ -0,0 +1,212 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testtreewidget.h"
+#include "testwidgetslog.h"
+
+#include <QTreeWidget>
+
+#include <qtuitestnamespace.h>
+
+namespace QtUiTest {
+
+TestTreeWidget::TestTreeWidget(QObject *_q)
+ : TestTreeView(_q), q(static_cast<QTreeWidget*>(_q))
+{
+}
+
+QStringList TestTreeWidget::list() const
+{
+ QStringList ret;
+ QTreeWidgetItemIterator it(q);
+ while (*it) {
+ for (int i=0; i<q->columnCount(); ++i) {
+ QtUiTest::ListWidget *lw = qtuitest_cast<QtUiTest::ListWidget*>(q->itemWidget(*it, i));
+ if (lw) {
+ QStringList widgetList = lw->list();
+ QString parent = itemName((*it)->parent(), i);
+ foreach (QString s, widgetList) {
+ ret << parent + "/" + s;
+ }
+ } else {
+ ret << itemName((*it), i);
+ }
+ }
+ ++it;
+ }
+
+ return ret;
+}
+
+QString TestTreeWidget::itemName(QTreeWidgetItem *item, int column) const
+{
+ QString ret;
+ if (!item) return ret;
+ ret = item->text(column);
+ if (item->parent() && item->parent() != q->invisibleRootItem()) {
+ return itemName(item->parent(), 0) + "/" + ret;
+ }
+
+ return ret;
+}
+
+QTreeWidgetItem *TestTreeWidget::itemLookup(QTreeWidgetItem *parent, QString const &name) const
+{
+ QTreeWidgetItem *ret = 0;
+
+ for (int i=0, childCount = parent->childCount(); i < childCount; ++i) {
+ QTreeWidgetItem *item = parent->child(i);
+ for (int j=0, colCount = q->columnCount(); j < colCount; ++j) {
+ if (item->text(j) == name) {
+ return item;
+ }
+ }
+ }
+
+ return ret;
+}
+
+QWidget *TestTreeWidget::itemWidgetLookup(QString const &name, QTreeWidgetItem *parent, QString &remainder) const
+{
+ static QRegExp slashRe("[^\\\\]/");
+ int ind;
+ QString top = name;
+ if ((ind = name.indexOf(slashRe)+1)) {
+ top = name.left(ind);
+ }
+
+ QTreeWidgetItem *widgetItem = itemLookup(parent, top);
+ if (widgetItem == 0) {
+ remainder = name;
+ for (int i=0, colCount = q->columnCount(); i < colCount; ++i) {
+ QWidget *iw = q->itemWidget(parent->child(i), 0);
+ if (iw) {
+ QtUiTest::ListWidget *lw = qtuitest_cast<QtUiTest::ListWidget*>(iw);
+ QStringList widgetList = lw->list();
+ if (widgetList.contains(remainder)) {
+ return iw;
+ }
+ }
+ }
+ return 0;
+ } else {
+ if (!widgetItem->isExpanded()) {
+ widgetItem->setExpanded(true);
+ }
+ return itemWidgetLookup(name.mid(ind+1), widgetItem, remainder);
+ }
+}
+
+bool TestTreeWidget::select(QString const &item)
+{
+ if (!canSelect(item)) {
+ TestWidgetsLog() << "can't select" << item;
+ return false;
+ }
+
+ QModelIndex index = indexForItem(item);
+ if (index.isValid()) {
+ return TestAbstractItemView::select(index);
+ }
+
+ QString remainder;
+ QWidget *w = itemWidgetLookup(item, q->invisibleRootItem(), remainder);
+ QtUiTest::Widget *qw = qtuitest_cast<QtUiTest::Widget*>(w);
+ QtUiTest::ListWidget *lw = qtuitest_cast<QtUiTest::ListWidget*>(w);
+ qw->ensureVisibleRegion(lw->visualRect(remainder));
+ QtUiTest::SelectWidget *sw = qtuitest_cast<QtUiTest::SelectWidget*>(w);
+ if (sw) {
+ return sw->select(remainder);
+ }
+
+ return false;
+}
+
+bool TestTreeWidget::ensureVisible(QString const &item)
+{
+ if (!canSelect(item)) {
+ TestWidgetsLog() << "can't select" << item;
+ return false;
+ }
+
+ QModelIndex index = indexForItem(item);
+ if (index.isValid()) {
+ return TestAbstractItemView::ensureVisible(index);
+ }
+
+ QString remainder;
+ QWidget *w = itemWidgetLookup(item, q->invisibleRootItem(), remainder);
+ QtUiTest::Widget *qw = qtuitest_cast<QtUiTest::Widget*>(w);
+ QtUiTest::ListWidget *lw = qtuitest_cast<QtUiTest::ListWidget*>(w);
+ return qw->ensureVisibleRegion(lw->visualRect(remainder));
+}
+
+QRect TestTreeWidget::visualRect(QString const &item) const
+{
+ QRect ret;
+
+ QModelIndex index = indexForItem(item);
+
+ if (index.isValid()) {
+ return q->visualRect(index);
+ } else {
+ QString remainder;
+ QWidget *w = itemWidgetLookup(item, q->invisibleRootItem(), remainder);
+ QtUiTest::ListWidget *lw = qtuitest_cast<QtUiTest::ListWidget*>(w);
+ if (lw) {
+ QRect rect = lw->visualRect(remainder);
+ rect.moveTopLeft( q->mapFromGlobal( w->mapToGlobal( rect.topLeft() ) ) );
+ return rect;
+ }
+ }
+
+ return ret;
+}
+
+bool TestTreeWidget::canSelect(QString const &item) const
+{
+ return list().contains(item);
+}
+
+bool TestTreeWidget::canWrap(QObject* o)
+{ return qobject_cast<QTreeWidget*>(o); }
+
+}
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testtreewidget.h b/old/plugins/qtuitest_widgets/qtwidgets/testtreewidget.h
new file mode 100644
index 0000000..292362c
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testtreewidget.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTTREEWIDGET_H
+#define TESTTREEWIDGET_H
+
+#include "testtreeview.h"
+
+class QTreeWidget;
+class QTreeWidgetItem;
+
+namespace QtUiTest {
+
+class TestTreeWidget : public TestTreeView
+{
+ Q_OBJECT
+
+public:
+ TestTreeWidget(QObject*);
+
+ virtual QRect visualRect(QString const&) const;
+ virtual QStringList list() const;
+ virtual bool canSelect(QString const&) const;
+ virtual bool select(QString const&);
+ virtual bool ensureVisible(QString const&);
+ static bool canWrap(QObject*);
+
+protected:
+ QString itemName(QTreeWidgetItem *item, int column) const;
+ QTreeWidgetItem *itemLookup(QTreeWidgetItem *parent, QString const &name) const;
+ QWidget *itemWidgetLookup(QString const &name, QTreeWidgetItem *parent, QString &remainder) const;
+
+private:
+ QTreeWidget *q;
+};
+
+}
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testwebview.cpp b/old/plugins/qtuitest_widgets/qtwidgets/testwebview.cpp
new file mode 100644
index 0000000..101287c
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testwebview.cpp
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testwebview.h"
+#include "testwidgetslog.h"
+
+#include <QWebView>
+#include <QWebPage>
+#include <QWebFrame>
+#include <QWebElementCollection>
+
+namespace QtUiTest {
+
+TestWebView::TestWebView(QObject *_q)
+ : TestWidget(_q), m_progress(0.0), q(qobject_cast<QWebView*>(_q))
+{
+ connect(q->page(), SIGNAL(loadProgress(int)), this, SLOT(on_progress(int)));
+}
+
+QString TestWebView::text() const
+{
+ QWebPage *page = q->page();
+ if (page && page->mainFrame()) {
+ return page->mainFrame()->toPlainText();
+ }
+ return QString();
+}
+
+QString TestWebView::selectedText() const
+{
+ return q->selectedText();
+}
+
+QStringList TestWebView::list() const
+{
+ QStringList ret;
+
+ QWebPage *page = q->page();
+ if (page && page->mainFrame()) {
+ QWebElementCollection links = page->mainFrame()->findAllElements("a[href]");
+ foreach (QWebElement el, links) {
+ QString str = TestWidget::printable(el.toPlainText());
+ if (!str.isEmpty()) ret << str;
+ }
+ }
+ return ret;
+}
+
+QWebElement TestWebView::elementForItem(QString const &item) const
+{
+ QWebElement ret;
+ QWebPage *page = q->page();
+ if (page && page->mainFrame()) {
+ QWebElementCollection links = page->mainFrame()->findAllElements("a[href]");
+ foreach (QWebElement el, links) {
+ if (TestWidget::printable(el.toPlainText()) == item) {
+ ret = el;
+ break;
+ }
+ }
+ }
+ return ret;
+}
+
+QRect TestWebView::visualRect(QString const &item) const
+{
+ return visualRect(elementForItem(item));
+}
+
+QRect TestWebView::visualRect(QWebElement const &el) const
+{
+ QRect ret;
+ if (!el.isNull()) {
+ ret = el.geometry();
+ ret.translate(el.webFrame()->geometry().topLeft()-el.webFrame()->scrollPosition());
+ }
+ return ret;
+}
+
+bool TestWebView::canSelect(QString const &item) const
+{ return list().contains(item); }
+
+bool TestWebView::select(QString const &item)
+{
+ QWebElement el(elementForItem(item));
+ if (el.isNull()) return false;
+
+ QRect rect = visualRect(el);
+ QPoint pos = rect.center();
+ QRect geometry = q->visibleRegion().boundingRect(); //q->geometry();
+ QWebFrame *frame = el.webFrame();
+ QRect horizScroll = frame->scrollBarGeometry(Qt::Horizontal);
+ QRect vertScroll = frame->scrollBarGeometry(Qt::Vertical);
+ if (!horizScroll.isEmpty()) {
+ geometry.setBottom(horizScroll.top()-1);
+ }
+ if (!vertScroll.isEmpty()) {
+ geometry.setRight(vertScroll.left()-1);
+ }
+
+ if (!geometry.contains(pos, true)) {
+ //TODO: Is there a way to get the scrollbar up/down buttons? The scrollbar is
+ // not a QScrollBar. For now, use the API to scroll.
+
+ // Scroll vertically
+ if (geometry.bottom() < rect.bottom()) {
+ frame->scroll(0, rect.bottom() - geometry.bottom() + geometry.height()/2);
+ } else if (geometry.top() > rect.top()) {
+ frame->scroll(0, rect.top() - geometry.top() - geometry.height()/2);
+ }
+
+ // Scroll horizontally
+ if (geometry.right() < pos.x()) {
+ frame->scroll(rect.right() - geometry.right(), 0);
+ } else if (geometry.left() > pos.x()) {
+ frame->scroll(rect.left() - geometry.left(), 0);
+ }
+
+ pos = visualRect(el).center();
+ }
+
+ QtUiTest::mouseClick(q->mapToGlobal(pos), Qt::LeftButton);
+ waitForSignal(q, SIGNAL(linkClicked(QUrl)));
+ return true;
+}
+
+void TestWebView::on_progress(int p)
+{
+ if (m_progress == p/100.0)
+ return;
+ m_progress = p/100.0;
+}
+
+QVariant TestWebView::getProperty(const QString& name) const
+{
+ QVariant ret;
+
+ if (name.toUpper() == "PROGRESS") {
+ ret = m_progress;
+ } else {
+ ret = q->property(name.toLatin1());
+ }
+
+ return ret;
+}
+
+bool TestWebView::canWrap(QObject *o)
+{ return qobject_cast<QWebView*>(o); }
+
+} \ No newline at end of file
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testwebview.h b/old/plugins/qtuitest_widgets/qtwidgets/testwebview.h
new file mode 100644
index 0000000..78cfec0
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testwebview.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTWEBVIEW_H
+#define TESTWEBVIEW_H
+
+#include <testwidget.h>
+
+class QWebView;
+class QWebElement;
+
+namespace QtUiTest {
+
+class TestWebView : public TestWidget,
+ public QtUiTest::TextWidget,
+ public QtUiTest::ListWidget,
+ public QtUiTest::SelectWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::TextWidget
+ QtUiTest::ListWidget
+ QtUiTest::SelectWidget)
+
+public:
+ TestWebView(QObject*);
+
+ virtual QString text() const;
+ virtual QString selectedText() const;
+
+ virtual QStringList list() const;
+ virtual QRect visualRect(QString const&) const;
+
+ virtual bool canSelect(QString const&) const;
+ virtual bool select(QString const&);
+
+ virtual QVariant getProperty(const QString&) const;
+
+ static bool canWrap(QObject*);
+
+protected:
+ QWebElement elementForItem(QString const&) const;
+ virtual QRect visualRect(QWebElement const&) const;
+
+private slots:
+ void on_progress(int);
+
+private:
+ qreal m_progress;
+ QWebView *q;
+};
+
+}
+
+#endif
+
diff --git a/old/plugins/qtuitest_widgets/qtwidgets/testwidgetslog.h b/old/plugins/qtuitest_widgets/qtwidgets/testwidgetslog.h
new file mode 100644
index 0000000..01d2efe
--- /dev/null
+++ b/old/plugins/qtuitest_widgets/qtwidgets/testwidgetslog.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTWIDGETSLOG_H
+#define TESTWIDGETSLOG_H
+
+#include <QApplication>
+#include <QStringList>
+
+#include <QDebug>
+#define qLog(A) if (1); else qDebug() << #A
+
+/*
+ This header provides a slight convenience layer on top of qLog.
+
+ By using the TestWidgetsLog macro in the same way qLog would normally be used,
+ a log message will be output which automatically includes the name of the current
+ function.
+*/
+
+namespace TestWidgetsLogImpl
+{
+ /*
+ Returns a log header to be output at the beginning of each TestWidgetsLog.
+ */
+ inline QByteArray header(char const*,int,char const* function)
+ {
+ QString ret = qApp->applicationName();
+
+ // Extract just the name of the function (discard return type and arguments)
+ QString id;
+ QStringList l1 = QString(function).split(" ");
+ QStringList l2 = l1.filter("(");
+ if (l2.count()) id = l2.at(0);
+ else id = l1.at(0);
+ if (id.contains("(")) id = id.left(id.indexOf("("));
+
+ ret += " " + id;
+
+ return ret.toLocal8Bit();
+ }
+};
+
+#define TestWidgetsLog() qLog(QtUitestWidgets) << TestWidgetsLogImpl::header(__FILE__,__LINE__,Q_FUNC_INFO).constData()
+
+#endif
+
diff --git a/old/plugins/styles/qtuitest/qtuitest.pro b/old/plugins/styles/qtuitest/qtuitest.pro
new file mode 100644
index 0000000..b9f94bc
--- /dev/null
+++ b/old/plugins/styles/qtuitest/qtuitest.pro
@@ -0,0 +1,42 @@
+TEMPLATE=lib
+CONFIG+=plugin
+SOURCES+=style.cpp
+HEADERS+=style.h
+TARGET=qtuiteststyle
+TARGET=$$qtLibraryTarget($$TARGET)
+QT+=network
+INCLUDEPATH+=$$SRCROOT/libqtslave
+INCLUDEPATH+=$$SRCROOT
+DEPENDPATH+=$$SRCROOT
+
+include($$SRCROOT/libqtuitest/libqtuitest.pri)
+
+target.path=$$[QT_INSTALL_PLUGINS]/styles
+unix:!symbian {
+ MOC_DIR=$$OUT_PWD/.moc
+ OBJECTS_DIR=$$OUT_PWD/.obj
+ INSTALLS+=target
+ !mac {
+ LIBS+=-L$$BUILDROOT/lib -lqtslave
+ }
+}
+
+symbian {
+ TARGET.EPOCALLOWDLLDATA=1
+ TARGET.CAPABILITY += AllFiles ReadDeviceData ReadUserData SwEvent WriteUserData NetworkServices
+ MOC_DIR=$$OUT_PWD/moc
+ OBJECTS_DIR=$$OUT_PWD/obj
+ LIBS+= -lqtslave.lib -lws32 -leuser -lcone
+}
+
+mac {
+ CONFIG(debug,debug|release): LIBS += -L$$BUILDROOT/lib -lqtslave_debug
+ CONFIG(release,debug|release): LIBS += -L$$BUILDROOT/lib -lqtslave
+}
+
+win32 {
+ CONFIG(debug,debug|release): LIBS+= -L$$BUILDROOT/libqtslave/debug -lqtslaved
+ CONFIG(release,debug|release):LIBS+= -L$$BUILDROOT/libqtslave/release -lqtslave
+}
+
+INSTALLS += target
diff --git a/old/plugins/styles/qtuitest/style.cpp b/old/plugins/styles/qtuitest/style.cpp
new file mode 100644
index 0000000..1b8d75f
--- /dev/null
+++ b/old/plugins/styles/qtuitest/style.cpp
@@ -0,0 +1,241 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QWidget>
+#include <QDebug>
+#include <qtestslave.h>
+#include "style.h"
+#include <QCoreApplication>
+#ifdef Q_OS_SYMBIAN
+# include <QS60Style>
+# include <sys/socket.h>
+# include <net/if.h>
+#elif defined Q_OS_MAC
+# include <QMacStyle>
+#endif
+
+#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
+extern Q_GUI_EXPORT bool qt_use_native_dialogs;
+#endif
+
+struct TestSlaveServer : public QTcpServer
+{
+ TestSlaveServer()
+ : QTcpServer(), showDebug(false), started(false)
+ {
+ }
+
+ ~TestSlaveServer()
+ {
+ close();
+ }
+
+ void incomingConnection(int sd)
+ { slave.setSocket(sd); }
+
+ void startService();
+ void stopService();
+
+
+ QTestSlave slave;
+ bool showDebug;
+ bool started;
+};
+
+Q_GLOBAL_STATIC(TestSlaveServer, testSlaveServer);
+
+
+void TestSlaveServer::startService()
+{
+ short aut_port = DEFAULT_AUT_PORT;
+ bool parseOk;
+ bool setAutPort = false;
+ QStringList args = QCoreApplication::arguments();
+ QByteArray autPortEnvBa = qgetenv("QTUITEST_PORT");
+ QString autPortEnv = QString(autPortEnvBa);
+ QByteArray debugEnvBa = qgetenv("QTUITEST_DEBUG");
+ QString debugEnv = QString(debugEnvBa);
+
+
+#ifndef QTUITEST_DEBUG
+ int debugValue = debugEnv.toInt(&parseOk);
+ if (parseOk && (debugValue > 0))
+ showDebug = true;
+#else
+ showDebug = true;
+#endif
+
+ if (showDebug)
+ qWarning("QtUiTest: Start service");
+
+ for (int index = 0; index < args.count(); index++){
+ if (args[index].endsWith("qtuitestrunner")){
+ if (showDebug)
+ qWarning() << "QtUiTest: Not starting TestSlaveServer::startService for qtuitestrunner";
+ return;
+ }
+ }
+
+ if (started){
+ if (showDebug)
+ qWarning() << "QtUiTest: Closing TestSlaveServer connection";
+
+ close();
+ }
+ if (!autPortEnv.isEmpty()){
+ aut_port = autPortEnv.toUShort(&parseOk);
+ if (!parseOk){
+ aut_port = DEFAULT_AUT_PORT;
+ qWarning() << "QtUiTest: Unable to parse QTUITEST_PORT" << autPortEnv;
+ }else{
+ setAutPort = true;
+ if (showDebug)
+ qWarning() << "QtUiTest: Set port via QTUITEST_PORT to" << aut_port;
+ }
+ }
+ for (int index = 0; index < args.count(); index++){
+ if ((args[index] == QLatin1String("-autport")) && (index + 1 < args.count())){
+ aut_port = args[index + 1].toUShort(&parseOk);
+ if (!parseOk){
+ aut_port = DEFAULT_AUT_PORT;
+ qWarning() << "QtUiTest: Unable to parse -autport" << args[index];
+ }else{
+ setAutPort = true;
+ if (showDebug)
+ qWarning() << "QtUiTest: Set port via -autport to" << aut_port;
+ }
+ }
+ }
+
+ if (!listen(QHostAddress::Any, aut_port)) {
+ qWarning() << "QtUiTest: couldn't listen for connections on " << aut_port << " :"
+ << errorString() << " started :" << started;
+ started = false;
+ close();
+ }else {
+ started = true;
+ if (showDebug)
+ qWarning() << "QtUiTest: listening for connections on" << aut_port;
+ }
+}
+
+void TestSlaveServer::stopService()
+{
+ if (showDebug)
+ qWarning("QtUiTest : Stoping service");
+
+ close();
+ started = false;
+}
+
+QtUiTestStylePlugin::~QtUiTestStylePlugin()
+{
+ testSlaveServer()->stopService();
+}
+
+void QtUiTestStylePlugin::initSlave()
+{
+#ifdef Q_OS_SYMBIAN
+ struct ifreq ifReq;
+ strcpy( ifReq.ifr_name, "qtuitest");
+ int err = setdefaultif( &ifReq );
+#endif
+
+ testSlaveServer()->startService();
+
+#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
+ // Use QFileDialog instead of native OS file dialog
+ qt_use_native_dialogs = false;
+#endif
+
+#ifdef Q_OS_MAC
+ QTimer::singleShot(200, this, SLOT(raiseWindow()));
+#endif
+}
+
+QStringList QtUiTestStylePlugin::keys() const
+{
+ return QStringList() << "QtUiTest_NoStyle" << "QtUiTest";
+}
+
+QStyle *QtUiTestStylePlugin::create(const QString &key)
+{
+ static bool initialised = false;
+
+ if (key.toLower() == "qtuitest_nostyle") {
+ // QApplication::style() has failed to initialise app style
+ // so is trying all styles. In this case we DO NOT want the
+ // QtUiTest style to be initialised unintentionally...
+ initialised = true;
+ }
+ if (key.toLower() == "qtuitest" && !initialised) {
+ initSlave();
+ initialised = true;
+#ifdef Q_OS_SYMBIAN
+ return new QS60Style();
+#elif defined Q_WS_MAC
+ return new QMacStyle();
+#else
+ return qApp->style();
+#endif
+ }
+ return 0;
+}
+
+void QtUiTestStylePlugin::raiseWindow()
+{
+ QWidget *aw = qApp->activeWindow();
+ if (!aw) {
+ bool found = false;
+ foreach (QWidget *w, qApp->topLevelWidgets()) {
+ if (w->isVisible()) {
+ found = true;
+ w->raise();
+ break;
+ }
+ }
+ if (!found) qWarning() << "no visible window";
+ }
+}
+
+#include <qplugin.h>
+Q_EXPORT_PLUGIN2(QtUiTestStylePlugin, QtUiTestStylePlugin)
diff --git a/old/plugins/styles/qtuitest/style.h b/old/plugins/styles/qtuitest/style.h
new file mode 100644
index 0000000..29e0ff1
--- /dev/null
+++ b/old/plugins/styles/qtuitest/style.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of QtUiTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtGui>
+#include "qtuitest_config.h"
+
+class QtUiTestStylePlugin : public QStylePlugin
+{
+ Q_OBJECT
+
+public:
+ QtUiTestStylePlugin() {};
+ virtual ~QtUiTestStylePlugin();
+
+ QStringList keys() const;
+ QStyle *create(const QString &key);
+
+public slots:
+ void raiseWindow();
+
+protected:
+ void initSlave();
+};
diff --git a/old/plugins/styles/styles.pro b/old/plugins/styles/styles.pro
new file mode 100644
index 0000000..3b4bbb8
--- /dev/null
+++ b/old/plugins/styles/styles.pro
@@ -0,0 +1,3 @@
+TEMPLATE=subdirs
+SUBDIRS=\
+ qtuitest