summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2016-07-28 13:20:41 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2016-08-01 18:20:00 +0200
commitf6fc34294f5691da8aa7ab8dc0452c6fa9036b67 (patch)
tree3b8fe9841f88aa81e2f8f2d57cbbca2c4736ca6f /tests/auto/widgets
parent6f75096afc000991111bb0fd7a7e530ce3518627 (diff)
parent0eb77c3011ee4d6bbc46dd2d40c9324e9bfcbecf (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: configure 5.7 now supports clang on android; but dev re-worked configure src/gui/kernel/qevent.h One side renamed a parameter of a constructor; the other added an alternate constructor on the next line. Applied the rename to both for consistency. tests/auto/tools/moc/tst_moc.cpp Each side added a new test at the end. .qmake.conf Ignored 5.7's change to MODULE_VERSION. configure.json No conflict noticed by git; but changes in 5.7 were needed for the re-worked configure to accommodate 5.7's stricter handling of C++11. Change-Id: I9cda53836a32d7bf83828212c7ea00b1de3e09d2
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro2
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp62
2 files changed, 63 insertions, 1 deletions
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro b/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro
index 9405c33a48..10cd1dcc54 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro
+++ b/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro
@@ -1,6 +1,6 @@
CONFIG += testcase
TARGET = tst_qitemdelegate
-QT += widgets testlib
+QT += widgets widgets-private testlib
SOURCES += tst_qitemdelegate.cpp
win32:!winrt: LIBS += -luser32
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index e67edfcccb..0720a4f766 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -51,6 +51,8 @@
#include <QPlainTextEdit>
#include <QDialog>
+#include <QtWidgets/private/qabstractitemdelegate_p.h>
+
Q_DECLARE_METATYPE(QAbstractItemDelegate::EndEditHint)
#if defined (Q_OS_WIN) && !defined(Q_OS_WINRT)
@@ -216,6 +218,8 @@ private slots:
void task257859_finalizeEdit();
void QTBUG4435_keepSelectionOnCheck();
+
+ void QTBUG16469_textForRole();
};
@@ -1521,6 +1525,64 @@ void tst_QItemDelegate::testLineEditValidation()
QCOMPARE(item->data(Qt::DisplayRole).toString(), QStringLiteral("abc,def"));
}
+void tst_QItemDelegate::QTBUG16469_textForRole()
+{
+#ifndef QT_BUILD_INTERNAL
+ QSKIP("This test requires a developer build");
+#else
+ struct TestDelegate : public QItemDelegate
+ {
+ QString textForRole(Qt::ItemDataRole role, const QVariant &value, const QLocale &locale)
+ {
+ QAbstractItemDelegatePrivate *d = reinterpret_cast<QAbstractItemDelegatePrivate *>(qGetPtrHelper(d_ptr));
+ return d->textForRole(role, value, locale);
+ }
+ } delegate;
+ QLocale locale;
+
+ const float f = 123.456f;
+ QCOMPARE(delegate.textForRole(Qt::DisplayRole, f, locale), locale.toString(f));
+ QCOMPARE(delegate.textForRole(Qt::ToolTipRole, f, locale), locale.toString(f));
+ const double d = 123.456;
+ QCOMPARE(delegate.textForRole(Qt::DisplayRole, d, locale), locale.toString(d, 'g', 6));
+ QCOMPARE(delegate.textForRole(Qt::ToolTipRole, d, locale), locale.toString(d, 'g', 6));
+ const int i = 1234567;
+ QCOMPARE(delegate.textForRole(Qt::DisplayRole, i, locale), locale.toString(i));
+ QCOMPARE(delegate.textForRole(Qt::ToolTipRole, i, locale), locale.toString(i));
+ const qlonglong ll = 1234567;
+ QCOMPARE(delegate.textForRole(Qt::DisplayRole, ll, locale), locale.toString(ll));
+ QCOMPARE(delegate.textForRole(Qt::ToolTipRole, ll, locale), locale.toString(ll));
+ const uint ui = 1234567;
+ QCOMPARE(delegate.textForRole(Qt::DisplayRole, ui, locale), locale.toString(ui));
+ QCOMPARE(delegate.textForRole(Qt::ToolTipRole, ui, locale), locale.toString(ui));
+ const qulonglong ull = 1234567;
+ QCOMPARE(delegate.textForRole(Qt::DisplayRole, ull, locale), locale.toString(ull));
+ QCOMPARE(delegate.textForRole(Qt::ToolTipRole, ull, locale), locale.toString(ull));
+
+ const QDateTime dateTime = QDateTime::currentDateTime();
+ const QDate date = dateTime.date();
+ const QTime time = dateTime.time();
+ const QString shortDate = locale.toString(date, QLocale::ShortFormat);
+ const QString longDate = locale.toString(date, QLocale::LongFormat);
+ const QString shortTime = locale.toString(time, QLocale::ShortFormat);
+ const QString longTime = locale.toString(time, QLocale::LongFormat);
+ QCOMPARE(delegate.textForRole(Qt::DisplayRole, date, locale), shortDate);
+ QCOMPARE(delegate.textForRole(Qt::ToolTipRole, date, locale), longDate);
+ QCOMPARE(delegate.textForRole(Qt::DisplayRole, time, locale), shortTime);
+ QCOMPARE(delegate.textForRole(Qt::ToolTipRole, time, locale), longTime);
+ QCOMPARE(delegate.textForRole(Qt::DisplayRole, dateTime, locale), shortDate + QLatin1Char(' ') + shortTime);
+ QCOMPARE(delegate.textForRole(Qt::ToolTipRole, dateTime, locale), longDate + QLatin1Char(' ') + longTime);
+
+ const QString text("text");
+ QCOMPARE(delegate.textForRole(Qt::DisplayRole, text, locale), text);
+ QCOMPARE(delegate.textForRole(Qt::ToolTipRole, text, locale), text);
+ const QString multipleLines("multiple\nlines");
+ QString multipleLines2 = multipleLines;
+ multipleLines2.replace(QLatin1Char('\n'), QChar::LineSeparator);
+ QCOMPARE(delegate.textForRole(Qt::DisplayRole, multipleLines, locale), multipleLines2);
+ QCOMPARE(delegate.textForRole(Qt::ToolTipRole, multipleLines, locale), multipleLines);
+#endif
+}
// ### _not_ covered: