|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Main test class for hspluginmodel library. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "t_caclientnotifier.h" |
|
19 #include "caentry.h" |
|
20 #include "canotifier.h" |
|
21 #include "canotifierfilter.h" |
|
22 #include "caservice.h" |
|
23 |
|
24 // --------------------------------------------------------------------------- |
|
25 // |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 TestCaClientNotifier::TestCaClientNotifier(): |
|
29 mEntryId(0), |
|
30 mGroupId(0), |
|
31 mChangeType(AddChangeType), |
|
32 mEntry(NULL), |
|
33 mCount(0), |
|
34 mEntryIds(new QList<int>()), |
|
35 mGroupIds(new QList<int>()), |
|
36 mChangeTypes(new QList<ChangeType>()), |
|
37 mEntries(new QList<const CaEntry *>()), |
|
38 mFilter(NULL), |
|
39 mNotifier(NULL) |
|
40 { |
|
41 |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 TestCaClientNotifier::TestCaClientNotifier(const CaService &service, CaNotifierFilter *filter): |
|
49 mEntryId(0), |
|
50 mGroupId(0), |
|
51 mChangeType(AddChangeType), |
|
52 mEntry(NULL), |
|
53 mCount(0), |
|
54 mEntryIds(new QList<int>()), |
|
55 mGroupIds(new QList<int>()), |
|
56 mChangeTypes(new QList<ChangeType>()), |
|
57 mEntries(new QList<const CaEntry *>()) |
|
58 { |
|
59 if (!filter) { |
|
60 mFilter = new CaNotifierFilter(); |
|
61 mNotifier = service.createNotifier(*mFilter); |
|
62 } else { |
|
63 mFilter = NULL; |
|
64 mNotifier = service.createNotifier(*filter); |
|
65 } |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 void TestCaClientNotifier::clean() |
|
73 { |
|
74 mEntryId = 0; |
|
75 mGroupId = 0; |
|
76 mChangeType = AddChangeType; |
|
77 mCount = 0; |
|
78 delete mEntryIds; |
|
79 mEntryIds = new QList<int>(); |
|
80 delete mGroupIds; |
|
81 mGroupIds = new QList<int>(); |
|
82 delete mChangeTypes; |
|
83 mChangeTypes = new QList<ChangeType>(); |
|
84 delete mEntries; |
|
85 mEntries = new QList<const CaEntry *>(); |
|
86 delete mEntry; |
|
87 mEntry = NULL; |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 TestCaClientNotifier::~TestCaClientNotifier() |
|
95 { |
|
96 delete mEntry; |
|
97 delete mFilter; |
|
98 delete mNotifier; |
|
99 delete mEntryIds; |
|
100 delete mGroupIds; |
|
101 delete mChangeTypes; |
|
102 delete mEntries; |
|
103 |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 CaNotifier *TestCaClientNotifier::getNotifier() const |
|
111 { |
|
112 return mNotifier; |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 CaNotifierFilter *TestCaClientNotifier::getFilter() const |
|
120 { |
|
121 return mFilter; |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 void TestCaClientNotifier::entryChanged(int entryId, ChangeType changeType) |
|
129 { |
|
130 mEntryId = entryId; |
|
131 mChangeType = changeType; |
|
132 mEntryIds->append(entryId); |
|
133 mChangeTypes->append(changeType); |
|
134 mEntries->append(NULL); |
|
135 mGroupIds->append(0); |
|
136 mCount++; |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void TestCaClientNotifier::entryChanged(const CaEntry &entry, ChangeType changeType) |
|
144 { |
|
145 delete mEntry; |
|
146 mEntry = new CaEntry(entry); |
|
147 mEntryId = entry.id(); |
|
148 mChangeType = changeType; |
|
149 mEntryIds->append(entry.id()); |
|
150 mChangeTypes->append(changeType); |
|
151 mEntries->append(&entry); |
|
152 mGroupIds->append(0); |
|
153 mCount++; |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 void TestCaClientNotifier::entryTouched(int id) |
|
161 { |
|
162 mEntryId = id; |
|
163 mEntryIds->append(id); |
|
164 mChangeTypes->append(AddChangeType); |
|
165 mEntries->append(NULL); |
|
166 mGroupIds->append(0); |
|
167 mCount++; |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void TestCaClientNotifier::groupContentChanged(int groupId) |
|
175 { |
|
176 mGroupId = groupId; |
|
177 mEntryIds->append(0); |
|
178 mChangeTypes->append(AddChangeType); |
|
179 mEntries->append(NULL); |
|
180 mGroupIds->append(groupId); |
|
181 mCount++; |
|
182 } |