summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp14
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp123
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp21
-rw-r--r--tests/auto/qurl/tst_qurl.cpp6
-rw-r--r--tests/auto/qvector/tst_qvector.cpp600
-rw-r--r--tests/benchmarks/corelib/kernel/events/events.pro1
-rw-r--r--tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro1
-rw-r--r--tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro2
-rw-r--r--tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro1
-rw-r--r--tests/benchmarks/corelib/tools/containers-associative/main.cpp1
-rw-r--r--tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro1
11 files changed, 749 insertions, 22 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 055ae80..81097be 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -7293,7 +7293,7 @@ void tst_QGraphicsItem::update()
QCOMPARE(item->repaints, 1);
QCOMPARE(view.repaints, 1);
QRect itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform())
- .mapRect(item->boundingRect()).toRect();
+ .mapRect(item->boundingRect()).toAlignedRect();
QRegion expectedRegion = itemDeviceBoundingRect.adjusted(-2, -2, 2, 2);
// The entire item's bounding rect (adjusted for antialiasing) should have been painted.
QCOMPARE(view.paintedRegion, expectedRegion);
@@ -7372,7 +7372,7 @@ void tst_QGraphicsItem::update()
scene.addItem(parent);
QTest::qWait(50);
itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform())
- .mapRect(item->boundingRect()).toRect();
+ .mapRect(item->boundingRect()).toAlignedRect();
expectedRegion = itemDeviceBoundingRect.adjusted(-2, -2, 2, 2);
view.reset();
item->repaints = 0;
@@ -7648,7 +7648,7 @@ void tst_QGraphicsItem::moveItem()
// Item's boundingRect: (-10, -10, 20, 20).
QRect parentDeviceBoundingRect = parent->deviceTransform(view.viewportTransform())
- .mapRect(parent->boundingRect()).toRect()
+ .mapRect(parent->boundingRect()).toAlignedRect()
.adjusted(-2, -2, 2, 2); // Adjusted for antialiasing.
parent->setPos(20, 20);
@@ -7711,8 +7711,14 @@ void tst_QGraphicsItem::moveLineItem()
QTest::qWait(200);
view.reset();
+ QRectF brect = item->boundingRect();
+ // Do same adjustments as in qgraphicsscene.cpp
+ if (!brect.width())
+ brect.adjust(qreal(-0.00001), 0, qreal(0.00001), 0);
+ if (!brect.height())
+ brect.adjust(0, qreal(-0.00001), 0, qreal(0.00001));
const QRect itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform())
- .mapRect(item->boundingRect()).toRect();
+ .mapRect(brect).toAlignedRect();
QRegion expectedRegion = itemDeviceBoundingRect.adjusted(-2, -2, 2, 2); // antialiasing
// Make sure the calculated region is correct.
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index d0752af..1df9a37 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -216,6 +216,8 @@ private slots:
void exposeRegion();
void update_data();
void update();
+ void update2_data();
+ void update2();
void inputMethodSensitivity();
void inputContextReset();
void indirectPainting();
@@ -1383,28 +1385,48 @@ void tst_QGraphicsView::itemsInRect_cosmeticAdjust_data()
{
QTest::addColumn<QRect>("updateRect");
QTest::addColumn<int>("numPaints");
+ QTest::addColumn<bool>("adjustForAntialiasing");
- QTest::newRow("nil") << QRect() << 1;
- QTest::newRow("0, 0, 300, 100") << QRect(0, 0, 300, 100) << 1;
- QTest::newRow("0, 0, 100, 300") << QRect(0, 0, 100, 300) << 1;
- QTest::newRow("200, 0, 100, 300") << QRect(200, 0, 100, 300) << 1;
- QTest::newRow("0, 200, 300, 100") << QRect(0, 200, 300, 100) << 1;
- QTest::newRow("0, 0, 300, 99") << QRect(0, 0, 300, 99) << 0;
- QTest::newRow("0, 0, 99, 300") << QRect(0, 0, 99, 300) << 0;
- QTest::newRow("201, 0, 99, 300") << QRect(201, 0, 99, 300) << 0;
- QTest::newRow("0, 201, 300, 99") << QRect(0, 201, 300, 99) << 0;
+ // Aliased.
+ QTest::newRow("nil") << QRect() << 1 << false;
+ QTest::newRow("0, 0, 300, 100") << QRect(0, 0, 300, 100) << 1 << false;
+ QTest::newRow("0, 0, 100, 300") << QRect(0, 0, 100, 300) << 1 << false;
+ QTest::newRow("200, 0, 100, 300") << QRect(200, 0, 100, 300) << 1 << false;
+ QTest::newRow("0, 200, 300, 100") << QRect(0, 200, 300, 100) << 1 << false;
+ QTest::newRow("0, 0, 300, 99") << QRect(0, 0, 300, 99) << 0 << false;
+ QTest::newRow("0, 0, 99, 300") << QRect(0, 0, 99, 300) << 0 << false;
+ QTest::newRow("201, 0, 99, 300") << QRect(201, 0, 99, 300) << 0 << false;
+ QTest::newRow("0, 201, 300, 99") << QRect(0, 201, 300, 99) << 0 << false;
+
+ // Anti-aliased.
+ QTest::newRow("nil") << QRect() << 1 << true;
+ QTest::newRow("0, 0, 300, 100") << QRect(0, 0, 300, 100) << 1 << true;
+ QTest::newRow("0, 0, 100, 300") << QRect(0, 0, 100, 300) << 1 << true;
+ QTest::newRow("200, 0, 100, 300") << QRect(200, 0, 100, 300) << 1 << true;
+ QTest::newRow("0, 200, 300, 100") << QRect(0, 200, 300, 100) << 1 << true;
+ QTest::newRow("0, 0, 300, 99") << QRect(0, 0, 300, 99) << 1 << true;
+ QTest::newRow("0, 0, 99, 300") << QRect(0, 0, 99, 300) << 1 << true;
+ QTest::newRow("201, 0, 99, 300") << QRect(201, 0, 99, 300) << 1 << true;
+ QTest::newRow("0, 201, 300, 99") << QRect(0, 201, 300, 99) << 1 << true;
+ QTest::newRow("0, 0, 300, 98") << QRect(0, 0, 300, 98) << 0 << false;
+ QTest::newRow("0, 0, 98, 300") << QRect(0, 0, 98, 300) << 0 << false;
+ QTest::newRow("202, 0, 98, 300") << QRect(202, 0, 98, 300) << 0 << false;
+ QTest::newRow("0, 202, 300, 98") << QRect(0, 202, 300, 98) << 0 << false;
}
void tst_QGraphicsView::itemsInRect_cosmeticAdjust()
{
QFETCH(QRect, updateRect);
QFETCH(int, numPaints);
+ QFETCH(bool, adjustForAntialiasing);
QGraphicsScene scene(-100, -100, 200, 200);
CountPaintItem *rect = new CountPaintItem(QRectF(-50, -50, 100, 100));
scene.addItem(rect);
QGraphicsView view(&scene);
+ view.setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing, !adjustForAntialiasing);
+ view.setRenderHint(QPainter::Antialiasing, adjustForAntialiasing);
view.setFrameStyle(0);
view.resize(300, 300);
view.show();
@@ -2219,8 +2241,8 @@ void tst_QGraphicsView::viewportUpdateMode()
QTRY_VERIFY(!view.lastUpdateRegions.isEmpty());
#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
QCOMPARE(view.lastUpdateRegions.last().rects().size(), 2);
- QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), QSize(15, 15));
- QCOMPARE(view.lastUpdateRegions.last().rects().at(1).size(), QSize(15, 15));
+ QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), QSize(14, 14));
+ QCOMPARE(view.lastUpdateRegions.last().rects().at(1).size(), QSize(14, 14));
#endif
// Set full update mode.
@@ -2254,7 +2276,7 @@ void tst_QGraphicsView::viewportUpdateMode()
// The view gets one bounding rect update.
QCOMPARE(view.lastUpdateRegions.last().rects().size(), 1);
- QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), QSize(33, 33));
+ QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), QSize(32, 32));
// Set no update mode
view.setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
@@ -3647,7 +3669,6 @@ void tst_QGraphicsView::update()
const bool intersects = updateRect.intersects(viewportRect);
QGraphicsViewPrivate *viewPrivate = static_cast<QGraphicsViewPrivate *>(qt_widget_private(&view));
QTRY_COMPARE(viewPrivate->updateRect(updateRect), intersects);
- QCOMPARE(viewPrivate->updateRegion(updateRect), intersects);
view.lastUpdateRegions.clear();
viewPrivate->processPendingUpdates();
@@ -3658,13 +3679,85 @@ void tst_QGraphicsView::update()
QTRY_VERIFY(view.lastUpdateRegions.isEmpty());
} else {
QTRY_COMPARE(view.lastUpdateRegions.size(), 1);
- // Note that we adjust by 2 for antialiasing.
- QTRY_COMPARE(view.lastUpdateRegions.at(0), QRegion(updateRect.adjusted(-2, -2, 2, 2) & viewportRect));
+ QTRY_COMPARE(view.lastUpdateRegions.at(0), QRegion(updateRect) & viewportRect);
}
QTRY_VERIFY(!viewPrivate->fullUpdatePending);
#endif
}
+void tst_QGraphicsView::update2_data()
+{
+ QTest::addColumn<qreal>("penWidth");
+ QTest::addColumn<bool>("antialiasing");
+
+ // Anti-aliased.
+ QTest::newRow("pen width: 0.0, antialiasing: true") << 0.0 << true;
+ QTest::newRow("pen width: 1.5, antialiasing: true") << 1.5 << true;
+ QTest::newRow("pen width: 2.0, antialiasing: true") << 2.0 << true;
+ QTest::newRow("pen width: 3.0, antialiasing: true") << 3.0 << true;
+
+ // Aliased.
+ QTest::newRow("pen width: 0.0, antialiasing: false") << 0.0 << false;
+ QTest::newRow("pen width: 1.5, antialiasing: false") << 1.5 << false;
+ QTest::newRow("pen width: 2.0, antialiasing: false") << 2.0 << false;
+ QTest::newRow("pen width: 3.0, antialiasing: false") << 3.0 << false;
+}
+
+void tst_QGraphicsView::update2()
+{
+ QFETCH(qreal, penWidth);
+ QFETCH(bool, antialiasing);
+
+ // Create a rect item.
+ const QRectF rawItemRect(-50.4, -50.3, 100.2, 100.1);
+ CountPaintItem *rect = new CountPaintItem(rawItemRect);
+ QPen pen;
+ pen.setWidthF(penWidth);
+ rect->setPen(pen);
+
+ // Add item to a scene.
+ QGraphicsScene scene(-100, -100, 200, 200);
+ scene.addItem(rect);
+
+ // Create a view on the scene.
+ CustomView view(&scene);
+ view.setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing, !antialiasing);
+ view.setRenderHint(QPainter::Antialiasing, antialiasing);
+ view.setFrameStyle(0);
+ view.resize(200, 200);
+ view.show();
+ QTest::qWaitForWindowShown(&view) ;
+ QTRY_VERIFY(rect->numPaints > 0);
+
+ // Calculate expected update region for the rect.
+ QRectF expectedItemBoundingRect = rawItemRect;
+ const qreal halfPenWidth = penWidth / qreal(2.0);
+ expectedItemBoundingRect.adjust(-halfPenWidth, -halfPenWidth, halfPenWidth, halfPenWidth);
+ QCOMPARE(rect->boundingRect(), expectedItemBoundingRect);
+
+ QRect expectedItemDeviceBoundingRect = rect->deviceTransform(view.viewportTransform())
+ .mapRect(expectedItemBoundingRect).toAlignedRect();
+ if (antialiasing)
+ expectedItemDeviceBoundingRect.adjust(-2, -2, 2, 2);
+ else
+ expectedItemDeviceBoundingRect.adjust(-1, -1, 1, 1);
+ const QRegion expectedUpdateRegion(expectedItemDeviceBoundingRect);
+
+ // Reset.
+ rect->numPaints = 0;
+ view.lastUpdateRegions.clear();
+ view.painted = false;
+
+ rect->update();
+ QTRY_VERIFY(view.painted);
+
+#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
+ QTRY_VERIFY(view.painted);
+ QCOMPARE(view.lastUpdateRegions.size(), 1);
+ QCOMPARE(view.lastUpdateRegions.at(0), expectedUpdateRegion);
+#endif
+}
+
class FocusItem : public QGraphicsRectItem
{
public:
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index 2062e8e..3e5d077 100644
--- a/tests/auto/qtableview/tst_qtableview.cpp
+++ b/tests/auto/qtableview/tst_qtableview.cpp
@@ -202,6 +202,7 @@ private slots:
void taskQTBUG_8585_crashForNoGoodReason();
void taskQTBUG_7774_RtoLVisualRegionForSelection();
void taskQTBUG_8777_scrollToSpans();
+ void taskQTBUG_10169_sizeHintForRow();
void mouseWheel_data();
void mouseWheel();
@@ -478,6 +479,11 @@ public:
return QTableView::selectedIndexes();
}
+ int sizeHintForRow(int row) const
+ {
+ return QTableView::sizeHintForRow(row);
+ }
+
bool checkSignalOrder;
public slots:
void currentChanged(QModelIndex , QModelIndex ) {
@@ -4042,5 +4048,20 @@ void tst_QTableView::taskQTBUG_8777_scrollToSpans()
QVERIFY(table.verticalScrollBar()->value() > 10);
}
+void tst_QTableView::taskQTBUG_10169_sizeHintForRow()
+{
+ QtTestTableView tableView;
+ QStandardItemModel model(1, 3);
+ model.setData(model.index(0, 0), "Word wrapping text goes here.");
+ tableView.setModel(&model);
+ tableView.verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
+ const int orderedHeight = tableView.sizeHintForRow(0);
+ tableView.horizontalHeader()->moveSection(2, 0);
+ const int reorderedHeight = tableView.sizeHintForRow(0);
+
+ //the order of the columns shouldn't matter.
+ QCOMPARE(orderedHeight, reorderedHeight);
+}
+
QTEST_MAIN(tst_QTableView)
#include "tst_qtableview.moc"
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index b7cbdb8..fa42adc 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -1632,6 +1632,10 @@ void tst_QUrl::toString_data()
QTest::newRow("nopath_task31320") << QString::fromLatin1("host://protocol")
<< uint(QUrl::None)
<< QString::fromLatin1("host://protocol");
+
+ QTest::newRow("underscore_QTBUG-7434") << QString::fromLatin1("http://foo_bar.host.com/rss.php")
+ << uint(QUrl::None)
+ << QString::fromLatin1("http://foo_bar.host.com/rss.php");
}
void tst_QUrl::toString()
@@ -3244,7 +3248,6 @@ void tst_QUrl::std3violations_data()
QTest::newRow("question") << "foo?bar" << true;
QTest::newRow("at") << "foo@bar" << true;
QTest::newRow("backslash") << "foo\\bar" << false;
- QTest::newRow("underline") << "foo_bar" << false;
// these characters are transformed by NFKC to non-LDH characters
QTest::newRow("dot-like") << QString::fromUtf8("foo\342\200\244bar") << false; // U+2024 ONE DOT LEADER
@@ -3289,6 +3292,7 @@ void tst_QUrl::std3deviations_data()
QTest::newRow("ending-dot") << "example.com.";
QTest::newRow("ending-dot3002") << QString("example.com") + QChar(0x3002);
+ QTest::newRow("underline") << "foo_bar"; //QTBUG-7434
}
void tst_QUrl::std3deviations()
diff --git a/tests/auto/qvector/tst_qvector.cpp b/tests/auto/qvector/tst_qvector.cpp
index ebc19ed..2bc8d15 100644
--- a/tests/auto/qvector/tst_qvector.cpp
+++ b/tests/auto/qvector/tst_qvector.cpp
@@ -55,10 +55,610 @@ public:
virtual ~tst_QVector() {}
private slots:
+ void constructors() const;
+ void append() const;
+ void at() const;
+ void capacity() const;
+ void clear() const;
+ void constData() const;
+ void contains() const;
+ void count() const;
+ void data() const;
+ void empty() const;
+ void endsWith() const;
+ void fill() const;
+ void first() const;
+ void fromList() const;
+ void fromStdVector() const;
+ void indexOf() const;
+ void insert() const;
+ void isEmpty() const;
+ void last() const;
+ void lastIndexOf() const;
+ void mid() const;
+ void prepend() const;
+ void remove() const;
+ void size() const;
+ void startsWith() const;
+ void toList() const;
+ void toStdVector() const;
+ void value() const;
+
+ void testOperators() const;
+
void outOfMemory();
void QTBUG6416_reserve();
};
+void tst_QVector::constructors() const
+{
+ // pre-reserve capacity
+ {
+ QVector<int> myvec(5);
+
+ QVERIFY(myvec.capacity() == 5);
+ }
+
+ // default-initialise items
+ {
+ QVector<int> myvec(5, 42);
+
+ QVERIFY(myvec.capacity() == 5);
+
+ // make sure all items are initialised ok
+ foreach (int meaningoflife, myvec) {
+ QCOMPARE(meaningoflife, 42);
+ }
+ }
+}
+
+void tst_QVector::append() const
+{
+ QVector<int> myvec;
+ myvec.append(42);
+ myvec.append(43);
+ myvec.append(44);
+
+ QVERIFY(myvec.size() == 3);
+ QCOMPARE(myvec, QVector<int>() << 42 << 43 << 44);
+}
+
+void tst_QVector::at() const
+{
+ QVector<QString> myvec;
+ myvec << "foo" << "bar" << "baz";
+
+ QVERIFY(myvec.size() == 3);
+ QCOMPARE(myvec.at(0), QLatin1String("foo"));
+ QCOMPARE(myvec.at(1), QLatin1String("bar"));
+ QCOMPARE(myvec.at(2), QLatin1String("baz"));
+
+ // append an item
+ myvec << "hello";
+ QVERIFY(myvec.size() == 4);
+ QCOMPARE(myvec.at(0), QLatin1String("foo"));
+ QCOMPARE(myvec.at(1), QLatin1String("bar"));
+ QCOMPARE(myvec.at(2), QLatin1String("baz"));
+ QCOMPARE(myvec.at(3), QLatin1String("hello"));
+
+ // remove an item
+ myvec.remove(1);
+ QVERIFY(myvec.size() == 3);
+ QCOMPARE(myvec.at(0), QLatin1String("foo"));
+ QCOMPARE(myvec.at(1), QLatin1String("baz"));
+ QCOMPARE(myvec.at(2), QLatin1String("hello"));
+}
+
+void tst_QVector::capacity() const
+{
+ QVector<QString> myvec;
+
+ // TODO: is this guarenteed? seems a safe assumption, but I suppose preallocation of a
+ // few items isn't an entirely unforseeable possibility.
+ QVERIFY(myvec.capacity() == 0);
+
+ // test it gets a size
+ myvec << "aaa" << "bbb" << "ccc";
+ QVERIFY(myvec.capacity() >= 3);
+
+ // make sure it grows ok
+ myvec << "aaa" << "bbb" << "ccc";
+ QVERIFY(myvec.capacity() >= 6);
+
+ // let's try squeeze a bit
+ myvec.remove(3);
+ myvec.remove(3);
+ myvec.remove(3);
+ // TODO: is this a safe assumption? presumably it won't release memory until shrink(), but can we asser that is true?
+ QVERIFY(myvec.capacity() >= 6);
+ myvec.squeeze();
+ QVERIFY(myvec.capacity() >= 3);
+
+ myvec.remove(0);
+ myvec.remove(0);
+ myvec.remove(0);
+ // TODO: as above note
+ QVERIFY(myvec.capacity() >= 3);
+ myvec.squeeze();
+ QVERIFY(myvec.capacity() == 0);
+}
+
+void tst_QVector::clear() const
+{
+ QVector<QString> myvec;
+ myvec << "aaa" << "bbb" << "ccc";
+
+ QVERIFY(myvec.size() == 3);
+ myvec.clear();
+ QVERIFY(myvec.size() == 0);
+ QVERIFY(myvec.capacity() == 0);
+}
+
+void tst_QVector::constData() const
+{
+ int arr[] = { 42, 43, 44 };
+ QVector<int> myvec;
+ myvec << 42 << 43 << 44;
+
+ QVERIFY(memcmp(myvec.constData(), reinterpret_cast<const int *>(&arr), sizeof(int) * 3) == 0);
+}
+
+void tst_QVector::contains() const
+{
+ QVector<QString> myvec;
+ myvec << "aaa" << "bbb" << "ccc";
+
+ QVERIFY(myvec.contains(QLatin1String("aaa")));
+ QVERIFY(myvec.contains(QLatin1String("bbb")));
+ QVERIFY(myvec.contains(QLatin1String("ccc")));
+ QVERIFY(!myvec.contains(QLatin1String("I don't exist")));
+
+ // add it and make sure it does :)
+ myvec.append(QLatin1String("I don't exist"));
+ QVERIFY(myvec.contains(QLatin1String("I don't exist")));
+}
+
+void tst_QVector::count() const
+{
+ // total size
+ {
+ // zero size
+ QVector<int> myvec;
+ QVERIFY(myvec.count() == 0);
+
+ // grow
+ myvec.append(42);
+ QVERIFY(myvec.count() == 1);
+ myvec.append(42);
+ QVERIFY(myvec.count() == 2);
+
+ // shrink
+ myvec.remove(0);
+ QVERIFY(myvec.count() == 1);
+ myvec.remove(0);
+ QVERIFY(myvec.count() == 0);
+ }
+
+ // count of items
+ {
+ QVector<QString> myvec;
+ myvec << "aaa" << "bbb" << "ccc";
+
+ // initial tests
+ QVERIFY(myvec.count(QLatin1String("aaa")) == 1);
+ QVERIFY(myvec.count(QLatin1String("pirates")) == 0);
+
+ // grow
+ myvec.append(QLatin1String("aaa"));
+ QVERIFY(myvec.count(QLatin1String("aaa")) == 2);
+
+ // shrink
+ myvec.remove(0);
+ QVERIFY(myvec.count(QLatin1String("aaa")) == 1);
+ }
+}
+
+void tst_QVector::data() const
+{
+ QVector<int> myvec;
+ myvec << 42 << 43 << 44;
+
+ // make sure it starts off ok
+ QCOMPARE(*(myvec.data() + 1), 43);
+
+ // alter it
+ *(myvec.data() + 1) = 69;
+
+ // check it altered
+ QCOMPARE(*(myvec.data() + 1), 69);
+
+ int arr[] = { 42, 69, 44 };
+ QVERIFY(memcmp(myvec.data(), reinterpret_cast<int *>(&arr), sizeof(int) * 3) == 0);
+}
+
+void tst_QVector::empty() const
+{
+ QVector<int> myvec;
+
+ // starts empty
+ QVERIFY(myvec.empty());
+
+ // not empty
+ myvec.append(1);
+ QVERIFY(!myvec.empty());
+
+ // empty again
+ myvec.remove(0);
+ QVERIFY(myvec.empty());
+}
+
+void tst_QVector::endsWith() const
+{
+ QVector<int> myvec;
+
+ // empty vector
+ QVERIFY(!myvec.endsWith(1));
+
+ // add the one, should work
+ myvec.append(1);
+ QVERIFY(myvec.endsWith(1));
+
+ // add something else, fails now
+ myvec.append(3);
+ QVERIFY(!myvec.endsWith(1));
+
+ // remove it again :)
+ myvec.remove(1);
+ QVERIFY(myvec.endsWith(1));
+}
+
+void tst_QVector::fill() const
+{
+ QVector<int> myvec;
+
+ // resize
+ myvec.resize(5);
+ myvec.fill(69);
+ QCOMPARE(myvec, QVector<int>() << 69 << 69 << 69 << 69 << 69);
+
+ // make sure it can resize itself too
+ myvec.fill(42, 10);
+ QCOMPARE(myvec, QVector<int>() << 42 << 42 << 42 << 42 << 42 << 42 << 42 << 42 << 42 << 42);
+}
+
+void tst_QVector::first() const
+{
+ QVector<int> myvec;
+ myvec << 69 << 42 << 3;
+
+ // test it starts ok
+ QCOMPARE(myvec.first(), 69);
+
+ // test removal changes
+ myvec.remove(0);
+ QCOMPARE(myvec.first(), 42);
+
+ // test prepend changes
+ myvec.prepend(23);
+ QCOMPARE(myvec.first(), 23);
+}
+
+void tst_QVector::fromList() const
+{
+ QList<QString> list;
+ list << "aaa" << "bbb" << "ninjas" << "pirates";
+
+ QVector<QString> myvec;
+ myvec = QVector<QString>::fromList(list);
+
+ // test it worked ok
+ QCOMPARE(myvec, QVector<QString>() << "aaa" << "bbb" << "ninjas" << "pirates");
+ QCOMPARE(list, QList<QString>() << "aaa" << "bbb" << "ninjas" << "pirates");
+}
+
+void tst_QVector::fromStdVector() const
+{
+ // stl = :(
+ std::vector<QString> svec;
+ svec.push_back(QLatin1String("aaa"));
+ svec.push_back(QLatin1String("bbb"));
+ svec.push_back(QLatin1String("ninjas"));
+ svec.push_back(QLatin1String("pirates"));
+ QVector<QString> myvec = QVector<QString>::fromStdVector(svec);
+
+ // test it converts ok
+ QCOMPARE(myvec, QVector<QString>() << "aaa" << "bbb" << "ninjas" << "pirates");
+}
+
+void tst_QVector::indexOf() const
+{
+ QVector<QString> myvec;
+ myvec << "A" << "B" << "C" << "B" << "A";
+
+ QVERIFY(myvec.indexOf("B") == 1);
+ QVERIFY(myvec.indexOf("B", 1) == 1);
+ QVERIFY(myvec.indexOf("B", 2) == 3);
+ QVERIFY(myvec.indexOf("X") == -1);
+ QVERIFY(myvec.indexOf("X", 2) == -1);
+
+ // add an X
+ myvec << "X";
+ QVERIFY(myvec.indexOf("X") == 5);
+ QVERIFY(myvec.indexOf("X", 5) == 5);
+ QVERIFY(myvec.indexOf("X", 6) == -1);
+
+ // remove first A
+ myvec.remove(0);
+ QVERIFY(myvec.indexOf("A") == 3);
+ QVERIFY(myvec.indexOf("A", 3) == 3);
+ QVERIFY(myvec.indexOf("A", 4) == -1);
+}
+
+void tst_QVector::insert() const
+{
+ QVector<QString> myvec;
+ myvec << "A" << "B" << "C";
+
+ // first position
+ QCOMPARE(myvec.at(0), QLatin1String("A"));
+ myvec.insert(0, QLatin1String("X"));
+ QCOMPARE(myvec.at(0), QLatin1String("X"));
+ QCOMPARE(myvec.at(1), QLatin1String("A"));
+
+ // middle
+ myvec.insert(1, QLatin1String("Z"));
+ QCOMPARE(myvec.at(0), QLatin1String("X"));
+ QCOMPARE(myvec.at(1), QLatin1String("Z"));
+ QCOMPARE(myvec.at(2), QLatin1String("A"));
+
+ // end
+ myvec.insert(5, QLatin1String("T"));
+ QCOMPARE(myvec.at(5), QLatin1String("T"));
+ QCOMPARE(myvec.at(4), QLatin1String("C"));
+
+ // insert a lot of garbage in the middle
+ myvec.insert(2, 2, QLatin1String("infinity"));
+ QCOMPARE(myvec, QVector<QString>() << "X" << "Z" << "infinity" << "infinity"
+ << "A" << "B" << "C" << "T");
+}
+
+void tst_QVector::isEmpty() const
+{
+ QVector<QString> myvec;
+
+ // starts ok
+ QVERIFY(myvec.isEmpty());
+
+ // not empty now
+ myvec.append(QLatin1String("hello there"));
+ QVERIFY(!myvec.isEmpty());
+
+ // empty again
+ myvec.remove(0);
+ QVERIFY(myvec.isEmpty());
+}
+
+void tst_QVector::last() const
+{
+ QVector<QString> myvec;
+ myvec << "A" << "B" << "C";
+
+ // test starts ok
+ QCOMPARE(myvec.last(), QLatin1String("C"));
+
+ // test it changes ok
+ myvec.append(QLatin1String("X"));
+ QCOMPARE(myvec.last(), QLatin1String("X"));
+
+ // and remove again
+ myvec.remove(3);
+ QCOMPARE(myvec.last(), QLatin1String("C"));
+}
+
+void tst_QVector::lastIndexOf() const
+{
+ QVector<QString> myvec;
+ myvec << "A" << "B" << "C" << "B" << "A";
+
+ QVERIFY(myvec.lastIndexOf("B") == 3);
+ QVERIFY(myvec.lastIndexOf("B", 2) == 1);
+ QVERIFY(myvec.lastIndexOf("X") == -1);
+ QVERIFY(myvec.lastIndexOf("X", 2) == -1);
+
+ // add an X
+ myvec << "X";
+ QVERIFY(myvec.lastIndexOf("X") == 5);
+ QVERIFY(myvec.lastIndexOf("X", 5) == 5);
+ QVERIFY(myvec.lastIndexOf("X", 3) == -1);
+
+ // remove first A
+ myvec.remove(0);
+ QVERIFY(myvec.lastIndexOf("A") == 3);
+ QVERIFY(myvec.lastIndexOf("A", 3) == 3);
+ QVERIFY(myvec.lastIndexOf("A", 2) == -1);
+}
+
+void tst_QVector::mid() const
+{
+ QVector<QString> list;
+ list << "foo" << "bar" << "baz" << "bak" << "buck" << "hello" << "kitty";
+
+ QCOMPARE(list.mid(3, 3), QVector<QString>() << "bak" << "buck" << "hello");
+ QCOMPARE(list.mid(4), QVector<QString>() << "buck" << "hello" << "kitty");
+}
+
+void tst_QVector::prepend() const
+{
+ QVector<QString> myvec;
+ myvec << "A" << "B" << "C";
+
+ // starts ok
+ QVERIFY(myvec.size() == 3);
+ QCOMPARE(myvec.at(0), QLatin1String("A"));
+
+ // add something
+ myvec.prepend(QLatin1String("X"));
+ QCOMPARE(myvec.at(0), QLatin1String("X"));
+ QCOMPARE(myvec.at(1), QLatin1String("A"));
+ QVERIFY(myvec.size() == 4);
+
+ // something else
+ myvec.prepend(QLatin1String("Z"));
+ QCOMPARE(myvec.at(0), QLatin1String("Z"));
+ QCOMPARE(myvec.at(1), QLatin1String("X"));
+ QCOMPARE(myvec.at(2), QLatin1String("A"));
+ QVERIFY(myvec.size() == 5);
+
+ // clear and append to an empty vector
+ myvec.clear();
+ QVERIFY(myvec.size() == 0);
+ myvec.prepend(QLatin1String("ninjas"));
+ QVERIFY(myvec.size() == 1);
+ QCOMPARE(myvec.at(0), QLatin1String("ninjas"));
+}
+
+void tst_QVector::remove() const
+{
+ QVector<QString> myvec;
+ myvec << "A" << "B" << "C";
+
+ // remove middle
+ myvec.remove(1);
+ QCOMPARE(myvec, QVector<QString>() << "A" << "C");
+
+ // remove rest
+ myvec.remove(0, 2);
+ QCOMPARE(myvec, QVector<QString>());
+}
+
+// ::reserve() is really hard to think of tests for, so not doing it.
+// ::resize() is tested in ::capacity().
+
+void tst_QVector::size() const
+{
+ // total size
+ {
+ // zero size
+ QVector<int> myvec;
+ QVERIFY(myvec.size() == 0);
+
+ // grow
+ myvec.append(42);
+ QVERIFY(myvec.size() == 1);
+ myvec.append(42);
+ QVERIFY(myvec.size() == 2);
+
+ // shrink
+ myvec.remove(0);
+ QVERIFY(myvec.size() == 1);
+ myvec.remove(0);
+ QVERIFY(myvec.size() == 0);
+ }
+}
+
+// ::squeeze() is tested in ::capacity().
+
+void tst_QVector::startsWith() const
+{
+ QVector<int> myvec;
+
+ // empty vector
+ QVERIFY(!myvec.startsWith(1));
+
+ // add the one, should work
+ myvec.prepend(1);
+ QVERIFY(myvec.startsWith(1));
+
+ // add something else, fails now
+ myvec.prepend(3);
+ QVERIFY(!myvec.startsWith(1));
+
+ // remove it again :)
+ myvec.remove(0);
+ QVERIFY(myvec.startsWith(1));
+}
+
+void tst_QVector::toList() const
+{
+ QVector<QString> myvec;
+ myvec << "A" << "B" << "C";
+
+ // make sure it converts and doesn't modify the original vector
+ QCOMPARE(myvec.toList(), QList<QString>() << "A" << "B" << "C");
+ QCOMPARE(myvec, QVector<QString>() << "A" << "B" << "C");
+}
+
+void tst_QVector::toStdVector() const
+{
+ QVector<QString> myvec;
+ myvec << "A" << "B" << "C";
+
+ std::vector<QString> svec = myvec.toStdVector();
+ QCOMPARE(svec.at(0), QLatin1String("A"));
+ QCOMPARE(svec.at(1), QLatin1String("B"));
+ QCOMPARE(svec.at(2), QLatin1String("C"));
+
+ QCOMPARE(myvec, QVector<QString>() << "A" << "B" << "C");
+}
+
+void tst_QVector::value() const
+{
+ QVector<QString> myvec;
+ myvec << "A" << "B" << "C";
+
+ // valid calls
+ QCOMPARE(myvec.value(0), QLatin1String("A"));
+ QCOMPARE(myvec.value(1), QLatin1String("B"));
+ QCOMPARE(myvec.value(2), QLatin1String("C"));
+
+ // default calls
+ QCOMPARE(myvec.value(-1), QString());
+ QCOMPARE(myvec.value(3), QString());
+
+ // test calls with a provided default, valid calls
+ QCOMPARE(myvec.value(0, QLatin1String("default")), QLatin1String("A"));
+ QCOMPARE(myvec.value(1, QLatin1String("default")), QLatin1String("B"));
+ QCOMPARE(myvec.value(2, QLatin1String("default")), QLatin1String("C"));
+
+ // test calls with a provided default that will return the default
+ QCOMPARE(myvec.value(-1, QLatin1String("default")), QLatin1String("default"));
+ QCOMPARE(myvec.value(3, QLatin1String("default")), QLatin1String("default"));
+}
+
+void tst_QVector::testOperators() const
+{
+ QVector<QString> myvec;
+ myvec << "A" << "B" << "C";
+ QVector<QString> myvectwo;
+ myvectwo << "D" << "E" << "F";
+ QVector<QString> combined;
+ combined << "A" << "B" << "C" << "D" << "E" << "F";
+
+ // !=
+ QVERIFY(myvec != myvectwo);
+
+ // +
+ QCOMPARE(myvec + myvectwo, combined);
+ QCOMPARE(myvec, QVector<QString>() << "A" << "B" << "C");
+ QCOMPARE(myvectwo, QVector<QString>() << "D" << "E" << "F");
+
+ // +=
+ myvec += myvectwo;
+ QCOMPARE(myvec, combined);
+
+ // ==
+ QVERIFY(myvec == combined);
+
+ // []
+ QCOMPARE(myvec[0], QLatin1String("A"));
+ QCOMPARE(myvec[1], QLatin1String("B"));
+ QCOMPARE(myvec[2], QLatin1String("C"));
+ QCOMPARE(myvec[3], QLatin1String("D"));
+ QCOMPARE(myvec[4], QLatin1String("E"));
+ QCOMPARE(myvec[5], QLatin1String("F"));
+}
+
+
int fooCtor;
int fooDtor;
diff --git a/tests/benchmarks/corelib/kernel/events/events.pro b/tests/benchmarks/corelib/kernel/events/events.pro
index 43a7131..d7d770a 100644
--- a/tests/benchmarks/corelib/kernel/events/events.pro
+++ b/tests/benchmarks/corelib/kernel/events/events.pro
@@ -5,3 +5,4 @@ DEPENDPATH += .
INCLUDEPATH += .
# Input
SOURCES += main.cpp
+QT -= gui
diff --git a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro
index 9c6b16b..5ecb94c 100644
--- a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro
+++ b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro
@@ -9,3 +9,4 @@ CONFIG += release
SOURCES += tst_qtimer_vs_qmetaobject.cpp
+QT -= gui
diff --git a/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro b/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro
index 654b7b6..e8014d6 100644
--- a/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro
+++ b/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro
@@ -3,4 +3,4 @@ TEMPLATE = app
TARGET = tst_bench_qthreadstorage
SOURCES += tst_qthreadstorage.cpp
-
+QT -= gui
diff --git a/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro b/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro
index 3e3bf2b..0dcee4f 100644
--- a/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro
+++ b/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro
@@ -6,3 +6,4 @@ INCLUDEPATH += .
# Input
SOURCES += main.cpp
+QT -= gui
diff --git a/tests/benchmarks/corelib/tools/containers-associative/main.cpp b/tests/benchmarks/corelib/tools/containers-associative/main.cpp
index 4c6dae4..afb1ea5 100644
--- a/tests/benchmarks/corelib/tools/containers-associative/main.cpp
+++ b/tests/benchmarks/corelib/tools/containers-associative/main.cpp
@@ -38,7 +38,6 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <QtGui>
#include <QString>
#include <qtest.h>
diff --git a/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro b/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro
index 4236b35..656510e 100644
--- a/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro
+++ b/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro
@@ -6,3 +6,4 @@ INCLUDEPATH += .
# Input
SOURCES += main.cpp
+QT -= gui