summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-06-12 07:47:49 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-06-12 07:47:49 (GMT)
commit6ab9ca55342dad0ce16402b7d2f8d47d61a0af76 (patch)
tree8a022fb07d41cb3d7f3850ae5f68a15ecd8130c5 /tests/auto
parent144154046529e557616738c13b3721e3cab77301 (diff)
parentd0baa9b8dc9ed191903447032f1cf6afe9a2463e (diff)
downloadQt-6ab9ca55342dad0ce16402b7d2f8d47d61a0af76.zip
Qt-6ab9ca55342dad0ce16402b7d2f8d47d61a0af76.tar.gz
Qt-6ab9ca55342dad0ce16402b7d2f8d47d61a0af76.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts: src/gui/graphicsview/qgraphicsitem_p.h
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/auto.pro10
-rw-r--r--tests/auto/qgraphicsobject/qgraphicsobject.pro2
-rw-r--r--tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp255
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp63
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp2
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp99
-rw-r--r--tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp49
-rw-r--r--tests/auto/qtextcodec/test/test.pro6
-rw-r--r--tests/auto/qtextcodec/tst_qtextcodec.cpp66
-rw-r--r--tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp2
-rw-r--r--tests/auto/qtextstream/tst_qtextstream.cpp21
-rw-r--r--tests/auto/qvariant/tst_qvariant.cpp14
-rw-r--r--tests/auto/uiloader/baseline/css_task255849_downarrow.ui144
-rw-r--r--tests/auto/uiloader/baseline/images/arrow-down.pngbin0 -> 1006 bytes
-rw-r--r--tests/auto/uiloader/baseline/images/arrow-up.pngbin0 -> 927 bytes
15 files changed, 699 insertions, 34 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index a65c172..d5803bc 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -141,9 +141,17 @@ SUBDIRS += _networkselftest \
qglobal \
qgraphicsitem \
qgraphicsitemanimation \
+ qgraphicslayout \
+ qgraphicslayoutitem \
+ qgraphicslinearlayout \
+ qgraphicsobject \
+ qgraphicspixmapitem \
+ qgraphicspolygonitem \
+ qgraphicsproxywidget \
qgraphicsscene \
qgraphicsview \
- qgridlayout \
+ qgraphicswidget \
+ qgridlayout \
qgroupbox \
qguivariant \
qhash \
diff --git a/tests/auto/qgraphicsobject/qgraphicsobject.pro b/tests/auto/qgraphicsobject/qgraphicsobject.pro
new file mode 100644
index 0000000..965b319
--- /dev/null
+++ b/tests/auto/qgraphicsobject/qgraphicsobject.pro
@@ -0,0 +1,2 @@
+load(qttest_p4)
+SOURCES += tst_qgraphicsobject.cpp
diff --git a/tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp b/tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp
new file mode 100644
index 0000000..eb12c48
--- /dev/null
+++ b/tests/auto/qgraphicsobject/tst_qgraphicsobject.cpp
@@ -0,0 +1,255 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qgraphicsitem.h>
+#include <qgraphicsscene.h>
+#include <qgraphicssceneevent.h>
+#include <qgraphicsview.h>
+#include <qstyleoption.h>
+#include "../../shared/util.h"
+
+class tst_QGraphicsObject : public QObject {
+ Q_OBJECT
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void pos();
+ void x();
+ void y();
+ void z();
+ void opacity();
+ void enabled();
+ void visible();
+};
+
+
+// This will be called before the first test function is executed.
+// It is only called once.
+void tst_QGraphicsObject::initTestCase()
+{
+}
+
+// This will be called after the last test function is executed.
+// It is only called once.
+void tst_QGraphicsObject::cleanupTestCase()
+{
+}
+
+// This will be called before each test function is executed.
+void tst_QGraphicsObject::init()
+{
+}
+
+// This will be called after every test function.
+void tst_QGraphicsObject::cleanup()
+{
+}
+
+
+class MyGraphicsObject : public QGraphicsObject
+{
+public:
+ MyGraphicsObject() : QGraphicsObject() {}
+ virtual QRectF boundingRect() const { return QRectF(); }
+ virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {}
+};
+
+void tst_QGraphicsObject::pos()
+{
+ MyGraphicsObject object;
+ QSignalSpy xSpy(&object, SIGNAL(xChanged()));
+ QSignalSpy ySpy(&object, SIGNAL(yChanged()));
+ QVERIFY(object.pos() == QPointF(0, 0));
+ object.setPos(10, 10);
+ QCOMPARE(xSpy.count(), 1);
+ QCOMPARE(ySpy.count(), 1);
+
+ QVERIFY(object.pos() == QPointF(10,10));
+
+ object.setPos(10, 10);
+ QCOMPARE(xSpy.count(), 1);
+ QCOMPARE(ySpy.count(), 1);
+
+ object.setProperty("pos", QPointF(0, 0));
+ QCOMPARE(xSpy.count(), 2);
+ QCOMPARE(ySpy.count(), 2);
+ QVERIFY(object.property("pos") == QPointF(0,0));
+
+ object.setProperty("pos", QPointF(10, 0));
+ QCOMPARE(xSpy.count(), 3);
+ QCOMPARE(ySpy.count(), 2);
+ QVERIFY(object.property("pos") == QPointF(10,0));
+
+ object.setProperty("pos", QPointF(10, 10));
+ QCOMPARE(xSpy.count(), 3);
+ QCOMPARE(ySpy.count(), 3);
+ QVERIFY(object.property("pos") == QPointF(10, 10));
+}
+
+void tst_QGraphicsObject::x()
+{
+ MyGraphicsObject object;
+ QSignalSpy xSpy(&object, SIGNAL(xChanged()));
+ QSignalSpy ySpy(&object, SIGNAL(yChanged()));
+ QVERIFY(object.pos() == QPointF(0, 0));
+ object.setX(10);
+ QCOMPARE(xSpy.count(), 1);
+ QCOMPARE(ySpy.count(), 0);
+
+ QVERIFY(object.pos() == QPointF(10, 0));
+ QVERIFY(object.x() == 10);
+
+ object.setX(10);
+ QCOMPARE(xSpy.count(), 1);
+ QCOMPARE(ySpy.count(), 0);
+
+ object.setProperty("x", 0);
+ QCOMPARE(xSpy.count(), 2);
+ QCOMPARE(ySpy.count(), 0);
+ QVERIFY(object.property("x") == 0);
+}
+
+void tst_QGraphicsObject::y()
+{
+ MyGraphicsObject object;
+ QSignalSpy xSpy(&object, SIGNAL(xChanged()));
+ QSignalSpy ySpy(&object, SIGNAL(yChanged()));
+ QVERIFY(object.pos() == QPointF(0, 0));
+ object.setY(10);
+ QCOMPARE(xSpy.count(), 0);
+ QCOMPARE(ySpy.count(), 1);
+
+ QVERIFY(object.pos() == QPointF(0, 10));
+ QVERIFY(object.y() == 10);
+
+ object.setY(10);
+ QCOMPARE(xSpy.count(), 0);
+ QCOMPARE(ySpy.count(), 1);
+
+ object.setProperty("y", 0);
+ QCOMPARE(xSpy.count(), 0);
+ QCOMPARE(ySpy.count(), 2);
+ QVERIFY(object.property("y") == 0);
+}
+
+void tst_QGraphicsObject::z()
+{
+ MyGraphicsObject object;
+ QSignalSpy zSpy(&object, SIGNAL(zChanged()));
+ QVERIFY(object.zValue() == 0);
+ object.setZValue(10);
+ QCOMPARE(zSpy.count(), 1);
+
+ QVERIFY(object.zValue() == 10);
+
+ object.setZValue(10);
+ QCOMPARE(zSpy.count(), 1);
+
+ object.setProperty("z", 0);
+ QCOMPARE(zSpy.count(), 2);
+ QVERIFY(object.property("z") == 0);
+}
+
+void tst_QGraphicsObject::opacity()
+{
+ MyGraphicsObject object;
+ QSignalSpy spy(&object, SIGNAL(opacityChanged()));
+ QVERIFY(object.opacity() == 1.);
+ object.setOpacity(0);
+ QCOMPARE(spy.count(), 1);
+
+ QVERIFY(object.opacity() == 0.);
+
+ object.setOpacity(0);
+ QCOMPARE(spy.count(), 1);
+
+ object.setProperty("opacity", .5);
+ QCOMPARE(spy.count(), 2);
+ QVERIFY(object.property("opacity") == .5);
+}
+
+void tst_QGraphicsObject::enabled()
+{
+ MyGraphicsObject object;
+ QSignalSpy spy(&object, SIGNAL(enabledChanged()));
+ QVERIFY(object.isEnabled() == true);
+ object.setEnabled(false);
+ QCOMPARE(spy.count(), 1);
+
+ QVERIFY(object.isEnabled() == false);
+
+ object.setEnabled(false);
+ QCOMPARE(spy.count(), 1);
+
+ object.setProperty("enabled", true);
+ QCOMPARE(spy.count(), 2);
+ QVERIFY(object.property("enabled") == true);
+}
+
+void tst_QGraphicsObject::visible()
+{
+ MyGraphicsObject object;
+ QSignalSpy spy(&object, SIGNAL(visibleChanged()));
+ QVERIFY(object.isVisible() == true);
+ object.setVisible(false);
+ QCOMPARE(spy.count(), 1);
+
+ QVERIFY(object.isVisible() == false);
+
+ object.setVisible(false);
+ QCOMPARE(spy.count(), 1);
+
+ object.setProperty("visible", true);
+ QCOMPARE(spy.count(), 2);
+ QVERIFY(object.property("visible") == true);
+}
+
+
+QTEST_MAIN(tst_QGraphicsObject)
+#include "tst_qgraphicsobject.moc"
+
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 5167682..06b4a78 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -188,6 +188,8 @@ private slots:
void embeddedViews();
void scrollAfterResize_data();
void scrollAfterResize();
+ void moveItemWhileScrolling_data();
+ void moveItemWhileScrolling();
void centerOnDirtyItem();
void mouseTracking();
void mouseTracking2();
@@ -3045,6 +3047,67 @@ void tst_QGraphicsView::scrollAfterResize()
QCOMPARE(view.viewportTransform(), x3);
}
+void tst_QGraphicsView::moveItemWhileScrolling_data()
+{
+ QTest::addColumn<bool>("adjustForAntialiasing");
+
+ QTest::newRow("no adjust") << false;
+ QTest::newRow("adjust") << true;
+}
+
+void tst_QGraphicsView::moveItemWhileScrolling()
+{
+ QFETCH(bool, adjustForAntialiasing);
+
+ class MoveItemScrollView : public QGraphicsView
+ {
+ public:
+ MoveItemScrollView()
+ {
+ setScene(new QGraphicsScene(0, 0, 1000, 1000));
+ rect = scene()->addRect(0, 0, 10, 10);
+ rect->setPos(50, 50);
+ }
+ QRegion lastPaintedRegion;
+ QGraphicsItem *rect;
+ protected:
+ void paintEvent(QPaintEvent *event)
+ {
+ lastPaintedRegion = event->region();
+ QGraphicsView::paintEvent(event);
+ }
+ };
+
+ MoveItemScrollView view;
+ view.setFrameStyle(0);
+ view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ view.setResizeAnchor(QGraphicsView::NoAnchor);
+ view.setTransformationAnchor(QGraphicsView::NoAnchor);
+ if (!adjustForAntialiasing)
+ view.setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing);
+ view.show();
+ view.resize(200, 200);
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(100);
+
+ view.lastPaintedRegion = QRegion();
+ view.horizontalScrollBar()->setValue(view.horizontalScrollBar()->value() + 10);
+ view.rect->moveBy(0, 10);
+ QTest::qWait(100);
+
+ QRegion expectedRegion;
+ expectedRegion += QRect(0, 0, 200, 200);
+ expectedRegion -= QRect(0, 0, 190, 200);
+ int a = adjustForAntialiasing ? 2 : 1;
+ expectedRegion += QRect(40, 50, 10, 10).adjusted(-a, -a, a, a);
+ expectedRegion += QRect(40, 60, 10, 10).adjusted(-a, -a, a, a);
+
+ QCOMPARE(view.lastPaintedRegion, expectedRegion);
+}
+
void tst_QGraphicsView::centerOnDirtyItem()
{
QGraphicsView view;
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 8a6b63b..058c3c6 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -376,7 +376,7 @@ void tst_QPixmap::scroll()
QFETCH(QRegion, exposed);
QFETCH(bool, newPix);
- QPixmap pixmap(input);
+ QPixmap pixmap = QPixmap::fromImage(input);
QRegion exp;
qint64 oldKey = pixmap.cacheKey();
pixmap.scroll(dx, dy, rect, &exp);
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index d7c231f..274b177 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -134,6 +134,7 @@ private slots:
void task250023_fetchMore();
void task251296_hiddenChildren();
void task252507_mapFromToSource();
+ void task255652_removeRowsRecursive();
protected:
void buildHierarchy(const QStringList &data, QAbstractItemModel *model);
@@ -390,7 +391,7 @@ void tst_QSortFilterProxyModel::sort()
QModelIndex index = m_proxy->index(row, 0, QModelIndex());
QCOMPARE(m_proxy->data(index, Qt::DisplayRole).toString(), initial.at(row));
}
-
+
}
void tst_QSortFilterProxyModel::sortHierarchy_data()
@@ -411,7 +412,7 @@ void tst_QSortFilterProxyModel::sortHierarchy_data()
<< static_cast<int>(Qt::AscendingOrder)
<< (QStringList() << "a" << "<" << "b" << "<" << "c" << ">" << ">")
<< (QStringList() << "a" << "<" << "b" << "<" << "c" << ">" << ">");
-
+
#if 1
QTest::newRow("hierarchical ascending")
<< static_cast<int>(Qt::AscendingOrder)
@@ -571,7 +572,7 @@ void tst_QSortFilterProxyModel::insertRows()
QModelIndex index = m_proxy->index(row, 0, QModelIndex());
QCOMPARE(m_proxy->data(index, Qt::DisplayRole).toString(), initial.at(row));
}
-
+
// insert the row
m_proxy->insertRows(position, insert.count(), QModelIndex());
QCOMPARE(m_model->rowCount(QModelIndex()), expected.count());
@@ -615,7 +616,7 @@ void tst_QSortFilterProxyModel::prependRow()
QStandardItem sub2("sub2");
sub2.appendRow(new QStandardItem("sub3"));
item.insertRow(0, &sub2);
-
+
QModelIndex index_sub2 = proxy.mapFromSource(model.indexFromItem(&sub2));
QCOMPARE(sub2.rowCount(), proxy.rowCount(index_sub2));
@@ -626,7 +627,7 @@ void tst_QSortFilterProxyModel::prependRow()
/*
void tst_QSortFilterProxyModel::insertColumns_data()
{
-
+
}
void tst_QSortFilterProxyModel::insertColumns()
@@ -923,7 +924,7 @@ void tst_QSortFilterProxyModel::removeRows()
// prepare model
foreach (QString s, initial)
model.appendRow(new QStandardItem(s));
-
+
// remove the rows
QCOMPARE(proxy.removeRows(position, count, QModelIndex()), success);
QCOMPARE(model.rowCount(QModelIndex()), expectedSource.count());
@@ -1164,10 +1165,10 @@ void tst_QSortFilterProxyModel::removeColumns()
proxy.setSourceModel(&model);
if (!filter.isEmpty())
proxy.setFilterRegExp(QRegExp(filter));
-
+
// prepare model
model.setHorizontalHeaderLabels(initial);
-
+
// remove the columns
QCOMPARE(proxy.removeColumns(position, count, QModelIndex()), success);
QCOMPARE(model.columnCount(QModelIndex()), expectedSource.count());
@@ -1266,7 +1267,7 @@ void tst_QSortFilterProxyModel::filter_data()
<< "golf"
<< "quebec"
<< "foxtrot"
- << "india"
+ << "india"
<< "romeo"
<< "november"
<< "oskar"
@@ -1274,9 +1275,9 @@ void tst_QSortFilterProxyModel::filter_data()
<< "kilo"
<< "whiskey"
<< "mike"
- << "papa"
+ << "papa"
<< "sierra"
- << "xray"
+ << "xray"
<< "viktor")
<< (QStringList()
<< "delta"
@@ -1334,7 +1335,7 @@ void tst_QSortFilterProxyModel::filterHierarchy_data()
<< "foo" << "boo" << "baz" << "moo" << "laa" << "haa")
<< (QStringList()
<< "foo" << "boo" << "moo");
-
+
QTest::newRow("simple hierarchy") << "b.*z"
<< (QStringList() << "baz" << "<" << "boz" << "<" << "moo" << ">" << ">")
<< (QStringList() << "baz" << "<" << "boz" << ">");
@@ -1671,7 +1672,7 @@ void tst_QSortFilterProxyModel::removeSourceRows()
QSignalSpy insertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex, int, int)));
QSignalSpy aboutToRemoveSpy(&proxy, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)));
QSignalSpy aboutToInsertSpy(&proxy, SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)));
-
+
model.removeRows(start, count, QModelIndex());
QCOMPARE(aboutToRemoveSpy.count(), expectedRemovedProxyIntervals.count());
@@ -1827,7 +1828,7 @@ void tst_QSortFilterProxyModel::changeFilter()
QFETCH(IntPairList, finalRemoveIntervals);
QFETCH(IntPairList, insertIntervals);
QFETCH(QStringList, finalProxyItems);
-
+
QStandardItemModel model;
QSortFilterProxyModel proxy;
@@ -1880,7 +1881,7 @@ void tst_QSortFilterProxyModel::changeFilter()
#ifdef Q_OS_IRIX
QEXPECT_FAIL("filter (2)", "Not reliable on IRIX", Abort);
-#endif
+#endif
QCOMPARE(finalInsertSpy.count(), insertIntervals.count());
for (int i = 0; i < finalInsertSpy.count(); ++i) {
QList<QVariant> args = finalInsertSpy.at(i);
@@ -2068,7 +2069,7 @@ void tst_QSortFilterProxyModel::sortFilterRole()
model.setData(index, sourceItems.at(i).first, Qt::DisplayRole);
model.setData(index, sourceItems.at(i).second, Qt::UserRole);
}
-
+
proxy.setFilterRegExp("2");
QCOMPARE(proxy.rowCount(), 0); // Qt::DisplayRole is default role
@@ -2358,7 +2359,7 @@ void tst_QSortFilterProxyModel::sourceInsertRows()
model.insertColumns(0, 1, parent);
model.insertRows(0, 1, parent);
}
-
+
model.insertRows(0, 1, QModelIndex());
model.insertRows(0, 1, QModelIndex());
@@ -2462,7 +2463,7 @@ void tst_QSortFilterProxyModel::task236755_hiddenColumns()
QVERIFY(view.isColumnHidden(0));
}
-void tst_QSortFilterProxyModel::task247867_insertRowsSort()
+void tst_QSortFilterProxyModel::task247867_insertRowsSort()
{
QStandardItemModel model(2,2);
QSortFilterProxyModel proxyModel;
@@ -2567,7 +2568,7 @@ void tst_QSortFilterProxyModel::task248868_dynamicSorting()
QStringList initial2 = initial;
initial2.replaceInStrings("bateau", "girafe");
model1.setStringList(initial2); //this will cause a reset
-
+
QStringList expected2 = initial2;
expected2.sort();
@@ -2648,7 +2649,7 @@ class QtTestModel: public QAbstractItemModel
{
if (!idx.isValid())
return QVariant();
-
+
if (role == Qt::DisplayRole) {
if (idx.row() < 0 || idx.column() < 0 || idx.column() >= cols || idx.row() >= rows) {
wrongIndex = true;
@@ -2756,5 +2757,63 @@ void tst_QSortFilterProxyModel::task252507_mapFromToSource()
QCOMPARE(proxy.mapFromSource(proxy.index(6, 2)), QModelIndex());
}
+static QStandardItem *addEntry(QStandardItem* pParent, const QString &description)
+{
+ QStandardItem* pItem = new QStandardItem(description);
+ pParent->appendRow(pItem);
+ return pItem;
+}
+
+
+void tst_QSortFilterProxyModel::task255652_removeRowsRecursive()
+{
+ QStandardItemModel pModel;
+ QStandardItem *pItem1 = new QStandardItem("root");
+ pModel.appendRow(pItem1);
+ QList<QStandardItem *> items;
+
+ QStandardItem *pItem11 = addEntry(pItem1,"Sub-heading");
+ items << pItem11;
+ QStandardItem *pItem111 = addEntry(pItem11,"A");
+ items << pItem111;
+ items << addEntry(pItem111,"A1");
+ items << addEntry(pItem111,"A2");
+ QStandardItem *pItem112 = addEntry(pItem11,"B");
+ items << pItem112;
+ items << addEntry(pItem112,"B1");
+ items << addEntry(pItem112,"B2");
+ QStandardItem *pItem1123 = addEntry(pItem112,"B3");
+ items << pItem1123;
+ items << addEntry(pItem1123,"B3-");
+
+ QSortFilterProxyModel proxy;
+ proxy.setSourceModel(&pModel);
+
+ QList<QPersistentModelIndex> sourceIndexes;
+ QList<QPersistentModelIndex> proxyIndexes;
+ foreach (QStandardItem *item, items) {
+ QModelIndex idx = item->index();
+ sourceIndexes << idx;
+ proxyIndexes << proxy.mapFromSource(idx);
+ }
+
+ foreach (const QPersistentModelIndex &pidx, sourceIndexes)
+ QVERIFY(pidx.isValid());
+ foreach (const QPersistentModelIndex &pidx, proxyIndexes)
+ QVERIFY(pidx.isValid());
+
+ QList<QStandardItem*> itemRow = pItem1->takeRow(0);
+
+ QCOMPARE(itemRow.count(), 1);
+ QCOMPARE(itemRow.first(), pItem11);
+
+ foreach (const QPersistentModelIndex &pidx, sourceIndexes)
+ QVERIFY(!pidx.isValid());
+ foreach (const QPersistentModelIndex &pidx, proxyIndexes)
+ QVERIFY(!pidx.isValid());
+
+ delete pItem11;
+}
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_qsortfilterproxymodel.moc"
diff --git a/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp
index 84bda92..8067554 100644
--- a/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp
+++ b/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp
@@ -135,6 +135,7 @@ private slots:
void rootItemFlags();
void treeDragAndDrop();
+ void removeRowsAndColumns();
private:
QAbstractItemModel *m_model;
@@ -1403,7 +1404,7 @@ bool tst_QStandardItemModel::compareItems(QStandardItem *item1, QStandardItem *i
return true;
if (!item1 || !item2)
return false;
- if (item1->text() != item2->text()){
+ if (item1->text() != item2->text()){
qDebug() << item1->text() << item2->text();
return false;
}
@@ -1606,6 +1607,52 @@ void tst_QStandardItemModel::treeDragAndDrop()
}
}
+void tst_QStandardItemModel::removeRowsAndColumns()
+{
+#define VERIFY_MODEL \
+ for (int c = 0; c < col_list.count(); c++) \
+ for (int r = 0; r < row_list.count(); r++) \
+ QCOMPARE(model.item(r,c)->text() , row_list[r] + "x" + col_list[c]);
+
+ QVector<QString> row_list = QString("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20").split(',').toVector();
+ QVector<QString> col_list = row_list;
+ QStandardItemModel model;
+ for (int c = 0; c < col_list.count(); c++)
+ for (int r = 0; r < row_list.count(); r++)
+ model.setItem(r, c, new QStandardItem(row_list[r] + "x" + col_list[c]));
+ VERIFY_MODEL
+
+ row_list.remove(3);
+ model.removeRow(3);
+ VERIFY_MODEL
+
+ col_list.remove(5);
+ model.removeColumn(5);
+ VERIFY_MODEL
+
+ row_list.remove(2, 5);
+ model.removeRows(2, 5);
+ VERIFY_MODEL
+
+ col_list.remove(1, 6);
+ model.removeColumns(1, 6);
+ VERIFY_MODEL
+
+ QList<QStandardItem *> row_taken = model.takeRow(6);
+ QCOMPARE(row_taken.count(), col_list.count());
+ for (int c = 0; c < col_list.count(); c++)
+ QCOMPARE(row_taken[c]->text() , row_list[6] + "x" + col_list[c]);
+ row_list.remove(6);
+ VERIFY_MODEL
+
+ QList<QStandardItem *> col_taken = model.takeColumn(10);
+ QCOMPARE(col_taken.count(), row_list.count());
+ for (int r = 0; r < row_list.count(); r++)
+ QCOMPARE(col_taken[r]->text() , row_list[r] + "x" + col_list[10]);
+ col_list.remove(10);
+ VERIFY_MODEL
+}
+
QTEST_MAIN(tst_QStandardItemModel)
#include "tst_qstandarditemmodel.moc"
diff --git a/tests/auto/qtextcodec/test/test.pro b/tests/auto/qtextcodec/test/test.pro
index e52bb7a..9c07e76 100644
--- a/tests/auto/qtextcodec/test/test.pro
+++ b/tests/auto/qtextcodec/test/test.pro
@@ -6,7 +6,7 @@ wince*: {
addFiles.path = .
DEPLOYMENT += addFiles
DEPLOYMENT_PLUGIN += qcncodecs qjpcodecs qkrcodecs qtwcodecs
+ DEFINES += SRCDIR=\\\"\\\"
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD/../\\\"
}
-
-
-
diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp
index 97c409b..1802c3e 100644
--- a/tests/auto/qtextcodec/tst_qtextcodec.cpp
+++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp
@@ -74,6 +74,9 @@ private slots:
void utf8Codec_data();
void utf8Codec();
+ void utf8bom_data();
+ void utf8bom();
+
void utfHeaders_data();
void utfHeaders();
@@ -92,8 +95,8 @@ void tst_QTextCodec::toUnicode_data()
QTest::addColumn<QString>("fileName");
QTest::addColumn<QString>("codecName");
- QTest::newRow( "korean-eucKR" ) << "korean.txt" << "eucKR";
- QTest::newRow( "UTF-8" ) << "utf8.txt" << "UTF-8";
+ QTest::newRow( "korean-eucKR" ) << SRCDIR "korean.txt" << "eucKR";
+ QTest::newRow( "UTF-8" ) << SRCDIR "utf8.txt" << "UTF-8";
}
void tst_QTextCodec::toUnicode()
@@ -234,7 +237,7 @@ void tst_QTextCodec::fromUnicode()
void tst_QTextCodec::toUnicode_codecForHtml()
{
- QFile file(QString("QT4-crashtest.txt"));
+ QFile file(QString(SRCDIR "QT4-crashtest.txt"));
QVERIFY(file.open(QFile::ReadOnly));
QByteArray data = file.readAll();
@@ -1513,6 +1516,63 @@ void tst_QTextCodec::utf8Codec()
QCOMPARE(str, res);
}
+void tst_QTextCodec::utf8bom_data()
+{
+ QTest::addColumn<QByteArray>("data");
+ QTest::addColumn<QString>("result");
+
+ QTest::newRow("nobom")
+ << QByteArray("\302\240", 2)
+ << QString("\240");
+
+ {
+ static const ushort data[] = { 0x201d };
+ QTest::newRow("nobom 2")
+ << QByteArray("\342\200\235", 3)
+ << QString::fromUtf16(data, sizeof(data)/sizeof(short));
+ }
+
+ {
+ static const ushort data[] = { 0xf000 };
+ QTest::newRow("bom1")
+ << QByteArray("\357\200\200", 3)
+ << QString::fromUtf16(data, sizeof(data)/sizeof(short));
+ }
+
+ {
+ static const ushort data[] = { 0xfec0 };
+ QTest::newRow("bom2")
+ << QByteArray("\357\273\200", 3)
+ << QString::fromUtf16(data, sizeof(data)/sizeof(short));
+ }
+
+ {
+ QTest::newRow("normal-bom")
+ << QByteArray("\357\273\277a", 4)
+ << QString("a");
+ }
+
+ {
+ static const ushort data[] = { 0x61, 0xfeff, 0x62 };
+ QTest::newRow("middle-bom")
+ << QByteArray("a\357\273\277b", 5)
+ << QString::fromUtf16(data, sizeof(data)/sizeof(short));
+ }
+}
+
+void tst_QTextCodec::utf8bom()
+{
+ QFETCH(QByteArray, data);
+ QFETCH(QString, result);
+
+ QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
+ Q_ASSERT(codec);
+
+ QCOMPARE(codec->toUnicode(data.constData(), data.length(), 0), result);
+
+ QTextCodec::ConverterState state;
+ QCOMPARE(codec->toUnicode(data.constData(), data.length(), &state), result);
+}
void tst_QTextCodec::utfHeaders_data()
{
diff --git a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp
index f92e30f..f8c7cdf 100644
--- a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp
+++ b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp
@@ -133,7 +133,7 @@ void tst_QTextOdfWriter::testWriteParagraph_data()
QTest::newRow("tab") << "word\ttab x" <<
"<text:p text:style-name=\"p1\"><text:span text:style-name=\"c0\">word<text:tab/>tab x</text:span></text:p>";
QTest::newRow("tab2") << "word\t\ttab\tx" <<
- "<text:p text:style-name=\"p1\"><text:span text:style-name=\"c0\">word<text:tab text:tab-ref=\"2\"/>tab<text:tab/>x</text:span></text:p>";
+ "<text:p text:style-name=\"p1\"><text:span text:style-name=\"c0\">word<text:tab/><text:tab/>tab<text:tab/>x</text:span></text:p>";
QTest::newRow("misc") << "foobar word\ttab x" <<
"<text:p text:style-name=\"p1\"><text:span text:style-name=\"c0\">foobar <text:s text:c=\"2\"/>word<text:tab/>tab x</text:span></text:p>";
QTest::newRow("misc2") << "\t \tFoo" <<
diff --git a/tests/auto/qtextstream/tst_qtextstream.cpp b/tests/auto/qtextstream/tst_qtextstream.cpp
index 358b4b6..9573957 100644
--- a/tests/auto/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/qtextstream/tst_qtextstream.cpp
@@ -552,8 +552,15 @@ void tst_QTextStream::generateLineData(bool for_QString)
QTest::newRow("threelines/crlf/crlf/crlf") << QByteArray("ole\r\ndole\r\ndoffen\r\n") << (QStringList() << "ole" << "dole" << "doffen");
QTest::newRow("threelines/crlf/crlf/nothing") << QByteArray("ole\r\ndole\r\ndoffen") << (QStringList() << "ole" << "dole" << "doffen");
- // utf-16
if (!for_QString) {
+ // utf-8
+ QTest::newRow("utf8/twolines")
+ << QByteArray("\xef\xbb\xbf"
+ "\x66\x67\x65\x0a"
+ "\x66\x67\x65\x0a", 11)
+ << (QStringList() << "fge" << "fge");
+
+ // utf-16
// one line
QTest::newRow("utf16-BE/nothing")
<< QByteArray("\xfe\xff"
@@ -593,6 +600,18 @@ void tst_QTextStream::generateLineData(bool for_QString)
"\xe5\x00\x67\x00\x65\x00\x0a\x00"
"\xe5\x00\x67\x00\x65\x00\x0a\x00", 26)
<< (QStringList() << "\345ge" << "\345ge" << "\345ge");
+
+ // utf-32
+ QTest::newRow("utf32-BE/twolines")
+ << QByteArray("\x00\x00\xfe\xff"
+ "\x00\x00\x00\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a"
+ "\x00\x00\x00\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a", 36)
+ << (QStringList() << "\345ge" << "\345ge");
+ QTest::newRow("utf32-LE/twolines")
+ << QByteArray("\xff\xfe\x00\x00"
+ "\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a\x00\x00\x00"
+ "\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a\x00\x00\x00", 36)
+ << (QStringList() << "\345ge" << "\345ge");
}
// partials
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp
index 0ede920..2d26914 100644
--- a/tests/auto/qvariant/tst_qvariant.cpp
+++ b/tests/auto/qvariant/tst_qvariant.cpp
@@ -2449,14 +2449,22 @@ void tst_QVariant::saveLoadCustomTypes()
void tst_QVariant::url()
{
- QUrl url("http://www.trolltech.com");
+ QString str("http://www.trolltech.com");
+ QUrl url(str);
- QVariant v(url);
+ QVariant v(url); //built with a QUrl
QVariant v2 = v;
- QVERIFY(v2.toUrl() == url);
+ QVariant v3(str); //built with a QString
+ QCOMPARE(v2.toUrl(), url);
+ QVERIFY(qVariantCanConvert<QUrl>(v3));
+ QCOMPARE(v2.toUrl(), v3.toUrl());
+
+ QVERIFY(qVariantCanConvert<QString>(v2));
+ QCOMPARE(v2.toString(), str);
+ QCOMPARE(v3.toString(), str);
}
void tst_QVariant::globalColor()
diff --git a/tests/auto/uiloader/baseline/css_task255849_downarrow.ui b/tests/auto/uiloader/baseline/css_task255849_downarrow.ui
new file mode 100644
index 0000000..d3e99b1
--- /dev/null
+++ b/tests/auto/uiloader/baseline/css_task255849_downarrow.ui
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>275</width>
+ <height>175</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">/* Some widget were not displaying the arrow if only the arrow was set */
+*::down-arrow { image: url(&quot;images/arrow-down.png&quot;) }
+*::up-arrow { image: url(&quot;images/arrow-up.png&quot;) }
+
+
+</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0" colspan="2">
+ <widget class="QComboBox" name="comboBox"/>
+ </item>
+ <item row="0" column="2" rowspan="5">
+ <widget class="QTreeWidget" name="treeWidget">
+ <property name="sortingEnabled">
+ <bool>true</bool>
+ </property>
+ <attribute name="headerShowSortIndicator" stdset="0">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="headerShowSortIndicator" stdset="0">
+ <bool>true</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string>1</string>
+ </property>
+ </column>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QSpinBox" name="spinBox"/>
+ </item>
+ <item row="1" column="1">
+ <widget class="QToolButton" name="toolButton">
+ <property name="text">
+ <string>foo</string>
+ </property>
+ <property name="arrowType">
+ <enum>Qt::DownArrow</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QDoubleSpinBox" name="doubleSpinBox"/>
+ </item>
+ <item row="3" column="0" colspan="2">
+ <widget class="QPushButton" name="pushButton">
+ <property name="contextMenuPolicy">
+ <enum>Qt::NoContextMenu</enum>
+ </property>
+ <property name="text">
+ <string>PushButton</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/auto/uiloader/baseline/images/arrow-down.png b/tests/auto/uiloader/baseline/images/arrow-down.png
new file mode 100644
index 0000000..7c9274f
--- /dev/null
+++ b/tests/auto/uiloader/baseline/images/arrow-down.png
Binary files differ
diff --git a/tests/auto/uiloader/baseline/images/arrow-up.png b/tests/auto/uiloader/baseline/images/arrow-up.png
new file mode 100644
index 0000000..758a0d1
--- /dev/null
+++ b/tests/auto/uiloader/baseline/images/arrow-up.png
Binary files differ