Timeline: Test parenting of equal start times

If you insert events with equal start times in a way that the model can
not reorder them by their end times the parenting follows the indexes,
not the end times. This has caused confusion multiple times and it's
good to test it.

Change-Id: I3e9ba212ff377dc2afa2a2893637bb55edebafea
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2015-04-08 18:05:20 +02:00
parent e112647397
commit 153a57ce80

View File

@@ -88,6 +88,7 @@ private slots:
void insertStartEnd();
void rowCount();
void prevNext();
void parentingOfEqualStarts();
};
DummyModel::DummyModel(int modelId) :
@@ -443,6 +444,22 @@ void tst_TimelineModel::prevNext()
QCOMPARE(dummy.prevItemByTypeId(-1, 10, 5), 4);
}
void tst_TimelineModel::parentingOfEqualStarts()
{
DummyModel dummy;
// Trick it so that it cannot reorder the events and has to parent them in the "wrong" way ...
QCOMPARE(dummy.insert(1, 10, 998), 0);
QCOMPARE(dummy.insertStart(1, 999), 1);
dummy.insertEnd(1, 20);
dummy.computeNesting();
// .. which is reflected in the resulting order.
QCOMPARE(dummy.selectionId(0), 998);
QCOMPARE(dummy.selectionId(1), 999);
QCOMPARE(dummy.firstIndex(10), 0);
QCOMPARE(dummy.lastIndex(2), 1);
}
QTEST_MAIN(tst_TimelineModel)
#include "tst_timelinemodel.moc"