summaryrefslogtreecommitdiffstats
path: root/old/tests
diff options
context:
space:
mode:
Diffstat (limited to 'old/tests')
-rw-r--r--old/tests/qtuitest/qtuitest.pro33
-rw-r--r--old/tests/qtuitest/sys_assistant/sys_assistant.pro9
-rw-r--r--old/tests/qtuitest/sys_assistant/sys_assistant.qtt231
-rw-r--r--old/tests/qtuitest/sys_designer/sys_designer.pro9
-rw-r--r--old/tests/qtuitest/sys_designer/sys_designer.qtt419
-rw-r--r--old/tests/qtuitest/sys_graphicsView/sys_graphicsView.pro11
-rw-r--r--old/tests/qtuitest/sys_graphicsView/sys_graphicsView.qtt55
-rw-r--r--old/tests/qtuitest/sys_input/sys_input.pro11
-rw-r--r--old/tests/qtuitest/sys_input/sys_input.qtt363
-rw-r--r--old/tests/qtuitest/sys_input/testdata/enter_invisible/failure_.txt48
-rw-r--r--old/tests/qtuitest/sys_input/testdata/select_groupbox_subitem/failure_.txt46
-rw-r--r--old/tests/qtuitest/sys_linguist/sys_linguist.pro10
-rw-r--r--old/tests/qtuitest/sys_linguist/sys_linguist.qtt152
-rw-r--r--old/tests/qtuitest/sys_linguist/testdata/test_fr.ts158
-rw-r--r--old/tests/qtuitest/testapps/fileDialogSaveApp/fileDialogSaveApp.pro23
-rw-r--r--old/tests/qtuitest/testapps/fileDialogSaveApp/main.cpp10
-rw-r--r--old/tests/qtuitest/testapps/graphicsViewTest/graphicsViewTest.pro19
-rw-r--r--old/tests/qtuitest/testapps/graphicsViewTest/main.cpp15
-rw-r--r--old/tests/qtuitest/testapps/graphicsViewTest/mainwindow.cpp35
-rw-r--r--old/tests/qtuitest/testapps/graphicsViewTest/mainwindow.h27
-rw-r--r--old/tests/qtuitest/testapps/testapp1/main.cpp245
-rw-r--r--old/tests/qtuitest/testapps/testapp1/testapp1.pro27
-rw-r--r--old/tests/qtuitest/testapps/testapp2/main.cpp262
-rw-r--r--old/tests/qtuitest/testapps/testapp2/testapp2.pro25
-rw-r--r--old/tests/qtuitest/testapps/testapp3/main.cpp142
-rw-r--r--old/tests/qtuitest/testapps/testapp3/testapp3.pro25
-rw-r--r--old/tests/qtuitest/testapps/testapp4/main.cpp90
-rw-r--r--old/tests/qtuitest/testapps/testapp4/testapp4.pro25
-rw-r--r--old/tests/qtuitest/testapps/testapps.pro8
-rw-r--r--old/tests/qtuitest/tst_qalternatestack/tst_qalternatestack.cpp418
-rw-r--r--old/tests/qtuitest/tst_qalternatestack/tst_qalternatestack.pro19
-rw-r--r--old/tests/qtuitest/tst_qelapsedtimer/tst_qelapsedtimer.cpp78
-rw-r--r--old/tests/qtuitest/tst_qelapsedtimer/tst_qelapsedtimer.pro21
-rw-r--r--old/tests/qtuitest/tst_qinputgenerator/nativeevent.h19
-rw-r--r--old/tests/qtuitest/tst_qinputgenerator/nativeevent_noop.cpp17
-rw-r--r--old/tests/qtuitest/tst_qinputgenerator/nativeevent_x11.cpp85
-rw-r--r--old/tests/qtuitest/tst_qinputgenerator/tst_qinputgenerator.cpp756
-rw-r--r--old/tests/qtuitest/tst_qinputgenerator/tst_qinputgenerator.pro27
-rw-r--r--old/tests/qtuitest/tst_qtestprotocol/testprotocol.cpp49
-rw-r--r--old/tests/qtuitest/tst_qtestprotocol/testprotocol.h65
-rw-r--r--old/tests/qtuitest/tst_qtestprotocol/testprotocolserver.cpp71
-rw-r--r--old/tests/qtuitest/tst_qtestprotocol/testprotocolserver.h72
-rw-r--r--old/tests/qtuitest/tst_qtestprotocol/tst_qtestprotocol.cpp192
-rw-r--r--old/tests/qtuitest/tst_qtestprotocol/tst_qtestprotocol.pro25
-rw-r--r--old/tests/qtuitest/tst_qtuitestnamespace/tst_qtuitestnamespace.cpp898
-rw-r--r--old/tests/qtuitest/tst_qtuitestnamespace/tst_qtuitestnamespace.pro20
-rw-r--r--old/tests/qtuitest/tst_qtuitestwidgets/tst_qtuitestwidgets.cpp554
-rw-r--r--old/tests/qtuitest/tst_qtuitestwidgets/tst_qtuitestwidgets.pro27
-rw-r--r--old/tests/shared/filedialog.qtt113
-rw-r--r--old/tests/tests.pro3
50 files changed, 6062 insertions, 0 deletions
diff --git a/old/tests/qtuitest/qtuitest.pro b/old/tests/qtuitest/qtuitest.pro
new file mode 100644
index 0000000..f1dbaa4
--- /dev/null
+++ b/old/tests/qtuitest/qtuitest.pro
@@ -0,0 +1,33 @@
+TEMPLATE=subdirs
+SUBDIRS+= \
+ testapps \
+ sys_input \
+ sys_assistant \
+ sys_designer \
+ sys_graphicsView \
+ sys_linguist \
+ tst_qalternatestack \
+ tst_qelapsedtimer \
+ tst_qinputgenerator \
+ tst_qtuitestnamespace
+
+# Tests which should run in Pulse (currently, those which do not require X server)
+PULSE_TESTS = \
+ tst_qalternatestack \
+ tst_qelapsedtimer \
+ tst_qtestprotocol \
+
+!win32 {
+ SUBDIRS+=tst_qtestprotocol tst_qtuitestwidgets
+}
+
+symbian {
+ SUBDIRS-=tst_qalternatestack tst_qtestprotocol tst_qtuitestwidgets
+}
+
+pulsetest.CONFIG = recursive
+pulsetest.recurse = $$PULSE_TESTS
+pulsetest.target = pulsetest
+pulsetest.recurse_target = junittest
+QMAKE_EXTRA_TARGETS += pulsetest
+
diff --git a/old/tests/qtuitest/sys_assistant/sys_assistant.pro b/old/tests/qtuitest/sys_assistant/sys_assistant.pro
new file mode 100644
index 0000000..a057ba3
--- /dev/null
+++ b/old/tests/qtuitest/sys_assistant/sys_assistant.pro
@@ -0,0 +1,9 @@
+SOURCES=sys_assistant.qtt
+CONFIG+=systemtest
+
+
+target.path += \
+ /usr/local/bin
+
+INSTALLS += \
+ target \ No newline at end of file
diff --git a/old/tests/qtuitest/sys_assistant/sys_assistant.qtt b/old/tests/qtuitest/sys_assistant/sys_assistant.qtt
new file mode 100644
index 0000000..f2449d4
--- /dev/null
+++ b/old/tests/qtuitest/sys_assistant/sys_assistant.qtt
@@ -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$
+**
+****************************************************************************/
+
+
+testcase = {
+
+ //TODO: In Progress. Not expected to pass (or even work correctly) yet.
+
+ init: function() {
+ startApplication("assistant");
+ if (getLabels().contains("Updating search index")) {
+ print("Waiting for search index update to complete...");
+ waitFor(60000) {
+ return (!getLabels().contains("Updating search index"));
+ }
+ }
+ },
+
+ check_registered_docs: function() {
+ select("Edit/Preferences...", menuBar());
+ select("Documentation", tabBar());
+ setLabelOrientation(LabelAbove);
+ var docs = getText("Registered Documentation:");
+ if (!docs.contains("com.trolltech.assistant.") ||
+ !docs.contains("com.trolltech.designer.") ||
+ !docs.contains("com.trolltech.linguist.") ||
+ !docs.contains("com.trolltech.qmake.") ||
+ !docs.contains("com.trolltech.qt.")) {
+ fail("Documentation has not been registered. Subsequent tests will fail.");
+ }
+ },
+
+ browse_contents: function() {
+ select("Contents", tabBar());
+ var content = helpContent();
+
+ select("Qt Linguist Manual/Manual", content);
+ waitFor() { return(getText(tabBar(1)).contains("Qt Linguist Manual")); }
+
+ select("Qt Reference Documentation/Overviews/An Introduction to Model\\/View Programming", content);
+ waitFor() { return(getText(tabBar(1)).contains("An Introduction to Model/View Programming")); }
+
+ select("Qt Reference Documentation/Classes/QList Class Reference/List of all members", content);
+ waitFor() { return(getText(tabBar(1)).contains("List of All Members for QList")); }
+ },
+
+ browse_index_data: {
+ countryToString: [ "countryToString", "QLocale Class Reference" ]
+ },
+
+ browse_index: function(item, pageTitle) {
+ select("Index", tabBar());
+ var indexWidget = helpIndex();
+
+ select(item, indexWidget);
+ select("Open Link", contextMenu());
+ waitFor() { return(getText(tabBar(1)).contains(pageTitle)); }
+ },
+
+ create_bookmark_data: {
+ one: [ "sys_assistant", "test_subfolder" ]
+ },
+
+ create_bookmark: function(topLevelFolder, subFolder) {
+ select("Bookmarks", tabBar());
+ var bookmarkTree = helpBookmarks();
+
+ // If there is already a folder with the same name, remove it
+ if (getList(bookmarkTree).contains(topLevelFolder)) {
+ select(topLevelFolder, bookmarkTree);
+ select("Bookmarks/Remove");
+ select("Yes");
+ }
+
+ // Create a new bookmark
+ select("Bookmarks/Add");
+ var pageName = getText("Bookmark:").replace(/\//g, "\\\\/");;
+ select("+");
+ select("New Folder");
+ select("Rename Folder", contextMenu());
+ enter(topLevelFolder);
+ select("New Folder");
+ select("Rename Folder", contextMenu());
+ enter(subFolder);
+ select("OK");
+
+ // Verify that it is in the list
+ var bookmarkList = getList(bookmarkTree);
+ verify(bookmarkList.contains(topLevelFolder));
+ verify(bookmarkList.contains(topLevelFolder + "/" + subFolder));
+ verify(bookmarkList.contains(topLevelFolder + "/" + subFolder + "/" + pageName));
+
+ // Remove it
+ select(topLevelFolder, bookmarkTree);
+ select("Bookmarks/Remove");
+ select("Yes");
+
+ // Verify that it is no longer in the list
+ var bookmarkList = getList(bookmarkTree);
+ verify(!bookmarkList.contains(topLevelFolder));
+ verify(!bookmarkList.contains(topLevelFolder + "/" + subFolder));
+ verify(!bookmarkList.contains(topLevelFolder + "/" + subFolder + "/" + pageName));
+ },
+
+ search_data: {
+ simpleText: [ "Simple Text", "Simple Text Viewer Example" ],
+ designerWidgets: [ "Designer Widgets", "Creating Custom Widgets for Qt Designer" ],
+ includePath: [ "INCLUDEPATH", "qmake Variable Reference" ]
+ },
+
+ search: function(query, expectedResult) {
+ select("View/Search", menuBar());
+ select("Search", tabBar(1));
+ enter(query, "Search for:");
+ select("Search");
+ var results = searchResults();
+ waitFor() { return(getText(results).contains(expectedResult)); }
+ select(expectedResult, results);
+ waitFor() { return(getText(tabBar(1)).contains(expectedResult)); }
+ verify(getText(helpViewer()).contains(expectedResult));
+ },
+
+ follow_links_data: {
+ one: [ "Qt Reference Documentation/Overviews/View Classes", "View Classes",
+ [ ["delegates", "Delegate Classes"],
+ ["Spin Box Delegate", "Spin Box Delegate Example"],
+ ["QItemDelegate", "QItemDelegate Class Reference"],
+ ["QSqlRelationalDelegate","QSqlRelationalDelegate Class Reference"] ] ]
+ },
+
+ follow_links: function(browseItem, firstTitle, links) {
+
+ // Select browseItem from the Contents
+ select("Contents", tabBar());
+ var content = helpContent();
+ select(browseItem, content);
+ waitFor() { return(getText(tabBar(1)).contains(firstTitle)); }
+
+ // Get a handle for the Help Viewer widget
+ var viewer = helpViewer(); //findByProperty( { inherits: "QWebView" } );
+
+ // Click on each link in turn
+ for (var i=0; i<links.length; ++i) {
+ select(links[i][0], viewer);
+ waitFor() { return(getText(tabBar(1)).contains(links[i][1])); }
+ }
+
+ // Now navigate back...
+ for (var i=links.length-1; i>=0; --i) {
+ verify(getText(tabBar(1)).contains(links[i][1]));
+ select("Back");
+ }
+
+ // ... and confirm that we're back to the first page
+ verify(getText(tabBar(1)).contains(firstTitle));
+ }
+
+}
+
+function contextMenu()
+{
+ keyClick(Qt.Key_Menu);
+ var menu = findByProperty( { inherits: "QMenu" } );
+ if (menu.isEmpty()) {
+ fail("Context menu did not appear.");
+ }
+ return menu[0];
+}
+
+function helpViewer()
+{
+ return findByProperty( { className: "HelpViewer" } );
+}
+
+function helpContent()
+{
+ return findByProperty( { className: "QHelpContentWidget" } );
+}
+
+function helpIndex()
+{
+ return findByProperty( { className: "QHelpIndexWidget" } );
+}
+
+function helpBookmarks()
+{
+ return findByProperty( { child_of: "Bookmarks", inherits: "QTreeView" } );
+}
+
+function searchResults()
+{
+ return findByProperty( { className: "QCLuceneResultWidget" } );
+}
diff --git a/old/tests/qtuitest/sys_designer/sys_designer.pro b/old/tests/qtuitest/sys_designer/sys_designer.pro
new file mode 100644
index 0000000..2fa97f5
--- /dev/null
+++ b/old/tests/qtuitest/sys_designer/sys_designer.pro
@@ -0,0 +1,9 @@
+SOURCES=sys_designer.qtt
+CONFIG+=systemtest
+
+
+target.path += \
+ /usr/local/bin
+
+INSTALLS += \
+ target \ No newline at end of file
diff --git a/old/tests/qtuitest/sys_designer/sys_designer.qtt b/old/tests/qtuitest/sys_designer/sys_designer.qtt
new file mode 100644
index 0000000..7defc99
--- /dev/null
+++ b/old/tests/qtuitest/sys_designer/sys_designer.qtt
@@ -0,0 +1,419 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+
+testcase = {
+
+ //TODO: In Progress. Not expected to pass (or even work correctly) yet.
+
+ init: function() {
+ clearCachedWidgets();
+ startApplication("designer");
+
+ if (currentTitle() == translate("QDesignerWorkbench", "Backup Information")) {
+ select(translate("QDialogButtonBox", "&No"));
+ }
+
+ select("Widgets/QFrame");
+ select("Create");
+
+ select("Expand all", contextMenu(widgetBoxTree()));
+ select("List View", contextMenu(widgetBoxTree()));
+ },
+
+ test1: function() {
+ var fc = getGeometry(formWindow()).center();
+
+ // Create a form layout and add some rows to it...
+ dragItem("Layouts/Form Layout", widgetBoxTree(), fc);
+
+ select("Frame/formLayout", objectInspector());
+ select("Add form layout row...", contextMenu());
+ enter("LineEdit1", "Label text:");
+ select("QLineEdit", "Field type:");
+ select("OK");
+
+ select("Frame/formLayout", objectInspector());
+ select("Add form layout row...", contextMenu());
+ enter("ComboBox1", "Label text:");
+ select("QComboBox", "Field type:");
+ select("OK");
+
+ // Set the available items in the combobox...
+ select("Edit Items...", contextMenu("ComboBox1"));
+ select("New");
+ enter("One");
+ select("New");
+ enter("Two");
+ select("New");
+ enter("Three");
+ select("New");
+ enter("Four");
+ select("New");
+ enter("Five");
+ select("OK");
+
+ // Edit signal/slot connections using the interactive editor...
+ select("Edit/Edit Signals\\/Slots", mainMenuBar());
+
+ // The labels don't seem to have buddy widgets set, although they are set
+ // correctly when previewed. So the combobox ends up being self-labelled
+ drag(getGeometry("One").center(), getGeometry("LineEdit1").center());
+ var sigSlotList = findByProperty( { className: "QListWidget" } );
+ select("activated(QString)", sigSlotList[0]);
+ select("setText(QString)", sigSlotList[1]);
+ select("OK");
+
+ // Preview, ensure that changing the combobox value also changes the lineedit value...
+ select("Form/Preview...", mainMenuBar());
+
+ select("Three", "ComboBox1");
+ compare(getText("LineEdit1"), "Three");
+ },
+
+ test2: function() {
+ // Add some radio buttons to the form...
+ var fc = getGeometry(formWindow()).center();
+ dragItem("Buttons/Radio Button", widgetBoxTree(), fc);
+ dragItem("Buttons/Radio Button", widgetBoxTree(), fc);
+ dragItem("Buttons/Radio Button", widgetBoxTree(), fc);
+ dragItem("Buttons/Radio Button", widgetBoxTree(), fc);
+
+ // Set widget properties...
+ select("Frame/radioButton", objectInspector());
+ selectProperty("QAbstractButton/text");
+ enter("Radio 1");
+
+ select("Frame/radioButton_2", objectInspector());
+ selectProperty("QAbstractButton/text");
+ enter("Radio 2");
+
+ select("Frame/radioButton_3", objectInspector());
+ selectProperty("QAbstractButton/text");
+ enter("Radio 3");
+
+ select("Frame/radioButton_4", objectInspector());
+ selectProperty("QAbstractButton/text");
+ enter("Radio 4");
+
+ // Set layout...
+ select("Edit/Select All", mainMenuBar());
+ select("Assign to button group/New button group", contextMenu("Radio 1"));
+ select("Form/Lay Out Vertically", mainMenuBar());
+
+ // Preview, to ensure only one radio button can be active at a time...
+ select("Form/Preview...", mainMenuBar());
+
+ setChecked(true, "Radio 1");
+ verify(!isChecked("Radio 2"));
+ verify(!isChecked("Radio 3"));
+ verify(!isChecked("Radio 4"));
+
+ setChecked(true, "Radio 2");
+ verify(!isChecked("Radio 1"));
+ verify(!isChecked("Radio 3"));
+ verify(!isChecked("Radio 4"));
+
+ setChecked(true, "Radio 3");
+ verify(!isChecked("Radio 1"));
+ verify(!isChecked("Radio 2"));
+ verify(!isChecked("Radio 4"));
+
+ setChecked(true, "Radio 4");
+ verify(!isChecked("Radio 1"));
+ verify(!isChecked("Radio 2"));
+ verify(!isChecked("Radio 3"));
+
+ // Close the preview window...
+ invokeMethod(activeWindow(), "close()");
+
+ // Change the exclusive property of the button group...
+ select("Frame/buttonGroup", objectInspector());
+ selectProperty("QButtonGroup/exclusive");
+ setChecked(false);
+
+ // Preview, ensure that all buttons can be set at once...
+ select("Form/Preview...", mainMenuBar());
+
+ setChecked(true, "Radio 1");
+ setChecked(true, "Radio 2");
+ setChecked(true, "Radio 3");
+ setChecked(true, "Radio 4");
+ verify(isChecked("Radio 1"));
+ verify(isChecked("Radio 2"));
+ verify(isChecked("Radio 3"));
+ verify(isChecked("Radio 4"));
+ },
+
+ test3: function() {
+ var fc = getGeometry(formWindow()).center();
+
+ // Add some widgets to the form...
+ dragItem("Input Widgets/Line Edit", widgetBoxTree(), new QPoint(fc.x()+30, fc.y()-20));
+ dragItem("Input Widgets/Spin Box", widgetBoxTree(), new QPoint(fc.x()-30, fc.y()+20));
+ dragItem("Display Widgets/Label", widgetBoxTree(), new QPoint(fc.x()-30, fc.y()-20));
+ dragItem("Display Widgets/Label", widgetBoxTree(), new QPoint(fc.x()+30, fc.y()+20));
+ dragItem("Buttons/Push Button", widgetBoxTree(), new QPoint(fc.x()-30, fc.y()+40));
+ dragItem("Buttons/Push Button", widgetBoxTree(), new QPoint(fc.x()+30, fc.y()+40));
+
+ select("Edit/Select All", mainMenuBar());
+ select("Form/Lay Out in a Grid", mainMenuBar());
+
+ // Set widget properties...
+ select("Frame/gridLayout/label", objectInspector());
+ selectProperty("QLabel/text");
+ enter("LineEdit1");
+
+ select("Frame/gridLayout/label_2", objectInspector());
+ selectProperty("QLabel/text");
+ enter("SpinBox1");
+
+ select("Frame/gridLayout/pushButton", objectInspector());
+ selectProperty("QAbstractButton/text");
+ enter("Down");
+
+ select("Frame/gridLayout/pushButton_2", objectInspector());
+ selectProperty("QAbstractButton/text");
+ enter("Up");
+
+ select("Frame/gridLayout/spinBox", objectInspector());
+ selectProperty("QSpinBox/maximum");
+ enter(100);
+
+ selectProperty("QAbstractSpinBox/specialValueText");
+ enter("Infinity");
+
+ // Set buddies...
+ select("Edit/Edit Buddies", mainMenuBar());
+ drag(getGeometry(findByProperty( { text: "LineEdit1" } )).center(), getGeometry(findByProperty( { className: "QLineEdit"} )).center());
+ drag(getGeometry(findByProperty( { text: "SpinBox1" } )).center(), getGeometry(findByProperty( { className: "QSpinBox"} )).center());
+
+ // Set up signal/slot connections...
+ connectSignalSlot("spinBox", "valueChanged(QString)", "lineEdit", "setText(QString)");
+ connectSignalSlot("pushButton", "clicked()", "spinBox", "stepDown()")
+ connectSignalSlot("pushButton_2", "clicked()","spinBox" , "stepUp()");
+
+ // Preview the form, and make sure it behaves as expected...
+ select("Form/Preview...", mainMenuBar());
+
+ enter(50, "SpinBox1");
+ compare(50, getText("LineEdit1"));
+
+ for (var i=0; i<8; ++i) {
+ select("Down");
+ }
+ compare(42, getText("LineEdit1"));
+
+ enter(5, "SpinBox1");
+ compare(5, getText("LineEdit1"));
+
+ for (var i=0; i<4; ++i) {
+ select("Down");
+ }
+ compare(1, getText("LineEdit1"));
+ select("Down");
+ compare("Infinity", getText("LineEdit1"));
+ select("Down");
+ compare("Infinity", getText("LineEdit1"));
+
+ enter(95, "SpinBox1");
+ compare(95, getText("LineEdit1"));
+
+ for (var i=0; i<4; ++i) {
+ select("Up");
+ }
+ compare(99, getText("LineEdit1"));
+ select("Up");
+ compare(100, getText("LineEdit1"));
+ select("Up");
+ compare(100, getText("LineEdit1"));
+
+ enter("Goodbye", "LineEdit1");
+ compare(100, getText("SpinBox1"));
+ }
+
+}
+
+function dragItem(item, widget, point)
+{
+ ensureVisible(item, widget);
+ var center = getCenter(item, widget);
+ drag(center, point);
+}
+
+function drag(a, b)
+{
+ var dx = (b.x() - a.x());
+ var dy = (b.y() - a.y());
+ var steps = 2 + (Math.abs(dx) + Math.abs(dy))/20;
+ dx = dx/steps;
+ dy = dy/steps;
+ var x=a.x();
+ var y=a.y();
+ mousePress(x, y);
+ wait(200);
+ for (var i=0; i<steps; i++) {
+ x += dx;
+ y += dy;
+ mousePress(x, y);
+ wait(1);
+ }
+ mousePress(b.x(), b.y());
+ wait(50);
+ mouseRelease(b.x(), b.y());
+ wait(500);
+}
+
+function clearCachedWidgets()
+{
+ testcase.cachedWidgets = {};
+}
+
+function formWindow()
+{
+ return findByProperty( { className: "QDesignerFormWindow" } );
+}
+
+function propertyEditor()
+{
+ selectDockedWindow("Property Editor");
+ if (testcase.cachedWidgets.propertyEditor == undefined) {
+ testcase.cachedWidgets.propertyEditor = findByProperty( { className: "QtPropertyEditorView" } );
+ }
+ return testcase.cachedWidgets.propertyEditor;
+}
+
+function widgetBoxTree()
+{
+ selectDockedWindow("Qt Designer");
+ if (testcase.cachedWidgets.widgetBoxTree == undefined) {
+ testcase.cachedWidgets.widgetBoxTree = findByProperty( { className: "qdesigner_internal::WidgetBoxTreeWidget" } );
+ }
+ return testcase.cachedWidgets.widgetBoxTree;
+}
+
+function objectInspector()
+{
+ selectDockedWindow("Object Inspector");
+ if (testcase.cachedWidgets.objectInspector == undefined) {
+ testcase.cachedWidgets.objectInspector = findByProperty( { descendant_of: "Object Inspector", inherits: "QTreeView"} );
+ }
+ return testcase.cachedWidgets.objectInspector;
+}
+
+function signalSlotEditor()
+{
+ selectDockedWindow("Signal/Slot Editor");
+ if (testcase.cachedWidgets.signalSlotEditor == undefined) {
+ testcase.cachedWidgets.signalSlotEditor = findByProperty( { className: "qdesigner_internal::SignalSlotEditorWindow"} );
+ }
+ return testcase.cachedWidgets.signalSlotEditor;
+}
+
+function mainMenuBar()
+{
+ activateWindow("Qt Designer");
+ if (testcase.cachedWidgets.menuBar == undefined) {
+ testcase.cachedWidgets.menuBar = menuBar();
+ }
+ return testcase.cachedWidgets.menuBar;
+}
+
+function contextMenu(widget)
+{
+ if (widget == undefined) {
+ keyClick(Qt.Key_Menu);
+ } else {
+ mouseClick(widget, new Qt.MouseButtons(Qt.RightButton));
+ }
+ var menu = findByProperty( { inherits: "QMenu" } );
+ if (menu.isEmpty()) {
+ fail("Context menu did not appear.");
+ }
+ return menu[0];
+}
+
+function selectDockedWindow(window)
+{
+ if (getWindowTitles().contains(window)) {
+ activateWindow(window);
+ } else {
+ var tb = tabBar();
+ if (getList(tb).contains(window)) {
+ select(window, tb);
+ }
+ }
+}
+
+function selectProperty(propName)
+{
+ var pe = propertyEditor();
+ select(propName, pe);
+ var idx = getSelectedIndex(pe);
+ idx[idx.length -1]++;
+ selectIndex(idx, pe);
+}
+
+function connectSignalSlot(sender, signal, receiver, slot)
+{
+ selectDockedWindow("Signal/Slot Editor");
+ if (currentTitle() == "Signal/Slot Editor") {
+ if (testcase.cachedWidgets.addConnect == undefined) {
+ testcase.cachedWidgets.addConnect = findByProperty( { className: "QToolButton" } )[0];
+ testcase.cachedWidgets.signalSlotView = findByProperty( { className: "QTreeView" } );
+ }
+ } else {
+ if (testcase.cachedWidgets.addConnect == undefined) {
+ testcase.cachedWidgets.addConnect = findByProperty( { descendant_of: "Signal/Slot Editor", className: "QToolButton" } )[0];
+ testcase.cachedWidgets.signalSlotView = findByProperty( { descendant_of: "Signal/Slot Editor", className: "QTreeView" } );
+ }
+ }
+
+ select(testcase.cachedWidgets.addConnect);
+ select("<sender>", testcase.cachedWidgets.signalSlotView);
+ enter(sender);
+ select("<signal>", testcase.cachedWidgets.signalSlotView);
+ enter(signal);
+ select("<receiver>", testcase.cachedWidgets.signalSlotView);
+ enter(receiver);
+ select("<slot>", testcase.cachedWidgets.signalSlotView);
+ enter(slot);
+} \ No newline at end of file
diff --git a/old/tests/qtuitest/sys_graphicsView/sys_graphicsView.pro b/old/tests/qtuitest/sys_graphicsView/sys_graphicsView.pro
new file mode 100644
index 0000000..cdae5b4
--- /dev/null
+++ b/old/tests/qtuitest/sys_graphicsView/sys_graphicsView.pro
@@ -0,0 +1,11 @@
+SOURCES=sys_graphicsView.qtt
+TESTAPPS=graphicsViewTest
+CONFIG+=systemtest
+
+
+
+target.path += \
+ /usr/local/bin
+
+INSTALLS += \
+ target \ No newline at end of file
diff --git a/old/tests/qtuitest/sys_graphicsView/sys_graphicsView.qtt b/old/tests/qtuitest/sys_graphicsView/sys_graphicsView.qtt
new file mode 100644
index 0000000..9e23617
--- /dev/null
+++ b/old/tests/qtuitest/sys_graphicsView/sys_graphicsView.qtt
@@ -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$
+**
+****************************************************************************/
+
+
+testcase = {
+
+ //TODO: In Progress. Not expected to pass (or even work correctly) yet.
+
+ launch_app: function() {
+ startApplication("graphicsViewTest");
+
+ print(getLabels());
+ verifyImage("test1", "here is some text");
+ verifyImage("test2", "and here is some more");
+ prompt(activeWidgetInfo());
+ }
+} \ No newline at end of file
diff --git a/old/tests/qtuitest/sys_input/sys_input.pro b/old/tests/qtuitest/sys_input/sys_input.pro
new file mode 100644
index 0000000..63c63f5
--- /dev/null
+++ b/old/tests/qtuitest/sys_input/sys_input.pro
@@ -0,0 +1,11 @@
+SOURCES=sys_input.qtt
+TESTAPPS=testapp1 testapp2 testapp3
+CONFIG+=systemtest
+
+
+
+target.path += \
+ /usr/local/bin
+
+INSTALLS += \
+ target \ No newline at end of file
diff --git a/old/tests/qtuitest/sys_input/sys_input.qtt b/old/tests/qtuitest/sys_input/sys_input.qtt
new file mode 100644
index 0000000..56a0908
--- /dev/null
+++ b/old/tests/qtuitest/sys_input/sys_input.qtt
@@ -0,0 +1,363 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+
+testcase = {
+
+ activate_tabBar: function() {
+ startApplication("testapp1");
+
+ select( "First Tab", tabBar() );
+ compare( getSelectedText(tabBar()), "First Tab" );
+
+ select( "Cow Tab", tabBar() );
+ compare( getSelectedText(tabBar()), "Cow Tab" );
+
+ select( "First Tab", tabBar() );
+ compare( getSelectedText(tabBar()), "First Tab" );
+
+ select( "Awesome Tab", tabBar() );
+ compare( getSelectedText(tabBar()), "Awesome Tab" );
+ },
+
+ enter_single_data: {
+ numeric: "0",
+ asterisk: "*",
+ percent: "%",
+ question: "?",
+ comma: ",",
+ lower1: "a",
+ upper: "B",
+ lower2: "z"
+ },
+
+ enter_single: function(character) {
+ startApplication("testapp1");
+ select( "First Tab", tabBar() );
+ enter(character, "Status");
+ compare(getText("Status"), character);
+
+ },
+
+ enter_text: function(text) {
+ startApplication("testapp1");
+
+ select( "First Tab", tabBar() );
+ enter(text, "LineEdit1");
+ compare( getText("Status"), "LineEdit1 text changed" );
+ compare( getText("LineEdit1"), text );
+
+ enter("clear", "LineEdit2");
+ compare( getText("Status"), "LineEdit2 text changed" );
+ compare( getText("LineEdit2"), "clear" );
+
+ if (mousePreferred()) {
+ mouseClick("LineEdit1");
+ keyClick(Qt.Key_Home);
+ mouseClick("LineEdit2");
+ }
+ enter("overwrite", "LineEdit1");
+ compare( getText("LineEdit1"), "overwrite" );
+ },
+
+ enter_text_data: {
+ mixed_case: [ "MiXeD CASe" ],
+ punctuation: [ "!@#$%^&*()-=_+[]{}\|;:',./<>?`~" ],
+ allsorts: [ "$100! How Much?" ],
+ with_numbers: [ "1 2 3SD770 4 25 312" ],
+ in_dict: [ "hello kitty" ],
+ not_in_dict: [ "jtnerlnjas mtrnen" ],
+ long_str: [ "this is a really long string to test we can overwrite properly" ],
+
+ // Test for bug: "Jimmy" sometimes gives "Jinny" in predictive keyboard.
+ jimmy: [ "Jimmy jimmy" ]
+ },
+
+ enter_QTextEdit: function(text) {
+ startApplication("testapp3");
+
+ select("Text", tabBar());
+
+ enter(text, "Text");
+ compare( getText("Text"), text );
+
+ enter("overwrite", "Text");
+ compare( getText("Text"), "overwrite" );
+ },
+
+ enter_QTextEdit_data: {
+ single_line: [ "This is a single line" ],
+ //multi_lines: [ "This is\nmultiple lines of\n\ntext" ]
+ alotta_text: [ "This is a lot of text to ensure we get a scroll bar happening yes this is a lot of text to ensure we get a scroll bar happening yes" ]
+ },
+
+ enter_QTimeEdit: function(time, shouldPass) {
+ startApplication("testapp1");
+
+ select("Awesome Tab", tabBar());
+
+ if (!shouldPass) expectFail("Bad time given");
+ enter(time, "Time");
+
+ compare( getValue("Time"), time );
+ },
+
+ enter_QTimeEdit_data: {
+ simple1: [ new QTime(16, 55, 00), true ],
+ simple2: [ new QTime(14, 10, 38), true ],
+ sdigit1: [ new QTime(1, 33, 10), true ],
+ sdigit2: [ new QTime(19, 7, 11), true ],
+ sdigit3: [ new QTime(22, 21, 1), true ],
+
+ bad1: [ new QTime(25, 21, 1), false ],
+ bad2: [ new QTime(22, 88, 1), false ],
+ bad3: [ new QTime(21, 21, -1), false ]
+ },
+
+ // enter() with QDateEdit fields.
+ enter_QDateEdit: function(date) {
+ startApplication("testapp1");
+
+ select("Awesome Tab", tabBar());
+
+ enter(date, "Date");
+
+ compare( getValue("Date"), date );
+
+ },
+
+ enter_QDateEdit_data: {
+ simple1: [ new Date(2000, 6, 15) ],
+ december: [ new Date(2000, 12, 15) ],
+ end_of_month: [ new Date(2002, 6, 30) ],
+ simple2: [ new Date(2004, 10, 11) ]
+ },
+
+ // enter() with QDateTimeEdit fields.
+ enter_QDateTimeEdit: function(date) {
+ startApplication("testapp1");
+
+ select("Awesome Tab", tabBar());
+
+ enter(date, "DateTime");
+
+ compare( getValue("DateTime"), date );
+
+ },
+
+ enter_QDateTimeEdit_data: {
+ simple1: [ new Date(2000, 6, 15, 17, 27, 0) ],
+ december: [ new Date(2000, 11, 15, 0, 30, 0) ],
+ end_of_month: [ new Date(2002, 5, 30, 12, 15, 0) ],
+ simple2: [ new Date(2004, 10, 11) ]
+ },
+
+ // Explicit mouse clicks on widgets
+ mouseClick: function() {
+ startApplication("testapp1");
+ select( "Cow Tab", tabBar() );
+ compare( getSelectedText(tabBar()), "Cow Tab" );
+
+ mouseClick("CowButton1");
+ compare( getText("CowStatus"), "CowButton1 clicked" );
+
+ mouseClick("CowButton2");
+ compare( getText("CowStatus"), "CowButton2 clicked" );
+
+ mouseClick("CowButton16");
+ compare( getText("CowStatus"), "CowButton16 clicked" );
+
+ mouseClick("CowButton0");
+ compare( getText("CowStatus"), "CowButton0 clicked" );
+ },
+
+ activate_button: function() {
+ startApplication("testapp1");
+
+ select("First Tab", tabBar());
+ compare( getSelectedText(tabBar()), "First Tab" );
+
+ select("Button1");
+ compare( getText("Status"), "Button1 clicked" );
+ select("Button2");
+ compare( getText("Status"), "Button2 clicked" );
+ },
+
+ activate_combobox: function() {
+ startApplication("testapp1");
+
+ select( "Cow Tab", tabBar() );
+
+ select( "Woof", "Cow Goes?" );
+ compare( getText("CowStatus"), "Cow Goes? changed" );
+ compare( getSelectedText("Cow Goes?"), "Woof" );
+
+ // To clear 'Status'
+ select( "CowButton0" );
+ compare( getText("CowStatus"), "CowButton0 clicked" );
+
+ select( "Moo", "Cow Goes?" );
+ compare( getText("CowStatus"), "Cow Goes? changed" );
+ compare( getSelectedText("Cow Goes?"), "Moo" );
+ },
+
+ activate_editable_combobox: function() {
+ startApplication("testapp1");
+
+ select( "First Tab", tabBar() );
+
+ select( "Yellow", "Colour" );
+ compare( getText("Status"), "Colour changed" );
+ compare( getSelectedText("Colour"), "Yellow" );
+
+ // To clear 'Status'
+ select("Button1");
+ compare( getText("Status"), "Button1 clicked" );
+
+ select( "Blue", "Colour" );
+ compare( getText("Status"), "Colour changed" );
+ compare( getSelectedText("Colour"), "Blue" );
+ },
+
+ scroll_scrollarea_vertical: function() {
+ startApplication("testapp1");
+
+ select( "Cow Tab", tabBar() );
+
+ select( "CowButton0" );
+ compare( getText("CowStatus"), "CowButton0 clicked" );
+
+ // Scroll down to the bottom
+ select( "CowButton15" );
+ compare( getText("CowStatus"), "CowButton15 clicked" );
+
+ // Scroll up to the top
+ select( "CowButton0" );
+ compare( getText("CowStatus"), "CowButton0 clicked" );
+ },
+
+ scroll_combobox: function() {
+ startApplication("testapp1");
+
+ select( "Cow Tab", tabBar() );
+
+ select( "Woof", "Cow Goes?" );
+ compare( getText("CowStatus"), "Cow Goes? changed" );
+ compare( getSelectedText("Cow Goes?"), "Woof" );
+
+ // This item is the last one in the combobox
+ select( "Choo choo!", "Cow Goes?" );
+ compare( getText("CowStatus"), "Cow Goes? changed" );
+ compare( getSelectedText("Cow Goes?"), "Choo choo!" );
+ },
+
+ setChecked_checkbox: function() {
+ startApplication("testapp1");
+
+ select( "Awesome Tab", tabBar() );
+
+ select( "Clear" );
+ compare( getText("Status"), "'Clear' clicked" );
+
+ setChecked( true, "Checkbox" );
+ compare( getText("Status"), "'Checkbox' clicked" );
+ verify( isChecked("Checkbox") );
+
+ select( "Clear" );
+ compare( getText("Status"), "'Clear' clicked" );
+
+ setChecked( false, "Checkbox" );
+ compare( getText("Status"), "'Checkbox' clicked" );
+ verify( !isChecked("Checkbox") );
+
+ select( "Clear" );
+ compare( getText("Status"), "'Clear' clicked" );
+
+ setChecked( true, "Checkbox" );
+ compare( getText("Status"), "'Checkbox' clicked" );
+ verify( isChecked("Checkbox") );
+ },
+
+ select_groupbox_subitem: function() {
+ startApplication("testapp2");
+
+ setChecked(true, "Checkable");
+ select("Checkable/Groupie");
+ compare("'Groupie' clicked", getText("Status"));
+
+ setChecked(false, "Checkable");
+ expectFail("Can't select disabled button");
+ select("Checkable/Groupie");
+ },
+
+ select_from_popup: function() {
+ startApplication("testapp2");
+ select( "Tab Two", tabBar() );
+
+ select("Popup");
+ select("&No");
+ compare("No", getText("Popup response"));
+
+ select("Popup");
+ select("&Yes");
+ compare("Yes", getText("Popup response"));
+ },
+
+ enter_invisible: function() {
+ startApplication("testapp2");
+ select( "Tab Two", tabBar() );
+
+ setChecked(true, "Checkbox");
+ enter("hello world", "Silly 1");
+
+ setChecked(false, "Checkbox");
+ expectFail("Can't enter text into non-visible widget");
+ enter("hello again world", "Silly 2");
+ },
+
+ select_menu: function() {
+ startApplication("testapp2");
+ select( "Tab Free", tabBar() );
+
+ select("Menu Item #3", "Menu");
+ compare("Menu Item #3", getText("Menu"));
+ }
+}
diff --git a/old/tests/qtuitest/sys_input/testdata/enter_invisible/failure_.txt b/old/tests/qtuitest/sys_input/testdata/enter_invisible/failure_.txt
new file mode 100644
index 0000000..8c3ee3d
--- /dev/null
+++ b/old/tests/qtuitest/sys_input/testdata/enter_invisible/failure_.txt
@@ -0,0 +1,48 @@
+ERROR: Buddy widget for 'Silly 2' not found.
+Available labels: Popup,Dialog,Popup response,Checkbox,CheckGroup,CheckGroup/Do Nothing
+Application :
+Active Widget: TestWidget[fvvvvvuvqpn9o]
+Focus Widget : QCheckBox[40u930]
+Buddypairs:
+ Label: QPushButton[40tjn8] 'Popup' -- Buddy: QPushButton[40tjn8] 'Popup' x:15 y:714 h:28 w:618
+ Label: QGroupBox[40vi90] 'CheckGroup' -- Buddy: QGroupBox[40vi90] 'CheckGroup' x:15 y:853 h:68 w:618
+ Label: QCheckBox[40u930] 'Checkbox' -- Buddy: QCheckBox[40u930] 'Checkbox' x:15 y:812 h:23 w:618
+ Label: QPushButton[40u72o] 'Dialog' -- Buddy: QPushButton[40u72o] 'Dialog' x:15 y:748 h:28 w:618
+ Label: QLabel[40ua88] 'Popup response' -- Buddy: QLineEdit[4146ho] '' x:128 y:782 h:24 w:505
+ Label: QPushButton[413pv0] 'CheckGroup/Do Nothing' -- Buddy: QPushButton[413pv0] 'CheckGroup/Do Nothing' x:26 y:882 h:28 w:596
+Widgets without a buddy Label:
+ QTabBar[40icko] x:4 y:679 h:26 w:238
+Disabled widgets without a buddy Label:
+ QTabBar[40icko] x:4 y:679 h:26 w:238
+Buddy widgets sorted on position:
+ QTabBar[40icko] x:4 y:679 h:26 w:238
+ QPushButton[40tjn8] x:15 y:714 h:28 w:618
+ QPushButton[40u72o] x:15 y:748 h:28 w:618
+ QLineEdit[4146ho] x:128 y:782 h:24 w:505
+ QCheckBox[40u930] x:15 y:812 h:23 w:618
+ QGroupBox[40vi90] x:15 y:853 h:68 w:618
+ QPushButton[413pv0] x:26 y:882 h:28 w:596
+Location: /home/daviclar/build/qtuitest-rd/tests/qtuitest/sys_input/sys_input.js:333
+Also see failure_.png for a screenshot.
+Application :
+Active Widget: TestWidget[fvvvvvuvqpn9o]
+Focus Widget : QCheckBox[40u930]
+Buddypairs:
+ Label: QPushButton[40tjn8] 'Popup' -- Buddy: QPushButton[40tjn8] 'Popup' x:15 y:714 h:28 w:618
+ Label: QGroupBox[40vi90] 'CheckGroup' -- Buddy: QGroupBox[40vi90] 'CheckGroup' x:15 y:853 h:68 w:618
+ Label: QCheckBox[40u930] 'Checkbox' -- Buddy: QCheckBox[40u930] 'Checkbox' x:15 y:812 h:23 w:618
+ Label: QPushButton[40u72o] 'Dialog' -- Buddy: QPushButton[40u72o] 'Dialog' x:15 y:748 h:28 w:618
+ Label: QLabel[40ua88] 'Popup response' -- Buddy: QLineEdit[4146ho] '' x:128 y:782 h:24 w:505
+ Label: QPushButton[413pv0] 'CheckGroup/Do Nothing' -- Buddy: QPushButton[413pv0] 'CheckGroup/Do Nothing' x:26 y:882 h:28 w:596
+Widgets without a buddy Label:
+ QTabBar[40icko] x:4 y:679 h:26 w:238
+Disabled widgets without a buddy Label:
+ QTabBar[40icko] x:4 y:679 h:26 w:238
+Buddy widgets sorted on position:
+ QTabBar[40icko] x:4 y:679 h:26 w:238
+ QPushButton[40tjn8] x:15 y:714 h:28 w:618
+ QPushButton[40u72o] x:15 y:748 h:28 w:618
+ QLineEdit[4146ho] x:128 y:782 h:24 w:505
+ QCheckBox[40u930] x:15 y:812 h:23 w:618
+ QGroupBox[40vi90] x:15 y:853 h:68 w:618
+ QPushButton[413pv0] x:26 y:882 h:28 w:596
diff --git a/old/tests/qtuitest/sys_input/testdata/select_groupbox_subitem/failure_.txt b/old/tests/qtuitest/sys_input/testdata/select_groupbox_subitem/failure_.txt
new file mode 100644
index 0000000..fadfa4b
--- /dev/null
+++ b/old/tests/qtuitest/sys_input/testdata/select_groupbox_subitem/failure_.txt
@@ -0,0 +1,46 @@
+Object QPushButton(0x817be90 "") was expected to emit pressed() within 2000 milliseconds, but it didn't.
+Location: /home/daviclar/build/qtuitest-rd/tests/qtuitest/sys_input/sys_input.js:308
+Failed to save failure screenshot: AUT returned a null screenshot.
+Application :
+Active Widget: TestWidget[fvvvvvuvu9928]
+Focus Widget : QGroupBox[410k10]
+Buddypairs:
+ Label: QGroupBox[410k10] 'Checkable' -- Buddy: QGroupBox[410k10] 'Checkable' x:15 y:812 h:68 w:602
+ Label: QPushButton[41eboo] 'Spacer 3' -- Buddy: QPushButton[41eboo] 'Spacer 3' x:15 y:1058 h:28 w:602
+ Label: QPushButton[41bac0] 'Spacer 0' -- Buddy: QPushButton[41bac0] 'Spacer 0' x:15 y:956 h:28 w:602
+ Label: QPushButton[40t330] 'Spacer 1' -- Buddy: QPushButton[40t330] 'Spacer 1' x:15 y:990 h:28 w:602
+ Label: QPushButton[41e8d0] 'Spacer 4' -- Buddy: QPushButton[41e8d0] 'Spacer 4' x:15 y:1092 h:28 w:602
+ Label: QPushButton[41ffkg] 'Checkable/Groupie' -- Buddy: QPushButton[41ffkg] 'Checkable/Groupie' x:26 y:841 h:28 w:580
+ Label: QLabel[40ve50] 'Status' -- Buddy: QLineEdit[40ss1g] '' x:63 y:714 h:24 w:554
+ Label: QPushButton[40tt90] 'Show Modal Dialog' -- Buddy: QPushButton[40tt90] 'Show Modal Dialog' x:15 y:778 h:28 w:602
+ Label: QGroupBox[40vfro] 'Bug206084' -- Buddy: QLineEdit[41cfj0] '' x:26 y:915 h:24 w:580
+ Label: QLabel[4161e8] 'Time' -- Buddy: QTimeEdit[41e2p0] '' x:63 y:1126 h:24 w:554
+ Label: QPushButton[41ee20] 'Spacer 2' -- Buddy: QPushButton[41ee20] 'Spacer 2' x:15 y:1024 h:28 w:602
+ Label: QPushButton[41f4k0] 'Do Nothing' -- Buddy: QPushButton[41f4k0] 'Do Nothing' x:15 y:744 h:28 w:602
+Widgets without a buddy Label:
+ QGroupBox[40vfro] x:15 y:886 h:64 w:602
+ QScrollBar[415o30] x:626 y:705 h:452 w:16
+ QScrollArea[4189ig] x:6 y:705 h:452 w:636
+ QTabBar[40icko] x:4 y:679 h:26 w:238
+Disabled widgets without a buddy Label:
+ QGroupBox[40vfro] x:15 y:886 h:64 w:602
+ QScrollBar[415o30] x:626 y:705 h:452 w:16
+ QScrollArea[4189ig] x:6 y:705 h:452 w:636
+ QTabBar[40icko] x:4 y:679 h:26 w:238
+Buddy widgets sorted on position:
+ QTabBar[40icko] x:4 y:679 h:26 w:238
+ QScrollArea[4189ig] x:6 y:705 h:452 w:636
+ QScrollBar[415o30] x:626 y:705 h:452 w:16
+ QLineEdit[40ss1g] x:63 y:714 h:24 w:554
+ QPushButton[41f4k0] x:15 y:744 h:28 w:602
+ QPushButton[40tt90] x:15 y:778 h:28 w:602
+ QGroupBox[410k10] x:15 y:812 h:68 w:602
+ QPushButton[41ffkg] x:26 y:841 h:28 w:580
+ QGroupBox[40vfro] x:15 y:886 h:64 w:602
+ QLineEdit[41cfj0] x:26 y:915 h:24 w:580
+ QPushButton[41bac0] x:15 y:956 h:28 w:602
+ QPushButton[40t330] x:15 y:990 h:28 w:602
+ QPushButton[41ee20] x:15 y:1024 h:28 w:602
+ QPushButton[41eboo] x:15 y:1058 h:28 w:602
+ QPushButton[41e8d0] x:15 y:1092 h:28 w:602
+ QTimeEdit[41e2p0] x:63 y:1126 h:24 w:554
diff --git a/old/tests/qtuitest/sys_linguist/sys_linguist.pro b/old/tests/qtuitest/sys_linguist/sys_linguist.pro
new file mode 100644
index 0000000..6a9c6c3
--- /dev/null
+++ b/old/tests/qtuitest/sys_linguist/sys_linguist.pro
@@ -0,0 +1,10 @@
+SOURCES=sys_linguist.qtt
+CONFIG+=systemtest
+
+
+
+target.path += \
+ /usr/local/bin
+
+INSTALLS += \
+ target \ No newline at end of file
diff --git a/old/tests/qtuitest/sys_linguist/sys_linguist.qtt b/old/tests/qtuitest/sys_linguist/sys_linguist.qtt
new file mode 100644
index 0000000..a098cc5
--- /dev/null
+++ b/old/tests/qtuitest/sys_linguist/sys_linguist.qtt
@@ -0,0 +1,152 @@
+/****************************************************************************
+**
+** 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("filedialog.qtt");
+
+testcase = {
+
+ //TODO: In Progress. Not expected to pass (or even work correctly) yet.
+
+ init: function() {
+ // Start the application
+ startApplication("linguist");
+
+ // Open file
+ select("File/Open...", menuBar());
+ FileDialog.openFile(baseDataPath() + "test_fr.ts");
+
+ // Make sure all views are shown
+ setChecked(true, "View/Views/Context", menuBar());
+ setChecked(true, "View/Views/Strings", menuBar());
+ setChecked(true, "View/Views/Phrases and guesses", menuBar());
+ setChecked(true, "View/Views/Sources and Forms", menuBar());
+ setChecked(true, "View/Views/Warnings", menuBar());
+
+ // Switch on all validation
+ setChecked(true, "Validation/Accelerators", menuBar());
+ setChecked(true, "Validation/Ending Punctuation", menuBar());
+ setChecked(true, "Validation/Phrase matches", menuBar());
+ setChecked(true, "Validation/Place Marker Matches", menuBar());
+
+ // Switch off Length Variants
+ setChecked(false, "View/Length Variants", menuBar());
+
+ // Labels are above their buddy widgets
+ setLabelOrientation(LabelAbove);
+ },
+
+ check_translation_data: {
+ blue: [ "Colours", "blue", "bleu" ],
+ third: [ "Ordinals", "third", "troisième" ],
+ nine: [ "Numbers", "nine", "neuf" ]
+ },
+
+ check_translation: function(context, sourceText, translated) {
+ select( context, "Context" );
+ select( sourceText, "Strings" );
+ compare(getText("Source text"), sourceText);
+ compare(getText("French translation"), translated);
+ },
+
+ check_warnings_data: {
+ warn1: [ "Placemarkers", "Read error reading from %1: %2",
+ "Translation does not refer to the same place markers as in the source text." ],
+ warn2: [ "Accelerators", "&hello world", "Accelerator possibly missing in translation." ]
+ },
+
+ check_warnings: function(context, sourceText, warning) {
+ select( context, "Context" );
+ select( sourceText, "Strings" );
+ compare(getText("Source text"), sourceText);
+ verify(getList("Warnings").contains(warning));
+ },
+
+ missing_translations: function() {
+ select( "Translation/Next Unfinished" );
+ var list = new Array();
+ var val = getSelectedValue("Context")[1] + " : " + getText("Source text");
+ var first = val;
+
+ do {
+ list.push(val);
+ select( "Translation/Next Unfinished" );
+ var val = getSelectedValue("Context")[1] + " : " + getText("Source text");
+ } while (val != first);
+
+ verify(list.contains("Numbers : four"));
+ verify(list.contains("Ordinals : sixth"));
+ verify(list.contains("Colours : a mauvy shade of pinky russet"));
+ },
+
+ check_statistics: function() {
+ //TODO: Should also check word count, however this is not easy to do
+ // in JavaScript for Unicode strings.
+
+ var sourceChars = 0;
+ var translatedChars = 0;
+ var sourceNonSpaceChars = 0;
+ var translatedNonSpaceChars = 0;
+ var first = getSelectedValue("Context")[1] + " : " + getText("Source text");
+
+ do {
+ var sourceText = getText("Source text");
+ var translatedText = getText("French translation");
+ sourceChars += sourceText.length;
+ translatedChars += translatedText.length;
+
+ sourceNonSpaceChars += sourceText.replace(/\s/g, "").length;
+ translatedNonSpaceChars += translatedText.replace(/\s/g, "").length;
+ select( "Translation/Next" );
+ var val = getSelectedValue("Context")[1] + " : " + getText("Source text");
+ } while (val != first);
+
+ select("View/Statistics", menuBar());
+ var labels = getLabels();
+
+ compare(sourceNonSpaceChars, labels[labels.indexOf("Characters:")+1]);
+ compare(translatedNonSpaceChars, labels[labels.indexOf("Characters:")+2]);
+ compare(sourceChars, labels[labels.indexOf("Characters (with spaces):")+1]);
+ compare(translatedChars, labels[labels.indexOf("Characters (with spaces):")+2]);
+ }
+
+}
diff --git a/old/tests/qtuitest/sys_linguist/testdata/test_fr.ts b/old/tests/qtuitest/sys_linguist/testdata/test_fr.ts
new file mode 100644
index 0000000..60108f5
--- /dev/null
+++ b/old/tests/qtuitest/sys_linguist/testdata/test_fr.ts
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="fr">
+<context>
+ <name>Numbers</name>
+ <message>
+ <source>one</source>
+ <translation>un</translation>
+ </message>
+ <message>
+ <source>two</source>
+ <translation>deux</translation>
+ </message>
+ <message>
+ <source>three</source>
+ <translation>trois</translation>
+ </message>
+ <message>
+ <source>four</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>five</source>
+ <translation>cinq</translation>
+ </message>
+ <message>
+ <source>six</source>
+ <translation>six</translation>
+ </message>
+ <message>
+ <source>seven</source>
+ <translation>sept</translation>
+ </message>
+ <message>
+ <source>eight</source>
+ <translation>huit</translation>
+ </message>
+ <message>
+ <source>nine</source>
+ <translation>neuf</translation>
+ </message>
+ <message>
+ <source>ten</source>
+ <translation>dix</translation>
+ </message>
+</context>
+<context>
+ <name>Ordinals</name>
+ <message>
+ <source>first</source>
+ <translation>premier</translation>
+ </message>
+ <message>
+ <source>second</source>
+ <translation>deuxième</translation>
+ </message>
+ <message>
+ <source>third</source>
+ <translation>troisième</translation>
+ </message>
+ <message>
+ <source>fourth</source>
+ <translation>quatrième</translation>
+ </message>
+ <message>
+ <source>fifth</source>
+ <translation>cinquième</translation>
+ </message>
+ <message>
+ <source>sixth</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>seventh</source>
+ <translation>septième</translation>
+ </message>
+ <message>
+ <source>eighth</source>
+ <translation>huitième</translation>
+ </message>
+ <message>
+ <source>ninth</source>
+ <translation>neuvième</translation>
+ </message>
+ <message>
+ <source>tenth</source>
+ <translation>dixième.</translation>
+ </message>
+</context>
+<context>
+ <name>Colours</name>
+ <message>
+ <source>red</source>
+ <translation>rouge</translation>
+ </message>
+ <message>
+ <source>orange</source>
+ <translation>orange</translation>
+ </message>
+ <message>
+ <source>yellow</source>
+ <translation>jaune</translation>
+ </message>
+ <message>
+ <source>green</source>
+ <translation>vert</translation>
+ </message>
+ <message>
+ <source>blue</source>
+ <translation>bleu</translation>
+ </message>
+ <message>
+ <source>a mauvy shade of pinky russet</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>Placemarkers</name>
+ <message>
+ <source>Read: %1</source>
+ <translation>Lecture : %1</translation>
+ </message>
+ <message>
+ <source>Write: %1</source>
+ <translation>Écriture : %1</translation>
+ </message>
+ <message>
+ <source>Delete: %1</source>
+ <translation>Supprimer: %1</translation>
+ </message>
+ <message>
+ <source>Read error reading from %1: %2</source>
+ <translation>Erreur de lecture sur %1</translation>
+ </message>
+ <message>
+ <source>Write error writing to %1: %2</source>
+ <translation>Erreur d&apos;écriture sur %1: %2</translation>
+ </message>
+</context>
+<context>
+ <name>Accelerators</name>
+ <message>
+ <source>&amp;hello world</source>
+ <translation>bonjour tout le monde</translation>
+ </message>
+ <message>
+ <source>&amp;goodbye</source>
+ <translation>au &amp;revoir</translation>
+ </message>
+</context>
+<context>
+ <name>Other</name>
+ <message>
+ <source>all for one, one for all.</source>
+ <translation>tout pour un, un pour tout</translation>
+ </message>
+</context>
+</TS>
diff --git a/old/tests/qtuitest/testapps/fileDialogSaveApp/fileDialogSaveApp.pro b/old/tests/qtuitest/testapps/fileDialogSaveApp/fileDialogSaveApp.pro
new file mode 100644
index 0000000..a458154
--- /dev/null
+++ b/old/tests/qtuitest/testapps/fileDialogSaveApp/fileDialogSaveApp.pro
@@ -0,0 +1,23 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Wed Jul 12 13:50:18 2006
+######################################################################
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+INCLUDEPATH += $$SRCROOT/libqsystemtest
+unix:!maemo* {
+ # avoid the need for make install on *nix
+ DESTDIR=$$BUILDROOT/bin
+}
+
+# Input
+SOURCES += main.cpp
+
+
+target.path += \
+ /usr/local/bin
+
+INSTALLS += \
+ target
diff --git a/old/tests/qtuitest/testapps/fileDialogSaveApp/main.cpp b/old/tests/qtuitest/testapps/fileDialogSaveApp/main.cpp
new file mode 100644
index 0000000..ac651f1
--- /dev/null
+++ b/old/tests/qtuitest/testapps/fileDialogSaveApp/main.cpp
@@ -0,0 +1,10 @@
+#include <QtGui>
+
+int main (int argc, char* argv[])
+{
+ QApplication app( argc, argv );
+ QFileDialog fd;
+ fd.show();
+
+ return app.exec();
+}
diff --git a/old/tests/qtuitest/testapps/graphicsViewTest/graphicsViewTest.pro b/old/tests/qtuitest/testapps/graphicsViewTest/graphicsViewTest.pro
new file mode 100644
index 0000000..fa21ee2
--- /dev/null
+++ b/old/tests/qtuitest/testapps/graphicsViewTest/graphicsViewTest.pro
@@ -0,0 +1,19 @@
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+unix:!maemo* {
+ # avoid the need for make install on *nix
+ DESTDIR=$$BUILDROOT/bin
+}
+
+HEADERS += mainwindow.h
+SOURCES += main.cpp mainwindow.cpp
+mac:DESTDIR=$$BUILDROOT/bin
+
+
+target.path += \
+ /usr/local/bin
+
+INSTALLS += \
+ target \ No newline at end of file
diff --git a/old/tests/qtuitest/testapps/graphicsViewTest/main.cpp b/old/tests/qtuitest/testapps/graphicsViewTest/main.cpp
new file mode 100644
index 0000000..d5a6826
--- /dev/null
+++ b/old/tests/qtuitest/testapps/graphicsViewTest/main.cpp
@@ -0,0 +1,15 @@
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argv, char *args[])
+{
+ QApplication gearsofwartactics(argv, args);
+ MainWindow mainWindow;
+ mainWindow.setGeometry(100, 100, 1024, 768);
+ mainWindow.show();
+
+ return gearsofwartactics.exec();
+}
+
diff --git a/old/tests/qtuitest/testapps/graphicsViewTest/mainwindow.cpp b/old/tests/qtuitest/testapps/graphicsViewTest/mainwindow.cpp
new file mode 100644
index 0000000..45e3c88
--- /dev/null
+++ b/old/tests/qtuitest/testapps/graphicsViewTest/mainwindow.cpp
@@ -0,0 +1,35 @@
+#include <QtGui>
+
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ const QString pixmapString = "qtlogo4.png";
+ item = new QGraphicsPixmapItem(pixmapString);
+
+ textItem = new QGraphicsTextItem("here is some text");
+ textItem->setTextInteractionFlags(Qt::TextEditable);
+ QGraphicsTextItem *textItem2 = new QGraphicsTextItem("and here is some more");
+ textItem2->setTextInteractionFlags(Qt::TextEditable);
+ textItem2->setPos(20, 30);
+ scene = new QGraphicsScene();
+// scene->addItem(item);
+ scene->addItem(textItem);
+ scene->addItem(textItem2);
+ scene->setBackgroundBrush(Qt::lightGray);
+
+ view = new QGraphicsView(scene);
+ view->rotate(-30);
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->addWidget(view);
+ QLabel *label = new QLabel("hello world");
+ layout->addWidget(label);
+ QWidget *widget = new QWidget;
+ widget->setLayout(layout);
+
+ setCentralWidget(widget);
+ setWindowTitle(tr("Diagramscene"));
+
+
+}
diff --git a/old/tests/qtuitest/testapps/graphicsViewTest/mainwindow.h b/old/tests/qtuitest/testapps/graphicsViewTest/mainwindow.h
new file mode 100644
index 0000000..c8b68aa
--- /dev/null
+++ b/old/tests/qtuitest/testapps/graphicsViewTest/mainwindow.h
@@ -0,0 +1,27 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+class QGraphicsView;
+class QGraphicsScene;
+class QGraphicsItem;
+class QGraphicsTextItem;
+class QGraphicsPixmapItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+private:
+
+ QGraphicsView *view;
+ QGraphicsScene *scene;
+ QGraphicsItem *item;
+ QGraphicsTextItem *textItem;
+ QGraphicsPixmapItem *gowtPixmapItem;
+};
+
+#endif
diff --git a/old/tests/qtuitest/testapps/testapp1/main.cpp b/old/tests/qtuitest/testapps/testapp1/main.cpp
new file mode 100644
index 0000000..aa6c53c
--- /dev/null
+++ b/old/tests/qtuitest/testapps/testapp1/main.cpp
@@ -0,0 +1,245 @@
+/****************************************************************************
+**
+** 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>
+
+class TestWidget : public QTabWidget
+{
+Q_OBJECT
+public:
+ TestWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
+private slots:
+ void setupWidgets();
+
+private:
+ QLineEdit *testEdit;
+};
+#include "main.moc"
+
+TestWidget::TestWidget(QWidget *parent, Qt::WindowFlags f)
+ : QTabWidget(parent)
+{
+ setWindowFlags(f);
+ setWindowTitle("testapp1");
+ QTimer::singleShot(0, this, SLOT(setupWidgets()));
+}
+
+void TestWidget::setupWidgets() {
+ {
+ QWidget *page = new QWidget(this);
+ QSignalMapper *sm = new QSignalMapper(page);
+
+ QFormLayout *fl(new QFormLayout);
+
+ QLineEdit *statusEdit = new QLineEdit;
+ fl->addRow("Status", statusEdit);
+
+ QLineEdit *le1 = new QLineEdit;
+ QPushButton *pb1 = new QPushButton("Button1");
+ QLineEdit *le2 = new QLineEdit;
+ QPushButton *pb2 = new QPushButton("Button2");
+
+ fl->addRow("LineEdit1", le1);
+ fl->addRow(pb1);
+ fl->addRow("LineEdit2", le2);
+ fl->addRow(pb2);
+
+ QComboBox *ecb = new QComboBox;
+ ecb->setEditable(true);
+ ecb->addItem("Red");
+ ecb->addItem("Green");
+ ecb->addItem("Blue");
+ ecb->addItem("Cyan");
+ ecb->addItem("Magenta");
+ ecb->addItem("Yellow");
+ ecb->addItem("Black");
+ ecb->addItem("White");
+ fl->addRow("Colour", ecb);
+
+ QMenu *menu = new QMenu(page);
+ QAction *action1 = menu->addAction("Action 1", sm, SLOT(map()));
+ QAction *action2 = menu->addAction("Action 2", sm, SLOT(map()));
+ QAction *actionWithSubmenu = menu->addAction("Submenu", sm, SLOT(map()));
+ for ( int i = 1; i <= 8; ++i ) {
+ QString menuName = QString("Menu Item #%1").arg(i);
+ menu->addAction(menuName);
+ }
+
+ QAction *actionLast = menu->addAction("Last!", sm, SLOT(map()));
+
+ QMenu *submenu = new QMenu(page);
+ actionWithSubmenu->setMenu(submenu);
+ QAction *subaction1 = submenu->addAction( "Subaction 1", sm, SLOT(map()) );
+ QAction *subaction2 = submenu->addAction( "Subaction 2", sm, SLOT(map()) );
+
+ connect(le1, SIGNAL(textChanged(QString)), sm, SLOT(map()));
+ connect(le2, SIGNAL(textChanged(QString)), sm, SLOT(map()));
+ connect(pb1, SIGNAL(clicked()), sm, SLOT(map()));
+ connect(pb2, SIGNAL(clicked()), sm, SLOT(map()));
+ connect(ecb, SIGNAL(activated(int)), sm, SLOT(map()));
+
+ sm->setMapping(le1, "LineEdit1 text changed");
+ sm->setMapping(le2, "LineEdit2 text changed");
+ sm->setMapping(pb1, "Button1 clicked");
+ sm->setMapping(pb2, "Button2 clicked");
+ sm->setMapping(ecb, "Colour changed");
+ sm->setMapping(action1, "Action 1 activated");
+ sm->setMapping(action2, "Action 2 activated");
+ sm->setMapping(actionWithSubmenu, "Submenu activated");
+ sm->setMapping(actionLast, "Last activated");
+ sm->setMapping(subaction1, "Subaction 1 activated");
+ sm->setMapping(subaction2, "Subaction 2 activated");
+
+ connect(sm, SIGNAL(mapped(QString)), statusEdit, SLOT(setText(QString)));
+
+ page->setLayout(fl);
+
+ addTab(page, "First Tab");
+ }
+
+ {
+ QWidget *page = new QWidget;
+ QSignalMapper *sm = new QSignalMapper(page);
+
+ QFormLayout *fl(new QFormLayout);
+
+ QLineEdit *statusEdit = new QLineEdit;
+ fl->addRow("CowStatus", statusEdit);
+
+ QComboBox *cb = new QComboBox;
+ cb->addItem("Neigh");
+ cb->addItem("Woof");
+ cb->addItem("Moo");
+ cb->addItem("Meow");
+ cb->addItem("Quack");
+ cb->addItem("Honk");
+ cb->addItem("Vrooooom");
+ cb->addItem("\"Hi Frank\"");
+ cb->addItem("Choo choo!");
+ fl->addRow("Cow Goes?", cb);
+ connect(cb, SIGNAL(activated(int)), sm, SLOT(map()));
+ sm->setMapping(cb, "Cow Goes? changed");
+
+ for (int i = 0; i < 20; ++i) {
+ QString name( QString("CowButton%1").arg(i) );
+ QPushButton *pb1 = new QPushButton(name);
+ fl->addRow(pb1);
+ connect(pb1, SIGNAL(clicked()), sm, SLOT(map()));
+ sm->setMapping(pb1, name + " clicked");
+ }
+
+ connect(sm, SIGNAL(mapped(QString)), statusEdit, SLOT(setText(QString)));
+
+ page->setLayout(fl);
+
+ QScrollArea *sa = new QScrollArea(this);
+ sa->setWidget(page);
+ sa->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ sa->setFocusPolicy(Qt::NoFocus);
+ sa->setFrameStyle(QFrame::NoFrame);
+ sa->setWidgetResizable(true);
+ addTab(sa, "Cow Tab");
+ }
+
+ {
+ QWidget *page = new QWidget;
+ QSignalMapper *sm = new QSignalMapper(page);
+
+ QFormLayout *fl(new QFormLayout);
+
+ QLineEdit *statusEdit = new QLineEdit;
+ fl->addRow("Status", statusEdit);
+
+ QCheckBox *cb = new QCheckBox("Checkbox");
+ cb->setChecked(false);
+ fl->addRow(cb);
+
+ QPushButton *pb = new QPushButton("Clear");
+ fl->addRow(pb);
+
+ QTimeEdit *te = new QTimeEdit;
+ te->setTime(QTime(12, 30, 30));
+ te->setDisplayFormat("hh:mm:ss");
+ fl->addRow("Time", te);
+
+ QDateEdit *de = new QDateEdit;
+ de->setDate(QDate(2001, 1, 1));
+ fl->addRow("Date", de);
+
+ QDateTimeEdit *dte = new QDateTimeEdit;
+ dte->setDate(QDate(2010, 12, 1));
+ dte->setTime(QTime(15, 0, 0));
+ dte->setDisplayFormat("dd MMMM yyyy hh:mm a");
+ fl->addRow("DateTime", dte);
+
+ connect(cb, SIGNAL(clicked()), sm, SLOT(map()));
+ connect(pb, SIGNAL(clicked()), sm, SLOT(map()));
+ connect(te, SIGNAL(editingFinished()), sm, SLOT(map()));
+ connect(de, SIGNAL(editingFinished()), sm, SLOT(map()));
+ connect(dte, SIGNAL(editingFinished()), sm, SLOT(map()));
+ sm->setMapping(cb, "'Checkbox' clicked");
+ sm->setMapping(pb, "'Clear' clicked");
+ sm->setMapping(te, "'Time' edited");
+ sm->setMapping(de, "'Date' edited");
+ sm->setMapping(dte, "'DateTime' edited");
+
+ connect(sm, SIGNAL(mapped(QString)), statusEdit, SLOT(setText(QString)));
+
+ page->setLayout(fl);
+
+ addTab(page, "Awesome Tab");
+ }
+
+ for (int i = 0; i < 5; ++i) {
+ QWidget* widget = new QWidget(this);
+ addTab(widget, QString("Distant Tab %1").arg(i));
+ }
+}
+
+int main(int argc, char** argv)
+{
+ QApplication app(argc, argv);
+ TestWidget tw;
+ tw.resize(640,480);
+ tw.show();
+ return app.exec();
+}
+
diff --git a/old/tests/qtuitest/testapps/testapp1/testapp1.pro b/old/tests/qtuitest/testapps/testapp1/testapp1.pro
new file mode 100644
index 0000000..eedc1f0
--- /dev/null
+++ b/old/tests/qtuitest/testapps/testapp1/testapp1.pro
@@ -0,0 +1,27 @@
+SOURCES*=main.cpp
+TEMPLATE=app
+unix:!maemo* {
+ # avoid the need for make install on *nix
+ DESTDIR=$$BUILDROOT/bin
+}
+
+QT+=network
+
+symbian {
+ TARGET.EPOCALLOWDLLDATA=1
+ TARGET.CAPABILITY += AllFiles ReadDeviceData ReadUserData SwEvent WriteUserData NetworkServices
+}
+
+win32 {
+ target.path=$$INSTALLROOT
+ INSTALLS+=target
+}
+
+mac {
+ CONFIG-=app_bundle
+}
+
+maemo5|maemo6 {
+ target.path = /usr/local/lib
+ INSTALLS += target
+}
diff --git a/old/tests/qtuitest/testapps/testapp2/main.cpp b/old/tests/qtuitest/testapps/testapp2/main.cpp
new file mode 100644
index 0000000..43193c1
--- /dev/null
+++ b/old/tests/qtuitest/testapps/testapp2/main.cpp
@@ -0,0 +1,262 @@
+/****************************************************************************
+**
+** 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>
+
+class TestWidget : public QTabWidget
+{
+Q_OBJECT
+public:
+ TestWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
+private slots:
+ void setupWidgets();
+ void raiseDialog();
+ void doPopup();
+ void doDialog();
+ void setButtonText(const QString &text);
+private:
+ QLineEdit *popupEdit;
+ QPushButton *menuButton;
+};
+#include "main.moc"
+
+TestWidget::TestWidget(QWidget *parent, Qt::WindowFlags f)
+ : QTabWidget(parent)
+{
+ setWindowFlags(f);
+ setWindowTitle("testapp2");
+ QTimer::singleShot(0, this, SLOT(setupWidgets()));
+}
+
+void TestWidget::setupWidgets() {
+ {
+ QWidget *page(new QWidget);
+ QFormLayout *fl(new QFormLayout);
+ QSignalMapper *sm(new QSignalMapper(page));
+
+ QLineEdit *statusEdit = new QLineEdit;
+ fl->addRow("Status", statusEdit);
+ QTimer::singleShot(0, statusEdit, SLOT(setFocus()));
+
+ QPushButton *nothing = new QPushButton("Do Nothing");
+ QPushButton *dialog = new QPushButton("Show Modal Dialog");
+ connect(dialog, SIGNAL(pressed()), this, SLOT(raiseDialog()));
+
+ QGroupBox *checkableGroupBox = new QGroupBox;
+ checkableGroupBox->setCheckable(true);
+ checkableGroupBox->setChecked(false);
+ checkableGroupBox->setTitle("Checkable");
+ QPushButton *buttonInGroupBox = new QPushButton("Groupie");
+ {
+ QFormLayout *subFl(new QFormLayout);
+ subFl->addRow(buttonInGroupBox);
+ checkableGroupBox->setLayout(subFl);
+ }
+
+ /*
+ Test that a focusable widget located in a noncheckable group box
+ which contains no other focusable widgets can be referred to using
+ the group box label.
+ */
+ QGroupBox *lineEditGroupBox = new QGroupBox;
+ {
+ lineEditGroupBox->setCheckable(false);
+ lineEditGroupBox->setTitle("Bug206084");
+ QHBoxLayout* hbox = new QHBoxLayout;
+ hbox->addWidget(new QLineEdit);
+ lineEditGroupBox->setLayout(hbox);
+ }
+
+ fl->addRow(nothing);
+ fl->addRow(dialog);
+ fl->addRow(checkableGroupBox);
+ fl->addRow(lineEditGroupBox);
+
+ for (int i = 0; i < 5; ++i) {
+ fl->addRow(new QPushButton(QString("Spacer %1").arg(i)));
+ }
+
+ QTimeEdit *te = new QTimeEdit;
+ te->setTime(QTime(12, 30));
+ te->setDisplayFormat("hh:mm");
+ fl->addRow("Time", te);
+
+ connect(nothing, SIGNAL(clicked()), sm, SLOT(map()));
+ connect(checkableGroupBox, SIGNAL(clicked(bool)), sm, SLOT(map()));
+ connect(buttonInGroupBox, SIGNAL(clicked()), sm, SLOT(map()));
+
+ sm->setMapping(nothing, "'Do Nothing' clicked");
+ sm->setMapping(checkableGroupBox, "'Checkable' clicked");
+ sm->setMapping(buttonInGroupBox, "'Groupie' clicked");
+
+ connect(sm, SIGNAL(mapped(QString)), statusEdit, SLOT(setText(QString)));
+
+ page->setLayout(fl);
+ QScrollArea *sa = new QScrollArea(this);
+ sa->setWidget(page);
+ sa->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ sa->setFocusPolicy(Qt::NoFocus);
+ sa->setFrameStyle(QFrame::NoFrame);
+ sa->setWidgetResizable(true);
+ addTab(sa, "Tab One");
+ }
+
+ {
+ QWidget *page(new QWidget);
+ QFormLayout *fl(new QFormLayout);
+
+ QPushButton *messageButton(new QPushButton("Popup"));
+ fl->addRow(messageButton);
+ connect(messageButton, SIGNAL(clicked()), this, SLOT(doPopup()));
+
+ QPushButton *dialogButton(new QPushButton("Dialog"));
+ fl->addRow(dialogButton);
+ connect(dialogButton, SIGNAL(clicked()), this, SLOT(doDialog()), Qt::QueuedConnection);
+
+ popupEdit = new QLineEdit;
+ fl->addRow("Popup response", popupEdit);
+
+ QCheckBox *cb = new QCheckBox("Checkbox");
+
+ QLineEdit *sillyLineEdit1 = new QLineEdit;
+ QLineEdit *sillyLineEdit2 = new QLineEdit;
+ QLabel *sillyLabel1 = new QLabel("Silly 1");
+ QLabel *sillyLabel2 = new QLabel("Silly 2");
+
+ sillyLineEdit1->setVisible(false);
+ sillyLineEdit2->setVisible(false);
+ sillyLabel1->setVisible(false);
+ sillyLabel2->setVisible(false);
+
+ connect(cb, SIGNAL(toggled(bool)), sillyLineEdit1, SLOT(setVisible(bool)));
+ connect(cb, SIGNAL(toggled(bool)), sillyLineEdit2, SLOT(setVisible(bool)));
+ connect(cb, SIGNAL(toggled(bool)), sillyLabel1, SLOT(setVisible(bool)));
+ connect(cb, SIGNAL(toggled(bool)), sillyLabel2, SLOT(setVisible(bool)));
+
+ fl->addRow(cb);
+ fl->addRow(sillyLabel1, sillyLineEdit1);
+ fl->addRow(sillyLabel2, sillyLineEdit2);
+
+ QGroupBox *gb = new QGroupBox("CheckGroup");
+ gb->setCheckable(true);
+ gb->setChecked(false);
+ {
+ QFormLayout *subFl(new QFormLayout);
+ subFl->addRow(new QPushButton("Do Nothing"));
+ gb->setLayout(subFl);
+ }
+ fl->addRow(gb);
+
+ page->setLayout(fl);
+ addTab(page, "Tab Two");
+ }
+
+ {
+ QWidget *page(new QWidget);
+ QFormLayout *fl(new QFormLayout);
+ QSignalMapper *sm(new QSignalMapper(page));
+
+ menuButton = new QPushButton("Menu");
+ QMenu *menu(new QMenu);
+ for ( int i = 1; i <= 6; ++i ) {
+ QString menuName = QString("Menu Item #%1").arg(i);
+ QAction *a = menu->addAction(menuName, sm, SLOT(map()));
+ sm->setMapping(a, a->text());
+ }
+ menuButton->setMenu(menu);
+ fl->addRow("Menu", menuButton);
+
+ connect(sm, SIGNAL(mapped(QString)), this, SLOT(setButtonText(QString)));
+
+ QTimeEdit *te(new QTimeEdit);
+ te->setDisplayFormat("hh:mm:ss");
+ te->setTime(QTime(12, 34, 56));
+ fl->addRow("Time", te);
+
+ QGroupBox *gb(new QGroupBox("Groupbox"));
+ QVBoxLayout *vb(new QVBoxLayout);
+ vb->addWidget( new QPushButton("Child Button 1") );
+ vb->addWidget( new QPushButton("Child Button 2") );
+ gb->setLayout(vb);
+ fl->addRow(gb);
+
+ page->setLayout(fl);
+ addTab(page, "Tab Free");
+ }
+
+}
+
+void TestWidget::raiseDialog() {
+ QDialog dlg;
+ QPushButton pb("Close", &dlg);
+ connect(&pb, SIGNAL(clicked()), &dlg, SLOT(accept()));
+ dlg.exec();
+}
+
+void TestWidget::doPopup() {
+ QString opt = (
+ QMessageBox::warning(this, "A Message Box", "Please choose yes or no",
+ QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) ? "Yes" : "No";
+ popupEdit->setText(opt);
+}
+
+void TestWidget::doDialog() {
+ QDialog dlg;
+ dlg.setWindowTitle("New Dialog");
+
+ QPushButton closeButton("Close", &dlg);
+ connect(&closeButton, SIGNAL(clicked()), &dlg, SLOT(accept()));
+
+ dlg.exec();
+}
+
+void TestWidget::setButtonText(const QString &text) {
+ menuButton->setText(text);
+}
+
+int main(int argc, char** argv)
+{
+ QApplication app(argc, argv);
+ TestWidget tw;
+ tw.resize(640,480);
+ tw.show();
+ return app.exec();
+}
diff --git a/old/tests/qtuitest/testapps/testapp2/testapp2.pro b/old/tests/qtuitest/testapps/testapp2/testapp2.pro
new file mode 100644
index 0000000..07ae95a
--- /dev/null
+++ b/old/tests/qtuitest/testapps/testapp2/testapp2.pro
@@ -0,0 +1,25 @@
+SOURCES*=main.cpp
+TEMPLATE=app
+unix:!maemo* {
+ # avoid the need for make install on *nix
+ DESTDIR=$$BUILDROOT/bin
+}
+
+symbian {
+ TARGET.EPOCALLOWDLLDATA=1
+ TARGET.CAPABILITY += AllFiles ReadDeviceData ReadUserData SwEvent WriteUserData NetworkServices
+}
+
+win32 {
+ target.path=$$INSTALLROOT
+ INSTALLS+=target
+}
+
+mac {
+ CONFIG-=app_bundle
+}
+
+maemo5|maemo6 {
+ target.path = /usr/local/lib
+ INSTALLS += target
+}
diff --git a/old/tests/qtuitest/testapps/testapp3/main.cpp b/old/tests/qtuitest/testapps/testapp3/main.cpp
new file mode 100644
index 0000000..0763484
--- /dev/null
+++ b/old/tests/qtuitest/testapps/testapp3/main.cpp
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** 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>
+
+class TestWidget : public QTabWidget
+{
+Q_OBJECT
+public:
+ TestWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
+private slots:
+ void setupWidgets();
+};
+#include "main.moc"
+
+TestWidget::TestWidget(QWidget *parent, Qt::WindowFlags f)
+ : QTabWidget(parent)
+{
+ setWindowFlags(f);
+ setWindowTitle("testapp3");
+ QTimer::singleShot(0, this, SLOT(setupWidgets()));
+}
+
+void TestWidget::setupWidgets() {
+ {
+ QWidget *page(new QWidget);
+ QFormLayout *fl(new QFormLayout);
+
+ QComboBox *cb = new QComboBox;
+ cb->addItems( QStringList() << "Off" << "Ask" << "On" );
+ fl->addRow("Automatic", cb);
+
+ cb = new QComboBox;
+ cb->addItems( QStringList() << "New York" << "Los Angeles" );
+ fl->addRow("Time Zone", cb);
+
+ page->setLayout(fl);
+ QScrollArea *sa = new QScrollArea(this);
+ sa->setWidget(page);
+ sa->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ sa->setFocusPolicy(Qt::NoFocus);
+ sa->setFrameStyle(QFrame::NoFrame);
+ sa->setWidgetResizable(true);
+ addTab(sa, "Time");
+ }
+
+ {
+ QWidget *page(new QWidget);
+ QFormLayout *fl(new QFormLayout);
+
+ QTextEdit *textEdit = new QTextEdit;
+ fl->addRow("Text", textEdit);
+
+ page->setLayout(fl);
+ addTab(page, "Text");
+ }
+
+ {
+ QWidget *page = new QWidget;
+ QSignalMapper *sm = new QSignalMapper(page);
+
+ QFormLayout *fl(new QFormLayout);
+
+ QLineEdit *statusEdit = new QLineEdit;
+ statusEdit->setFocusPolicy(Qt::NoFocus);
+ fl->addRow("Status", statusEdit);
+
+ QPushButton *button1 = new QPushButton("NoFocus1");
+ button1->setFocusPolicy(Qt::NoFocus);
+ button1->setShortcut(QKeySequence(Qt::Key_Select));
+ connect(button1, SIGNAL(clicked()), sm, SLOT(map()));
+ sm->setMapping(button1, "NoFocus1 clicked");
+ fl->addRow(button1);
+
+ QPushButton *button2 = new QPushButton("NoFocus2");
+ button2->setFocusPolicy(Qt::NoFocus);
+ button2->setShortcut(QKeySequence(Qt::Key_0));
+ connect(button2, SIGNAL(clicked()), sm, SLOT(map()));
+ sm->setMapping(button2, "NoFocus2 clicked");
+ fl->addRow(button2);
+
+ connect(sm, SIGNAL(mapped(QString)), statusEdit, SLOT(setText(QString)));
+ page->setLayout(fl);
+
+ QScrollArea *sa = new QScrollArea(this);
+ sa->setWidget(page);
+ sa->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ sa->setFocusPolicy(Qt::NoFocus);
+ sa->setFrameStyle(QFrame::NoFrame);
+ sa->setWidgetResizable(true);
+ addTab(sa, "Shortcuts");
+ }
+
+}
+
+int main(int argc, char** argv)
+{
+ QApplication app(argc, argv);
+ TestWidget tw;
+ tw.resize(640,480);
+ tw.show();
+ return app.exec();
+}
+
diff --git a/old/tests/qtuitest/testapps/testapp3/testapp3.pro b/old/tests/qtuitest/testapps/testapp3/testapp3.pro
new file mode 100644
index 0000000..07ae95a
--- /dev/null
+++ b/old/tests/qtuitest/testapps/testapp3/testapp3.pro
@@ -0,0 +1,25 @@
+SOURCES*=main.cpp
+TEMPLATE=app
+unix:!maemo* {
+ # avoid the need for make install on *nix
+ DESTDIR=$$BUILDROOT/bin
+}
+
+symbian {
+ TARGET.EPOCALLOWDLLDATA=1
+ TARGET.CAPABILITY += AllFiles ReadDeviceData ReadUserData SwEvent WriteUserData NetworkServices
+}
+
+win32 {
+ target.path=$$INSTALLROOT
+ INSTALLS+=target
+}
+
+mac {
+ CONFIG-=app_bundle
+}
+
+maemo5|maemo6 {
+ target.path = /usr/local/lib
+ INSTALLS += target
+}
diff --git a/old/tests/qtuitest/testapps/testapp4/main.cpp b/old/tests/qtuitest/testapps/testapp4/main.cpp
new file mode 100644
index 0000000..5882949
--- /dev/null
+++ b/old/tests/qtuitest/testapps/testapp4/main.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** 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 <QtCore>
+
+class TestWidget : public QWidget
+{
+Q_OBJECT
+public:
+ TestWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
+private slots:
+ void setupWidgets();
+};
+#include "main.moc"
+
+TestWidget::TestWidget(QWidget *parent, Qt::WindowFlags f)
+ : QWidget(parent,f)
+{
+ setWindowTitle("testapp4");
+ QTimer::singleShot(0, this, SLOT(setupWidgets()));
+}
+
+void TestWidget::setupWidgets() {
+
+ QTabWidget* tw = new QTabWidget;
+ QPushButton* tab1 = new QPushButton("A Button", this);
+ QPushButton* tab2 = new QPushButton("A Nother Button", this);
+
+ tw->addTab(tab1, "Thirst");
+ tw->addTab(tab2, "Sekond");
+
+ QLineEdit* le = new QLineEdit;
+
+ QFormLayout* form = new QFormLayout;
+ form->addRow("Thing", le);
+ form->addRow(tw);
+
+ setLayout(form);
+
+ le->setFocus();
+}
+
+int main(int argc, char** argv)
+{
+ QApplication app(argc, argv);
+ TestWidget tw;
+ tw.resize(640,480);
+ tw.show();
+ return app.exec();
+}
+
diff --git a/old/tests/qtuitest/testapps/testapp4/testapp4.pro b/old/tests/qtuitest/testapps/testapp4/testapp4.pro
new file mode 100644
index 0000000..07ae95a
--- /dev/null
+++ b/old/tests/qtuitest/testapps/testapp4/testapp4.pro
@@ -0,0 +1,25 @@
+SOURCES*=main.cpp
+TEMPLATE=app
+unix:!maemo* {
+ # avoid the need for make install on *nix
+ DESTDIR=$$BUILDROOT/bin
+}
+
+symbian {
+ TARGET.EPOCALLOWDLLDATA=1
+ TARGET.CAPABILITY += AllFiles ReadDeviceData ReadUserData SwEvent WriteUserData NetworkServices
+}
+
+win32 {
+ target.path=$$INSTALLROOT
+ INSTALLS+=target
+}
+
+mac {
+ CONFIG-=app_bundle
+}
+
+maemo5|maemo6 {
+ target.path = /usr/local/lib
+ INSTALLS += target
+}
diff --git a/old/tests/qtuitest/testapps/testapps.pro b/old/tests/qtuitest/testapps/testapps.pro
new file mode 100644
index 0000000..13079d1
--- /dev/null
+++ b/old/tests/qtuitest/testapps/testapps.pro
@@ -0,0 +1,8 @@
+TEMPLATE=subdirs
+SUBDIRS+= \
+ testapp1 \
+ testapp2 \
+ testapp3 \
+ testapp4 \
+ graphicsViewTest \
+ fileDialogSaveApp
diff --git a/old/tests/qtuitest/tst_qalternatestack/tst_qalternatestack.cpp b/old/tests/qtuitest/tst_qalternatestack/tst_qalternatestack.cpp
new file mode 100644
index 0000000..7b4e745
--- /dev/null
+++ b/old/tests/qtuitest/tst_qalternatestack/tst_qalternatestack.cpp
@@ -0,0 +1,418 @@
+/****************************************************************************
+**
+** 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 <QTest>
+#include <QObject>
+#include <qalternatestack_p.h>
+#include <QCoreApplication>
+//#include <shared/qtopiaunittest.h>
+
+#ifdef Q_OS_UNIX
+#include <signal.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <string.h>
+#include <errno.h>
+#endif
+
+//TESTED_COMPONENT=QA: Testing Framework (18707)
+
+class tst_QAlternateStack : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void start();
+ void switching();
+
+ void init();
+
+ void sigaltstack();
+
+ void multipleInstances();
+
+private:
+ static void stack_entry(QAlternateStack*, QVariant const&);
+
+ static void stack_entry1(QAlternateStack*, QVariant const&);
+ static void stack_entry2(QAlternateStack*, QVariant const&);
+ static void stack_entry3(QAlternateStack*, QVariant const&);
+ static void stack_entry4(QAlternateStack*, QVariant const&);
+ static void stack_entry_handler(QAlternateStack*,QVariant const&,int);
+
+ int m_shouldSwitchFrom;
+
+ QAlternateStack* m_stack;
+ QVariant m_data;
+ bool m_isActive;
+ bool m_isCurrentStack;
+
+ QList<QPair<int,QAlternateStack*> > m_stackEntries;
+};
+
+class tst_QAlternateStackWithStackBuffer : public tst_QAlternateStack
+{
+ Q_OBJECT
+};
+
+#ifdef Q_OS_UNIX
+extern char*& qalternatestack_stackbuf();
+extern int& qalternatestack_stackbuf_len();
+#endif
+
+int main(int argc, char** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ int ret = 0;
+
+ // First, test the regular heap-allocated alternate stack.
+ {
+ tst_QAlternateStack test;
+ ret += QTest::qExec(&test, argc, argv);
+ }
+
+#ifdef Q_OS_UNIX
+ // Now try using memory allocated from the main stack only.
+ {
+ char buf[65536*4];
+ qalternatestack_stackbuf() = buf;
+ qalternatestack_stackbuf_len() = 256*1024;
+ tst_QAlternateStackWithStackBuffer test;
+ ret += QTest::qExec(&test, argc, argv);
+ }
+#endif
+
+ return ret;
+}
+
+void tst_QAlternateStack::stack_entry(QAlternateStack* stack, QVariant const& data)
+{
+ QVariantList list = data.toList();
+ if (!list.count()) return;
+ if (!stack) return;
+
+ tst_QAlternateStack* test = qobject_cast<tst_QAlternateStack*>(list.at(0).value<QObject*>());
+ if (!test) return;
+
+ test->m_stack = stack;
+ test->m_data = data;
+ test->m_isActive = stack->isActive();
+ test->m_isCurrentStack = stack->isCurrentStack();
+
+ for (; test->m_shouldSwitchFrom > 0; --test->m_shouldSwitchFrom) {
+ stack->switchFrom();
+ test->m_isActive = stack->isActive();
+ test->m_isCurrentStack = stack->isCurrentStack();
+ }
+}
+
+void tst_QAlternateStack::stack_entry1(QAlternateStack* stack, QVariant const& data)
+{ stack_entry_handler(stack, data, 1); }
+void tst_QAlternateStack::stack_entry2(QAlternateStack* stack, QVariant const& data)
+{ stack_entry_handler(stack, data, 2); }
+void tst_QAlternateStack::stack_entry3(QAlternateStack* stack, QVariant const& data)
+{ stack_entry_handler(stack, data, 3); }
+void tst_QAlternateStack::stack_entry4(QAlternateStack* stack, QVariant const& data)
+{ stack_entry_handler(stack, data, 4); }
+
+void tst_QAlternateStack::stack_entry_handler(QAlternateStack* stack, QVariant const& data, int number)
+{
+ QVariantList list = data.toList();
+ if (!list.count()) return;
+
+ tst_QAlternateStack* test = qobject_cast<tst_QAlternateStack*>(list.at(0).value<QObject*>());
+ if (!test) return;
+
+ test->m_stackEntries << qMakePair(number, stack);
+ test->m_stack = stack;
+ test->m_isActive = stack->isActive();
+ test->m_isCurrentStack = stack->isCurrentStack();
+
+ // It is possible we've been called on a stack which overlaps some other memory.
+ // When this happens, try to increase the chances of causing a crash by corrupting memory.
+ static const int LEN = 32768;
+ char buf[LEN];
+ for (int i = 0; i < LEN; i += 4) {
+ buf[i] = 0xDE;
+ buf[i+1] = 0xAD;
+ buf[i+2] = 0xBE;
+ buf[i+3] = 0xEF;
+ }
+ // Make sure compiler doesn't optimize it out
+ qChecksum(buf, LEN);
+}
+
+/*
+ \req QTOPIA-78
+
+ \groups
+*/
+void tst_QAlternateStack::start()
+{
+ if (!QAlternateStack::isAvailable()) {
+ QSKIP("QAlternateStack is not available on this platform.", SkipAll);
+ }
+
+ QAlternateStack stack;
+
+ QCOMPARE(stack.isActive(), false);
+ QCOMPARE(stack.isCurrentStack(), false);
+
+ QVariantList list;
+ list.append( qVariantFromValue((QObject*)this) );
+
+ // Switch to the stack...
+ stack.start(tst_QAlternateStack::stack_entry, list);
+ // ... it should have returned almost immediately.
+
+ // Check that our private members were set to the expected values.
+ QCOMPARE(m_stack, &stack);
+ QCOMPARE(m_data, qVariantFromValue(list));
+ QCOMPARE(m_isActive, true);
+ QCOMPARE(m_isCurrentStack, true);
+
+ QCOMPARE(stack.isActive(), false);
+ QCOMPARE(stack.isCurrentStack(), false);
+}
+
+/*
+ \req QTOPIA-78
+
+ \groups
+*/
+void tst_QAlternateStack::switching()
+{
+ if (!QAlternateStack::isAvailable()) {
+ QSKIP("QAlternateStack is not available on this platform.", SkipAll);
+ }
+
+ QAlternateStack stack;
+
+ QCOMPARE(stack.isActive(), false);
+ QCOMPARE(stack.isCurrentStack(), false);
+
+ QVariantList list;
+ list.append( qVariantFromValue((QObject*)this) );
+
+ // Set it up so the alternate stack calls switchFrom() several times.
+ const int switchCount = 5;
+ m_shouldSwitchFrom = switchCount;
+
+ stack.start(tst_QAlternateStack::stack_entry, list);
+
+ for (int i = switchCount; i > 0; --i) {
+ // Check that our private members were set to the expected values.
+ QCOMPARE(m_stack, &stack);
+ QCOMPARE(m_data, qVariantFromValue(list));
+ QCOMPARE(m_isActive, true);
+ QCOMPARE(m_isCurrentStack, true);
+
+ QCOMPARE(m_shouldSwitchFrom, i);
+
+ // Still active, since we switched using switchFrom().
+ QCOMPARE(stack.isActive(), true);
+ QCOMPARE(stack.isCurrentStack(), false);
+
+ // Switch to the stack...
+ stack.switchTo();
+ }
+
+ // No longer active.
+ QCOMPARE(m_shouldSwitchFrom, 0);
+ QCOMPARE(stack.isActive(), false);
+ QCOMPARE(stack.isCurrentStack(), false);
+}
+
+char* addressof_dummy;
+int got_signal;
+
+void test_sighandler(int signum)
+{
+ got_signal = signum;
+
+ int dummy = 1;
+ addressof_dummy = (char*)&dummy;
+}
+
+/*
+ \req QTOPIA-78
+
+ \groups
+
+ Tests that sigaltstack() actually works on the target platform.
+
+ On some platforms, like the Greenphone, sigaltstack seems to be broken
+ and always causes a segfault. When porting QtUitest to a new platform,
+ run this testfunction to make sure QAlternateStack will work properly.
+*/
+void tst_QAlternateStack::sigaltstack()
+{
+#ifdef Q_OS_UNIX
+ // isAvailable() returns false on platforms where sigaltstack is known
+ // to be broken.
+ if (!QAlternateStack::isAvailable()) {
+ QSKIP("QAlternateStack is not available on this platform.", SkipAll);
+ }
+ QByteArray buffer;
+ buffer.resize(SIGSTKSZ);
+
+ stack_t stack;
+ stack.ss_sp = (qalternatestack_stackbuf() ? qalternatestack_stackbuf() : buffer.data());
+ stack.ss_size = SIGSTKSZ;
+ stack.ss_flags = 0;
+
+ QVERIFY( 0 == ::sigaltstack(&stack, 0) );
+
+ stack_t newstack;
+ QVERIFY( 0 == ::sigaltstack(0, &newstack) );
+ QVERIFY(stack.ss_sp == newstack.ss_sp);
+ QVERIFY(stack.ss_size == newstack.ss_size);
+ QVERIFY(stack.ss_flags == newstack.ss_flags);
+
+ struct sigaction action;
+ action.sa_handler = test_sighandler;
+ action.sa_flags = SA_ONSTACK;
+ sigemptyset(&action.sa_mask);
+
+ QVERIFY2( 0 == sigaction(SIGUSR2, &action, 0), strerror(errno) );
+
+ struct sigaction newaction;
+ QVERIFY2( 0 == sigaction(SIGUSR2,0,&newaction), strerror(errno) );
+ QVERIFY(newaction.sa_handler == action.sa_handler);
+ QVERIFY(newaction.sa_flags & SA_ONSTACK);
+
+ addressof_dummy = 0;
+ got_signal = 0;
+ //qLog(Autotest) << "About to raise";
+
+ // Greenphone crashes here.
+ raise(SIGUSR2);
+
+ QCOMPARE(got_signal, SIGUSR2);
+ //qLog(Autotest) << "dummy:" << (void*)addressof_dummy << "stack:" << stack.ss_sp;
+ QVERIFY( (addressof_dummy > (char*)stack.ss_sp) && (addressof_dummy < (char*)stack.ss_sp + stack.ss_size) );
+#else
+ QSKIP("Test not valid on this platform", SkipAll);
+#endif
+}
+
+void tst_QAlternateStack::multipleInstances()
+{
+ if (!QAlternateStack::isAvailable()) {
+ QSKIP("QAlternateStack is not available on this platform.", SkipAll);
+ }
+
+ QVariantList list;
+ list.append( qVariantFromValue((QObject*)this) );
+
+ QAlternateStack stack1;
+ QAlternateStack stack2;
+ QAlternateStack stack3;
+ QAlternateStack stack4;
+
+ QList<QAlternateStack*> stacks;
+ stacks << &stack1 << &stack2 << &stack3 << &stack4;
+
+ // Verify the usual stack functions work as expected.
+ foreach (QAlternateStack* stack, stacks) {
+ m_stack = 0;
+ m_isActive = false;
+ m_isCurrentStack = false;
+ QVERIFY(!stack->isActive());
+ QVERIFY(!stack->isCurrentStack());
+
+ stack->start(stack_entry1, list);
+
+ QCOMPARE(m_stack, stack);
+ QVERIFY(m_isActive);
+ QVERIFY(m_isCurrentStack);
+ QVERIFY(!stack->isActive());
+ QVERIFY(!stack->isCurrentStack());
+ }
+
+ {
+ QList<QPair<int,QAlternateStack*> > expected;
+ expected
+ << qMakePair(1, &stack1)
+ << qMakePair(1, &stack2)
+ << qMakePair(1, &stack3)
+ << qMakePair(1, &stack4)
+ ;
+ QCOMPARE(m_stackEntries, expected);
+ m_stackEntries.clear();
+ }
+
+ // Verify the correct functions all get called as expected.
+ stack1.start(stack_entry1, list);
+ stack4.start(stack_entry4, list);
+ stack2.start(stack_entry2, list);
+ stack3.start(stack_entry3, list);
+ stack1.start(stack_entry1, list);
+ stack4.start(stack_entry4, list);
+ stack3.start(stack_entry3, list);
+
+ {
+ QList<QPair<int,QAlternateStack*> > expected;
+ expected
+ << qMakePair(1, &stack1)
+ << qMakePair(4, &stack4)
+ << qMakePair(2, &stack2)
+ << qMakePair(3, &stack3)
+ << qMakePair(1, &stack1)
+ << qMakePair(4, &stack4)
+ << qMakePair(3, &stack3)
+ ;
+
+ QCOMPARE(m_stackEntries, expected);
+ }
+}
+
+void tst_QAlternateStack::init()
+{
+ m_shouldSwitchFrom = 0;
+ m_stack = 0;
+ m_data = QVariant();
+ m_isActive = false;
+ m_isCurrentStack = false;
+}
+
+#include "tst_qalternatestack.moc"
diff --git a/old/tests/qtuitest/tst_qalternatestack/tst_qalternatestack.pro b/old/tests/qtuitest/tst_qalternatestack/tst_qalternatestack.pro
new file mode 100644
index 0000000..ef73695
--- /dev/null
+++ b/old/tests/qtuitest/tst_qalternatestack/tst_qalternatestack.pro
@@ -0,0 +1,19 @@
+TEMPLATE=app
+CONFIG+=unittest
+QT = core
+TARGET=tst_qalternatestack
+CONFIG += qtestlib
+
+CONFIG-=debug_and_release_target
+
+SOURCES+= \
+ tst_qalternatestack.cpp
+
+include($$SRCROOT/libqtuitest/libqtuitest.pri)
+
+
+target.path += \
+ /usr/local/bin
+
+INSTALLS += \
+ target \ No newline at end of file
diff --git a/old/tests/qtuitest/tst_qelapsedtimer/tst_qelapsedtimer.cpp b/old/tests/qtuitest/tst_qelapsedtimer/tst_qelapsedtimer.cpp
new file mode 100644
index 0000000..feb2b56
--- /dev/null
+++ b/old/tests/qtuitest/tst_qelapsedtimer/tst_qelapsedtimer.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 <QTest>
+#include <QObject>
+#include <qtuitestelapsedtimer_p.h>
+
+//TESTED_COMPONENT=QA: Testing Framework (18707)
+
+class tst_QElapsedTimer : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void elapsed();
+};
+
+QTEST_MAIN(tst_QElapsedTimer)
+
+/*
+ \req QTOPIA-78
+
+ \groups
+*/
+void tst_QElapsedTimer::elapsed()
+{
+ QtUiTestElapsedTimer et;
+ et.start();
+
+ // Allow a lot of latency so the test doesn't break when the
+ // machine is under extreme load.
+ QVERIFY(et.elapsed() <= 1000);
+
+ QTest::qWait(5000);
+
+ QVERIFY(et.elapsed() >= 5000);
+ QVERIFY(et.elapsed() <= 30000);
+}
+
+#include "tst_qelapsedtimer.moc"
diff --git a/old/tests/qtuitest/tst_qelapsedtimer/tst_qelapsedtimer.pro b/old/tests/qtuitest/tst_qelapsedtimer/tst_qelapsedtimer.pro
new file mode 100644
index 0000000..a0754d7
--- /dev/null
+++ b/old/tests/qtuitest/tst_qelapsedtimer/tst_qelapsedtimer.pro
@@ -0,0 +1,21 @@
+TEMPLATE=app
+CONFIG+=unittest
+QT = core
+CONFIG+=qtestlib
+
+TARGET=tst_qelapsedtimer
+
+CONFIG-=debug_and_release_target
+
+SOURCES+= \
+ tst_qelapsedtimer.cpp
+
+include($$SRCROOT/libqtuitest/libqtuitest.pri)
+
+
+
+target.path += \
+ /usr/local/bin
+
+INSTALLS += \
+ target \ No newline at end of file
diff --git a/old/tests/qtuitest/tst_qinputgenerator/nativeevent.h b/old/tests/qtuitest/tst_qinputgenerator/nativeevent.h
new file mode 100644
index 0000000..f3b95ef
--- /dev/null
+++ b/old/tests/qtuitest/tst_qinputgenerator/nativeevent.h
@@ -0,0 +1,19 @@
+#ifndef NATIVEEVENT_H
+#define NATIVEEVENT_H
+
+#include <QList>
+#include <QPair>
+#include <QString>
+
+struct NativeEvent
+{
+ NativeEvent(void*);
+
+ static bool isInteresting(void*);
+
+ QString type;
+ QList<QPair<QString,QString> > things;
+};
+
+#endif
+
diff --git a/old/tests/qtuitest/tst_qinputgenerator/nativeevent_noop.cpp b/old/tests/qtuitest/tst_qinputgenerator/nativeevent_noop.cpp
new file mode 100644
index 0000000..411f2d4
--- /dev/null
+++ b/old/tests/qtuitest/tst_qinputgenerator/nativeevent_noop.cpp
@@ -0,0 +1,17 @@
+#include "nativeevent.h"
+
+NativeEvent::NativeEvent(void*)
+{}
+
+bool NativeEvent::isInteresting(void*)
+{
+ static bool warned = false;
+ if (!warned) {
+ warned = true;
+ qWarning("Don't understand native events, only logging Qt events.");
+ }
+
+ return false;
+}
+
+
diff --git a/old/tests/qtuitest/tst_qinputgenerator/nativeevent_x11.cpp b/old/tests/qtuitest/tst_qinputgenerator/nativeevent_x11.cpp
new file mode 100644
index 0000000..fc53441
--- /dev/null
+++ b/old/tests/qtuitest/tst_qinputgenerator/nativeevent_x11.cpp
@@ -0,0 +1,85 @@
+#include "nativeevent.h"
+
+#include <X11/Xlib.h>
+
+template <typename T>
+QString hexstr(T const& thing)
+{ return QString("0x%1").arg(thing, 8, 16, QLatin1Char('0')); }
+
+NativeEvent::NativeEvent(void* event)
+{
+ XEvent* e = static_cast<XEvent*>(event);
+
+#define GET_COMMON_THINGS(event) \
+ things << qMakePair(QString("serial"), hexstr(event->serial)); \
+ things << qMakePair(QString("send_event"), QString::number(event->send_event)); \
+ things << qMakePair(QString("x"), QString::number(event->x)); \
+ things << qMakePair(QString("y"), QString::number(event->y)); \
+ things << qMakePair(QString("x_root"), QString::number(event->x_root)); \
+ things << qMakePair(QString("y_root"), QString::number(event->y_root)); \
+ things << qMakePair(QString("state"), hexstr(event->state)); \
+ things << qMakePair(QString("same_screen"),QString("%1").arg(event->same_screen));
+
+ switch (e->type) {
+ case KeyPress:
+ case KeyRelease: {
+ if (e->type == KeyPress) type = "XKeyPressedEvent";
+ if (e->type == KeyRelease) type = "XKeyReleasedEvent";
+ XKeyEvent* xe = static_cast<XKeyEvent*>(event);
+ things << qMakePair(QString("keycode"), hexstr(xe->keycode));
+ GET_COMMON_THINGS(xe); }
+ break;
+
+ case ButtonPress:
+ case ButtonRelease: {
+ if (e->type == ButtonPress) type = "XButtonPressedEvent";
+ if (e->type == ButtonRelease) type = "XButtonReleasedEvent";
+ XButtonEvent* xe = static_cast<XButtonEvent*>(event);
+ things << qMakePair(QString("button"), hexstr(xe->button));
+ GET_COMMON_THINGS(xe); }
+ break;
+
+ case MotionNotify: {
+ type = "XMotionEvent";
+ XMotionEvent* xe = static_cast<XMotionEvent*>(event);
+ GET_COMMON_THINGS(xe); }
+ break;
+
+ case EnterNotify:
+ case LeaveNotify: {
+ if (e->type == EnterNotify) type = "XEnterWindowEvent";
+ if (e->type == LeaveNotify) type = "XLeaveWindowEvent";
+ XCrossingEvent* xe = static_cast<XCrossingEvent*>(event);
+ things << qMakePair(QString("focus"), QString("%1").arg(xe->focus));
+ GET_COMMON_THINGS(xe); }
+ break;
+
+ default:
+ type = QString("XEvent(type=%1)").arg(e->type);
+ break;
+ }
+}
+
+/* Returns true if the event is related to key or mouse inputs */
+bool NativeEvent::isInteresting(void* event)
+{
+ if (!event) return false;
+
+ XEvent* e = static_cast<XEvent*>(event);
+ switch (e->type) {
+ case KeyPress:
+ case KeyRelease:
+ case ButtonPress:
+ case ButtonRelease:
+ case MotionNotify:
+ case EnterNotify:
+ case LeaveNotify:
+ return true;
+ default:
+ break;
+ }
+
+ return false;
+}
+
+
diff --git a/old/tests/qtuitest/tst_qinputgenerator/tst_qinputgenerator.cpp b/old/tests/qtuitest/tst_qinputgenerator/tst_qinputgenerator.cpp
new file mode 100644
index 0000000..2c7d484
--- /dev/null
+++ b/old/tests/qtuitest/tst_qinputgenerator/tst_qinputgenerator.cpp
@@ -0,0 +1,756 @@
+/****************************************************************************
+**
+** 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 <QAbstractEventDispatcher>
+#include <QDebug>
+#include <QObject>
+#include <QTest>
+#include <qinputgenerator_p.h>
+
+#include "nativeevent.h"
+
+//TESTED_COMPONENT=QA: Testing Framework (18707)
+
+struct TestKeyEvent {
+ enum Type { KeyPress, KeyRelease, KeyClick };
+
+ TestKeyEvent(TestKeyEvent::Type _type, Qt::Key _key, Qt::KeyboardModifiers _modifiers,
+ bool _autorepeat)
+ : type(_type)
+ , key(_key)
+ , modifiers(_modifiers)
+ , autorepeat(_autorepeat)
+ {}
+
+ TestKeyEvent::Type type;
+ Qt::Key key;
+ Qt::KeyboardModifiers modifiers;
+ bool autorepeat;
+};
+
+typedef QList<TestKeyEvent> TestKeyEventList;
+Q_DECLARE_METATYPE(TestKeyEventList);
+
+typedef QList<QKeyEvent> QKeyEventList;
+Q_DECLARE_METATYPE(QKeyEventList);
+
+struct TestMouseEvent {
+ enum Type {
+ MouseButtonPress,
+ MouseButtonRelease,
+ MouseButtonClick
+ };
+
+ TestMouseEvent(TestMouseEvent::Type _type, const QPoint& _pos, Qt::MouseButtons _buttons)
+ : type(_type)
+ , pos(_pos)
+ , buttons(_buttons)
+ {}
+
+ TestMouseEvent::Type type;
+ QPoint pos;
+ Qt::MouseButtons buttons;
+};
+
+typedef QList<TestMouseEvent> TestMouseEventList;
+Q_DECLARE_METATYPE(TestMouseEventList);
+
+typedef QList<QMouseEvent> QMouseEventList;
+Q_DECLARE_METATYPE(QMouseEventList);
+
+QString toString(QKeyEvent const& e)
+{
+ QString out;
+ out += (e.type() == QEvent::KeyPress) ? "press" : "release";
+ out += ", " + QString("key:0x%1").arg(e.key(),8,16,QLatin1Char('0'));
+ out += "," + QString("modifiers:0x%1").arg(e.modifiers(),8,16,QLatin1Char('0'));
+ out += "," + QString("isAutoRepeat:%1").arg(e.isAutoRepeat());
+ out += "," + QString("nativeModifiers:0x%1").arg(e.nativeModifiers(),8,16,QLatin1Char('0'));
+ out += "," + QString("nativeScanCode:0x%1").arg(e.nativeScanCode(),8,16,QLatin1Char('0'));
+ out += "," + QString("nativeVirtualKey:0x%1").arg(e.nativeVirtualKey(),8,16,QLatin1Char('0'));
+ out += ",text:" + e.text();
+ /*
+ Only check count if it has some text.
+ When doing a 'Shift' key or similar, whether or not there's a count depends on
+ the platform, so we'll treat it as undefined.
+ */
+ if (!e.text().isEmpty())
+ out += "," + QString("count:%1").arg(e.count());
+ return out;
+}
+
+QString toString(QKeyEventList const& l)
+{
+ QString out;
+ QString sep = " ";
+ for (int i = 0; i < l.count(); ++i) {
+ out += sep + toString(l.at(i));
+ sep = "\n ";
+ }
+ return out;
+}
+
+QString toString(QPoint const& p)
+{
+ return QString("(%1,%2)").arg(p.x()).arg(p.y());
+}
+
+QString toString(Qt::MouseButton b)
+{
+ switch (b) {
+ case Qt::NoButton:
+ return "0";
+ case Qt::LeftButton:
+ return "left";
+ case Qt::RightButton:
+ return "right";
+ case Qt::MidButton:
+ return "mid";
+ case Qt::XButton1:
+ return "xbutton1";
+ case Qt::XButton2:
+ return "xbutton2";
+ default:
+ return QString("0x%1").arg(b, 8, 16, QLatin1Char('0'));
+ }
+}
+
+QString toString(Qt::MouseButtons b)
+{
+ QString out;
+ if (!b || (b & (~Qt::MouseButtonMask))) {
+ out = QString("0x%1").arg(b,8,16,QLatin1Char('0'));
+ }
+ else {
+ static const Qt::MouseButton AllButtons[] = {
+ Qt::LeftButton,
+ Qt::RightButton,
+ Qt::MidButton,
+ Qt::XButton1,
+ Qt::XButton2
+ };
+ QString sep;
+ for (unsigned int i = 0; i < sizeof(AllButtons)/sizeof(AllButtons[0]); ++i) {
+ if (b & AllButtons[i]) {
+ out += sep + toString(Qt::MouseButton((int)(b & AllButtons[i])));
+ sep = "|";
+ }
+ }
+ }
+ return out;
+}
+
+QString toString(QMouseEvent const& e)
+{
+ QString out;
+ switch (e.type()) {
+ case QEvent::MouseButtonPress:
+ out += "press";
+ break;
+ case QEvent::MouseButtonRelease:
+ out += "release";
+ break;
+ case QEvent::MouseButtonDblClick:
+ out += "doubleclick";
+ break;
+ case QEvent::MouseMove:
+ out += "move";
+ break;
+ default:
+ out += "unknown_type";
+ }
+ out += ", "+ QString("pos:%1").arg(toString(e.pos()));
+ out += "," + QString("globalPos:%1").arg(toString(e.globalPos()));
+ out += "," + QString("button:%1").arg(toString(e.button()));
+ out += "," + QString("buttons:%1").arg(toString(e.buttons()));
+ out += "," + QString("modifiers:0x%1").arg(e.modifiers(),8,16,QLatin1Char('0'));
+ return out;
+}
+
+QString toString(QMouseEventList const& l)
+{
+ QString out;
+ QString sep = " ";
+ for (int i = 0; i < l.count(); ++i) {
+ out += sep + toString(l.at(i));
+ sep = "\n ";
+ }
+ return out;
+}
+
+QString toString(NativeEvent const& e)
+{
+ QString out;
+ out += e.type;
+
+ QString sep = " ";
+ typedef QPair<QString,QString> StringPair;
+ foreach (StringPair const& p, e.things) {
+ out += sep + p.first + ":" + p.second;
+ sep = ",";
+ }
+
+ return out;
+}
+
+namespace QTest {
+template<>
+inline bool qCompare(QKeyEvent const &e1, QKeyEvent const &e2,
+ const char* actual, const char* expected, const char* file, int line)
+{
+ return qCompare(toString(e1), toString(e2), actual, expected, file, line);
+}
+template<>
+inline bool qCompare(QMouseEvent const &e1, QMouseEvent const &e2,
+ const char* actual, const char* expected, const char* file, int line)
+{
+ return qCompare(toString(e1), toString(e2), actual, expected, file, line);
+}
+}
+
+
+class tst_QInputGenerator : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QInputGenerator();
+ void eventTest();
+
+private slots:
+ void keyEvent();
+ void keyEvent_data();
+ void mouseEvent();
+ void mouseEvent_data();
+ void initTestCase();
+ void init();
+
+private:
+ template <typename T>
+ bool waitForCount(QList<T> const* list, int howmany, int timeout = 5000);
+ bool eventFilter(QObject*, QEvent*);
+ template <typename T1, typename T2>
+ static void dumpEvents(QList<T1> const& actual, QList<T2> const& expected);
+ static bool nativeEventFilter(void* event);
+
+private:
+ QList<QKeyEvent> m_keyEvents;
+ QList<QMouseEvent> m_mouseEvents;
+ QEventLoop* m_eventTestLoop;
+ QTime m_eventTestTime;
+ static tst_QInputGenerator* s_eventTestInstance;
+};
+tst_QInputGenerator* tst_QInputGenerator::s_eventTestInstance = 0;
+
+tst_QInputGenerator::tst_QInputGenerator()
+ : QObject()
+ , m_keyEvents()
+ , m_mouseEvents()
+ , m_eventTestLoop(0)
+ , m_eventTestTime()
+{
+}
+
+void tst_QInputGenerator::initTestCase()
+{
+ qApp->installEventFilter(this);
+}
+
+void tst_QInputGenerator::init()
+{
+ m_keyEvents.clear();
+ m_mouseEvents.clear();
+}
+
+void tst_QInputGenerator::keyEvent()
+{
+ QFETCH(TestKeyEventList, testEvents);
+ QFETCH(QKeyEventList, qtEvents);
+
+ QWidget w;
+ w.setFocus();
+ w.setFixedSize(1024, 768);
+ w.show();
+
+ QInputGenerator input;
+
+ /* Simulate all test events. */
+ while (testEvents.count()) {
+ TestKeyEvent next = testEvents.takeFirst();
+
+ if (next.type == TestKeyEvent::KeyPress) {
+ input.keyPress(next.key, next.modifiers, next.autorepeat);
+ }
+ else if (next.type == TestKeyEvent::KeyRelease) {
+ input.keyRelease(next.key, next.modifiers);
+ }
+ else if (next.type == TestKeyEvent::KeyClick) {
+ input.keyClick(next.key, next.modifiers);
+ }
+ }
+
+ /* Wait until we get the expected amount of qt events. */
+ if (m_keyEvents.count() < qtEvents.count()) {
+ bool waited = waitForCount(&m_keyEvents, qtEvents.count());
+ if (!waited) {
+ dumpEvents(m_keyEvents, qtEvents);
+ }
+ QVERIFY2(waited, qPrintable(QString("Expected %1 QKeyEvent(s) but got %2").arg(qtEvents.count()).arg(m_keyEvents.count())));
+ }
+
+ /* Compare actual qt events with expected. */
+ for (int i = 0; i < qtEvents.count(); ++i) {
+ const QKeyEvent& actual = m_keyEvents[i];
+ const QKeyEvent& expected = qtEvents[i];
+ if (!QTest::qCompare(actual, expected, "actual", "expected", __FILE__, __LINE__)) {
+ dumpEvents(m_keyEvents, qtEvents);
+ return;
+ }
+ }
+}
+
+void tst_QInputGenerator::keyEvent_data()
+{
+ QTest::addColumn<TestKeyEventList>("testEvents");
+ QTest::addColumn<QKeyEventList> ("qtEvents");
+
+ /* Make event definition a little less verbose... */
+#define TE(Type,K,Mod,Repeat) TestKeyEvent(TestKeyEvent::Key##Type, Qt::Key_##K, Mod, Repeat)
+#define QE(Type,K,Mod,Text,Repeat,Count) QKeyEvent(QEvent::Key##Type, Qt::Key_##K, Mod, QLatin1String(Text), Repeat, Count)
+ QTest::newRow("a (press only)")
+ << (TestKeyEventList() << TE(Press, A, 0, false))
+ << (QKeyEventList() << QE(Press, A, 0, "a", false, 1))
+ ;
+ QTest::newRow("a (release only)")
+ << (TestKeyEventList() << TE(Release, A, 0, false))
+ << (QKeyEventList() << QE(Release, A, 0, "a", false, 1))
+ ;
+ QTest::newRow("autorepeat b")
+ << (TestKeyEventList()
+ << TE(Press, B, 0, false)
+ /*
+ << TE(Press, B, 0, true)
+ << TE(Press, B, 0, true)
+ << TE(Press, B, 0, true)
+ << TE(Press, B, 0, true)
+ << TE(Press, B, 0, true)
+ */
+ << TE(Release, B, 0, false)
+
+ )
+ << (QKeyEventList()
+ << QE(Press, B, 0, "b", false, 1)
+ /*
+ << QE(Press, B, 0, "b", true, 1)
+ << QE(Press, B, 0, "b", true, 1)
+ << QE(Press, B, 0, "b", true, 1)
+ << QE(Press, B, 0, "b", true, 1)
+ << QE(Press, B, 0, "b", true, 1)
+ */
+ << QE(Release, B, 0, "b", false, 1)
+ )
+ ;
+ QTest::newRow("dog")
+ << (TestKeyEventList()
+ << TE(Click, D, 0, false)
+ << TE(Click, O, 0, false)
+ << TE(Click, G, 0, false)
+ )
+ << (QKeyEventList()
+ << QE(Press, D, 0, "d", false, 1) << QE(Release, D, 0, "d", false, 1)
+ << QE(Press, O, 0, "o", false, 1) << QE(Release, O, 0, "o", false, 1)
+ << QE(Press, G, 0, "g", false, 1) << QE(Release, G, 0, "g", false, 1)
+ )
+ ;
+ QTest::newRow("mIXEd caSE")
+ << (TestKeyEventList()
+ << TE(Click, M, 0, false)
+ << TE(Click, I, Qt::ShiftModifier, false)
+ << TE(Click, X, Qt::ShiftModifier, false)
+ << TE(Click, E, Qt::ShiftModifier, false)
+ << TE(Click, D, 0, false)
+ << TE(Click, Space, 0, false)
+ << TE(Click, C, 0, false)
+ << TE(Click, A, 0, false)
+ << TE(Click, S, Qt::ShiftModifier, false)
+ << TE(Click, E, Qt::ShiftModifier, false)
+ )
+ << (QKeyEventList()
+ << QE(Press, M, 0, "m", false, 1) << QE(Release, M, 0, "m", false, 1)
+ << QE(Press, Shift, 0, "", false, 0)
+ << QE(Press, I, Qt::ShiftModifier, "I", false, 1) << QE(Release, I, Qt::ShiftModifier, "I", false, 1)
+ << QE(Press, X, Qt::ShiftModifier, "X", false, 1) << QE(Release, X, Qt::ShiftModifier, "X", false, 1)
+ << QE(Press, E, Qt::ShiftModifier, "E", false, 1) << QE(Release, E, Qt::ShiftModifier, "E", false, 1)
+ << QE(Release, Shift, Qt::ShiftModifier, "", false, 0)
+ << QE(Press, D, 0, "d", false, 1) << QE(Release, D, 0, "d", false, 1)
+ << QE(Press, Space, 0, " ", false, 1) << QE(Release, Space, 0, " ", false, 1)
+ << QE(Press, C, 0, "c", false, 1) << QE(Release, C, 0, "c", false, 1)
+ << QE(Press, A, 0, "a", false, 1) << QE(Release, A, 0, "a", false, 1)
+ << QE(Press, Shift, 0, "", false, 0)
+ << QE(Press, S, Qt::ShiftModifier, "S", false, 1) << QE(Release, S, Qt::ShiftModifier, "S", false, 1)
+ << QE(Press, E, Qt::ShiftModifier, "E", false, 1) << QE(Release, E, Qt::ShiftModifier, "E", false, 1)
+ )
+ ;
+#undef TE
+#undef QE
+}
+
+void tst_QInputGenerator::mouseEvent()
+{
+ QFETCH(TestMouseEventList, testEvents);
+ QFETCH(QMouseEventList, qtEvents);
+
+ QWidget w1(0, Qt::FramelessWindowHint);
+ w1.setFocus();
+ w1.setGeometry(0, 0, 100, 100);
+ w1.setMouseTracking(false);
+ w1.show();
+
+ QWidget w2(0, Qt::FramelessWindowHint);
+ w2.setFocus();
+ w2.setGeometry(100, 0, 100, 100);
+ w2.setMouseTracking(false);
+ w2.show();
+
+ QWidget w3(0, Qt::FramelessWindowHint);
+ w3.setFocus();
+ w3.setGeometry(0, 100, 100, 100);
+ w3.setMouseTracking(false);
+ w3.show();
+
+ QWidget w4(0, Qt::FramelessWindowHint);
+ w4.setFocus();
+ w4.setGeometry(100, 100, 100, 100);
+ w4.setMouseTracking(false);
+ w4.show();
+
+ /* Make sure we go slow enough to avoid accidental double clicks */
+ int dblclick = qApp->doubleClickInterval();
+ QTest::qWait(dblclick);
+
+ QInputGenerator input;
+
+ /* Simulate all test events. */
+ while (testEvents.count()) {
+ TestMouseEvent next = testEvents.takeFirst();
+
+ if (next.type == TestMouseEvent::MouseButtonPress) {
+ input.mousePress(next.pos, next.buttons);
+ }
+ else if (next.type == TestMouseEvent::MouseButtonRelease) {
+ input.mouseRelease(next.pos, next.buttons);
+ }
+ else if (next.type == TestMouseEvent::MouseButtonClick) {
+ input.mouseClick(next.pos, next.buttons);
+ }
+ }
+
+ /* Wait until we get the expected amount of qt events. */
+ if (m_mouseEvents.count() < qtEvents.count()) {
+ bool waited = waitForCount(&m_mouseEvents, qtEvents.count());
+ if (!waited) {
+ dumpEvents(m_mouseEvents, qtEvents);
+ }
+ QVERIFY2(waited, qPrintable(QString("Expected %1 QMouseEvent(s) but got %2").arg(qtEvents.count()).arg(m_mouseEvents.count())));
+ }
+
+ /* Compare actual qt events with expected. */
+ for (int i = 0; i < qtEvents.count(); ++i) {
+ const QMouseEvent& actual = m_mouseEvents[i];
+ const QMouseEvent& expected = qtEvents[i];
+ if (!QTest::qCompare(actual, expected, "actual", "expected", __FILE__, __LINE__)) {
+ dumpEvents(m_mouseEvents, qtEvents);
+ return;
+ }
+ }
+}
+
+void tst_QInputGenerator::mouseEvent_data()
+{
+ QTest::addColumn<TestMouseEventList>("testEvents");
+ QTest::addColumn<QMouseEventList> ("qtEvents");
+
+ /*
+ To test mapping of global to local positions, 4 widgets are laid out in a 2x2 grid.
+ Each widget is 100x100 in size. The widgets are arranged so they sit exactly in the
+ top left 200x200 of the screen. The widgets are asked to be frameless.
+ */
+
+ /* Make event definition a little less verbose... */
+#define TE(Type,Pos,Buttons) TestMouseEvent(TestMouseEvent::Mouse##Type, Pos, Buttons)
+#define QE(Type,Pos,GlobalPos,Button,Buttons,Mod) QMouseEvent(QEvent::Mouse##Type, Pos, GlobalPos,Qt::MouseButton(Button),Buttons,Mod)
+ QTest::newRow("single left press, tl")
+ << (TestMouseEventList() << TE(ButtonPress, QPoint(50,50), Qt::LeftButton))
+ << (QMouseEventList() << QE(ButtonPress, QPoint(50,50), QPoint(50,50), Qt::LeftButton, Qt::LeftButton, 0))
+ ;
+ QTest::newRow("single left press, tr")
+ << (TestMouseEventList() << TE(ButtonPress, QPoint(150,50), Qt::LeftButton))
+ << (QMouseEventList() << QE(ButtonPress, QPoint(50,50), QPoint(150,50), Qt::LeftButton, Qt::LeftButton, 0))
+ ;
+ QTest::newRow("single left press, bl")
+ << (TestMouseEventList() << TE(ButtonPress, QPoint(25,150), Qt::LeftButton))
+ << (QMouseEventList() << QE(ButtonPress, QPoint(25,50), QPoint(25,150), Qt::LeftButton, Qt::LeftButton, 0))
+ ;
+ QTest::newRow("single left press, br")
+ << (TestMouseEventList() << TE(ButtonPress, QPoint(150,125),Qt::LeftButton))
+ << (QMouseEventList() << QE(ButtonPress, QPoint(50,25), QPoint(150,125),Qt::LeftButton, Qt::LeftButton, 0))
+ ;
+
+ QTest::newRow("single right click, tl")
+ << (TestMouseEventList() << TE(ButtonClick, QPoint(50,50), Qt::RightButton))
+ << (QMouseEventList()
+ << QE(ButtonPress, QPoint(50,50), QPoint(50,50), Qt::RightButton, Qt::RightButton, 0)
+ << QE(ButtonRelease, QPoint(50,50), QPoint(50,50), Qt::RightButton, 0, 0)
+ )
+ ;
+ QTest::newRow("single right click, tr")
+ << (TestMouseEventList() << TE(ButtonClick, QPoint(150,50), Qt::RightButton))
+ << (QMouseEventList()
+ << QE(ButtonPress, QPoint(50,50), QPoint(150,50), Qt::RightButton, Qt::RightButton, 0)
+ << QE(ButtonRelease, QPoint(50,50), QPoint(150,50), Qt::RightButton, 0, 0)
+ )
+ ;
+ QTest::newRow("single right click, bl")
+ << (TestMouseEventList() << TE(ButtonClick, QPoint(25,150), Qt::RightButton))
+ << (QMouseEventList()
+ << QE(ButtonPress, QPoint(25,50), QPoint(25,150), Qt::RightButton, Qt::RightButton, 0)
+ << QE(ButtonRelease, QPoint(25,50), QPoint(25,150), Qt::RightButton, 0, 0)
+ )
+ ;
+ QTest::newRow("single right click, br")
+ << (TestMouseEventList() << TE(ButtonClick, QPoint(150,125),Qt::RightButton))
+ << (QMouseEventList()
+ << QE(ButtonPress, QPoint(50,25), QPoint(150,125), Qt::RightButton, Qt::RightButton, 0)
+ << QE(ButtonRelease, QPoint(50,25), QPoint(150,125), Qt::RightButton, 0, 0)
+ )
+ ;
+
+ QTest::newRow("double middle click")
+ << (TestMouseEventList()
+ << TE(ButtonClick, QPoint(20,30),Qt::MidButton)
+ << TE(ButtonClick, QPoint(20,30),Qt::MidButton)
+ )
+ << (QMouseEventList()
+ << QE(ButtonPress, QPoint(20,30), QPoint(20,30), Qt::MidButton, Qt::MidButton, 0)
+ << QE(ButtonRelease, QPoint(20,30), QPoint(20,30), Qt::MidButton, 0, 0)
+ << QE(ButtonDblClick, QPoint(20,30), QPoint(20,30), Qt::MidButton, Qt::MidButton, 0)
+ << QE(ButtonRelease, QPoint(20,30), QPoint(20,30), Qt::MidButton, 0, 0)
+ )
+ ;
+
+ QTest::newRow("middle drag")
+ << (TestMouseEventList()
+ << TE(ButtonPress, QPoint(20,30),Qt::MidButton)
+ << TE(ButtonPress, QPoint(20,31),Qt::MidButton)
+ << TE(ButtonPress, QPoint(21,32),Qt::MidButton)
+ << TE(ButtonPress, QPoint(21,33),Qt::MidButton)
+ << TE(ButtonPress, QPoint(22,34),Qt::MidButton)
+ << TE(ButtonPress, QPoint(22,35),Qt::MidButton)
+ << TE(ButtonPress, QPoint(23,36),Qt::MidButton)
+ << TE(ButtonPress, QPoint(23,37),Qt::MidButton)
+ << TE(ButtonPress, QPoint(24,38),Qt::MidButton)
+ << TE(ButtonPress, QPoint(24,39),Qt::MidButton)
+ << TE(ButtonRelease, QPoint(25,40),Qt::MidButton)
+ )
+ << (QMouseEventList()
+ << QE(ButtonPress, QPoint(20,30), QPoint(20,30), Qt::MidButton, Qt::MidButton, 0)
+ /* Note, exactly how many move events we expect depends on platform... */
+ << QE(Move, QPoint(25,40), QPoint(25,40), 0, Qt::MidButton, 0)
+ << QE(ButtonRelease, QPoint(25,40), QPoint(25,40), Qt::MidButton, 0, 0)
+ )
+ ;
+
+ QTest::newRow("multiple buttons with shaky hands")
+ << (TestMouseEventList()
+ << TE(ButtonPress, QPoint(110,120),Qt::MidButton)
+ << TE(ButtonPress, QPoint(110,125),Qt::RightButton)
+ << TE(ButtonPress, QPoint(105,105),Qt::LeftButton)
+ << TE(ButtonRelease, QPoint(105,107),Qt::RightButton)
+ << TE(ButtonRelease, QPoint(110,119),Qt::MidButton)
+ << TE(ButtonPress, QPoint(110,112),Qt::RightButton)
+ << TE(ButtonRelease, QPoint(103,102),Qt::LeftButton)
+ << TE(ButtonRelease, QPoint(111,103),Qt::RightButton)
+ )
+ << (QMouseEventList()
+ << QE(ButtonPress, QPoint(10,20),QPoint(110,120), Qt::MidButton, Qt::MidButton, 0)
+
+ << QE(Move, QPoint(10,25),QPoint(110,125), 0, Qt::MidButton, 0)
+ << QE(ButtonPress, QPoint(10,25),QPoint(110,125), Qt::RightButton, Qt::MidButton|Qt::RightButton, 0)
+
+ << QE(Move, QPoint(5,5), QPoint(105,105), 0, Qt::MidButton|Qt::RightButton, 0)
+ << QE(ButtonPress, QPoint(5,5), QPoint(105,105), Qt::LeftButton, Qt::MidButton|Qt::RightButton|Qt::LeftButton, 0)
+
+ << QE(Move, QPoint(5,7), QPoint(105,107), 0, Qt::MidButton|Qt::RightButton|Qt::LeftButton, 0)
+ << QE(ButtonRelease, QPoint(5,7), QPoint(105,107), Qt::RightButton, Qt::MidButton|Qt::LeftButton, 0)
+
+ << QE(Move, QPoint(10,19),QPoint(110,119), 0, Qt::MidButton|Qt::LeftButton, 0)
+ << QE(ButtonRelease, QPoint(10,19),QPoint(110,119), Qt::MidButton, Qt::LeftButton, 0)
+
+ << QE(Move, QPoint(10,12),QPoint(110,112), 0, Qt::LeftButton, 0)
+ << QE(ButtonPress, QPoint(10,12),QPoint(110,112), Qt::RightButton, Qt::LeftButton|Qt::RightButton, 0)
+
+ << QE(Move, QPoint(3,2), QPoint(103,102), 0, Qt::LeftButton|Qt::RightButton, 0)
+ << QE(ButtonRelease, QPoint(3,2), QPoint(103,102), Qt::LeftButton, Qt::RightButton, 0)
+
+ << QE(Move, QPoint(11,3), QPoint(111,103), 0, Qt::RightButton, 0)
+ << QE(ButtonRelease, QPoint(11,3), QPoint(111,103), Qt::RightButton, 0, 0)
+ )
+ ;
+#undef TE
+#undef QE
+}
+
+bool tst_QInputGenerator::nativeEventFilter(void* event)
+{
+ tst_QInputGenerator* that = tst_QInputGenerator::s_eventTestInstance;
+ if (!that || !that->m_eventTestLoop) return false;
+
+ if (NativeEvent::isInteresting(event)) {
+ qDebug() << that->m_eventTestTime.elapsed() << qPrintable(toString(NativeEvent(event)));
+ that->m_eventTestLoop->quit();
+ }
+
+ return false;
+}
+
+void tst_QInputGenerator::eventTest()
+{
+ qApp->installEventFilter(this);
+ QAbstractEventDispatcher* dispatch = QAbstractEventDispatcher::instance();
+ dispatch->setEventFilter(tst_QInputGenerator::nativeEventFilter);
+ tst_QInputGenerator::s_eventTestInstance = this;
+
+ m_eventTestTime.start();
+
+ QWidget w;
+ w.setFixedSize(800,600);
+ w.show();
+
+ QEventLoop loop;
+ m_eventTestLoop = &loop;
+
+ qDebug() << "Running event test; use keyboard/mouse to interact with displayed widget.";
+ while (w.isVisible()) {
+ loop.exec();
+ }
+ m_eventTestLoop = 0;
+}
+
+bool tst_QInputGenerator::eventFilter(QObject* o, QEvent* e)
+{
+ QEvent::Type type = e->type();
+ if (type == QEvent::KeyPress || type == QEvent::KeyRelease) {
+ if (m_eventTestLoop) {
+ qDebug() << m_eventTestTime.elapsed() << "key" << qPrintable(toString(*static_cast<QKeyEvent*>(e)));
+ m_eventTestLoop->quit();
+ goto end;
+ }
+ m_keyEvents << *static_cast<QKeyEvent*>(e);
+ }
+ else if (type >= QEvent::MouseButtonPress && type <= QEvent::MouseMove) {
+ /*
+ Even when mouse tracking is turned off, Qt still generates events for mouse
+ moves on some platforms. Discard them, since it's unpredictable how many
+ there might be.
+ */
+ QMouseEvent* me = static_cast<QMouseEvent*>(e);
+ if (type == QEvent::MouseMove && o->isWidgetType()
+ && !static_cast<QWidget*>(o)->hasMouseTracking() && !me->buttons()) {
+ }
+ else {
+ if (m_eventTestLoop) {
+ qDebug() << m_eventTestTime.elapsed() << "mouse" << qPrintable(toString(*me));
+ m_eventTestLoop->quit();
+ goto end;
+ }
+ m_mouseEvents << *me;
+ }
+ }
+
+end:
+ return QObject::eventFilter(o,e);
+}
+
+template <typename T>
+bool tst_QInputGenerator::waitForCount(QList<T> const* list, int howmany, int timeout)
+{
+ while (list->count() < howmany && timeout > 0) {
+ QTest::qWait(10);
+ timeout -= 10;
+ }
+ return (list->count() >= howmany);
+}
+
+template <typename T1, typename T2>
+void tst_QInputGenerator::dumpEvents(QList<T1> const& actual, QList<T2> const& expected)
+{
+ qWarning("Events leading up to failure:");
+ qWarning("Actual:");
+ for (int i = 0; i < actual.count(); ++i) {
+ qWarning(qPrintable(QString(" %1").arg(toString(actual.at(i)))));
+ }
+ qWarning("Expected:");
+ for (int i = 0; i < expected.count(); ++i) {
+ qWarning(qPrintable(QString(" %1").arg(toString(expected.at(i)))));
+ }
+}
+
+#include "tst_qinputgenerator.moc"
+
+int main(int argc, char** argv)
+{
+ QApplication app(argc, argv);
+
+ bool eventTest = false;
+ for (int i = 0; i < argc; ++i) {
+ if (QByteArray(argv[i]) == "eventTest") {
+ eventTest = true;
+ }
+ }
+
+ tst_QInputGenerator test;
+ if (eventTest) {
+ test.eventTest();
+ return 0;
+ }
+ return QTest::qExec(&test, argc, argv);
+}
+
diff --git a/old/tests/qtuitest/tst_qinputgenerator/tst_qinputgenerator.pro b/old/tests/qtuitest/tst_qinputgenerator/tst_qinputgenerator.pro
new file mode 100644
index 0000000..d8ab687
--- /dev/null
+++ b/old/tests/qtuitest/tst_qinputgenerator/tst_qinputgenerator.pro
@@ -0,0 +1,27 @@
+TEMPLATE=app
+CONFIG+=unittest
+QT = core gui
+TARGET=tst_qinputgenerator
+CONFIG+=qtestlib
+
+CONFIG-=debug_and_release_target
+
+SOURCES+= \
+ tst_qinputgenerator.cpp
+
+unix:!mac:!embedded:!symbian {
+ SOURCES+=nativeevent_x11.cpp
+}
+else {
+ SOURCES+=nativeevent_noop.cpp
+}
+
+include($$SRCROOT/libqtuitest/libqtuitest.pri)
+
+
+
+target.path += \
+ /usr/local/bin
+
+INSTALLS += \
+ target \ No newline at end of file
diff --git a/old/tests/qtuitest/tst_qtestprotocol/testprotocol.cpp b/old/tests/qtuitest/tst_qtestprotocol/testprotocol.cpp
new file mode 100644
index 0000000..a597d08
--- /dev/null
+++ b/old/tests/qtuitest/tst_qtestprotocol/testprotocol.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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 "testprotocol.h"
+
+QList<QTestMessage>& TestProtocol::messages()
+{ return m_messages; }
+
+void TestProtocol::processMessage(QTestMessage* message)
+{ m_messages << *message; }
+
diff --git a/old/tests/qtuitest/tst_qtestprotocol/testprotocol.h b/old/tests/qtuitest/tst_qtestprotocol/testprotocol.h
new file mode 100644
index 0000000..ed926c6
--- /dev/null
+++ b/old/tests/qtuitest/tst_qtestprotocol/testprotocol.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 TESTPROTOCOL_H
+#define TESTPROTOCOL_H
+
+#include "qtestprotocol_p.h"
+
+/*
+ Test protocol which simply stores received messages in a list.
+*/
+class TestProtocol : public QTestProtocol
+{
+ Q_OBJECT
+
+public:
+ QList<QTestMessage>& messages();
+
+protected:
+ void processMessage(QTestMessage*);
+
+private:
+ QList<QTestMessage> m_messages;
+};
+
+#endif
+
diff --git a/old/tests/qtuitest/tst_qtestprotocol/testprotocolserver.cpp b/old/tests/qtuitest/tst_qtestprotocol/testprotocolserver.cpp
new file mode 100644
index 0000000..9ad77cc
--- /dev/null
+++ b/old/tests/qtuitest/tst_qtestprotocol/testprotocolserver.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 "testprotocolserver.h"
+
+TestProtocolServer::TestProtocolServer(QObject* parent)
+ : QTcpServer(parent)
+{}
+
+TestProtocolServer::~TestProtocolServer()
+{}
+
+TestProtocol* TestProtocolServer::nextPendingConnection()
+{
+ if (!m_pendingConnections.count())
+ return 0;
+ return m_pendingConnections.takeFirst();
+}
+
+bool TestProtocolServer::hasPendingConnections() const
+{ return m_pendingConnections.count(); }
+
+void TestProtocolServer::incomingConnection(int socket)
+{
+ if (m_pendingConnections.count() >= maxPendingConnections())
+ return;
+
+ TestProtocol* ret = new TestProtocol;
+ ret->setParent(this);
+ ret->setSocket(socket);
+ m_pendingConnections << ret;
+}
+
diff --git a/old/tests/qtuitest/tst_qtestprotocol/testprotocolserver.h b/old/tests/qtuitest/tst_qtestprotocol/testprotocolserver.h
new file mode 100644
index 0000000..b6c2e39
--- /dev/null
+++ b/old/tests/qtuitest/tst_qtestprotocol/testprotocolserver.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 TESTPROTOCOLSERVER_H
+#define TESTPROTOCOLSERVER_H
+
+#include <QTcpServer>
+#include <QList>
+
+#include "testprotocol.h"
+
+/*
+ TCP server which creates QTestProtocols instead of QTcpSockets.
+*/
+class TestProtocolServer : public QTcpServer
+{
+ Q_OBJECT
+
+public:
+ TestProtocolServer(QObject* =0);
+ virtual ~TestProtocolServer();
+
+ virtual TestProtocol* nextPendingConnection();
+ virtual bool hasPendingConnections() const;
+
+protected:
+ virtual void incomingConnection(int);
+
+private:
+ QList<TestProtocol*> m_pendingConnections;
+};
+
+#endif
+
diff --git a/old/tests/qtuitest/tst_qtestprotocol/tst_qtestprotocol.cpp b/old/tests/qtuitest/tst_qtestprotocol/tst_qtestprotocol.cpp
new file mode 100644
index 0000000..cba330e
--- /dev/null
+++ b/old/tests/qtuitest/tst_qtestprotocol/tst_qtestprotocol.cpp
@@ -0,0 +1,192 @@
+/****************************************************************************
+**
+** 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 <QTest>
+
+// for m_map
+#define protected public
+# include "qtestprotocol_p.h"
+#undef protected
+
+#include "testprotocol.h"
+#include "testprotocolserver.h"
+
+//TESTED_COMPONENT=QA: Testing Framework (18707)
+
+class tst_QTestProtocol : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void postMessage();
+ void postMessage_data();
+};
+
+QTEST_MAIN(tst_QTestProtocol)
+
+/*
+ Comparison for QTestMessage.
+*/
+namespace QTest {
+template<>
+inline bool qCompare
+ (QTestMessage const &m1, QTestMessage const &m2,
+ const char* actual, const char* expected, const char* file, int line)
+{
+#define COMPARE_MEMBER(a,b,args...) \
+ qCompare(a.args, b.args, \
+ qPrintable(QString("%1.%2").arg(actual).arg(#args)), \
+ qPrintable(QString("%1.%2").arg(expected).arg(#args)), \
+ file, line)
+
+ return COMPARE_MEMBER(m1,m2,event())
+ && COMPARE_MEMBER(m1,m2,toString())
+ && COMPARE_MEMBER(m1,m2,m_map);
+
+#undef COMPARE_MEMBER
+}
+}
+
+/*
+ \req QTOPIA-78
+
+ \groups
+ Simply tests that messages can be sent correctly without becoming corrupt.
+*/
+void tst_QTestProtocol::postMessage_data()
+{
+ QTest::addColumn<QTestMessage>("message");
+
+ QTest::newRow("empty")
+ << QTestMessage();
+
+ QTest::newRow("simple, no map")
+ << QTestMessage("foo");
+
+ {
+ QVariantMap vm;
+ vm["foo"] = 1;
+ vm["bar"] = "Hello.";
+
+ QTest::newRow("simple, small map")
+ << QTestMessage("foobar", vm);
+ }
+
+ {
+ QByteArray ba;
+ while (ba.size() < 1024*1024*10)
+ ba.append("zoop");
+
+ QVariantMap vm;
+ vm["aaa"] = "A";
+ vm["bbb"] = ba;
+ vm["ccc"] = "C";
+
+ QTest::newRow("10 Mb")
+ << QTestMessage("big_test", vm);
+ }
+}
+
+// Will try to wait for the condition while allowing event processing
+#define QTRY_COMPARE(__expr, __expected) \
+ do { \
+ const int __step = 50; \
+ const int __timeout = 5000; \
+ if ((__expr) != (__expected)) { \
+ QTest::qWait(0); \
+ } \
+ for (int __i = 0; __i < __timeout && ((__expr) != (__expected)); __i+=__step) { \
+ QTest::qWait(__step); \
+ } \
+ QCOMPARE(__expr, __expected); \
+ } while(0)
+
+void tst_QTestProtocol::postMessage()
+{
+ // Start a server to listen for connections.
+ TestProtocolServer server;
+ QVERIFY(server.listen());
+
+ // Create a test protocol which connects to the server.
+ TestProtocol* clientP = new TestProtocol;
+ clientP->setParent(&server);
+ clientP->connect( "127.0.0.1", server.serverPort() );
+
+ QVERIFY( clientP->waitForConnected(1000) );
+ QVERIFY( server.hasPendingConnections() );
+
+ // Get the protocol which should have been created on the server side
+ TestProtocol* serverP = server.nextPendingConnection();
+ QVERIFY( serverP );
+ // Should be no further connections
+ QVERIFY( !server.hasPendingConnections() );
+
+ // OK, now we have two peers. They should both be connected by now.
+ QVERIFY( clientP->isConnected() );
+ QVERIFY( serverP->isConnected() );
+
+ QList<QTestMessage>& clientMessages = clientP->messages();
+ QList<QTestMessage>& serverMessages = serverP->messages();
+
+ QFETCH(QTestMessage, message);
+
+ // Try sending the message from client to server.
+ uint post_id = clientP->postMessage(message);
+ QVERIFY(post_id);
+ QCOMPARE(serverMessages.count(), 0);
+ QTRY_COMPARE(serverMessages.count(), 1);
+
+ // Verify the message is OK.
+ QCOMPARE(serverMessages.takeFirst(), message);
+
+
+ // Try sending the message from server to client.
+ post_id = serverP->postMessage(message);
+ QVERIFY(post_id);
+ QCOMPARE(clientMessages.count(), 0);
+ QTRY_COMPARE(clientMessages.count(), 1);
+
+ // Verify the message is OK.
+ QCOMPARE(clientMessages.takeFirst(), message);
+}
+
+#include "tst_qtestprotocol.moc"
+
diff --git a/old/tests/qtuitest/tst_qtestprotocol/tst_qtestprotocol.pro b/old/tests/qtuitest/tst_qtestprotocol/tst_qtestprotocol.pro
new file mode 100644
index 0000000..6244019
--- /dev/null
+++ b/old/tests/qtuitest/tst_qtestprotocol/tst_qtestprotocol.pro
@@ -0,0 +1,25 @@
+TEMPLATE=app
+CONFIG+=unittest
+QT = core network
+TARGET=tst_qtestprotocol
+CONFIG+=qtestlib
+
+include($$SRCROOT/libqtuitest/libqtuitest.pri)
+
+CONFIG-=debug_and_release_target
+
+SOURCES+= \
+ tst_qtestprotocol.cpp \
+ testprotocol.cpp \
+ testprotocolserver.cpp
+
+HEADERS+= \
+ testprotocol.h \
+ testprotocolserver.h
+
+
+target.path += \
+ /usr/local/bin
+
+INSTALLS += \
+ target \ No newline at end of file
diff --git a/old/tests/qtuitest/tst_qtuitestnamespace/tst_qtuitestnamespace.cpp b/old/tests/qtuitest/tst_qtuitestnamespace/tst_qtuitestnamespace.cpp
new file mode 100644
index 0000000..d40723e
--- /dev/null
+++ b/old/tests/qtuitest/tst_qtuitestnamespace/tst_qtuitestnamespace.cpp
@@ -0,0 +1,898 @@
+/****************************************************************************
+**
+** 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 QT_NO_DEBUG
+#define QT_NO_DEBUG 1
+#endif
+
+#include <QAction>
+#include <QCoreApplication>
+#include <QObject>
+#include <QtTest/QTest>
+
+#include <qalternatestack_p.h>
+#include <qtuitestconnectionmanager_p.h>
+#include <qtuitestnamespace.h>
+
+#include <QTime>
+#include <QTimer>
+
+class tst_QtUiTestNamespace : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void wait();
+ void connectFirst();
+ void connectFirstIsFirst();
+ void connectFirstDestruction();
+ void connectFirstInvalid();
+ void connectFirstDefaultParam();
+ void disconnectFirstInvalid();
+ void disconnectFirstWildcards();
+};
+
+int g_exit_code;
+int g_argc;
+char** g_argv;
+bool g_test_done;
+QObject* g_test;
+
+void run_test(QAlternateStack*,QVariant const&)
+{
+ g_exit_code = QTest::qExec(g_test, g_argc, g_argv);
+ g_test_done = true;
+}
+
+int main(int argc, char** argv)
+{
+ QCoreApplication app(argc, argv);
+ tst_QtUiTestNamespace test;
+ g_test = &test;
+ g_argc = argc;
+ g_argv = argv;
+
+ // Most QtUiTest code runs in an alternate stack, while the original
+ // stack runs the event loop.
+ // Try to replicate that behavior for this test.
+ QAlternateStack stack;
+
+ g_test_done = false;
+ stack.start(run_test);
+ while (!g_test_done) {
+ app.processEvents(QEventLoop::WaitForMoreEvents);
+ }
+ return g_exit_code;
+}
+
+/*
+ Event loop where 'exec' is a slot, for convenience.
+*/
+class TestEventLoop : public QEventLoop
+{
+ Q_OBJECT
+public:
+ TestEventLoop(QObject* parent =0)
+ : QEventLoop(parent),
+ m_execCount(0),
+ m_exitCount(0)
+ {}
+
+ int m_execCount;
+ int m_exitCount;
+
+public slots:
+ int exec(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents)
+ {
+ ++m_execCount;
+ int ret = QEventLoop::exec(flags);
+ ++m_exitCount;
+ return ret;
+ }
+};
+
+/*
+ Class for emitting a particular integer value.
+*/
+class Emitter : public QObject
+{
+ Q_OBJECT
+
+public:
+ Emitter(QObject* parent =0)
+ : QObject(parent)
+ {}
+
+ void emitValue(int value)
+ {
+ emit valueChanged(value);
+ emit valueChanged2(value);
+ emit valueChangedWithDefault(value);
+ }
+
+ enum Values { DefaultValue = 1338 };
+
+signals:
+ void valueChanged(int);
+ void valueChanged2(int);
+ void valueChangedWithDefault(int = DefaultValue);
+};
+
+/*
+ Class for receiving an emitted value.
+*/
+class Receiver : public QObject
+{
+ Q_OBJECT
+
+public:
+ Receiver(QObject* parent =0)
+ : QObject(parent)
+ {}
+
+ QList<int> values;
+ QList<int> values2;
+
+ enum Values { DefaultValue = 1337 };
+
+public slots:
+ void receive(int value)
+ { values << value; }
+
+ void receive2(int value)
+ { values2 << value; }
+
+ void receiveMultipliedByTwo(int value)
+ { values << 2*value; }
+
+ void receiveDefault(int value = DefaultValue)
+ { values << value; }
+
+ void clear()
+ { values.clear(); }
+
+ void clear2()
+ { values2.clear(); }
+};
+
+// Verify that \a actual is bounded by \a min and \a max.
+#define QCOMPARE_BOUNDED(actual, min, max) \
+ do { \
+ QVERIFY2(actual >= min && actual <= max, qPrintable(QString( \
+ "actual %1, expected to be in range %2 .. %3" \
+ ).arg(actual).arg(min).arg(max))); \
+ } while(0)
+
+/*
+ The most important test ever written.
+
+ Verify that we can wait() for an arbitrary amount of time, while processing
+ events, without hanging if a nested event loop occurs.
+
+ See bug 194361.
+*/
+void tst_QtUiTestNamespace::wait()
+{
+ {
+ QTime t;
+ t.start();
+
+ QtUiTest::wait(1000);
+
+ QCOMPARE_BOUNDED(t.elapsed(), 1000, 30000);
+ }
+
+ // OK, so we can wait when there are no nested event loops.
+ // Big deal. The real test is: if we have a nested event loop, can we
+ // avoid hanging.
+ {
+ TestEventLoop loop;
+
+ QTime t;
+ t.start();
+
+ // The nested event loop will run for 2.5 seconds.
+ // But we only want to wait for 1 second.
+ // What on earth will happen... ???
+ QTimer::singleShot(0, &loop, SLOT(exec()));
+ QTimer::singleShot(2500, &loop, SLOT(quit()));
+ QtUiTest::wait(1000);
+
+ // Verify the loop really did exec.
+ QCOMPARE(loop.m_execCount, 1);
+ // Verify the loop really hasn't exited yet.
+ QCOMPARE(loop.m_exitCount, 0);
+ // Verify that we've waited for about as long as we wanted to wait.
+ QCOMPARE_BOUNDED(t.elapsed(), 1000, 30000);
+
+ // OK, now check inner loop really does exit, to ensure we haven't
+ // screwed things up by switching stacks.
+ for (int i = 0; i < 5000 && !loop.m_exitCount; i+=100, QtUiTest::wait(100))
+ {}
+ QCOMPARE(loop.m_exitCount, 1);
+ QCOMPARE_BOUNDED(t.elapsed(), 2500, 30000);
+ }
+}
+
+/*
+ Tests QtUiTest::connectFirst(), which works like QObject::connect but guarantees
+ that the connection comes before all existing connections.
+*/
+void tst_QtUiTestNamespace::connectFirst()
+{
+ QtUiTestConnectionManager* cm = QtUiTestConnectionManager::instance();
+ if (cm->m_connections.count())
+ QSKIP("Test cannot proceed; previous test left connection manager in incorrect state", SkipAll);
+
+ {
+ // Basic connection
+ Emitter e;
+ Receiver r;
+
+ QVERIFY(QtUiTest::connectFirst(&e, SIGNAL(valueChanged(int)), &r, SLOT(receive(int))));
+ QCOMPARE(cm->m_connections.count(), 1);
+
+ e.emitValue(1024);
+ e.emitValue(1025);
+ QCOMPARE(r.values, QList<int>() << 1024 << 1025);
+ r.values.clear();
+
+ // Basic disconnection
+ QVERIFY(QtUiTest::disconnectFirst(&e, SIGNAL(valueChanged(int)), &r, SLOT(receive(int))));
+ QCOMPARE(cm->m_connections.count(), 0);
+
+ e.emitValue(1027);
+ QCOMPARE(r.values, QList<int>());
+ }
+
+ {
+ // Multiply-connected
+ Emitter e1, e2;
+ Receiver r1, r2;
+
+ QVERIFY(QtUiTest::connectFirst(&e1, SIGNAL(valueChanged(int)), &r1, SLOT(receive(int))));
+ QCOMPARE(cm->m_connections.count(), 1);
+
+ QVERIFY(QtUiTest::connectFirst(&e1, SIGNAL(valueChanged(int)), &r1, SLOT(receive(int))));
+ QCOMPARE(cm->m_connections.count(), 2);
+
+ QVERIFY(QtUiTest::connectFirst(&e1, SIGNAL(valueChanged(int)), &r1, SLOT(receive(int))));
+ QCOMPARE(cm->m_connections.count(), 3);
+
+ // Connect to another object to make sure it doesn't just happen to work when all
+ // connections are identical.
+ QVERIFY(QtUiTest::connectFirst(&e2, SIGNAL(valueChanged2(int)), &r2, SLOT(receive2(int))));
+ QCOMPARE(cm->m_connections.count(), 4);
+
+ e1.emitValue(128);
+ e1.emitValue(129);
+ QCOMPARE(r1.values, QList<int>() << 128 << 128 << 128 << 129 << 129 << 129);
+ QCOMPARE(r1.values2, QList<int>());
+ QCOMPARE(r2.values, QList<int>());
+ QCOMPARE(r2.values2, QList<int>());
+ r1.values.clear();
+
+ e2.emitValue(130);
+ e2.emitValue(150);
+ QCOMPARE(r1.values, QList<int>());
+ QCOMPARE(r1.values2, QList<int>());
+ QCOMPARE(r2.values, QList<int>());
+ QCOMPARE(r2.values2, QList<int>() << 130 << 150);
+ r2.values2.clear();
+
+ // Disconnecting something which is multiply-connected
+ QVERIFY(QtUiTest::disconnectFirst(&e1, SIGNAL(valueChanged(int)), &r1, SLOT(receive(int))));
+ QCOMPARE(cm->m_connections.count(), 1);
+
+ e1.emitValue(1280);
+ e1.emitValue(1290);
+ QCOMPARE(r1.values, QList<int>());
+ QCOMPARE(r1.values2, QList<int>());
+ QCOMPARE(r2.values, QList<int>());
+ QCOMPARE(r2.values2, QList<int>());
+ r1.values.clear();
+
+ e2.emitValue(1300);
+ e2.emitValue(1500);
+ QCOMPARE(r1.values, QList<int>());
+ QCOMPARE(r1.values2, QList<int>());
+ QCOMPARE(r2.values, QList<int>());
+ QCOMPARE(r2.values2, QList<int>() << 1300 << 1500);
+ r2.values2.clear();
+
+ QVERIFY(QtUiTest::disconnectFirst(&e2, SIGNAL(valueChanged2(int)), &r2, SLOT(receive2(int))));
+ QCOMPARE(cm->m_connections.count(), 0);
+
+ e2.emitValue(280);
+ e2.emitValue(290);
+ QCOMPARE(r1.values, QList<int>());
+ QCOMPARE(r1.values2, QList<int>());
+ QCOMPARE(r2.values, QList<int>());
+ QCOMPARE(r2.values2, QList<int>());
+
+ }
+
+ {
+ // Large number of connections
+ QList<Emitter*> emitters;
+ QList<Receiver*> receivers;
+
+ static const int LARGE = 1000;
+ while (emitters.count() < LARGE) {
+ emitters << new Emitter;
+ receivers << new Receiver;
+ }
+
+ for (int i = 0; i < LARGE; ++i) {
+ QVERIFY(QtUiTest::connectFirst(emitters.at(i), SIGNAL(valueChanged(int)), receivers.at(i), SLOT(receive(int))));
+ QVERIFY(QtUiTest::connectFirst(emitters.at(i), SIGNAL(valueChanged(int)), receivers.at(i), SLOT(receive(int))));
+ QVERIFY(QtUiTest::connectFirst(emitters.at(i), SIGNAL(valueChanged2(int)), receivers.at(LARGE-i-1), SLOT(receive2(int))));
+ QVERIFY(QtUiTest::connectFirst(emitters.at(i), SIGNAL(valueChanged2(int)), receivers.at(LARGE-i-1), SLOT(receive2(int))));
+ QCOMPARE(cm->m_connections.count(), (i+1)*4);
+ }
+
+ for (int i = 0; i < LARGE; ++i) {
+ emitters.at(i)->emitValue(i);
+ }
+
+ for (int i = 0; i < LARGE; ++i) {
+ // receiver at i should have received (twice):
+ // value: i
+ // value2: LARGE-i-1
+ QCOMPARE( receivers.at(i)->values, QList<int>() << i << i );
+ QCOMPARE( receivers.at(i)->values2, QList<int>() << (LARGE-i-1) << (LARGE-i-1) );
+ receivers.at(i)->values.clear();
+ receivers.at(i)->values2.clear();
+ }
+
+ // Disconnect half of the objects.
+ for (int i = 0; i < LARGE; i += 2) {
+ QVERIFY(QtUiTest::disconnectFirst(emitters.at(i), SIGNAL(valueChanged(int)), 0, 0));
+ QVERIFY(QtUiTest::disconnectFirst(emitters.at(i), SIGNAL(valueChanged2(int)), 0, 0));
+ }
+ QCOMPARE(cm->m_connections.count(), LARGE*2);
+
+ for (int i = 0; i < LARGE; ++i) {
+ emitters.at(i)->emitValue(i);
+ }
+
+ for (int i = 0; i < LARGE; ++i) {
+ if (i % 2) {
+ QCOMPARE( receivers.at(i)->values, QList<int>() << i << i);
+ receivers.at(i)->values.clear();
+ } else {
+ QCOMPARE( receivers.at(i)->values, QList<int>() );
+ }
+
+ if (!(i % 2)) {
+ QCOMPARE( receivers.at(i)->values2, QList<int>() << (LARGE-i-1) << (LARGE-i-1));
+ receivers.at(i)->values2.clear();
+ } else {
+ QCOMPARE( receivers.at(i)->values2, QList<int>() );
+ }
+ }
+
+ // Delete half of the objects.
+ for (int i = 0; i < LARGE/2; ++i) {
+ delete receivers.takeLast();
+ delete emitters.takeLast();
+ }
+ // All the `2' connections have been severed
+ QCOMPARE(cm->m_connections.count(), LARGE/2);
+
+ for (int i = 0; i < LARGE/2; ++i) {
+ emitters.at(i)->emitValue(i);
+ }
+
+ for (int i = 0; i < LARGE/2; ++i) {
+ if (i % 2) {
+ QCOMPARE( receivers.at(i)->values, QList<int>() << i << i);
+ receivers.at(i)->values.clear();
+ } else {
+ QCOMPARE( receivers.at(i)->values, QList<int>() );
+ }
+ QCOMPARE( receivers.at(i)->values2, QList<int>() );
+ }
+
+ // Delete the rest.
+ while (receivers.count()) {
+ delete receivers.takeFirst();
+ delete emitters.takeFirst();
+ }
+ QCOMPARE(cm->m_connections.count(), 0);
+ }
+}
+
+
+void tst_QtUiTestNamespace::connectFirstIsFirst()
+{
+ QtUiTestConnectionManager* cm = QtUiTestConnectionManager::instance();
+ if (cm->m_connections.count())
+ QSKIP("Test cannot proceed; previous test left connection manager in incorrect state", SkipAll);
+
+ // Tests that connectFirst really does what its name says: establishes a connection which is
+ // activated _before_ all QObject::connect connections.
+ Emitter e;
+ Receiver r;
+
+ static const int LARGE = 200;
+
+ QVERIFY(QtUiTest::connectFirst(&e, SIGNAL(valueChanged(int)), &r, SLOT(receive(int))));
+
+ for (int i = 0; i < LARGE; ++i)
+ QVERIFY(QObject::connect (&e, SIGNAL(valueChanged(int)), &r, SLOT(receiveMultipliedByTwo(int))));
+
+ QVERIFY(QtUiTest::connectFirst(&e, SIGNAL(valueChanged(int)), &r, SLOT(receive(int))));
+
+ for (int i = 0; i < LARGE; ++i)
+ QVERIFY(QObject::connect (&e, SIGNAL(valueChanged(int)), &r, SLOT(receiveMultipliedByTwo(int))));
+
+ QVERIFY(QtUiTest::connectFirst(&e, SIGNAL(valueChanged(int)), &r, SLOT(receive(int))));
+
+ e.emitValue(1);
+ QCOMPARE(r.values.count(), LARGE*2+3);
+
+ // Verify that the QtUiTest-connected signals came first
+ for (int i = 0; i < 3; ++i)
+ QCOMPARE(r.values.at(i), 1);
+ for (int i = 0; i < LARGE*2; ++i)
+ QCOMPARE(r.values.at(i+3), 2);
+}
+
+void tst_QtUiTestNamespace::connectFirstDestruction()
+{
+ QtUiTestConnectionManager* cm = QtUiTestConnectionManager::instance();
+ if (cm->m_connections.count())
+ QSKIP("Test cannot proceed; previous test left connection manager in incorrect state", SkipAll);
+
+ {
+ // Verify connections are destroyed when sender is destroyed
+ Receiver r;
+ {
+ Emitter e;
+
+ QVERIFY(QtUiTest::connectFirst(&e, SIGNAL(valueChanged(int)), &r, SLOT(receive(int))));
+ QCOMPARE(cm->m_connections.count(), 1);
+ }
+ QCOMPARE(cm->m_connections.count(), 0);
+ }
+
+ {
+ // Verify connections are destroyed when receiver is destroyed
+ Emitter e;
+ {
+ Receiver r;
+
+ QVERIFY(QtUiTest::connectFirst(&e, SIGNAL(valueChanged(int)), &r, SLOT(receive(int))));
+ QCOMPARE(cm->m_connections.count(), 1);
+ }
+ QCOMPARE(cm->m_connections.count(), 0);
+ }
+}
+
+void tst_QtUiTestNamespace::connectFirstInvalid()
+{
+ QtUiTestConnectionManager* cm = QtUiTestConnectionManager::instance();
+ if (cm->m_connections.count())
+ QSKIP("Test cannot proceed; previous test left connection manager in incorrect state", SkipAll);
+
+ Emitter e;
+ Receiver r;
+
+ QVERIFY(!QtUiTest::connectFirst(0, 0, 0, 0));
+ QVERIFY(!cm->m_connections.count());
+
+ QVERIFY(!QtUiTest::connectFirst(&e, 0, 0, 0));
+ QVERIFY(!cm->m_connections.count());
+
+ QVERIFY(!QtUiTest::connectFirst(&e, 0, &r, 0));
+ QVERIFY(!cm->m_connections.count());
+
+ QVERIFY(!QtUiTest::connectFirst(0, 0, &r, 0));
+ QVERIFY(!cm->m_connections.count());
+
+ QVERIFY(!QtUiTest::connectFirst(&e, SIGNAL(notexist()), &r, 0));
+ QVERIFY(!cm->m_connections.count());
+
+ QVERIFY(!QtUiTest::connectFirst(&e, SIGNAL(valueChanged(int)), &r, 0));
+ QVERIFY(!cm->m_connections.count());
+
+ QVERIFY(!QtUiTest::connectFirst(&e, SIGNAL(valueChanged(int)), &r, SLOT(notexist())));
+ QVERIFY(!cm->m_connections.count());
+
+ QVERIFY(!QtUiTest::connectFirst(&e, SIGNAL(notexist()), &r, SLOT(receive(int))));
+ QVERIFY(!cm->m_connections.count());
+}
+
+void tst_QtUiTestNamespace::disconnectFirstInvalid()
+{
+ QtUiTestConnectionManager* cm = QtUiTestConnectionManager::instance();
+ if (cm->m_connections.count())
+ QSKIP("Test cannot proceed; previous test left connection manager in incorrect state", SkipAll);
+
+ Emitter e;
+ Receiver r;
+
+ QVERIFY(!QtUiTest::disconnectFirst(0, 0, 0, 0));
+ QVERIFY(!cm->m_connections.count());
+
+ // Not an error but there are no connections
+ QVERIFY(!QtUiTest::disconnectFirst(&e, 0, 0, 0));
+ QVERIFY(!cm->m_connections.count());
+
+ // Not an error but there are no connections
+ QVERIFY(!QtUiTest::disconnectFirst(&e, 0, &r, 0));
+ QVERIFY(!cm->m_connections.count());
+
+ QVERIFY(!QtUiTest::disconnectFirst(0, 0, &r, 0));
+ QVERIFY(!cm->m_connections.count());
+
+ QVERIFY(!QtUiTest::disconnectFirst(&e, SIGNAL(notexist()), &r, 0));
+ QVERIFY(!cm->m_connections.count());
+
+ // Not an error but there are no connections
+ QVERIFY(!QtUiTest::disconnectFirst(&e, SIGNAL(valueChanged(int)), &r, 0));
+ QVERIFY(!cm->m_connections.count());
+
+ QVERIFY(!QtUiTest::disconnectFirst(&e, SIGNAL(valueChanged(int)), &r, SLOT(notexist())));
+ QVERIFY(!cm->m_connections.count());
+
+ QVERIFY(!QtUiTest::disconnectFirst(&e, SIGNAL(notexist2()), &r, SLOT(receive(int))));
+ QVERIFY(!cm->m_connections.count());
+
+ // Not an error but there are no connections
+ QVERIFY(!QtUiTest::disconnectFirst(&e, SIGNAL(valueChanged(int)), &r, SLOT(receive(int))));
+ QVERIFY(!cm->m_connections.count());
+}
+
+/*
+ Tests QtUiTest::connectFirst() for signals/slots which have default parameters.
+*/
+void tst_QtUiTestNamespace::connectFirstDefaultParam()
+{
+ QtUiTestConnectionManager* cm = QtUiTestConnectionManager::instance();
+ if (cm->m_connections.count())
+ QSKIP("Test cannot proceed; previous test left connection manager in incorrect state", SkipAll);
+
+ { // x,x
+ Emitter e;
+ Receiver r;
+
+ QVERIFY(QtUiTest::connectFirst(&e, SIGNAL(valueChangedWithDefault(int)), &r, SLOT(receiveDefault(int))));
+ QCOMPARE(cm->m_connections.count(), 1);
+ e.emitValue(-99);
+ QCOMPARE(r.values, QList<int>() << -99);
+ }
+
+ { // x,0
+ Emitter e;
+ Receiver r;
+
+ QVERIFY(QtUiTest::connectFirst(&e, SIGNAL(valueChangedWithDefault(int)), &r, SLOT(receiveDefault())));
+ QCOMPARE(cm->m_connections.count(), 1);
+ e.emitValue(129);
+ QCOMPARE(r.values, QList<int>() << r.DefaultValue);
+ }
+
+ { // 0,x: can't work
+ Emitter e;
+ Receiver r;
+
+ QVERIFY(!QtUiTest::connectFirst(&e, SIGNAL(valueChangedWithDefault()), &r, SLOT(receiveDefault(int))));
+ QCOMPARE(cm->m_connections.count(), 0);
+ }
+
+ { // 0,0
+ Emitter e;
+ Receiver r;
+
+ QVERIFY(QtUiTest::connectFirst(&e, SIGNAL(valueChangedWithDefault()), &r, SLOT(receiveDefault())));
+ QCOMPARE(cm->m_connections.count(), 1);
+ e.emitValue(130);
+
+ QEXPECT_FAIL("", "Bug 227908: signals with default parameters are discarded by QtUiTest::connectFirst()", Abort);
+
+ QCOMPARE(r.values.count(), 1);
+ QCOMPARE(r.values, QList<int>() << r.DefaultValue);
+ }
+}
+
+void tst_QtUiTestNamespace::disconnectFirstWildcards()
+{
+ QtUiTestConnectionManager* cm = QtUiTestConnectionManager::instance();
+ if (cm->m_connections.count())
+ QSKIP("Test cannot proceed; previous test left connection manager in incorrect state", SkipAll);
+
+#define INIT() \
+ Receiver r1; Emitter e1; \
+ Receiver r2; Emitter e2a; Emitter e2b; \
+ Receiver r3a; Receiver r3b; Emitter e3; \
+ Receiver r4a; Receiver r4b; Emitter e4; \
+\
+ QVERIFY(QtUiTest::connectFirst(&e1, SIGNAL(valueChanged(int)), &r1, SLOT(receive(int)))); \
+ QVERIFY(QtUiTest::connectFirst(&e1, SIGNAL(valueChanged(int)), &r1, SLOT(receive2(int)))); \
+\
+ QVERIFY(QtUiTest::connectFirst(&e2a, SIGNAL(valueChanged(int)), &r2, SLOT(receive(int)))); \
+ QVERIFY(QtUiTest::connectFirst(&e2a, SIGNAL(valueChanged(int)), &r2, SLOT(receive2(int)))); \
+ QVERIFY(QtUiTest::connectFirst(&e2b, SIGNAL(valueChanged(int)), &r2, SLOT(receive(int)))); \
+ QVERIFY(QtUiTest::connectFirst(&e2b, SIGNAL(valueChanged(int)), &r2, SLOT(receive2(int)))); \
+\
+ QVERIFY(QtUiTest::connectFirst(&e3, SIGNAL(valueChanged(int)), &r3a, SLOT(receive(int)))); \
+ QVERIFY(QtUiTest::connectFirst(&e3, SIGNAL(valueChanged(int)), &r3a, SLOT(receive(int)))); \
+ QVERIFY(QtUiTest::connectFirst(&e3, SIGNAL(valueChanged(int)), &r3b, SLOT(receive(int)))); \
+ QVERIFY(QtUiTest::connectFirst(&e3, SIGNAL(valueChanged(int)), &r3b, SLOT(receive2(int)))); \
+\
+ QVERIFY(QtUiTest::connectFirst(&e4, SIGNAL(valueChanged(int)), &r4a, SLOT(receive(int)))); \
+ QVERIFY(QtUiTest::connectFirst(&e4, SIGNAL(valueChanged(int)), &r4a, SLOT(receive2(int)))); \
+ QVERIFY(QtUiTest::connectFirst(&e4, SIGNAL(valueChanged2(int)), &r4a, SLOT(receive(int)))); \
+ QVERIFY(QtUiTest::connectFirst(&e4, SIGNAL(valueChanged2(int)), &r4a, SLOT(receive2(int)))); \
+ QVERIFY(QtUiTest::connectFirst(&e4, SIGNAL(valueChanged(int)), &r4b, SLOT(receive(int)))); \
+ QVERIFY(QtUiTest::connectFirst(&e4, SIGNAL(valueChanged(int)), &r4b, SLOT(receive2(int)))); \
+ QVERIFY(QtUiTest::connectFirst(&e4, SIGNAL(valueChanged2(int)), &r4b, SLOT(receive(int)))); \
+ QVERIFY(QtUiTest::connectFirst(&e4, SIGNAL(valueChanged2(int)), &r4b, SLOT(receive2(int))));
+
+ {
+ INIT();
+
+ // Verify connections for correctness
+ QCOMPARE(cm->m_connections.count(), 18);
+
+ e1. emitValue(10);
+ e2a.emitValue(20);
+ e2b.emitValue(21);
+ e3. emitValue(30);
+ e4. emitValue(40);
+ QCOMPARE(r1.values, QList<int>() << 10);
+ QCOMPARE(r1.values2, QList<int>() << 10);
+ QCOMPARE(r2.values, QList<int>() << 20 << 21);
+ QCOMPARE(r2.values2, QList<int>() << 20 << 21);
+ QCOMPARE(r3a.values, QList<int>() << 30 << 30);
+ QCOMPARE(r3a.values2, QList<int>());
+ QCOMPARE(r3b.values, QList<int>() << 30);
+ QCOMPARE(r3b.values2, QList<int>() << 30);
+ QCOMPARE(r4a.values, QList<int>() << 40 << 40);
+ QCOMPARE(r4a.values2, QList<int>() << 40 << 40);
+ QCOMPARE(r4b.values, QList<int>() << 40 << 40);
+ QCOMPARE(r4b.values2, QList<int>() << 40 << 40);
+ }
+
+ {
+ INIT();
+
+ // All of these disconnects should fail:
+ // 0,0,0,0
+ // 0,0,0,x
+ // 0,0,x,0
+ // 0,0,x,x
+ // 0,x,0,0
+ // 0,x,0,x
+ // 0,x,x,0
+ // 0,x,x,x
+ QVERIFY(!QtUiTest::disconnectFirst(0, 0, 0, 0));
+ QVERIFY(!QtUiTest::disconnectFirst(0, 0, 0, SLOT(receive(int))));
+ QVERIFY(!QtUiTest::disconnectFirst(0, 0, &r1, 0));
+ QVERIFY(!QtUiTest::disconnectFirst(0, 0, &r1, SLOT(receive(int))));
+ QVERIFY(!QtUiTest::disconnectFirst(0, SIGNAL(valueChanged(int)), 0, 0));
+ QVERIFY(!QtUiTest::disconnectFirst(0, SIGNAL(valueChanged2(int)), 0, SLOT(receive(int))));
+ QVERIFY(!QtUiTest::disconnectFirst(0, SIGNAL(valueChanged(int)), &r1, 0));
+ QVERIFY(!QtUiTest::disconnectFirst(0, SIGNAL(valueChanged2(int)), &r2, SLOT(receive2(int))));
+ QCOMPARE(cm->m_connections.count(), 18);
+ }
+
+ {
+ INIT();
+
+ // Test x,0,0,0
+ QVERIFY(QtUiTest::disconnectFirst(&e4,0,0,0));
+ QCOMPARE(cm->m_connections.count(), 10);
+
+ e1. emitValue(10);
+ e2a.emitValue(20);
+ e2b.emitValue(21);
+ e3. emitValue(30);
+ e4. emitValue(40);
+ QCOMPARE(r1.values, QList<int>() << 10);
+ QCOMPARE(r1.values2, QList<int>() << 10);
+ QCOMPARE(r2.values, QList<int>() << 20 << 21);
+ QCOMPARE(r2.values2, QList<int>() << 20 << 21);
+ QCOMPARE(r3a.values, QList<int>() << 30 << 30);
+ QCOMPARE(r3a.values2, QList<int>());
+ QCOMPARE(r3b.values, QList<int>() << 30);
+ QCOMPARE(r3b.values2, QList<int>() << 30);
+ QCOMPARE(r4a.values, QList<int>());
+ QCOMPARE(r4a.values2, QList<int>());
+ QCOMPARE(r4b.values, QList<int>());
+ QCOMPARE(r4b.values2, QList<int>());
+ }
+
+ {
+ INIT();
+
+ // Test x,0,0,x: should fail
+ QVERIFY(!QtUiTest::disconnectFirst(&e4, 0, 0, SLOT(receive2(int))));
+ QCOMPARE(cm->m_connections.count(), 18);
+ }
+
+ {
+ INIT();
+
+ // Test x,0,x,0
+ QVERIFY(QtUiTest::disconnectFirst(&e4, 0, &r4a, 0));
+ QCOMPARE(cm->m_connections.count(), 14);
+
+ e1. emitValue(10);
+ e2a.emitValue(20);
+ e2b.emitValue(21);
+ e3. emitValue(30);
+ e4. emitValue(40);
+ QCOMPARE(r1.values, QList<int>() << 10);
+ QCOMPARE(r1.values2, QList<int>() << 10);
+ QCOMPARE(r2.values, QList<int>() << 20 << 21);
+ QCOMPARE(r2.values2, QList<int>() << 20 << 21);
+ QCOMPARE(r3a.values, QList<int>() << 30 << 30);
+ QCOMPARE(r3a.values2, QList<int>());
+ QCOMPARE(r3b.values, QList<int>() << 30);
+ QCOMPARE(r3b.values2, QList<int>() << 30);
+ QCOMPARE(r4a.values, QList<int>());
+ QCOMPARE(r4a.values2, QList<int>());
+ QCOMPARE(r4b.values, QList<int>() << 40 << 40);
+ QCOMPARE(r4b.values2, QList<int>() << 40 << 40);
+ }
+
+ {
+ INIT();
+
+ // Test x,0,x,x
+ QVERIFY(QtUiTest::disconnectFirst(&e4, 0, &r4a, SLOT(receive2(int))));
+
+ QCOMPARE(cm->m_connections.count(), 16);
+
+ e1. emitValue(10);
+ e2a.emitValue(20);
+ e2b.emitValue(21);
+ e3. emitValue(30);
+ e4. emitValue(40);
+ QCOMPARE(r1.values, QList<int>() << 10);
+ QCOMPARE(r1.values2, QList<int>() << 10);
+ QCOMPARE(r2.values, QList<int>() << 20 << 21);
+ QCOMPARE(r2.values2, QList<int>() << 20 << 21);
+ QCOMPARE(r3a.values, QList<int>() << 30 << 30);
+ QCOMPARE(r3a.values2, QList<int>());
+ QCOMPARE(r3b.values, QList<int>() << 30);
+ QCOMPARE(r3b.values2, QList<int>() << 30);
+ QCOMPARE(r4a.values, QList<int>() << 40 << 40);
+ QCOMPARE(r4a.values2, QList<int>());
+ QCOMPARE(r4b.values, QList<int>() << 40 << 40);
+ QCOMPARE(r4b.values2, QList<int>() << 40 << 40);
+ }
+
+ {
+ INIT();
+
+ // Test x,x,0,0
+ QVERIFY(QtUiTest::disconnectFirst(&e4, SIGNAL(valueChanged(int)), 0, 0));
+ QCOMPARE(cm->m_connections.count(), 14);
+
+ e1. emitValue(10);
+ e2a.emitValue(20);
+ e2b.emitValue(21);
+ e3. emitValue(30);
+ e4. emitValue(40);
+ QCOMPARE(r1.values, QList<int>() << 10);
+ QCOMPARE(r1.values2, QList<int>() << 10);
+ QCOMPARE(r2.values, QList<int>() << 20 << 21);
+ QCOMPARE(r2.values2, QList<int>() << 20 << 21);
+ QCOMPARE(r3a.values, QList<int>() << 30 << 30);
+ QCOMPARE(r3a.values2, QList<int>());
+ QCOMPARE(r3b.values, QList<int>() << 30);
+ QCOMPARE(r3b.values2, QList<int>() << 30);
+ QCOMPARE(r4a.values, QList<int>() << 40);
+ QCOMPARE(r4a.values2, QList<int>() << 40);
+ QCOMPARE(r4b.values, QList<int>() << 40);
+ QCOMPARE(r4b.values2, QList<int>() << 40);
+ }
+
+ {
+ INIT();
+
+ // Test x,x,0,x: should fail
+ QVERIFY(!QtUiTest::disconnectFirst(&e2a, SIGNAL(valueChanged(int)), 0, SLOT(receive(int))));
+
+ QCOMPARE(cm->m_connections.count(), 18);
+ }
+
+ {
+ INIT();
+
+ // Test x,x,x,0
+ QVERIFY(QtUiTest::disconnectFirst(&e1, SIGNAL(valueChanged(int)), &r1, 0));
+
+ QCOMPARE(cm->m_connections.count(), 16);
+
+ e1. emitValue(10);
+ e2a.emitValue(20);
+ e2b.emitValue(21);
+ e3. emitValue(30);
+ e4. emitValue(40);
+ QCOMPARE(r1.values, QList<int>());
+ QCOMPARE(r1.values2, QList<int>());
+ QCOMPARE(r2.values, QList<int>() << 20 << 21);
+ QCOMPARE(r2.values2, QList<int>() << 20 << 21);
+ QCOMPARE(r3a.values, QList<int>() << 30 << 30);
+ QCOMPARE(r3a.values2, QList<int>());
+ QCOMPARE(r3b.values, QList<int>() << 30);
+ QCOMPARE(r3b.values2, QList<int>() << 30);
+ QCOMPARE(r4a.values, QList<int>() << 40 << 40);
+ QCOMPARE(r4a.values2, QList<int>() << 40 << 40);
+ QCOMPARE(r4b.values, QList<int>() << 40 << 40);
+ QCOMPARE(r4b.values2, QList<int>() << 40 << 40);
+ }
+
+ {
+ INIT();
+
+ // Test x,x,x,x
+ QVERIFY(QtUiTest::disconnectFirst(&e3, SIGNAL(valueChanged(int)), &r3a, SLOT(receive(int))));
+
+ QCOMPARE(cm->m_connections.count(), 16);
+
+ e1. emitValue(10);
+ e2a.emitValue(20);
+ e2b.emitValue(21);
+ e3. emitValue(30);
+ e4. emitValue(40);
+ QCOMPARE(r1.values, QList<int>() << 10);
+ QCOMPARE(r1.values2, QList<int>() << 10);
+ QCOMPARE(r2.values, QList<int>() << 20 << 21);
+ QCOMPARE(r2.values2, QList<int>() << 20 << 21);
+ QCOMPARE(r3a.values, QList<int>());
+ QCOMPARE(r3a.values2, QList<int>());
+ QCOMPARE(r3b.values, QList<int>() << 30);
+ QCOMPARE(r3b.values2, QList<int>() << 30);
+ QCOMPARE(r4a.values, QList<int>() << 40 << 40);
+ QCOMPARE(r4a.values2, QList<int>() << 40 << 40);
+ QCOMPARE(r4b.values, QList<int>() << 40 << 40);
+ QCOMPARE(r4b.values2, QList<int>() << 40 << 40);
+ }
+
+}
+
+#include "tst_qtuitestnamespace.moc"
diff --git a/old/tests/qtuitest/tst_qtuitestnamespace/tst_qtuitestnamespace.pro b/old/tests/qtuitest/tst_qtuitestnamespace/tst_qtuitestnamespace.pro
new file mode 100644
index 0000000..6c5a505
--- /dev/null
+++ b/old/tests/qtuitest/tst_qtuitestnamespace/tst_qtuitestnamespace.pro
@@ -0,0 +1,20 @@
+TEMPLATE=app
+CONFIG+=unittest
+QT = core gui
+TARGET=tst_qtuitestnamespace
+CONFIG+=qtestlib
+
+CONFIG-=debug_and_release_target
+
+include($$SRCROOT/libqtuitest/libqtuitest.pri)
+
+SOURCES+= \
+ tst_qtuitestnamespace.cpp
+
+
+
+target.path += \
+ /usr/local/bin
+
+INSTALLS += \
+ target
diff --git a/old/tests/qtuitest/tst_qtuitestwidgets/tst_qtuitestwidgets.cpp b/old/tests/qtuitest/tst_qtuitestwidgets/tst_qtuitestwidgets.cpp
new file mode 100644
index 0000000..544d030
--- /dev/null
+++ b/old/tests/qtuitest/tst_qtuitestwidgets/tst_qtuitestwidgets.cpp
@@ -0,0 +1,554 @@
+/****************************************************************************
+**
+** 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 <QTest>
+
+#define private public
+#include <qtuitestwidgets_p.h>
+#undef private
+
+#include <qtuitestnamespace.h>
+
+#include <QLabel>
+#include <QCheckBox>
+#include <qplugin.h>
+
+//TESTED_COMPONENT=QA: Testing Framework (18707)
+
+using namespace QtUiTest;
+
+class tst_QtUiTestWidgets : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void cast_zero();
+ void cast_inherit_single();
+ void cast_self();
+ void cast();
+ void cast_unregistered();
+
+ void cleanup();
+};
+
+QTEST_MAIN(tst_QtUiTestWidgets)
+
+class WidgetObject : public QObject, public Widget
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::Widget)
+
+public:
+ WidgetObject(QObject *_wrappee)
+ : QObject(), wrappee(_wrappee), geometryCalls(0)
+ { ++constructed; }
+
+ virtual ~WidgetObject()
+ { ++destructed; }
+
+ virtual const QRect& geometry() const
+ { ++geometryCalls; static QRect nullRect; return nullRect; }
+
+ virtual QRect rect() const
+ { return QRect(); }
+
+ virtual bool isVisible() const
+ { return false; }
+
+ virtual QRegion visibleRegion() const
+ { return QRegion(); }
+
+ virtual QRegion childrenVisibleRegion() const
+ { return QRegion(); }
+
+ virtual const QObjectList &children() const
+ { static QObjectList c; return c; }
+
+ virtual QObject *parent() const
+ { return 0; }
+
+ virtual QString windowTitle() const
+ { return QString(); }
+
+ virtual QPoint mapToGlobal(QPoint const&) const
+ { return QPoint(); }
+
+ virtual QPoint mapFromGlobal(QPoint const&) const
+ { return QPoint(); }
+
+ virtual bool setFocus()
+ { return false; }
+
+ virtual bool setEditFocus(bool)
+ { return false; }
+
+ virtual void focusOutEvent()
+ {}
+
+ virtual bool hasFocus() const
+ { return false; }
+
+ virtual bool hasEditFocus() const
+ { return false; }
+
+ virtual bool ensureVisibleRegion(QRegion const&)
+ { return false; }
+
+ QObject *wrappee;
+ mutable int geometryCalls;
+
+ static int constructed;
+ static int destructed;
+};
+int WidgetObject::constructed = 0;
+int WidgetObject::destructed = 0;
+
+class TextWidgetObject : public WidgetObject, public TextWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::TextWidget)
+
+public:
+ TextWidgetObject(QObject *_wrappee)
+ : WidgetObject(_wrappee)
+ { ++constructed; }
+
+ virtual ~TextWidgetObject()
+ { ++destructed; }
+
+ virtual QString text() const
+ {
+ QLabel const *label = qobject_cast<QLabel*>(wrappee);
+ return label ? label->text() : QString();
+ }
+
+ virtual QString selectedText() const
+ { return text(); }
+
+ static int constructed;
+ static int destructed;
+
+ static QObject* constructor(QObject* wrappee)
+ { return new TextWidgetObject(wrappee); }
+};
+int TextWidgetObject::constructed = 0;
+int TextWidgetObject::destructed = 0;
+
+
+class TestableCheckBox : public QCheckBox,
+ public Widget, public CheckWidget, public TextWidget
+{
+ Q_OBJECT
+ Q_INTERFACES(
+ QtUiTest::Widget
+ QtUiTest::CheckWidget
+ QtUiTest::TextWidget)
+
+public:
+ TestableCheckBox(QWidget *parent = 0)
+ : QCheckBox(parent)
+ { ++constructed; }
+
+ virtual ~TestableCheckBox()
+ { ++destructed; }
+
+ virtual const QRect& geometry() const
+ { return QCheckBox::geometry(); }
+
+ virtual QRect rect() const
+ { return QCheckBox::rect(); }
+
+ virtual bool isVisible() const
+ { return QCheckBox::isVisible(); }
+
+ virtual QRegion visibleRegion() const
+ { return QCheckBox::visibleRegion(); }
+
+ virtual QRegion childrenVisibleRegion() const
+ { return QRegion(); }
+
+ virtual const QObjectList &children() const
+ { return QCheckBox::children(); }
+
+ virtual QObject *parent() const
+ { return QCheckBox::parent(); }
+
+ virtual QString windowTitle() const
+ { return QCheckBox::windowTitle(); }
+
+ virtual QString text() const
+ { return QCheckBox::text(); }
+
+ virtual QString selectedText() const
+ { return QCheckBox::text(); }
+
+ virtual bool isTristate() const
+ { return QCheckBox::isTristate(); }
+
+ virtual Qt::CheckState checkState() const
+ { return QCheckBox::checkState(); }
+
+ virtual QPoint mapToGlobal(QPoint const &p) const
+ { return QCheckBox::mapToGlobal(p); }
+
+ virtual QPoint mapFromGlobal(QPoint const &p) const
+ { return QCheckBox::mapFromGlobal(p); }
+
+ virtual bool setFocus()
+ { QCheckBox::setFocus(); return true; }
+
+ virtual bool setEditFocus(bool)
+ { return false; }
+
+ virtual void focusOutEvent()
+ {}
+
+ virtual bool ensureVisibleRegion(QRegion const&)
+ { return false; }
+
+ virtual bool hasFocus() const
+ { return QCheckBox::hasFocus(); }
+
+ virtual bool hasEditFocus() const
+ { return hasFocus(); }
+
+ static QObject* constructor(QObject* wrappee)
+ { return qobject_cast<TestableCheckBox*>(wrappee); }
+
+ static int constructed;
+ static int destructed;
+};
+int TestableCheckBox::constructed = 0;
+int TestableCheckBox::destructed = 0;
+
+
+class TestWidgetFactory : public QObject, public WidgetFactory
+{
+ Q_OBJECT
+ Q_INTERFACES(QtUiTest::WidgetFactory)
+
+ public:
+ QObject* create(QObject *wrappee)
+ {
+ QObject *ret = 0;
+ if (!ret && wrappee->inherits("QLabel"))
+ ret = new TextWidgetObject(wrappee);
+ if (!ret && wrappee->inherits("QWidget"))
+ ret = new WidgetObject(wrappee);
+ return ret;
+ }
+
+ QStringList keys() const
+ { return QStringList() << "QLabel" << "QWidget"; }
+};
+Q_EXPORT_PLUGIN2(testwidgetfactory, TestWidgetFactory)
+
+Q_IMPORT_PLUGIN(testwidgetfactory)
+
+
+/*
+ \req QTOPIA-78
+
+ \groups
+*/
+void tst_QtUiTestWidgets::cast_unregistered()
+{
+ // Test that casting without calling registerClass fails.
+ QObject obj;
+ QVERIFY(!qtuitest_cast<Widget*>(&obj));
+ // Cast again to ensure any caching code path gets executed.
+ QVERIFY(!qtuitest_cast<Widget*>(&obj));
+}
+
+/*
+ \req QTOPIA-78
+
+ \groups
+*/
+void tst_QtUiTestWidgets::cast()
+{
+ QtUiTestWidgets::instance()->clear();
+
+ QCOMPARE(WidgetObject::constructed, 0);
+ QCOMPARE(WidgetObject::destructed, 0);
+
+ Widget *wrapper = 0;
+ WidgetObject *wo = 0;
+
+ {
+ QWidget widget;
+
+ QtUiTestWidgets::instance()->refreshPlugins();
+
+ QCOMPARE(WidgetObject::constructed, 0);
+ QCOMPARE(WidgetObject::destructed, 0);
+
+ wrapper = qtuitest_cast<Widget*>(&widget);
+ wo = static_cast<WidgetObject*>(wrapper);
+ QVERIFY(wrapper);
+ QVERIFY(wo);
+ QCOMPARE(wo->wrappee, &widget);
+ QCOMPARE(wo->geometryCalls, 0);
+
+ QCOMPARE(WidgetObject::constructed, 1);
+ QCOMPARE(WidgetObject::destructed, 0);
+
+ // Cast something that's already a wrapper
+ QCOMPARE(qtuitest_cast<Widget*>(wo), wrapper);
+
+ QCOMPARE(WidgetObject::constructed, 1);
+ QCOMPARE(WidgetObject::destructed, 0);
+
+ // Verify that WidgetObject's functions are really being called
+ wrapper->geometry();
+ QCOMPARE(wo->geometryCalls, 1);
+
+ // Cast again and verify that it returns the object we already have
+ QCOMPARE( qtuitest_cast<Widget*>(&widget), wrapper );
+ QCOMPARE(WidgetObject::constructed, 1);
+ QCOMPARE(WidgetObject::destructed, 0);
+
+ // Delete wrapped object and verify that testwidget gets deleted
+ }
+ QCOMPARE(WidgetObject::constructed, 1);
+ QCOMPARE(WidgetObject::destructed, 1);
+
+ // Construct and test again
+ {
+ QWidget widget;
+ wrapper = qtuitest_cast<Widget*>(&widget);
+ wo = static_cast<WidgetObject*>(wrapper);
+ QVERIFY(wrapper);
+ QVERIFY(wo);
+ QCOMPARE(wo->wrappee, &widget);
+ QCOMPARE(wo->geometryCalls, 0);
+
+ QCOMPARE(WidgetObject::constructed, 2);
+ QCOMPARE(WidgetObject::destructed, 1);
+
+ // Delete wrapper without deleting object
+ delete wrapper;
+ QCOMPARE(WidgetObject::constructed, 2);
+ QCOMPARE(WidgetObject::destructed, 2);
+
+ // Verify new wrapper can be obtained after deleting old wrapper
+ wrapper = qtuitest_cast<Widget*>(&widget);
+ wo = static_cast<WidgetObject*>(wrapper);
+ QVERIFY(wrapper);
+ QVERIFY(wo);
+ QCOMPARE(wo->wrappee, &widget);
+ QCOMPARE(wo->geometryCalls, 0);
+
+ QCOMPARE(WidgetObject::constructed, 3);
+ QCOMPARE(WidgetObject::destructed, 2);
+
+ QCOMPARE( qtuitest_cast<Widget*>(&widget), wrapper );
+ QCOMPARE(WidgetObject::constructed, 3);
+ QCOMPARE(WidgetObject::destructed, 2);
+ }
+ QCOMPARE(WidgetObject::constructed, 3);
+ QCOMPARE(WidgetObject::destructed, 3);
+}
+
+/*
+ \req QTOPIA-78
+
+ \groups
+ Test case where an interface is implemented by a class which inherits a
+ class which implements one other interface.
+*/
+void tst_QtUiTestWidgets::cast_inherit_single()
+{
+ QCOMPARE(WidgetObject::constructed, 0);
+ QCOMPARE(WidgetObject::destructed, 0);
+ QCOMPARE(TextWidgetObject::constructed, 0);
+ QCOMPARE(TextWidgetObject::destructed, 0);
+
+ QtUiTestWidgets::instance()->refreshPlugins();
+
+ Widget *w;
+ TextWidget *tw;
+
+ {
+ QWidget widget;
+ QLabel label;
+
+ w = qtuitest_cast<Widget*>(&widget);
+ tw = qtuitest_cast<TextWidget*>(&label);
+
+ QVERIFY(w);
+ QVERIFY(tw);
+ QCOMPARE(TextWidgetObject::constructed, 1);
+ QCOMPARE(TextWidgetObject::destructed, 0);
+
+ /* One or more widget objects may have been constructed while finding
+ * the interfaces for QLabel. However there should be exactly 2
+ * still existing. */
+ QCOMPARE(WidgetObject::constructed - WidgetObject::destructed, 2);
+
+ QCOMPARE(tw->text(), QString());
+ label.setText("Hi there");
+ QCOMPARE(tw->text(), QString("Hi there"));
+ }
+
+ QCOMPARE(TextWidgetObject::constructed, 1);
+ QCOMPARE(TextWidgetObject::destructed, 1);
+ QCOMPARE(WidgetObject::constructed - WidgetObject::destructed, 0);
+}
+
+/*
+ \req QTOPIA-78
+
+ \groups
+ Test casting of a widget class which implements its own interfaces.
+*/
+void tst_QtUiTestWidgets::cast_self()
+{
+ QtUiTestWidgets::instance()->clear();
+
+ QCOMPARE( TestableCheckBox::constructed, 0 );
+ QCOMPARE( TestableCheckBox::destructed, 0 );
+
+ Widget *w;
+ TextWidget *tw;
+ CheckWidget *cw;
+
+ {
+ TestableCheckBox tcb;
+ QCheckBox *cb = &tcb;
+
+ QCOMPARE( TestableCheckBox::constructed, 1 );
+ QCOMPARE( TestableCheckBox::destructed, 0 );
+
+ /* Doesn't need to be registered before cast. */
+ QVERIFY( w = qtuitest_cast<Widget*>(&tcb) );
+ QVERIFY( tw = qtuitest_cast<TextWidget*>(&tcb) );
+ QVERIFY( cw = qtuitest_cast<CheckWidget*>(&tcb) );
+
+ QCOMPARE( w, &tcb );
+ QCOMPARE( tw, &tcb );
+ QCOMPARE( cw, &tcb );
+
+ /* However, should still work when other classes are registered...*/
+ QtUiTestWidgets::instance()->refreshPlugins();
+ QCOMPARE( qtuitest_cast<Widget*>(&tcb), w );
+ QCOMPARE( qtuitest_cast<TextWidget*>(&tcb), tw );
+ QCOMPARE( qtuitest_cast<CheckWidget*>(&tcb), cw );
+ QCOMPARE( WidgetObject::constructed, 0 );
+ QCOMPARE( WidgetObject::destructed, 0 );
+
+ QCOMPARE( TestableCheckBox::constructed, 1 );
+ QCOMPARE( TestableCheckBox::destructed, 0 );
+
+ /* Use it a bit and make sure it works as expected. */
+ QCOMPARE( w->geometry(), tcb.geometry() );
+
+ tcb.setText("Walk the Dog");
+ QCOMPARE( tw->text(), tcb.text() );
+
+ tcb.setTristate(true);
+ cb->setCheckState(Qt::PartiallyChecked);
+ QCOMPARE( cw->isTristate(), tcb.isTristate() );
+ QCOMPARE( cw->checkState(), tcb.checkState() );
+ }
+
+ /* Ensure we didn't double-delete */
+ QCOMPARE( TestableCheckBox::constructed, 1 );
+ QCOMPARE( TestableCheckBox::destructed, 1 );
+
+ /* Ensure we can make another one with no problems */
+ {
+ TestableCheckBox tcb;
+
+ QCOMPARE( TestableCheckBox::constructed, 2 );
+ QCOMPARE( TestableCheckBox::destructed, 1 );
+
+ QVERIFY( w = qtuitest_cast<Widget*>(&tcb) );
+ QVERIFY( tw = qtuitest_cast<TextWidget*>(&tcb) );
+ QVERIFY( cw = qtuitest_cast<CheckWidget*>(&tcb) );
+
+ QCOMPARE( w, &tcb );
+ QCOMPARE( tw, &tcb );
+ QCOMPARE( cw, &tcb );
+ }
+ QCOMPARE( TestableCheckBox::constructed, 2 );
+ QCOMPARE( TestableCheckBox::destructed, 2 );
+
+ /* Ensure casting a null pointer has no ill effects */
+ w = qtuitest_cast<Widget*>( static_cast<TestableCheckBox*>(0) );
+ QVERIFY( !w );
+
+ QCOMPARE( TestableCheckBox::constructed, 2 );
+ QCOMPARE( TestableCheckBox::destructed, 2 );
+
+ QCOMPARE( WidgetObject::constructed, 0 );
+ QCOMPARE( WidgetObject::destructed, 0 );
+}
+
+/*
+ \req QTOPIA-78
+
+ \groups
+*/
+void tst_QtUiTestWidgets::cast_zero()
+{
+ QtUiTestWidgets::instance()->clear();
+
+ QVERIFY( !qtuitest_cast<Widget*>(static_cast<QObject*>(0)) );
+
+ QtUiTestWidgets::instance()->refreshPlugins();
+
+ QVERIFY( !qtuitest_cast<Widget*>(static_cast<QObject*>(0)) );
+}
+
+void tst_QtUiTestWidgets::cleanup()
+{
+ QtUiTestWidgets::instance()->clear();
+ QtUiTestWidgets::instance()->refreshPlugins();
+ WidgetObject::constructed = 0;
+ WidgetObject::destructed = 0;
+ TextWidgetObject::constructed = 0;
+ TextWidgetObject::destructed = 0;
+ TestableCheckBox::constructed = 0;
+ TestableCheckBox::destructed = 0;
+}
+
+#include "tst_qtuitestwidgets.moc"
diff --git a/old/tests/qtuitest/tst_qtuitestwidgets/tst_qtuitestwidgets.pro b/old/tests/qtuitest/tst_qtuitestwidgets/tst_qtuitestwidgets.pro
new file mode 100644
index 0000000..c86258f
--- /dev/null
+++ b/old/tests/qtuitest/tst_qtuitestwidgets/tst_qtuitestwidgets.pro
@@ -0,0 +1,27 @@
+TEMPLATE=app
+CONFIG+=unittest
+CONFIG+=qtestlib
+QT = core gui
+
+TARGET=tst_qtuitestwidgets
+
+CONFIG-=debug_and_release_target
+
+SOURCES+= \
+ tst_qtuitestwidgets.cpp
+
+DEFINES+=QT_STATICPLUGIN
+
+include($$SRCROOT/libqtuitest/libqtuitest.pri)
+
+symbian {
+ LIBS+=-L$$OUT_PWD -lqtwidgets
+}
+
+
+
+target.path += \
+ /usr/local/bin
+
+INSTALLS += \
+ target \ No newline at end of file
diff --git a/old/tests/shared/filedialog.qtt b/old/tests/shared/filedialog.qtt
new file mode 100644
index 0000000..0a4f904
--- /dev/null
+++ b/old/tests/shared/filedialog.qtt
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+
+FileDialog = {
+
+ dialog: function() {
+ return findByProperty( { className: "QFileDialog" } );
+ },
+
+ openFile: function(path) {
+ var viewMode = getProperty(FileDialog.dialog(), "viewMode");
+ var lookIn = findByProperty( { objectName: "lookInCombo" } );
+ if (viewMode == 1) {
+ var view = findByProperty( { objectName: "listView" } );
+ } else {
+ view = findByProperty( { objectName: "treeView" } );
+ }
+
+ // The "Look in:" QFileDialogComboBox gets populated in showPopup, so it is
+ // necessary to make the popup appear before we can use it...
+ mouseClick(lookIn);
+
+ // FIXME: Unix only. Should make this work cross-platform
+ select("/", lookIn);
+
+ var pathSplit = path.split("/");
+ for (var i=1; i<pathSplit.length; ++i) {
+ select(pathSplit[i], view);
+ activate( translate("QFileDialog", "&Open") );
+ }
+ },
+
+ newFolder: function(name) {
+ var nf = findByProperty( { objectName: "newFolderButton" } );
+ activate(nf);
+ enter(name);
+ keyClick(Qt.Key_Enter);
+ if (currentTitle() == translate("QFileSystemModel", "Invalid filename")) {
+ fail("Invalid filename");
+ }
+ },
+
+ rename: function(oldName, newName) {
+ var lv = findByProperty( { objectName: "listView" } );
+ select(oldName, lv);
+ keyClick(Qt.Key_Menu);
+ select( translate("QFileDialog", "&Rename"), findByProperty( { className: "QMenu" } ));
+ enter(newName);
+ keyClick(Qt.Key_Enter);
+ if (currentTitle() == translate("QFileSystemModel", "Invalid filename")) {
+ fail("Invalid filename");
+ }
+ },
+
+ back: function() {
+ return ( findByProperty( { objectName: "backButton" } ) );
+ },
+
+ forward: function() {
+ return ( findByProperty( { objectName: "forwardButton" } ) );
+ },
+
+ parentDir: function() {
+ return ( findByProperty( { objectName: "toParentButton" } ) );
+ },
+
+ listView: function() {
+ return ( findByProperty( { objectName: "listModeButton" } ) );
+ },
+
+ detailView: function() {
+ return ( findByProperty( { objectName: "detailModeButton" } ) );
+ }
+}
diff --git a/old/tests/tests.pro b/old/tests/tests.pro
new file mode 100644
index 0000000..7b62cb1
--- /dev/null
+++ b/old/tests/tests.pro
@@ -0,0 +1,3 @@
+TEMPLATE=subdirs
+CONFIG+=systemtest
+SUBDIRS+=qtuitest