diff options
author | Chris Adams <chris.adams@jollamobile.com> | 2016-04-20 13:10:11 +1000 |
---|---|---|
committer | Christopher Adams <chris.adams@jollamobile.com> | 2016-06-15 07:37:19 +0000 |
commit | 15f85780ba1bbce6c4f8bb4e3198298185d0b294 (patch) | |
tree | b9aa5edbee85ba30f81d90981c66d00ec2b1507a /tests | |
parent | 1df28e5c81923272123fd8ddccb8a2cd28d199b3 (diff) |
Fix crashing unit test for QDeclarativeOrganizerModel
This commit works around potential bug QTBUG-41485 by ensuring that
the view is temporarily disconnected from the array model while the
array model contents is modified, then re-connected to the view.
It also ensures that the test no longer attempts to reuse event
instances once saved into a particular collection, as some manager
backends (e.g., memory) don't allow events to exist in more than
one collection.
Change-Id: Ie0584a0cc4ee37a72a21339315510fc9fbab6286
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Reviewed-by: Renato Araujo Oliveira Filho <renato.filho@canonical.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/organizer/qmlorganizer/testcases/tst_organizermodel.qml | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/tests/auto/organizer/qmlorganizer/testcases/tst_organizermodel.qml b/tests/auto/organizer/qmlorganizer/testcases/tst_organizermodel.qml index fb9471f06..a115a8715 100644 --- a/tests/auto/organizer/qmlorganizer/testcases/tst_organizermodel.qml +++ b/tests/auto/organizer/qmlorganizer/testcases/tst_organizermodel.qml @@ -1118,19 +1118,6 @@ TestCase { var model = utility.createModel(data.managerToBeTested); - var event1 = utility.create_testobject( - "import QtOrganizer 5.0\n" - + "Event {\n" - + " startDateTime: new Date(2011, 12, 7, 11)\n" - + " endDateTime: new Date(2011, 12, 8, 0, 30)\n" - + "}\n", modelTests); - - var collection1 = utility.create_testobject("import QtQuick 2.0 \n" - + "import QtOrganizer 5.0\n" - + "Collection {\n" - + "id: coll1\n" - + "}\n", modelTests); - var view = utility.create_testobject( "import QtQuick 2.0\n" + "ListView {\n" @@ -1138,6 +1125,9 @@ TestCase { + " delegate: Text{ text: name }\n" + "}\n", modelTests); + var collections = [] + var events = [] + var modelChangedSpy = utility.create_testobject("import QtTest 1.0; SignalSpy{}", modelTests) modelChangedSpy.target = model modelChangedSpy.signalName = "modelChanged" @@ -1152,9 +1142,22 @@ TestCase { // add collections var ncoll = 10; for (var i=1; i<=ncoll; ++i) { + var collection1 = utility.create_testobject("import QtQuick 2.0 \n" + + "import QtOrganizer 5.0\n" + + "Collection {\n" + + "id: coll1\n" + + "}\n", modelTests); + collections[i] = collection1 collection1.name = 'collection ' + i model.saveCollection(collection1); collectionsChangedSpy.wait(signalWaitTime); + var event1 = utility.create_testobject( + "import QtOrganizer 5.0\n" + + "Event {\n" + + " startDateTime: new Date(2011, 12, 7, 11)\n" + + " endDateTime: new Date(2011, 12, 8, 0, 30)\n" + + "}\n", modelTests); + events[i] = event1 event1.collectionId = model.collections[i].collectionId; model.saveItem(event1); modelChangedSpy.wait(signalWaitTime); @@ -1166,6 +1169,7 @@ TestCase { verify(view.contentHeight > 0, 'view content is empty'); compare(view.count, ncoll+1); + view.model = [] // avoid QTBUG-41485 model.removeCollection(model.collections[ncoll].collectionId); collectionsChangedSpy.wait(signalWaitTime); view.model = model.collections; @@ -1174,8 +1178,6 @@ TestCase { compare(view.count, ncoll); view.destroy() - collection1.destroy() - event1.destroy() model.destroy(); } |