diff options
author | Joona Petrell <joona.t.petrell@nokia.com> | 2010-07-12 01:22:16 (GMT) |
---|---|---|
committer | Joona Petrell <joona.t.petrell@nokia.com> | 2010-07-12 01:30:48 (GMT) |
commit | 0fdf5122c72eb86d49cba2b69f80d3a9c5949da6 (patch) | |
tree | 2b3fd00bdbf1c890450350da4cb7e4935fffd584 /tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp | |
parent | b4ceee6ee8f8bd45567c900be0b89dc13af57c3d (diff) | |
download | Qt-0fdf5122c72eb86d49cba2b69f80d3a9c5949da6.zip Qt-0fdf5122c72eb86d49cba2b69f80d3a9c5949da6.tar.gz Qt-0fdf5122c72eb86d49cba2b69f80d3a9c5949da6.tar.bz2 |
Add copy(), cut() and paste() support to TextInput
Task-number: QTBUG-12086
Reviewed-by: Michael Brasser
Diffstat (limited to 'tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 859221e..c8767b5 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -100,6 +100,7 @@ private slots: void cursorDelegate(); void navigation(); + void copyAndPaste(); void readOnly(); void openInputPanelOnClick(); @@ -697,6 +698,40 @@ void tst_qdeclarativetextinput::navigation() delete canvas; } +void tst_qdeclarativetextinput::copyAndPaste() { +#ifndef QT_NO_CLIPBOARD + QString componentStr = "import Qt 4.7\nTextInput { text: \"Hello world!\" }"; + QDeclarativeComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QDeclarativeTextInput *textInput = qobject_cast<QDeclarativeTextInput*>(textInputComponent.create()); + QVERIFY(textInput != 0); + + // copy and paste + QCOMPARE(textInput->text().length(), 12); + textInput->select(0, textInput->text().length());; + textInput->copy(); + QCOMPARE(textInput->selectedText(), QString("Hello world!")); + QCOMPARE(textInput->selectedText().length(), 12); + textInput->setCursorPosition(0); + textInput->paste(); + QCOMPARE(textInput->text(), QString("Hello world!Hello world!")); + QCOMPARE(textInput->text().length(), 24); + + // select word + textInput->setCursorPosition(0); + textInput->selectWord(); + QCOMPARE(textInput->selectedText(), QString("Hello")); + + // select all and cut + textInput->selectAll(); + textInput->cut(); + QCOMPARE(textInput->text().length(), 0); + textInput->paste(); + QCOMPARE(textInput->text(), QString("Hello world!Hello world!")); + QCOMPARE(textInput->text().length(), 24); +#endif +} + void tst_qdeclarativetextinput::cursorDelegate() { QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml"); @@ -1008,7 +1043,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QCOMPARE(ic.openInputPanelReceived, false); // input method should be disabled - // if TextEdit loses focus + // if TextInput loses focus input.setFocus(false); QApplication::processEvents(); QVERIFY(view.inputContext() == 0); |