~chris.gagnon/+junk/qtpim-coverage

« back to all changes in this revision

Viewing changes to tests/auto/organizer/qmlorganizer/testcases/tst_organizervisualreminder.qml

  • Committer: chris.gagnon
  • Date: 2013-12-10 23:09:37 UTC
  • Revision ID: chris.gagnon@canonical.com-20131210230937-2akf1ft1edcttk87
first post

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
 
4
** Contact: http://www.qt-project.org/legal
 
5
**
 
6
** This file is part of the test suite of the Qt Toolkit.
 
7
**
 
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.
 
16
**
 
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.
 
24
**
 
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.
 
28
**
 
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.
 
36
**
 
37
**
 
38
** $QT_END_LICENSE$
 
39
**
 
40
****************************************************************************/
 
41
 
 
42
import QtQuick 2.0
 
43
import QtTest 1.0
 
44
import QtOrganizer 5.0
 
45
 
 
46
Rectangle {
 
47
    id: test;
 
48
 
 
49
    QOrganizerTestUtility {
 
50
        id: utility
 
51
    }
 
52
 
 
53
    TestCase {
 
54
        name: "VisualReminder"
 
55
        function test_visualReminder_data() {
 
56
            return [
 
57
                   { tag: " no properties",
 
58
                     code: "import QtOrganizer 5.0;"
 
59
                        + "VisualReminder {"
 
60
                        + "}"
 
61
                    },
 
62
                    { tag: " 1 properties",
 
63
                      code: "import QtOrganizer 5.0;"
 
64
                        + "VisualReminder {"
 
65
                        + "    repetitionCount: 3; }"
 
66
                    },
 
67
                    { tag: " 2 properties",
 
68
                      code: "import QtOrganizer 5.0;"
 
69
                        + "VisualReminder {"
 
70
                        + "    repetitionCount: 3; "
 
71
                        + "    repetitionDelay: 30;}"
 
72
                    },
 
73
                    { tag: " 3 properties",
 
74
                      code: "import QtOrganizer 5.0;"
 
75
                        + "VisualReminder {"
 
76
                        + "    repetitionCount: 0; "
 
77
                        + "    secondsBeforeStart: 100;}"
 
78
                    },
 
79
                    { tag: " 4 properties",
 
80
                      code: "import QtOrganizer 5.0;"
 
81
                         + "VisualReminder {"
 
82
                         + "    repetitionCount: 3; "
 
83
                         + "    repetitionDelay: 30; "
 
84
                         + "    secondsBeforeStart: 40; "
 
85
                         + "    dataUrl: \"www.nokia.com\"  }"
 
86
                    },
 
87
                    { tag: " 5 properties",
 
88
                      code: "import QtOrganizer 5.0;"
 
89
                         + "VisualReminder {"
 
90
                         + "    repetitionCount: 3; "
 
91
                         + "    repetitionDelay: 30; "
 
92
                         + "    secondsBeforeStart: 40; "
 
93
                         + "    message: \"visual reminder Message\"; "
 
94
                         + "    dataUrl: \"www.nokia.com\"  }"
 
95
                    },
 
96
            ]
 
97
        }
 
98
 
 
99
        function test_visualReminder(data) {
 
100
 
 
101
            var list = utility.getManagerList();
 
102
            if (list.length < 0) {
 
103
                console.log("No manager to test");
 
104
                return;
 
105
            }
 
106
            //Test all manager backends
 
107
            for (var i = 0; i < list.length; i ++) {
 
108
                var managerName = list[i];
 
109
                if (managerName == "jsondb")//jsondb backend does not support visual reminder
 
110
                    return;
 
111
                console.log("VisualReminder test start! :" + managerName);
 
112
                var model = Qt.createQmlObject(
 
113
                      "import QtOrganizer 5.0;"
 
114
                    + "OrganizerModel {"
 
115
                    + "   manager: \"qtorganizer:" + managerName + ":id=qml\";"
 
116
                    + "   startPeriod:'2009-01-01';"
 
117
                    + "   endPeriod:'2012-12-31';"
 
118
                    + "   autoUpdate:true; }"
 
119
                    , test);
 
120
 
 
121
                var visualReminderEvent = Qt.createQmlObject(
 
122
                          "import QtOrganizer 5.0;"
 
123
                        + "Event { "
 
124
                        + "   id:event;"
 
125
                        + "   displayLabel: \"organizer qml reminder test event\"; "
 
126
                        + "   description: \"This is a new reminder event!!!\"; "
 
127
                        + "   startDateTime: '2010-12-12'; "
 
128
                        + "   endDateTime: '2010-12-13'; }"
 
129
                        , test);
 
130
 
 
131
                var visualReminderDetail = Qt.createQmlObject(data.code , visualReminderEvent);
 
132
                utility.init(model);
 
133
                utility.empty_calendar();
 
134
                //------Create and save the detail test------//
 
135
                utility.debug("Create and save the detail test", debugFlag);
 
136
                visualReminderDetail.dataUrl = "http://www.test0.com";
 
137
                visualReminderEvent.addDetail(visualReminderDetail);
 
138
                if (managerName == "jsondb") {
 
139
                    // custom fields allowed in JsonDb for audible reminder
 
140
                    // simple test here, since already fully tested in C++
 
141
                    var extendedDetail = Qt.createQmlObject(
 
142
                        "import QtOrganizer 5.0;"
 
143
                        + "ExtendedDetail {"
 
144
                        + "  name: \"reminder\";"
 
145
                        + "  data: \{"
 
146
                        + "    Qt: \"Everywhere\";"
 
147
                        + "    Url: \"http://www.qt-project.org/\";"
 
148
                        + "  }"
 
149
                        + "}"
 
150
                        , test);
 
151
                    visualReminderEvent.addDetail(extendedDetail);
 
152
                }
 
153
                model.saveItem(event);
 
154
                //Let's wait for the model to be up-to-date
 
155
                utility.waitModelChange(1);
 
156
                compare(model.itemCount, 1)
 
157
                var fetchVisuallist = model.items;
 
158
                var savedVisualEvent = fetchVisuallist[0];
 
159
                verify(savedVisualEvent != undefined);
 
160
                verify(savedVisualEvent.detail(Detail.VisualReminder) != undefined);
 
161
                utility.compareReminderDetails(visualReminderDetail, savedVisualEvent.detail(Detail.VisualReminder));
 
162
 
 
163
                //------update the details test------//
 
164
                var savedEventDetail = savedVisualEvent.detail(Detail.VisualReminder);
 
165
                savedEventDetail.dataUrl = "http://www.test222.com";
 
166
                savedEventDetail.message = "visual reminder message";
 
167
                savedEventDetail.secondsBeforeStart = 300;
 
168
                savedEventDetail.repetitionCount = 0;
 
169
 
 
170
                visualReminderDetail.dataUrl = "http://www.test222.com";
 
171
                visualReminderDetail.message = "visual reminder message";
 
172
                visualReminderDetail.secondsBeforeStart = 300;
 
173
                visualReminderDetail.repetitionCount = 0;
 
174
 
 
175
                savedVisualEvent.setDetail(savedEventDetail);
 
176
 
 
177
                model.saveItem(savedVisualEvent);
 
178
                utility.organizerChangedSpy.wait();
 
179
                //no new event created
 
180
                compare(model.itemCount, 1)
 
181
                fetchVisuallist = model.items;
 
182
                var updatedEvent = fetchVisuallist[0];
 
183
                verify(updatedEvent != undefined);
 
184
                verify(updatedEvent.detail(Detail.VisualReminder) != undefined);
 
185
                var updatedEventDetail = updatedEvent.detail(Detail.VisualReminder);
 
186
                utility.compareReminderDetails(savedEventDetail, updatedEventDetail);
 
187
                utility.compareReminderDetails(visualReminderDetail, updatedEventDetail);
 
188
 
 
189
                //------remove the details test------//
 
190
                var removeEventDetail = updatedEvent.detail(Detail.VisualReminder);
 
191
                updatedEvent.removeDetail(removeEventDetail);
 
192
                model.saveItem(updatedEvent);
 
193
                utility.organizerChangedSpy.wait();
 
194
                //no new event created
 
195
                compare(model.itemCount, 1)
 
196
                fetchVisuallist = model.items;
 
197
                var detailRemovedEvent = fetchVisuallist[0];
 
198
                var detailRemovedEventDetailList = detailRemovedEvent.details(Detail.VisualReminder);
 
199
                if (detailRemovedEventDetailList.length > 0) {
 
200
                    var detailRemovedEventDetail = detailRemovedEvent.detail(Detail.VisualReminder);
 
201
                    utility.outputEvent(detailRemovedEvent)
 
202
                }
 
203
                verify(detailRemovedEventDetailList.length == 0);
 
204
                verify(removeEventDetail != undefined)
 
205
                utility.organizerChangedSpy.clear();
 
206
                utility.organizerChangedSpy.destroy();
 
207
                model.destroy();
 
208
                visualReminderEvent.destroy();
 
209
                visualReminderDetail.destroy();
 
210
    //            utility.empty_calendar();
 
211
            }
 
212
        }
 
213
    }
 
214
}