summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2012-09-19 10:12:40 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-27 09:15:00 +0200
commit507b90ac868202d7ed7ef8d820003e51327e4222 (patch)
tree3db8b2b2c03ba77425d466f8cb30f14475180547 /tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
parentb0b7d9cf6b213cebcdc5be7583119af15feb5bf6 (diff)
QtWidgets auto tests: revise clipboard related tests
Use PlatformClipboard::isAvailable() and omit relevant test cases when QT_NO_CLIPBOARD is defined. Change-Id: I7e7b20a0a18f1a82987564f0e5e6c76d9207bc4b Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Diffstat (limited to 'tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp')
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp47
1 files changed, 10 insertions, 37 deletions
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index 3458b587cd..27369adc22 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -64,6 +64,7 @@
#include <qtextdocumentfragment.h>
#include <qsyntaxhighlighter.h>
+#include "../../../shared/platformclipboard.h"
#include "../../../shared/platforminputcontext.h"
#include <private/qinputmethod_p.h>
@@ -76,23 +77,6 @@ Q_DECLARE_METATYPE(keyPairType);
Q_DECLARE_METATYPE(QList<bool>);
Q_DECLARE_METATYPE(QList<int>);
-#ifdef Q_OS_MAC
-#include <Carbon/Carbon.h>
-#endif
-
-bool nativeClipboardWorking()
-{
-#ifdef Q_OS_MAC
- PasteboardRef pasteboard;
- OSStatus status = PasteboardCreate(0, &pasteboard);
- if (status == noErr)
- CFRelease(pasteboard);
- return status == noErr;
-#endif
- return true;
-}
-
-
QT_FORWARD_DECLARE_CLASS(QTextEdit)
class tst_QTextEdit : public QObject
@@ -187,7 +171,9 @@ private slots:
void wordWrapProperty();
void lineWrapProperty();
void selectionChanged();
+#ifndef QT_NO_CLIPBOARD
void copyPasteBackgroundImage();
+#endif
void setText();
void cursorRect();
#ifdef QT_BUILD_INTERNAL
@@ -220,7 +206,6 @@ private slots:
private:
void createSelection();
int blockCount() const;
- bool nativeClipboardWorking();
void compareWidgetAndImage(QTextEdit &widget, const QString &imageFileName);
QTextEdit *ed;
@@ -229,18 +214,6 @@ private:
const QString m_fullWidthSelectionImagesFolder;
};
-bool tst_QTextEdit::nativeClipboardWorking()
-{
-#ifdef Q_OS_MAC
- PasteboardRef pasteboard;
- OSStatus status = PasteboardCreate(0, &pasteboard);
- if (status == noErr)
- CFRelease(pasteboard);
- return status == noErr;
-#endif
- return true;
-}
-
// Testing get/set functions
void tst_QTextEdit::getSetCheck()
{
@@ -525,7 +498,7 @@ void tst_QTextEdit::createSelection()
#ifndef QT_NO_CLIPBOARD
void tst_QTextEdit::clearMustNotChangeClipboard()
{
- if (!nativeClipboardWorking())
+ if (!PlatformClipboard::isAvailable())
QSKIP("Clipboard not working with cron-started unit tests");
ed->textCursor().insertText("Hello World");
QString txt("This is different text");
@@ -814,7 +787,7 @@ void tst_QTextEdit::setTextCursor()
#ifndef QT_NO_CLIPBOARD
void tst_QTextEdit::undoAvailableAfterPaste()
{
- if (!nativeClipboardWorking())
+ if (!PlatformClipboard::isAvailable())
QSKIP("Clipboard not working with cron-started unit tests");
QSignalSpy spy(ed->document(), SIGNAL(undoAvailable(bool)));
@@ -1035,7 +1008,7 @@ void tst_QTextEdit::preserveCharFormatInAppend()
#ifndef QT_NO_CLIPBOARD
void tst_QTextEdit::copyAndSelectAllInReadonly()
{
- if (!nativeClipboardWorking())
+ if (!PlatformClipboard::isAvailable())
QSKIP("Clipboard not working with cron-started unit tests");
ed->setReadOnly(true);
@@ -1581,7 +1554,7 @@ void tst_QTextEdit::selectWordsFromStringsContainingSeparators()
#ifndef QT_NO_CLIPBOARD
void tst_QTextEdit::canPaste()
{
- if (!nativeClipboardWorking())
+ if (!PlatformClipboard::isAvailable())
QSKIP("Clipboard not working with cron-started unit tests");
QApplication::clipboard()->setText(QString());
@@ -1880,10 +1853,10 @@ void tst_QTextEdit::selectionChanged()
QCOMPARE(selectionChangedSpy.count(), 4);
}
+#ifndef QT_NO_CLIPBOARD
void tst_QTextEdit::copyPasteBackgroundImage()
{
-#ifndef QT_NO_CLIPBOARD
- if (!nativeClipboardWorking())
+ if (!PlatformClipboard::isAvailable())
QSKIP("Native clipboard not working in this setup");
QImage foo(16, 16, QImage::Format_ARGB32_Premultiplied);
@@ -1923,8 +1896,8 @@ void tst_QTextEdit::copyPasteBackgroundImage()
QVERIFY(ba.textureImage().cacheKey() == bb.textureImage().cacheKey() ||
ba.texture().cacheKey() == bb.texture().cacheKey());
QFile::remove(QLatin1String("foo.png"));
-#endif
}
+#endif
void tst_QTextEdit::setText()
{