summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-05-13 16:09:00 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-05-13 16:09:00 (GMT)
commitb9f9d811cfb71ab2983f25f3514da958e444de4b (patch)
tree40b0f8571a98ffa6377adb075256e300652343e7 /tests/auto
parentb205fca78bcede0b2eefc8c0b12fed040e77eff1 (diff)
parent3d27a19ca009836b812b59c3359db1369d391181 (diff)
downloadQt-b9f9d811cfb71ab2983f25f3514da958e444de4b.zip
Qt-b9f9d811cfb71ab2983f25f3514da958e444de4b.tar.gz
Qt-b9f9d811cfb71ab2983f25f3514da958e444de4b.tar.bz2
Merge branch 4.7 into qt-4.8-from-4.7
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp10
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/data/preventContextMenu.qml22
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp63
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml8
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp36
5 files changed, 139 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index 8b90030..23ac523 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -714,6 +714,16 @@ void tst_QDeclarativeListView::removed(bool animated)
QTRY_VERIFY(name = findItem<QDeclarativeText>(contentItem, "textName", model.count()-1));
QCOMPARE(name->text(), QString("New"));
+ // Add some more items so that we don't run out
+ for (int i = 50; i < 100; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ // QTBUG-19198 move to end and remove all visible items one at a time.
+ listview->positionViewAtEnd();
+ for (int i = 0; i < 18; ++i)
+ model.removeItems(model.count() - 1, 1);
+ QTRY_VERIFY(findItems<QDeclarativeItem>(contentItem, "wrapper").count() > 16);
+
delete canvas;
}
diff --git a/tests/auto/declarative/qdeclarativemousearea/data/preventContextMenu.qml b/tests/auto/declarative/qdeclarativemousearea/data/preventContextMenu.qml
new file mode 100644
index 0000000..dcbb5d7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemousearea/data/preventContextMenu.qml
@@ -0,0 +1,22 @@
+import QtQuick 1.1
+import Test 1.0
+
+Item {
+ width: 200
+ height: 200
+
+ property alias mouseAreaEnabled: mouseArea.enabled
+ property alias eventsReceived: receiver.eventCount
+
+ ContextMenuEventReceiver {
+ id: receiver
+ anchors.fill: parent
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
+ enabled: true
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
index e1c34fc..fea7865 100644
--- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
+++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
@@ -47,6 +47,7 @@
#include <QtDeclarative/qdeclarativeview.h>
#include <QtDeclarative/qdeclarativecontext.h>
#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativeproperty.h>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@@ -70,6 +71,9 @@ private slots:
void preventStealing();
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
+#ifndef QT_NO_CONTEXTMENU
+ void preventContextMenu();
+#endif // QT_NO_CONTEXTMENU
private:
QDeclarativeView *createView();
@@ -637,6 +641,65 @@ void tst_QDeclarativeMouseArea::testQtQuick11Attributes_data()
<< ":1 \"MouseArea.preventStealing\" is not available in QtQuick 1.0.\n";
}
+#ifndef QT_NO_CONTEXTMENU
+class ContextMenuEventReceiver : public QDeclarativeItem
+{
+ Q_OBJECT
+ Q_PROPERTY(int eventCount READ eventCount NOTIFY eventCountChanged);
+public:
+ ContextMenuEventReceiver(QDeclarativeItem *parent = 0) : QDeclarativeItem(parent), m_eventCount(0) { }
+ int eventCount() const { return m_eventCount; }
+signals:
+ void eventCountChanged(int);
+protected:
+ void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
+ if (event->reason() == QGraphicsSceneContextMenuEvent::Mouse) {
+ m_eventCount++;
+ emit eventCountChanged(m_eventCount);
+ }
+ }
+private:
+ int m_eventCount;
+};
+
+void tst_QDeclarativeMouseArea::preventContextMenu()
+{
+ // A MouseArea accepting Left, Middle and Right buttons should prevent context menu
+ // events with "Mouse" reason to hit the Item below.
+
+ qmlRegisterType<ContextMenuEventReceiver>("Test", 1, 0, "ContextMenuEventReceiver");
+
+ QDeclarativeView *view = createView();
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/preventContextMenu.qml"));
+ view->show();
+ QVERIFY(view->rootObject() != 0);
+
+ QDeclarativeProperty mouseAreaEnabled(view->rootObject(), "mouseAreaEnabled");
+ QVERIFY(mouseAreaEnabled.read().toBool());
+
+ QDeclarativeProperty eventsReceived(view->rootObject(), "eventsReceived");
+ QCOMPARE(eventsReceived.read().toInt(), 0);
+
+ QPoint targetPoint = view->mapFromScene(QPoint(80, 80));
+
+ QContextMenuEvent fakeEvent1(QContextMenuEvent::Mouse, targetPoint);
+ QApplication::sendEvent(view->viewport(), &fakeEvent1);
+ QCOMPARE(eventsReceived.read().toInt(), 0);
+
+ mouseAreaEnabled.write(false);
+ QVERIFY(!mouseAreaEnabled.read().toBool());
+ QContextMenuEvent fakeEvent2(QContextMenuEvent::Mouse, targetPoint);
+ QApplication::sendEvent(view->viewport(), &fakeEvent2);
+ QCOMPARE(eventsReceived.read().toInt(), 1);
+
+ mouseAreaEnabled.write(true);
+ QVERIFY(mouseAreaEnabled.read().toBool());
+ QContextMenuEvent fakeEvent3(QContextMenuEvent::Mouse, targetPoint);
+ QApplication::sendEvent(view->viewport(), &fakeEvent3);
+ QCOMPARE(eventsReceived.read().toInt(), 1);
+}
+#endif // QT_NO_CONTEXTMENU
+
QTEST_MAIN(tst_QDeclarativeMouseArea)
#include "tst_qdeclarativemousearea.moc"
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml
new file mode 100644
index 0000000..af23f6d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml
@@ -0,0 +1,8 @@
+import QtQuick 1.1
+
+TextEdit {
+ focus: true
+ text: "0123456789ABCDEFGHIJKLMNOPQRS\nTUVWXYZ"
+ selectByMouse: true
+ mouseSelectionMode: TextInput.SelectWords
+}
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 7bbef21..f8af433 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -119,6 +119,7 @@ private slots:
void moveCursorSelectionSequence();
void mouseSelection_data();
void mouseSelection();
+ void multilineMouseSelection();
void deferEnableSelectByMouse_data();
void deferEnableSelectByMouse();
void deferDisableSelectByMouse_data();
@@ -1364,6 +1365,41 @@ void tst_qdeclarativetextedit::mouseSelection()
delete canvas;
}
+void tst_qdeclarativetextedit::multilineMouseSelection()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/mouseselection_multiline.qml");
+
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject());
+ QVERIFY(textEditObject != 0);
+
+ // press-and-drag from x1,y1 to x2,y1
+ int x1 = 10;
+ int x2 = textEditObject->width() - 10;
+ int y1 = textEditObject->height() / 4;
+ int y2 = textEditObject->height() * 3 / 4;
+ QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y1)));
+ QMouseEvent mv1(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y1)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv1);
+ QString str1 = textEditObject->selectedText();
+ QVERIFY(str1.length() > 3); // don't reallly care *what* was selected (and it's too sensitive to platform)
+
+ // drag-and-release from x2,y1 to x2,y2
+ QMouseEvent mv2(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y2)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv2);
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y2)));
+ QString str2 = textEditObject->selectedText();
+ QVERIFY(str1 != str2);
+ QVERIFY(str2.length() > 3);
+
+ delete canvas;
+}
+
void tst_qdeclarativetextedit::deferEnableSelectByMouse_data()
{
QTest::addColumn<QString>("qmlfile");