diff options
3 files changed, 20 insertions, 85 deletions
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 9254e82532..215e25ce6e 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -51,13 +51,9 @@ #include <qpa/qplatformtheme.h> #include "qstylehints.h" #include <private/qguiapplication_p.h> - -#ifndef QT_NO_CLIPBOARD #include "qclipboard.h" -#endif #ifdef Q_OS_MAC -#include <Carbon/Carbon.h> // For the random function. #include <cstdlib> // For the random function. #endif @@ -74,6 +70,7 @@ #include "qplatformdefs.h" +#include "../../../shared/platformclipboard.h" #include "../../../shared/platforminputcontext.h" #include <private/qinputmethod_p.h> @@ -1431,21 +1428,9 @@ void tst_QLineEdit::undo_keypressevents() } #ifndef QT_NO_CLIPBOARD -static bool nativeClipboardWorking() -{ -#ifdef Q_OS_MAC - PasteboardRef pasteboard; - OSStatus status = PasteboardCreate(0, &pasteboard); - if (status == noErr) - CFRelease(pasteboard); - return status == noErr; -#endif - return true; -} - void tst_QLineEdit::QTBUG5786_undoPaste() { - if (!nativeClipboardWorking()) + if (!PlatformClipboard::isAvailable()) QSKIP("this machine doesn't support the clipboard"); QString initial("initial"); QString string("test"); @@ -2826,16 +2811,9 @@ void tst_QLineEdit::setSelection() #ifndef QT_NO_CLIPBOARD void tst_QLineEdit::cut() { -#ifdef Q_OS_MAC - { - PasteboardRef pasteboard; - OSStatus status = PasteboardCreate(0, &pasteboard); - if (status == noErr) - CFRelease(pasteboard); - else - QSKIP("Autotests run from cron and pasteboard don't get along quite ATM"); - } -#endif + if (!PlatformClipboard::isAvailable()) + QSKIP("Autotests run from cron and pasteboard don't get along quite ATM"); + // test newlines in cut'n'paste testWidget->setText("A\nB\nC\n"); testWidget->setSelection(0, 6); diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp index f8fabdd22b..a71302096f 100644 --- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp @@ -58,6 +58,7 @@ #include <qtextdocumentfragment.h> #include "qplaintextedit.h" +#include "../../../shared/platformclipboard.h" //Used in copyAvailable typedef QPair<Qt::Key, Qt::KeyboardModifier> keyPairType; @@ -66,10 +67,6 @@ Q_DECLARE_METATYPE(pairListType); Q_DECLARE_METATYPE(keyPairType); Q_DECLARE_METATYPE(QList<bool>); -#ifdef Q_OS_MAC -#include <Carbon/Carbon.h> -#endif - QT_FORWARD_DECLARE_CLASS(QPlainTextEdit) class tst_QPlainTextEdit : public QObject @@ -155,24 +152,11 @@ private: void createSelection(); int blockCount() const; int lineCount() const; - bool nativeClipboardWorking(); QPlainTextEdit *ed; qreal rootFrameMargin; }; -bool tst_QPlainTextEdit::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_QPlainTextEdit::getSetCheck() { @@ -305,7 +289,7 @@ void tst_QPlainTextEdit::createSelection() #ifndef QT_NO_CLIPBOARD void tst_QPlainTextEdit::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"); @@ -482,7 +466,7 @@ void tst_QPlainTextEdit::setTextCursor() #ifndef QT_NO_CLIPBOARD void tst_QPlainTextEdit::undoAvailableAfterPaste() { - if (!nativeClipboardWorking()) + if (!PlatformClipboard::isAvailable()) QSKIP("Clipboard not working with cron-started unit tests"); QSignalSpy spy(ed->document(), SIGNAL(undoAvailable(bool))); @@ -675,7 +659,7 @@ void tst_QPlainTextEdit::preserveCharFormatInAppend() #ifndef QT_NO_CLIPBOARD void tst_QPlainTextEdit::copyAndSelectAllInReadonly() { - if (!nativeClipboardWorking()) + if (!PlatformClipboard::isAvailable()) QSKIP("Clipboard not working with cron-started unit tests"); ed->setReadOnly(true); @@ -1192,7 +1176,7 @@ void tst_QPlainTextEdit::selectWordsFromStringsContainingSeparators() #ifndef QT_NO_CLIPBOARD void tst_QPlainTextEdit::canPaste() { - if (!nativeClipboardWorking()) + if (!PlatformClipboard::isAvailable()) QSKIP("Clipboard not working with cron-started unit tests"); QApplication::clipboard()->setText(QString()); 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() { |