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'
56
description: 'unionFilter test'
66
name: "Organizer union filter test"
67
function test_unionFilter_data() {
70
code: "import QtOrganizer 5.0;"
78
function test_unionFilter(data) {
79
var list = utility.getManagerList();
80
if (list.length < 0) {
81
console.log("No manager to test");
84
//Test all manager backends
85
for (var i = 0; i < list.length; i ++) {
86
var managerName = list[i];
88
console.log("test_unionFilter test start! :" + managerName);
89
var model = Qt.createQmlObject(
90
"import QtOrganizer 5.0;"
92
+ " manager: \"qtorganizer:" + managerName + ":id=qml\";"
93
+ " startPeriod:'2009-01-01';"
94
+ " endPeriod:'2012-12-31';"
95
+ " autoUpdate:true; }"
98
var unionFilter = Qt.createQmlObject(data.code, test);
100
var event = Qt.createQmlObject(
101
"import QtOrganizer 5.0;"
104
+ " displayLabel: \"organizer union filter test event\"; "
105
+ " description: \"organizer union filter test event\"; "
106
+ " startDateTime: '2010-12-12'; "
107
+ " endDateTime: '2010-12-13'; }"
111
utility.waitModelChange();
112
utility.empty_calendar();
113
//------prepare filter data: save event and collection------//
114
var collectionLegnth = model.collections.length
116
model.saveCollection(testCollection)
117
//Let's wait for the model to be up-to-date
118
utility.waitModelChange(collectionLegnth + 1, utility.collectionChange);
120
//we should have more than default collection now
121
var savedCollection = model.collections[model.collections.length - 1];
122
model.saveItem(event);
123
utility.waitModelChange(1);
124
compare(model.itemCount, 1)
126
//event with new collection id
127
event.collectionId = savedCollection.collectionId;
128
model.saveItem(event);
129
utility.waitModelChange(2);
130
compare(model.itemCount, 2)
132
var fetchlist = model.items;
134
var collectionEventId;
135
if (fetchlist[1].collectionId == savedCollection.collectionId) {
136
idEventId = fetchlist[0].itemId;
137
collectionEventId = fetchlist[1].itemId;
138
} else if (fetchlist[0].collectionId == savedCollection.collectionId) {
139
idEventId = fetchlist[1].itemId;
140
collectionEventId = fetchlist[0].itemId;
142
console.log("Something Wrong!");
145
utility.debug("Single filter", debugFlag);
146
idFilter.ids = [idEventId];
148
unionFilter.filters = [idFilter];
149
model.filter = unionFilter;
150
utility.waitModelChange(1);
152
compare(model.itemCount, 1)
153
//Change collection filter id
154
collectionFilter.ids = [savedCollection.collectionId];
156
model.filter.filters = [idFilter, collectionFilter]
157
utility.debug("Duoble filter", debugFlag);
158
utility.waitModelChange(2);
159
compare(model.itemCount, 2)
162
//Change collection filter id
163
collectionFilter.ids = [savedCollection.collectionId, model.defaultCollection().collectionId];
164
model.filter.filters = [idFilter, collectionFilter]
165
utility.debug("Duoble filter 2", debugFlag);
166
utility.waitModelChange(2);
167
compare(model.itemCount, 2)
170
//Change collection filter id
171
collectionFilter.ids = [savedCollection.collectionId, model.defaultCollection().collectionId];
172
idFilter.ids = [idEventId, collectionEventId];
173
utility.debug("Duoble filter ~3", debugFlag);
174
model.filter.filters = [idFilter, collectionFilter]
175
utility.debug("Duoble filter 3" + collectionFilter.ids, debugFlag);
176
utility.waitModelChange(2);
177
compare(model.itemCount, 2)
178
utility.debug("Test over!", debugFlag);
180
utility.empty_calendar();