summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-05-20 20:32:18 +0200
committerQt Continuous Integration System <qt-info@nokia.com>2010-05-20 20:32:18 +0200
commit471638950e8e3a63ceb0474f3b792112ebb46aba (patch)
tree3ef1ade022144ed961b6ce3e0c66ce52d9d0bfbc /tests
parentdfc61f6b59886f7d223722bf149342cdd46581a8 (diff)
parentef8cd7f2e68d6d34d70c3a12e82a67ed16b92b72 (diff)
downloadqt4-tools-471638950e8e3a63ceb0474f3b792112ebb46aba.tar.gz
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Fix crash when using fonts in non-gui QApplication Deselect the current selection when the QItemSelectionModel::model is reset. Autotest fix on macosx Compile with gcc 4.0.1 improve Unicode Normalization autotest more subtests for QChar nano optimization of canonicalOrderHelper() fix canonicalOrderHelper() for some corner case use new QChar::requiresSurrogates() instead of hardcoded value prevent fake normalization prefer QChar::*surrogate() over hardcoded values Fixed an assert in QMenu
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qchar/tst_qchar.cpp104
-rw-r--r--tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp47
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp54
3 files changed, 173 insertions, 32 deletions
diff --git a/tests/auto/qchar/tst_qchar.cpp b/tests/auto/qchar/tst_qchar.cpp
index 5ca225529f..93aaf9632f 100644
--- a/tests/auto/qchar/tst_qchar.cpp
+++ b/tests/auto/qchar/tst_qchar.cpp
@@ -43,6 +43,7 @@
#include <QtTest/QtTest>
#include <qchar.h>
#include <qfile.h>
+#include <qstringlist.h>
#include <private/qunicodetables_p.h>
#if defined(Q_OS_WINCE)
#include <qcoreapplication.h>
@@ -75,6 +76,7 @@ private slots:
void isPrint();
void isUpper();
void isLower();
+ void isTitle();
void category();
void direction();
void joining();
@@ -83,7 +85,9 @@ private slots:
void decomposition();
// void ligature();
void lineBreakClass();
+ void normalization_data();
void normalization();
+ void normalization_manual();
void normalizationCorrections();
void unicodeVersion();
#if defined(Q_OS_WINCE)
@@ -234,6 +238,11 @@ void tst_QChar::isUpper()
QVERIFY(!QChar('?').isUpper());
QVERIFY(QChar(0xC2).isUpper()); // A with ^
QVERIFY(!QChar(0xE2).isUpper()); // a with ^
+
+ for (uint codepoint = 0; codepoint <= UNICODE_LAST_CODEPOINT; ++codepoint) {
+ if (QChar::category(codepoint) == QChar::Letter_Uppercase)
+ QVERIFY(codepoint == QChar::toUpper(codepoint));
+ }
}
void tst_QChar::isLower()
@@ -245,6 +254,19 @@ void tst_QChar::isLower()
QVERIFY(!QChar('?').isLower());
QVERIFY(!QChar(0xC2).isLower()); // A with ^
QVERIFY(QChar(0xE2).isLower()); // a with ^
+
+ for (uint codepoint = 0; codepoint <= UNICODE_LAST_CODEPOINT; ++codepoint) {
+ if (QChar::category(codepoint) == QChar::Letter_Lowercase)
+ QVERIFY(codepoint == QChar::toLower(codepoint));
+ }
+}
+
+void tst_QChar::isTitle()
+{
+ for (uint codepoint = 0; codepoint <= UNICODE_LAST_CODEPOINT; ++codepoint) {
+ if (QChar::category(codepoint) == QChar::Letter_Titlecase)
+ QVERIFY(codepoint == QChar::toTitleCase(codepoint));
+ }
}
void tst_QChar::category()
@@ -486,31 +508,13 @@ void tst_QChar::lineBreakClass()
QVERIFY(QUnicodeTables::lineBreakClass(0x0fffdu) == QUnicodeTables::LineBreak_AL);
}
-void tst_QChar::normalization()
+void tst_QChar::normalization_data()
{
- {
- QString composed;
- composed += QChar(0xc0);
- QString decomposed;
- decomposed += QChar(0x41);
- decomposed += QChar(0x300);
+ QTest::addColumn<QStringList>("columns");
+ QTest::addColumn<int>("part");
- QVERIFY(composed.normalized(QString::NormalizationForm_D) == decomposed);
- QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed);
- QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed);
- QVERIFY(composed.normalized(QString::NormalizationForm_KC) == composed);
- }
- {
- QString composed;
- composed += QChar(0xa0);
- QString decomposed;
- decomposed += QChar(0x20);
-
- QVERIFY(composed.normalized(QString::NormalizationForm_D) == composed);
- QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed);
- QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed);
- QVERIFY(composed.normalized(QString::NormalizationForm_KC) == decomposed);
- }
+ int linenum = 0;
+ int part = 0;
QFile f(SRCDIR "NormalizationTest.txt");
QVERIFY(f.exists());
@@ -518,6 +522,8 @@ void tst_QChar::normalization()
f.open(QIODevice::ReadOnly);
while (!f.atEnd()) {
+ linenum++;
+
QByteArray line;
line.resize(1024);
int len = f.readLine(line.data(), 1024);
@@ -527,8 +533,11 @@ void tst_QChar::normalization()
if (comment >= 0)
line = line.left(comment);
- if (line.startsWith("@"))
+ if (line.startsWith("@")) {
+ if (line.startsWith("@Part") && line.size() > 5 && QChar(line.at(5)).isDigit())
+ part = QChar(line.at(5)).digitValue();
continue;
+ }
if (line.isEmpty())
continue;
@@ -541,8 +550,10 @@ void tst_QChar::normalization()
Q_ASSERT(l.size() == 5);
- QString columns[5];
+ QStringList columns;
for (int i = 0; i < 5; ++i) {
+ columns.append(QString());
+
QList<QByteArray> c = l.at(i).split(' ');
Q_ASSERT(!c.isEmpty());
@@ -553,15 +564,26 @@ void tst_QChar::normalization()
columns[i].append(QChar(uc));
else {
// convert to utf16
- uc -= 0x10000;
- ushort high = uc/0x400 + 0xd800;
- ushort low = uc%0x400 + 0xdc00;
+ ushort high = QChar::highSurrogate(uc);
+ ushort low = QChar::lowSurrogate(uc);
columns[i].append(QChar(high));
columns[i].append(QChar(low));
}
}
}
+ QString nm = QString("line #%1:").arg(linenum);
+ QTest::newRow(nm.toLatin1()) << columns << part;
+ }
+}
+
+void tst_QChar::normalization()
+{
+ QFETCH(QStringList, columns);
+ QFETCH(int, part);
+
+ Q_UNUSED(part)
+
// CONFORMANCE:
// 1. The following invariants must be true for all conformant implementations
//
@@ -611,6 +633,32 @@ void tst_QChar::normalization()
// #################
+}
+
+void tst_QChar::normalization_manual()
+{
+ {
+ QString composed;
+ composed += QChar(0xc0);
+ QString decomposed;
+ decomposed += QChar(0x41);
+ decomposed += QChar(0x300);
+
+ QVERIFY(composed.normalized(QString::NormalizationForm_D) == decomposed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_KC) == composed);
+ }
+ {
+ QString composed;
+ composed += QChar(0xa0);
+ QString decomposed;
+ decomposed += QChar(0x20);
+
+ QVERIFY(composed.normalized(QString::NormalizationForm_D) == composed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_KC) == decomposed);
}
}
diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 3b2a7167c0..9858829936 100644
--- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -1536,6 +1536,43 @@ public:
inline void reset() { QStandardItemModel::reset(); }
};
+class ResetObserver : public QObject
+{
+ QItemSelectionModel * const m_selectionModel;
+ QItemSelection m_selection;
+ Q_OBJECT
+public:
+ ResetObserver(QItemSelectionModel *selectionModel)
+ : m_selectionModel(selectionModel)
+ {
+ connect(selectionModel->model(), SIGNAL(modelAboutToBeReset()),SLOT(modelAboutToBeReset()));
+ connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(selectionChanged(QItemSelection,QItemSelection)));
+ connect(selectionModel->model(), SIGNAL(modelReset()),SLOT(modelReset()));
+ }
+
+private slots:
+ void modelAboutToBeReset()
+ {
+ m_selection = m_selectionModel->selection();
+ foreach(const QItemSelectionRange &range, m_selection)
+ {
+ QVERIFY(range.isValid());
+ }
+ }
+
+ void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
+ {
+ qDebug() << deselected << selected;
+ QCOMPARE(m_selection, deselected);
+ m_selection.clear();
+ }
+
+ void modelReset()
+ {
+ QVERIFY(m_selectionModel->selection().isEmpty());
+ }
+};
+
void tst_QItemSelectionModel::resetModel()
{
MyStandardItemModel model(20, 20);
@@ -1555,11 +1592,13 @@ void tst_QItemSelectionModel::resetModel()
view.selectionModel()->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.at(1).count(), 2);
+ // We get this signal three times. Twice in this test method and once because the source reset causes the current selection to
+ // be deselected.
+ QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.at(2).count(), 2);
// make sure we don't get an "old selection"
- QCOMPARE(spy.at(1).at(1).userType(), qMetaTypeId<QItemSelection>());
- QVERIFY(qvariant_cast<QItemSelection>(spy.at(1).at(1)).isEmpty());
+ QCOMPARE(spy.at(2).at(1).userType(), qMetaTypeId<QItemSelection>());
+ QVERIFY(qvariant_cast<QItemSelection>(spy.at(2).at(1)).isEmpty());
}
void tst_QItemSelectionModel::removeRows_data()
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index e10d7ee69a..b6bdb36a96 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -51,6 +51,7 @@
#include <QListWidget>
#include <QWidgetAction>
#include <QDesktopWidget>
+#include <qdialog.h>
#include <qmenu.h>
#include <qstyle.h>
@@ -106,6 +107,7 @@ private slots:
void pushButtonPopulateOnAboutToShow();
void QTBUG7907_submenus_autoselect();
void QTBUG7411_submenus_activate();
+ void QTBUG_10735_crashWithDialog();
protected slots:
void onActivated(QAction*);
void onHighlighted(QAction*);
@@ -969,5 +971,57 @@ void tst_QMenu::QTBUG7411_submenus_activate()
+class MyMenu : public QMenu
+{
+ Q_OBJECT
+public:
+ MyMenu() : m_currentIndex(0)
+ {
+ for (int i = 0; i < 2; ++i)
+ dialogActions[i] = addAction( QString("dialog %1").arg(i), dialogs + i, SLOT(exec()));
+ }
+
+
+ void activateAction(int index)
+ {
+ m_currentIndex = index;
+ popup(QPoint());
+ QTest::qWaitForWindowShown(this);
+ setActiveAction(dialogActions[index]);
+ QTimer::singleShot(500, this, SLOT(checkVisibility()));
+ QTest::keyClick(this, Qt::Key_Enter); //activation
+ }
+
+public slots:
+ void activateLastAction()
+ {
+ activateAction(1);
+ }
+
+ void checkVisibility()
+ {
+ QTRY_VERIFY(dialogs[m_currentIndex].isVisible());
+ if (m_currentIndex == 1) {
+ QApplication::closeAllWindows(); //this is the end of the test
+ }
+ }
+
+
+private:
+ QAction *dialogActions[2];
+ QDialog dialogs[2];
+ int m_currentIndex;
+};
+
+void tst_QMenu::QTBUG_10735_crashWithDialog()
+{
+ MyMenu menu;
+
+ QTimer::singleShot(1000, &menu, SLOT(activateLastAction()));
+ menu.activateAction(0);
+
+}
+
+
QTEST_MAIN(tst_QMenu)
#include "tst_qmenu.moc"