aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktextedit
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-08-03 16:50:24 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-06 09:06:24 +0200
commit35c8ad7957aed842e1aba60df96e50c5e2dcf133 (patch)
tree78594d3984716574eb289c773ad286260d6031c4 /tests/auto/quick/qquicktextedit
parent082dff2c8f5383e8372c1a4d7c61bc2eebe5c9df (diff)
Fix pasting with the middle button in TextInput and TextEdit.
Neither item accepted the middle button which prevented the mouse events ever reaching them. Change-Id: Ia8f693099df4d6c248976453d554fef96d1d3b33 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquicktextedit')
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 9f381053a9..4953874809 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -153,6 +153,7 @@ private slots:
void copyAndPaste();
void canPaste();
void canPasteEmpty();
+ void middleClickPaste();
void textInput();
void inputMethodUpdate();
void openInputPanel();
@@ -2706,6 +2707,58 @@ void tst_qquicktextedit::canPasteEmpty() {
}
+void tst_qquicktextedit::middleClickPaste()
+{
+#ifndef QT_NO_CLIPBOARD
+
+#ifdef Q_OS_MAC
+ {
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ else
+ QSKIP("This machine doesn't support the clipboard");
+ }
+#endif
+
+ QQuickView window(testFileUrl("mouseselection_true.qml"));
+
+ window.show();
+ window.requestActivateWindow();
+ QTest::qWaitForWindowActive(&window);
+
+ QVERIFY(window.rootObject() != 0);
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(window.rootObject());
+ QVERIFY(textEditObject != 0);
+
+ textEditObject->setFocus(true);
+
+ QString originalText = textEditObject->text();
+ QString selectedText = "234567";
+
+ // press-and-drag-and-release from x1 to x2
+ const QPoint p1 = textEditObject->positionToRectangle(2).center().toPoint();
+ const QPoint p2 = textEditObject->positionToRectangle(8).center().toPoint();
+ const QPoint p3 = textEditObject->positionToRectangle(1).center().toPoint();
+ QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, p1);
+ QTest::mouseMove(&window, p2);
+ QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, p2);
+ QTRY_COMPARE(textEditObject->selectedText(), selectedText);
+
+ // Middle click pastes the selected text, assuming the platform supports it.
+ QTest::mouseClick(&window, Qt::MiddleButton, Qt::NoModifier, p3);
+
+ // ### This is to prevent double click detection from carrying over to the next test.
+ QTest::qWait(QGuiApplication::styleHints()->mouseDoubleClickInterval() + 10);
+
+ if (QGuiApplication::clipboard()->supportsSelection())
+ QCOMPARE(textEditObject->text().mid(1, selectedText.length()), selectedText);
+ else
+ QCOMPARE(textEditObject->text(), originalText);
+#endif
+}
+
void tst_qquicktextedit::readOnly()
{
QQuickView window(testFileUrl("readOnly.qml"));