From 153a57ce80cf278b6dcc52477d5f3e51c399cf2f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 8 Apr 2015 18:05:20 +0200 Subject: [PATCH] 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 --- .../timelinemodel/tst_timelinemodel.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/auto/timeline/timelinemodel/tst_timelinemodel.cpp b/tests/auto/timeline/timelinemodel/tst_timelinemodel.cpp index c253503d9a6..7080d11bbaa 100644 --- a/tests/auto/timeline/timelinemodel/tst_timelinemodel.cpp +++ b/tests/auto/timeline/timelinemodel/tst_timelinemodel.cpp @@ -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"