1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the test suite of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
44
import QtOrganizer 5.0
49
QOrganizerTestUtility {
55
name: 'My collection filter test'
56
description: 'collection filter test'
60
name: "Organizer collection filter test"
62
function test_collectionFilter_data() {
65
code: "import QtOrganizer 5.0;CollectionFilter{}"
70
function test_collectionFilter(data) {
72
var list = utility.getManagerList();
73
if (list.length < 0) {
74
console.log("No manager to test");
77
//Test all manager backends
78
for (var i = 0; i < list.length; i ++) {
79
var managerName = list[i];
81
console.log("test_collectionFilter test start! :" + managerName);
82
var model = Qt.createQmlObject(
83
"import QtOrganizer 5.0;"
85
+ " manager: \"qtorganizer:" + managerName + ":id=qml\";"
86
+ " startPeriod:'2009-01-01';"
87
+ " endPeriod:'2012-12-31';"
88
+ " autoUpdate:true; }"
91
utility.waitModelChange();
92
utility.empty_calendar();
94
var collectionFilter = Qt.createQmlObject(data.code, test);
96
var event = Qt.createQmlObject(
97
"import QtOrganizer 5.0;"
99
+ " displayLabel: \"organizer collection filter test event\"; "
100
+ " description: \"organizer collection filter test event\"; "
101
+ " startDateTime: '2010-12-12'; "
102
+ " endDateTime: '2010-12-13'; }"
105
//------Create and save the detail test------//
106
var collectionLength = model.collections.length;
107
model.saveCollection(testCollection)
109
//Let's wait for the model to be up-to-date
110
utility.waitModelChange(collectionLength + 1, utility.collectionChange);
112
//we should have more than default collection now
113
utility.debug("New collection length :" + model.collections.length, debugFlag);
114
var savedCollection = model.collections[model.collections.length - 1];
115
utility.debug("New collection id :" + savedCollection.collectionId, debugFlag);
116
event.collectionId = savedCollection.collectionId;
117
model.saveItem(event);
118
utility.waitModelChange(1, utility.itemChange);
120
var fetchlist = model.items;
121
compare(model.itemCount, 1)
122
var savedEvent = fetchlist[0];
123
utility.debug("New event collection id :" + savedEvent.collectionId, debugFlag);
124
compare(savedEvent.collectionId, event.collectionId);
126
//Change collection filter id
127
collectionFilter.ids = [event.collectionId];
128
model.filter = collectionFilter;
129
utility.waitModelChange(1);
130
compare(model.itemCount, 1)
133
utility.debug("default collection id :" + model.defaultCollection().collectionId, debugFlag);
134
var modelCollectionFilter = model.filter;
135
modelCollectionFilter.ids = [model.defaultCollection().collectionId];
136
utility.waitModelChange(0);
138
compare(model.itemCount, 0)
139
//save event to default collection
140
event.collectionId = model.defaultCollection().collectionId;
141
model.saveItem(event);
142
utility.waitModelChange(1);
145
modelCollectionFilter.ids = [];
146
utility.waitModelChange(0);
147
compare(model.itemCount, 0)
149
//remove collection filter or set empty filter
151
utility.waitModelChange(2);
152
compare(model.itemCount, 2);
155
collectionFilter = Qt.createQmlObject(data.code, test);
156
collectionFilter.ids = [event.collectionId];
157
model.filter = collectionFilter;
158
utility.waitModelChange(1);
159
compare(model.itemCount, 1);
161
//set more collection ids
162
modelCollectionFilter = model.filter
163
modelCollectionFilter.ids = [model.defaultCollection().collectionId, savedCollection.collectionId];
164
utility.waitModelChange(2);
165
compare(model.itemCount, 2);
167
//One invalid collection id
168
modelCollectionFilter.ids = [model.defaultCollection().collectionId, "12345666666",savedCollection.collectionId];
169
utility.waitModelChange(2);
170
compare(model.itemCount, 2);
172
utility.empty_calendar();