summaryrefslogtreecommitdiffstats
path: root/tests/auto/qclipboard
diff options
context:
space:
mode:
authorTitta Heikkala <EXT-Titta.2.Heikkala@nokia.com>2010-10-21 11:09:33 +0300
committerJanne Koskinen <janne.p.koskinen@digia.com>2010-10-21 11:09:33 +0300
commita3ceea583b9d14f809e4bf24a9c86fb9179a7797 (patch)
treeb9f688444cf148f8e7f4a763bfdf21d5ef4ac9c1 /tests/auto/qclipboard
parent80f031dfca7c161de4461514dfd8d9d664ea2f03 (diff)
Support for clipboard between Qt and Symbian applications
Clipboard now supports copying text between Qt and Symbian applications. Text is always copied to QClipboard and to Symbian clipboard. If QClipboard is empty, Symbian clipboard is checked and text is pasted from there. Corresponding test cases added. Task-number: QT-2085 Reviewed-by: Janne Koskinen Merge-request: 870 Reviewed-by: Janne Koskinen <janne.p.koskinen@digia.com>
Diffstat (limited to 'tests/auto/qclipboard')
-rw-r--r--tests/auto/qclipboard/test/test.pro2
-rw-r--r--tests/auto/qclipboard/tst_qclipboard.cpp79
2 files changed, 81 insertions, 0 deletions
diff --git a/tests/auto/qclipboard/test/test.pro b/tests/auto/qclipboard/test/test.pro
index 0f8cad1792..97b0c9c320 100644
--- a/tests/auto/qclipboard/test/test.pro
+++ b/tests/auto/qclipboard/test/test.pro
@@ -17,6 +17,8 @@ wince*|symbian: {
paster.path = paster
symbian: {
+ LIBS += -lbafl -lestor -letext
+
load(data_caging_paths)
rsc.sources = $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/copier.rsc
rsc.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/paster.rsc
diff --git a/tests/auto/qclipboard/tst_qclipboard.cpp b/tests/auto/qclipboard/tst_qclipboard.cpp
index d1f3e86a9b..a4fac43114 100644
--- a/tests/auto/qclipboard/tst_qclipboard.cpp
+++ b/tests/auto/qclipboard/tst_qclipboard.cpp
@@ -47,6 +47,11 @@
#ifdef Q_WS_MAC
#include <Carbon/Carbon.h>
#endif
+#ifdef Q_OS_SYMBIAN
+#include "private/qcore_symbian_p.h"
+#include "txtetext.h"
+#include <baclipb.h>
+#endif
//TESTED_CLASS=
//TESTED_FILES=
@@ -62,6 +67,10 @@ private slots:
void testSignals();
void setMimeData();
void clearBeforeSetText();
+#ifdef Q_OS_SYMBIAN
+ void pasteCopySymbian();
+ void copyPasteSymbian();
+#endif
private:
bool nativeClipboardWorking();
@@ -335,6 +344,76 @@ void tst_QClipboard::clearBeforeSetText()
QCOMPARE(QApplication::clipboard()->text(), text);
}
+/*
+ Test that text copied from qt application
+ can be pasted with symbian clipboard
+*/
+#ifdef Q_OS_SYMBIAN
+// ### This test case only makes sense in symbian
+void tst_QClipboard::pasteCopySymbian()
+{
+ if (!nativeClipboardWorking())
+ QSKIP("Native clipboard not working in this setup", SkipAll);
+ const QString string("Test string symbian.");
+ QApplication::clipboard()->setText(string);
+
+ const TInt KPlainTextBegin = 0;
+ RFs fs = qt_s60GetRFs();
+ CClipboard* cb = CClipboard::NewForReadingLC(fs);
+
+ CPlainText* text = CPlainText::NewL();
+ CleanupStack::PushL(text);
+ TInt dataLength = text->PasteFromStoreL(cb->Store(), cb->StreamDictionary(),
+ KPlainTextBegin);
+ if (dataLength == 0) {
+ User::Leave(KErrNotFound);
+ }
+ HBufC* hBuf = HBufC::NewL(dataLength);
+ TPtr buf = hBuf->Des();
+ text->Extract(buf, KPlainTextBegin, dataLength);
+
+ QString storeString = qt_TDesC2QString(buf);
+ CleanupStack::PopAndDestroy(text);
+ CleanupStack::PopAndDestroy(cb);
+
+ QCOMPARE(string, storeString);
+#endif
+}
+
+/*
+ Test that text copied to symbian clipboard
+ can be pasted to qt clipboard
+*/
+#ifdef Q_OS_SYMBIAN
+// ### This test case only makes sense in symbian
+void tst_QClipboard::copyPasteSymbian()
+{
+ if (!nativeClipboardWorking())
+ QSKIP("Native clipboard not working in this setup", SkipAll);
+ const QString string("Test string symbian.");
+ const TInt KPlainTextBegin = 0;
+
+ RFs fs = qt_s60GetRFs();
+ CClipboard* cb = CClipboard::NewForWritingLC(fs);
+ CStreamStore& store = cb->Store();
+ CStreamDictionary& dict = cb->StreamDictionary();
+ RStoreWriteStream symbianStream;
+ TStreamId symbianStId = symbianStream.CreateLC(cb->Store());
+
+ CPlainText* text = CPlainText::NewL();
+ CleanupStack::PushL(text);
+ TPtrC textPtr(qt_QString2TPtrC(string));
+ text->InsertL(KPlainTextBegin, textPtr);
+ text->CopyToStoreL(store, dict, KPlainTextBegin, textPtr.Length());
+ CleanupStack::PopAndDestroy(text);
+ (cb->StreamDictionary()).AssignL(KClipboardUidTypePlainText, symbianStId);
+ cb->CommitL();
+ CleanupStack::PopAndDestroy(2, cb);
+
+ QCOMPARE(QApplication::clipboard()->text(), string);
+#endif
+}
+
QTEST_MAIN(tst_QClipboard)
#include "tst_qclipboard.moc"