diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-01-10 08:11:19 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-01-11 00:34:50 (GMT) |
commit | 7d43a31902ca6d2132004c45db313194c9669bb6 (patch) | |
tree | 4f9528033ad7835cde33636adea1aacdbd0fd862 /tests/auto/declarative/qdeclarativetextedit | |
parent | 17872d698be857d93b4d613f6423800308614684 (diff) | |
download | Qt-7d43a31902ca6d2132004c45db313194c9669bb6.zip Qt-7d43a31902ca6d2132004c45db313194c9669bb6.tar.gz Qt-7d43a31902ca6d2132004c45db313194c9669bb6.tar.bz2 |
Disable dragging text in TextEdit.
Add a dragEnabled property to QTextControl so text dragging can
optionally be disabled.
Task-number: QTBUG-16248
Reviewed-by: Martin Jones
Diffstat (limited to 'tests/auto/declarative/qdeclarativetextedit')
-rw-r--r-- | tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 7af008f..649d34f 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -113,6 +113,7 @@ private slots: void moveCursorSelection(); void mouseSelection_data(); void mouseSelection(); + void dragMouseSelection(); void inputMethodHints(); void cursorDelegate(); @@ -916,6 +917,51 @@ void tst_qdeclarativetextedit::mouseSelection() QVERIFY(str.isEmpty()); } +void tst_qdeclarativetextedit::dragMouseSelection() +{ + QString qmlfile = SRCDIR "/data/mouseselection_true.qml"; + + QDeclarativeView *canvas = createView(qmlfile); + + 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); + + textEditObject->setAcceptDrops(true); + + // press-and-drag-and-release from x1 to x2 + int x1 = 10; + int x2 = 70; + int y = textEditObject->height()/2; + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y))); + { + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + } + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y))); + QString str1 = textEditObject->selectedText(); + QVERIFY(str1.length() > 3); + + // press and drag the current selection. + x1 = 40; + x2 = 100; + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y))); + { + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + } + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y))); + QString str2 = textEditObject->selectedText(); + QVERIFY(str2.length() > 3); + + QVERIFY(str1 != str2); // Verify the second press and drag is a new selection and doesn't not the first moved. +} + void tst_qdeclarativetextedit::inputMethodHints() { QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethodhints.qml"); |