summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/animation/qpauseanimation/BLACKLIST2
-rw-r--r--tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp28
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp6
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp11
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp2
-rw-r--r--tests/auto/corelib/tools/qchar/tst_qchar.cpp61
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp53
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp236
8 files changed, 373 insertions, 26 deletions
diff --git a/tests/auto/corelib/animation/qpauseanimation/BLACKLIST b/tests/auto/corelib/animation/qpauseanimation/BLACKLIST
index 3b2cd84749..8fc1b07502 100644
--- a/tests/auto/corelib/animation/qpauseanimation/BLACKLIST
+++ b/tests/auto/corelib/animation/qpauseanimation/BLACKLIST
@@ -2,3 +2,5 @@
osx-10.9
[pauseAndPropertyAnimations]
*
+[multipleSequentialGroups]
+osx
diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
index a13ff0358a..d2f345feb5 100644
--- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
+++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
@@ -34,6 +34,7 @@
#include <qsysinfo.h>
#if defined(Q_OS_UNIX) && !defined(Q_OS_VXWORKS)
#include <unistd.h>
+#include <sys/time.h>
#elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
# include <qt_windows.h>
#endif
@@ -59,6 +60,7 @@ private slots:
void noPermissions();
void noPermissionsWindows();
void corruptedLockFile();
+ void corruptedLockFileInTheFuture();
private:
static bool overwritePidInLockFile(const QString &filePath, qint64 pid);
@@ -521,6 +523,32 @@ void tst_QLockFile::corruptedLockFile()
QCOMPARE(int(secondLock.error()), int(QLockFile::NoError));
}
+void tst_QLockFile::corruptedLockFileInTheFuture()
+{
+#if !defined(Q_OS_UNIX)
+ QSKIP("This tests needs utimes");
+#else
+ // This test is the same as the previous one, but the corruption was so there is a corrupted
+ // .rmlock whose timestamp is in the future
+
+ const QString fileName = dir.path() + "/corruptedLockFile.rmlock";
+
+ {
+ QFile file(fileName);
+ QVERIFY(file.open(QFile::WriteOnly));
+ }
+
+ struct timeval times[2];
+ gettimeofday(times, 0);
+ times[1].tv_sec = (times[0].tv_sec += 600);
+ times[1].tv_usec = times[0].tv_usec;
+ utimes(fileName.toLocal8Bit(), times);
+
+ QTest::ignoreMessage(QtInfoMsg, "QLockFile: Lock file '" + fileName.toUtf8() + "' has a modification time in the future");
+ corruptedLockFile();
+#endif
+}
+
bool tst_QLockFile::overwritePidInLockFile(const QString &filePath, qint64 pid)
{
QFile f(filePath);
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index ee18151e4a..ebc240c285 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -3088,7 +3088,11 @@ void tst_QUrl::fromUserInputWithCwd_data()
}
// Existing files
- for (const char *fileName : {"file.txt", "file#a.txt", "file .txt", "file.txt "}) {
+ for (const char *fileName : {"file.txt", "file#a.txt", "file .txt", "file.txt "
+#ifndef Q_OS_WIN
+ , "file:colon.txt"
+#endif
+ }) {
const QString filePath = base + '/' + fileName;
QFile file(filePath);
QVERIFY2(file.open(QIODevice::WriteOnly), qPrintable(filePath));
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index f693d14029..143bf2f95d 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -1563,7 +1563,6 @@ DECLARE_NONSTREAMABLE(QJsonArray)
DECLARE_NONSTREAMABLE(QJsonDocument)
DECLARE_NONSTREAMABLE(QObject*)
DECLARE_NONSTREAMABLE(QWidget*)
-DECLARE_NONSTREAMABLE(std::nullptr_t)
#define DECLARE_GUI_CLASS_NONSTREAMABLE(MetaTypeName, MetaTypeId, RealType) \
DECLARE_NONSTREAMABLE(RealType)
@@ -1602,7 +1601,10 @@ void tst_QMetaType::saveAndLoadBuiltin()
if (isStreamable) {
QVERIFY(QMetaType::load(stream, type, value)); // Hmmm, shouldn't it return false?
- QCOMPARE(stream.status(), QDataStream::ReadPastEnd);
+
+ // std::nullptr_t is nullary: it doesn't actually read anything
+ if (type != QMetaType::Nullptr)
+ QCOMPARE(stream.status(), QDataStream::ReadPastEnd);
}
stream.device()->seek(0);
@@ -1612,7 +1614,10 @@ void tst_QMetaType::saveAndLoadBuiltin()
if (isStreamable) {
QVERIFY(QMetaType::load(stream, type, value)); // Hmmm, shouldn't it return false?
- QCOMPARE(stream.status(), QDataStream::ReadPastEnd);
+
+ // std::nullptr_t is nullary: it doesn't actually read anything
+ if (type != QMetaType::Nullptr)
+ QCOMPARE(stream.status(), QDataStream::ReadPastEnd);
}
QMetaType::destroy(type, value);
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
index 02ba987ccd..280e3f77a4 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
@@ -861,7 +861,7 @@ void tst_QMimeDatabase::fromThreads()
#if QT_CONFIG(process)
enum {
- UpdateMimeDatabaseTimeout = 120 * 1000 // 2min
+ UpdateMimeDatabaseTimeout = 4 * 60 * 1000 // 4min
};
static bool runUpdateMimeDatabase(const QString &path) // TODO make it a QMimeDatabase method?
diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
index 13898ace7b..e5a6e953d3 100644
--- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp
+++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
@@ -36,7 +36,7 @@ class tst_QChar : public QObject
{
Q_OBJECT
private slots:
- void operator_eqeq_int();
+ void operator_eqeq_null();
void operators_data();
void operators();
void toUpper();
@@ -72,35 +72,54 @@ private slots:
void unicodeVersion();
};
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-
-void tst_QChar::operator_eqeq_int()
+void tst_QChar::operator_eqeq_null()
{
{
const QChar ch = QLatin1Char(' ');
- QVERIFY(ch != 0);
- QVERIFY(!(ch == 0));
-
- QVERIFY(ch == 0x20);
- QVERIFY(!(ch != 0x20));
- QVERIFY(0x20 == ch);
- QVERIFY(!(0x20 != ch));
+#define CHECK(NUL) \
+ do { \
+ QVERIFY(!(ch == NUL)); \
+ QVERIFY( ch != NUL ); \
+ QVERIFY(!(ch < NUL)); \
+ QVERIFY( ch > NUL ); \
+ QVERIFY(!(ch <= NUL)); \
+ QVERIFY( ch >= NUL ); \
+ QVERIFY(!(NUL == ch )); \
+ QVERIFY( NUL != ch ); \
+ QVERIFY( NUL < ch ); \
+ QVERIFY(!(NUL > ch )); \
+ QVERIFY( NUL <= ch ); \
+ QVERIFY(!(NUL >= ch )); \
+ } while (0)
+
+ CHECK(0);
+ CHECK('\0');
+#undef CHECK
}
{
const QChar ch = QLatin1Char('\0');
- QVERIFY(ch == 0);
- QVERIFY(!(ch != 0));
-
- QVERIFY(ch != 0x20);
- QVERIFY(!(ch == 0x20));
- QVERIFY(0x20 != ch);
- QVERIFY(!(0x20 == ch));
+#define CHECK(NUL) \
+ do { \
+ QVERIFY( ch == NUL ); \
+ QVERIFY(!(ch != NUL)); \
+ QVERIFY(!(ch < NUL)); \
+ QVERIFY(!(ch > NUL)); \
+ QVERIFY( ch <= NUL ); \
+ QVERIFY( ch >= NUL ); \
+ QVERIFY( NUL == ch ); \
+ QVERIFY(!(NUL != ch )); \
+ QVERIFY(!(NUL < ch )); \
+ QVERIFY(!(NUL > ch )); \
+ QVERIFY( NUL <= ch ); \
+ QVERIFY( NUL >= ch ); \
+ } while (0)
+
+ CHECK(0);
+ CHECK('\0');
+#undef CHECK
}
}
-QT_WARNING_POP
-
void tst_QChar::operators_data()
{
QTest::addColumn<QChar>("lhs");
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index d241296a6b..f2cf78e8ac 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -45,6 +45,7 @@
#include <qpushbutton.h>
#include <qscrollbar.h>
#include <qboxlayout.h>
+#include <qitemdelegate.h>
#include <qlineedit.h>
#include <qscreen.h>
#include <qscopedpointer.h>
@@ -151,6 +152,7 @@ private slots:
void testSelectionModelInSyncWithView();
void testClickToSelect();
void testDialogAsEditor();
+ void QTBUG46785_mouseout_hover_state();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -2213,5 +2215,56 @@ void tst_QAbstractItemView::testDialogAsEditor()
QCOMPARE(delegate.result, QDialog::Accepted);
}
+class HoverItemDelegate : public QItemDelegate
+{
+public:
+ HoverItemDelegate()
+ : QItemDelegate()
+ , m_paintedWithoutHover(false)
+ { }
+
+ void paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &index) const override
+ {
+ Q_UNUSED(painter);
+
+ if (!(opt.state & QStyle::State_MouseOver)) {
+
+ // We don't want to set m_paintedWithoutHover for any item so check for the item at 0,0
+ if (index.row() == 0 && index.column() == 0) {
+ m_paintedWithoutHover = true;
+ }
+ }
+ }
+
+ mutable bool m_paintedWithoutHover;
+};
+
+void tst_QAbstractItemView::QTBUG46785_mouseout_hover_state()
+{
+ HoverItemDelegate delegate;
+
+ QTableWidget table(5, 5);
+ table.verticalHeader()->hide();
+ table.horizontalHeader()->hide();
+ table.setMouseTracking(true);
+ table.setItemDelegate(&delegate);
+ centerOnScreen(&table);
+ table.show();
+ QVERIFY(QTest::qWaitForWindowActive(&table));
+
+ QModelIndex item = table.model()->index(0, 0);
+ QRect itemRect = table.visualRect(item);
+
+ // Move the mouse into the center of the item at 0,0 to cause a paint event to occur
+ QTest::mouseMove(table.viewport(), itemRect.center());
+ QTest::mouseClick(table.viewport(), Qt::LeftButton, 0, itemRect.center());
+
+ delegate.m_paintedWithoutHover = false;
+
+ QTest::mouseMove(table.viewport(), QPoint(-50, 0));
+
+ QTRY_VERIFY(delegate.m_paintedWithoutHover);
+}
+
QTEST_MAIN(tst_QAbstractItemView)
#include "tst_qabstractitemview.moc"
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index b9ea310d80..bc94e2a05b 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -46,6 +46,7 @@
#include <qcommonstyle.h>
#include <qlayout.h>
#include <qdir.h>
+#include <qpaintengine.h>
#include <qabstracttextdocumentlayout.h>
#include <qtextdocumentfragment.h>
@@ -60,6 +61,8 @@ typedef QPair<Qt::Key, Qt::KeyboardModifier> keyPairType;
typedef QList<keyPairType> pairListType;
Q_DECLARE_METATYPE(keyPairType);
+Q_DECLARE_METATYPE(QList<QInputMethodEvent::Attribute>);
+
QT_FORWARD_DECLARE_CLASS(QTextEdit)
class tst_QTextEdit : public QObject
@@ -200,6 +203,9 @@ private slots:
void wheelEvent();
#endif
+ void preeditCharFormat_data();
+ void preeditCharFormat();
+
private:
void createSelection();
int blockCount() const;
@@ -2594,5 +2600,235 @@ void tst_QTextEdit::wheelEvent()
#endif
+namespace {
+ class MyPaintEngine : public QPaintEngine
+ {
+ public:
+ bool begin(QPaintDevice *)
+ {
+ return true;
+ }
+
+ bool end()
+ {
+ return true;
+ }
+
+ void updateState(const QPaintEngineState &)
+ {
+ }
+
+ void drawPixmap(const QRectF &, const QPixmap &, const QRectF &)
+ {
+ }
+
+ void drawTextItem(const QPointF &, const QTextItem &textItem) Q_DECL_OVERRIDE
+ {
+ itemFonts.append(qMakePair(textItem.text(), textItem.font()));
+ }
+
+ Type type() const { return User; }
+
+
+ QList<QPair<QString, QFont> > itemFonts;
+ };
+
+ class MyPaintDevice : public QPaintDevice
+ {
+ public:
+ MyPaintDevice() : m_paintEngine(new MyPaintEngine)
+ {
+ }
+
+
+ QPaintEngine *paintEngine () const
+ {
+ return m_paintEngine;
+ }
+
+ int metric (QPaintDevice::PaintDeviceMetric metric) const {
+ switch (metric) {
+ case QPaintDevice::PdmWidth:
+ case QPaintDevice::PdmHeight:
+ case QPaintDevice::PdmWidthMM:
+ case QPaintDevice::PdmHeightMM:
+ case QPaintDevice::PdmNumColors:
+ return INT_MAX;
+ case QPaintDevice::PdmDepth:
+ return 32;
+ case QPaintDevice::PdmDpiX:
+ case QPaintDevice::PdmDpiY:
+ case QPaintDevice::PdmPhysicalDpiX:
+ case QPaintDevice::PdmPhysicalDpiY:
+ return 72;
+ case QPaintDevice::PdmDevicePixelRatio:
+ case QPaintDevice::PdmDevicePixelRatioScaled:
+ ; // fall through
+ }
+ return 0;
+ }
+
+ MyPaintEngine *m_paintEngine;
+ };
+}
+
+void tst_QTextEdit::preeditCharFormat_data()
+{
+ QTest::addColumn<QList<QInputMethodEvent::Attribute> >("imeAttributes");
+ QTest::addColumn<QStringList>("substrings");
+ QTest::addColumn<QList<bool> >("boldnessList");
+ QTest::addColumn<QList<bool> >("italicnessList");
+ QTest::addColumn<QList<int> >("pointSizeList");
+
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ {
+ QTextCharFormat tcf;
+ tcf.setFontPointSize(13);
+ tcf.setFontItalic(true);
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 1, 1, tcf));
+ }
+
+ {
+ QTextCharFormat tcf;
+ tcf.setFontPointSize(8);
+ tcf.setFontWeight(QFont::Normal);
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 4, 2, tcf));
+ }
+
+ QTest::newRow("Two formats, middle, in order")
+ << attributes
+ << (QStringList() << "P" << "r" << "eE" << "di" << "tText")
+ << (QList<bool>() << true << true << true << false << true)
+ << (QList<bool>() << false << true << false << false << false)
+ << (QList<int>() << 20 << 13 << 20 << 8 << 20);
+ }
+
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ {
+ QTextCharFormat tcf;
+ tcf.setFontPointSize(8);
+ tcf.setFontWeight(QFont::Normal);
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 4, 2, tcf));
+ }
+
+ {
+ QTextCharFormat tcf;
+ tcf.setFontPointSize(13);
+ tcf.setFontItalic(true);
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 1, 1, tcf));
+ }
+
+ QTest::newRow("Two formats, middle, out of order")
+ << attributes
+ << (QStringList() << "P" << "r" << "eE" << "di" << "tText")
+ << (QList<bool>() << true << true << true << false << true)
+ << (QList<bool>() << false << true << false << false << false)
+ << (QList<int>() << 20 << 13 << 20 << 8 << 20);
+ }
+
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ {
+ QTextCharFormat tcf;
+ tcf.setFontPointSize(13);
+ tcf.setFontItalic(true);
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, 1, tcf));
+ }
+
+ {
+ QTextCharFormat tcf;
+ tcf.setFontPointSize(8);
+ tcf.setFontWeight(QFont::Normal);
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 4, 2, tcf));
+ }
+
+ QTest::newRow("Two formats, front, in order")
+ << attributes
+ << (QStringList() << "P" << "reE" << "di" << "tText")
+ << (QList<bool>() << true << true << false << true)
+ << (QList<bool>() << true << false << false << false)
+ << (QList<int>() << 13 << 20 << 8 << 20);
+ }
+
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ {
+ QTextCharFormat tcf;
+ tcf.setFontPointSize(8);
+ tcf.setFontWeight(QFont::Normal);
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 4, 2, tcf));
+ }
+
+ {
+ QTextCharFormat tcf;
+ tcf.setFontPointSize(13);
+ tcf.setFontItalic(true);
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, 1, tcf));
+ }
+
+ QTest::newRow("Two formats, front, out of order")
+ << attributes
+ << (QStringList() << "P" << "reE" << "di" << "tText")
+ << (QList<bool>() << true << true << false << true)
+ << (QList<bool>() << true << false << false << false)
+ << (QList<int>() << 13 << 20 << 8 << 20);
+ }
+}
+
+void tst_QTextEdit::preeditCharFormat()
+{
+ QFETCH(QList<QInputMethodEvent::Attribute>, imeAttributes);
+ QFETCH(QStringList, substrings);
+ QFETCH(QList<bool>, boldnessList);
+ QFETCH(QList<bool>, italicnessList);
+ QFETCH(QList<int>, pointSizeList);
+
+ QTextEdit *w = new QTextEdit;
+ w->show();
+ QVERIFY(QTest::qWaitForWindowExposed(w));
+
+ // Set main char format
+ {
+ QTextCharFormat tcf;
+ tcf.setFontPointSize(20);
+ tcf.setFontWeight(QFont::Bold);
+ w->mergeCurrentCharFormat(tcf);
+ }
+
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes.prepend(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor,
+ w->textCursor().position(),
+ 0,
+ QVariant()));
+
+ attributes += imeAttributes;
+
+ QInputMethodEvent event("PreEditText", attributes);
+ QApplication::sendEvent(w, &event);
+
+ MyPaintDevice device;
+ {
+ QPainter p(&device);
+ w->document()->drawContents(&p);
+ }
+
+ QCOMPARE(device.m_paintEngine->itemFonts.size(), substrings.size());
+ for (int i = 0; i < substrings.size(); ++i)
+ QCOMPARE(device.m_paintEngine->itemFonts.at(i).first, substrings.at(i));
+
+ for (int i = 0; i < substrings.size(); ++i)
+ QCOMPARE(device.m_paintEngine->itemFonts.at(i).second.bold(), boldnessList.at(i));
+
+ for (int i = 0; i < substrings.size(); ++i)
+ QCOMPARE(device.m_paintEngine->itemFonts.at(i).second.italic(), italicnessList.at(i));
+
+ for (int i = 0; i < substrings.size(); ++i)
+ QCOMPARE(device.m_paintEngine->itemFonts.at(i).second.pointSize(), pointSizeList.at(i));
+
+ delete w;
+}
+
QTEST_MAIN(tst_QTextEdit)
#include "tst_qtextedit.moc"