summaryrefslogtreecommitdiffstats
path: root/tests/auto/qclipboard
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-11-22 14:19:27 +0000
committerShane Kearns <shane.kearns@accenture.com>2011-11-22 14:43:06 +0000
commit431bb1e39f2df69329607b96f7178aea42962318 (patch)
treeeb323cc1986b33c3b64b3dddb56d00255a08ac36 /tests/auto/qclipboard
parentbd5dfa8fd2f4d5dc4a1fe0984a53b966cff6470f (diff)
Symbian: don't merge native clipboard, overwrite.
If copying text from a Qt application that has both plaintext and formatted text representations, then S60 applications only see the plaintext. If copying data from an S60 application, the Qt application can see the plaintext. However as this was merged with the existing clipboard contents in Qt, the formatted text was unchanged. Now, we clear the internal clipboard QMimeData before writing the contents of the symbian clipboard to it. This ensures stale data from a previous copy is not left behind. Task-Number: ou1cimx1#927246 Reviewed-By: mread
Diffstat (limited to 'tests/auto/qclipboard')
-rw-r--r--tests/auto/qclipboard/tst_qclipboard.cpp64
1 files changed, 51 insertions, 13 deletions
diff --git a/tests/auto/qclipboard/tst_qclipboard.cpp b/tests/auto/qclipboard/tst_qclipboard.cpp
index 94981cf8e5..ea470e7e5d 100644
--- a/tests/auto/qclipboard/tst_qclipboard.cpp
+++ b/tests/auto/qclipboard/tst_qclipboard.cpp
@@ -73,6 +73,7 @@ private slots:
#ifdef Q_OS_SYMBIAN
void pasteCopySymbian();
void copyPasteSymbian();
+ void copyCopyPasteSymbian();
#endif
private:
@@ -347,17 +348,17 @@ void tst_QClipboard::clearBeforeSetText()
QCOMPARE(QApplication::clipboard()->text(), text);
}
+#ifdef Q_OS_SYMBIAN
/*
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.");
+ const QString string("Test string qt->symbian.");
QApplication::clipboard()->setText(string);
const TInt KPlainTextBegin = 0;
@@ -381,19 +382,9 @@ void tst_QClipboard::pasteCopySymbian()
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()
+static void nativeCopyHelper(const QString &string)
{
- 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();
@@ -412,8 +403,55 @@ void tst_QClipboard::copyPasteSymbian()
(cb->StreamDictionary()).AssignL(KClipboardUidTypePlainText, symbianStId);
cb->CommitL();
CleanupStack::PopAndDestroy(2, cb);
+}
+
+/*
+ Test that text copied to symbian clipboard
+ can be pasted to qt clipboard
+*/
+// ### 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->qt.");
+
+ nativeCopyHelper(string);
+
+ QCOMPARE(QApplication::clipboard()->text(), string);
+}
+
+/*
+ Test that text copied to symbian clipboard
+ can be pasted to qt clipboard, even if Qt
+ clipboard already had copied formatted text
+*/
+// ### This test case only makes sense in symbian
+void tst_QClipboard::copyCopyPasteSymbian()
+{
+ if (!nativeClipboardWorking())
+ QSKIP("Native clipboard not working in this setup", SkipAll);
+
+ //first copy some mime data with text/html and text/plain representations
+ QMimeData *mimeData = new QMimeData;
+ const QString preCopy(QLatin1String("qt_symbian"));
+ mimeData->setText(preCopy);
+ mimeData->setHtml(preCopy);
+ QApplication::clipboard()->setMimeData(mimeData);
+
+ //check both representations are pastable
+ QCOMPARE(QApplication::clipboard()->mimeData()->html(), preCopy);
+ QCOMPARE(QApplication::clipboard()->mimeData()->text(), preCopy);
+
+ //native copy some plain text
+ const QString string("symbian_qt");
+ nativeCopyHelper(string);
+ //check text/plain is pastable
QCOMPARE(QApplication::clipboard()->text(), string);
+ QCOMPARE(QApplication::clipboard()->mimeData()->text(), string);
+ //check text/html is cleared
+ QVERIFY(QApplication::clipboard()->mimeData()->html().isEmpty());
}
#endif