summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativetextedit
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-07-12 01:22:16 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2010-07-13 04:44:19 (GMT)
commit35dc9919a0dadaafb72ab4651cc5e9ea29b9aa66 (patch)
tree94cf96d6b4bb5a633b901916fc269d6961b9e96c /tests/auto/declarative/qdeclarativetextedit
parent957751d93aeb8d5c2703fa3d13d8b3a0e0334d51 (diff)
downloadQt-35dc9919a0dadaafb72ab4651cc5e9ea29b9aa66.zip
Qt-35dc9919a0dadaafb72ab4651cc5e9ea29b9aa66.tar.gz
Qt-35dc9919a0dadaafb72ab4651cc5e9ea29b9aa66.tar.bz2
Add copy(), cut() and paste() support to TextInput
Task-number: QTBUG-12086 Reviewed-by: Michael Brasser (cherry picked from commit 0fdf5122c72eb86d49cba2b69f80d3a9c5949da6)
Diffstat (limited to 'tests/auto/declarative/qdeclarativetextedit')
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 4e4f45e..1ec700b 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -96,6 +96,7 @@ private slots:
void delegateLoading();
void navigation();
void readOnly();
+ void copyAndPaste();
void openInputPanelOnClick();
void openInputPanelOnFocus();
void geometrySignals();
@@ -842,6 +843,40 @@ void tst_qdeclarativetextedit::navigation()
QVERIFY(input->hasFocus() == true);
}
+void tst_qdeclarativetextedit::copyAndPaste() {
+#ifndef QT_NO_CLIPBOARD
+ QString componentStr = "import Qt 4.7\nTextEdit { text: \"Hello world!\" }";
+ QDeclarativeComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEdit = qobject_cast<QDeclarativeTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ // copy and paste
+ QCOMPARE(textEdit->text().length(), 12);
+ textEdit->select(0, textEdit->text().length());;
+ textEdit->copy();
+ QCOMPARE(textEdit->selectedText(), QString("Hello world!"));
+ QCOMPARE(textEdit->selectedText().length(), 12);
+ textEdit->setCursorPosition(0);
+ textEdit->paste();
+ QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
+ QCOMPARE(textEdit->text().length(), 24);
+
+ // select word
+ textEdit->setCursorPosition(0);
+ textEdit->selectWord();
+ QCOMPARE(textEdit->selectedText(), QString("Hello"));
+
+ // select all and cut
+ textEdit->selectAll();
+ textEdit->cut();
+ QCOMPARE(textEdit->text().length(), 0);
+ textEdit->paste();
+ QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
+ QCOMPARE(textEdit->text().length(), 24);
+#endif
+}
+
void tst_qdeclarativetextedit::readOnly()
{
QDeclarativeView *canvas = createView(SRCDIR "/data/readOnly.qml");