Merge lp:~super-friends/qml-friends/raring into lp:qml-friends
- raring
- Merge into trunk
Proposed by
Ken VanDine
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ken VanDine | ||||
Approved revision: | 38 | ||||
Merged at revision: | 34 | ||||
Proposed branch: | lp:~super-friends/qml-friends/raring | ||||
Merge into: | lp:qml-friends | ||||
Diff against target: |
1000 lines (+538/-149) 19 files modified
debian/changelog (+15/-0) debian/control (+7/-0) examples/README (+95/-0) examples/streamview.qml (+0/-121) friends.pro (+3/-0) modules/Friends/plugin/friendsdispatcher.cpp (+8/-0) modules/Friends/plugin/friendsdispatcher.h (+2/-0) modules/Friends/plugin/friendsutils.cpp (+0/-2) modules/Friends/plugin/friendsutils.h (+1/-6) modules/Friends/plugin/plugin.cpp (+9/-11) modules/Friends/plugin/plugin.h (+2/-3) modules/Friends/plugin/plugin.pro (+8/-6) modules/Friends/plugin/streammodel.cpp (+176/-0) modules/Friends/plugin/streammodel.h (+46/-0) tests/tests.pro (+4/-0) tests/unit/main.cpp (+2/-0) tests/unit/run.sh (+7/-0) tests/unit/tst_test.qml (+140/-0) tests/unit/unit.pro (+13/-0) |
||||
To merge this branch: | bzr merge lp:~super-friends/qml-friends/raring | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Ken VanDine | Approve | ||
Review via email: mp+154367@code.launchpad.net |
Commit message
* Added StreamModel
- Filters available for stream, service, and account (LP: #1156941)
* Added Refresh
* Added tests
* Updated for the schema changes in friends
* debian/control
- build depend on libdee-qt5-dev
- Added build depends for running tests: dbus-test-runner, xvfb,
qtdeclara
- build depend on friends-dispatcher (>= 0.1.2daily13.03.14)
Description of the change
Merged queued changes for raring now that the FFe is approved
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) : | # |
review:
Approve
(continuous-integration)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/changelog' | |||
2 | --- debian/changelog 2013-03-07 16:38:08 +0000 | |||
3 | +++ debian/changelog 2013-03-20 13:31:31 +0000 | |||
4 | @@ -1,3 +1,18 @@ | |||
5 | 1 | qml-friends (0.1.1-0ubuntu1) UNRELEASED; urgency=low | ||
6 | 2 | |||
7 | 3 | * Added StreamModel | ||
8 | 4 | - Filters available for stream, service, and account (LP: #1156941) | ||
9 | 5 | * Added Refresh | ||
10 | 6 | * Added tests | ||
11 | 7 | * Updated for the schema changes in friends | ||
12 | 8 | * debian/control | ||
13 | 9 | - build depend on libdee-qt5-dev | ||
14 | 10 | - Added build depends for running tests: dbus-test-runner, xvfb, | ||
15 | 11 | qtdeclarative5-qtquick2-plugin, and qtdeclarative5-test-plugin | ||
16 | 12 | - build depend on friends-dispatcher (>= 0.1.2daily13.03.14) | ||
17 | 13 | |||
18 | 14 | -- Ken VanDine <ken.vandine@canonical.com> Mon, 18 Mar 2013 22:49:02 -0400 | ||
19 | 15 | |||
20 | 1 | qml-friends (0.1.0bzr13.03.07-0ubuntu1) raring; urgency=low | 16 | qml-friends (0.1.0bzr13.03.07-0ubuntu1) raring; urgency=low |
21 | 2 | 17 | ||
22 | 3 | * Use the correct callback for likeAsync | 18 | * Use the correct callback for likeAsync |
23 | 4 | 19 | ||
24 | === modified file 'debian/control' | |||
25 | --- debian/control 2013-03-05 18:52:53 +0000 | |||
26 | +++ debian/control 2013-03-20 13:31:31 +0000 | |||
27 | @@ -11,7 +11,14 @@ | |||
28 | 11 | qt5-qmake, | 11 | qt5-qmake, |
29 | 12 | qtbase5-dev, | 12 | qtbase5-dev, |
30 | 13 | qtdeclarative5-dev, | 13 | qtdeclarative5-dev, |
31 | 14 | qtdeclarative5-test-plugin, | ||
32 | 15 | libdee-qt5-dev, | ||
33 | 16 | friends-dispatcher (>= 0.1.2daily13.03.14), | ||
34 | 14 | libfriends-dev (>= 0.1.1bzr13.02.07-0ubuntu1), | 17 | libfriends-dev (>= 0.1.1bzr13.02.07-0ubuntu1), |
35 | 18 | dbus-test-runner, | ||
36 | 19 | xvfb, | ||
37 | 20 | qtdeclarative5-qtquick2-plugin, | ||
38 | 21 | qtdeclarative5-test-plugin, | ||
39 | 15 | Standards-Version: 3.9.3 | 22 | Standards-Version: 3.9.3 |
40 | 16 | Section: libs | 23 | Section: libs |
41 | 17 | Homepage: https://launchpad.net/qml-friends | 24 | Homepage: https://launchpad.net/qml-friends |
42 | 18 | 25 | ||
43 | === added file 'examples/README' | |||
44 | --- examples/README 1970-01-01 00:00:00 +0000 | |||
45 | +++ examples/README 2013-03-20 13:31:31 +0000 | |||
46 | @@ -0,0 +1,95 @@ | |||
47 | 1 | Code examples for qml-friends | ||
48 | 2 | |||
49 | 3 | All the dependencies can be installed from ppa:super-friends/ppa | ||
50 | 4 | |||
51 | 5 | Installing the qtdeclarative5-friends-plugin package should bring in the necessary dependencies | ||
52 | 6 | |||
53 | 7 | /* Sending | ||
54 | 8 | http://bazaar.launchpad.net/~super-friends/qml-friends/raring/view/head:/examples/poster.qml */ | ||
55 | 9 | |||
56 | 10 | import Friends 0.1 | ||
57 | 11 | |||
58 | 12 | FriendsDispatcher { | ||
59 | 13 | id: friends | ||
60 | 14 | // use this to check if the send was successfull | ||
61 | 15 | onSendComplete: { | ||
62 | 16 | if (success) { | ||
63 | 17 | console.log ("Send completed successfully"); | ||
64 | 18 | } else { | ||
65 | 19 | console.log ("Send failed: " + errorMessage); | ||
66 | 20 | } | ||
67 | 21 | } | ||
68 | 22 | } | ||
69 | 23 | |||
70 | 24 | Button { | ||
71 | 25 | id: sendButton | ||
72 | 26 | text: i18n.tr("Send") | ||
73 | 27 | onClicked: { | ||
74 | 28 | /* async method to send, connect to onSendComplete for success/failure */ | ||
75 | 29 | friends.sendAsync(entry.text); | ||
76 | 30 | } | ||
77 | 31 | } | ||
78 | 32 | |||
79 | 33 | Getting a model of the data from Friends | ||
80 | 34 | http://bazaar.launchpad.net/~super-friends/qml-friends/raring/view/head:/examples/streamview.qml | ||
81 | 35 | |||
82 | 36 | /* To get a model of all posts, suitable for use in a ListView, | ||
83 | 37 | Repeater, etc */ | ||
84 | 38 | StreamModel { | ||
85 | 39 | id: streamModel | ||
86 | 40 | } | ||
87 | 41 | |||
88 | 42 | /* The roleNames provided from streamModel isn't all that intuitive right now. | ||
89 | 43 | service: column_0 | ||
90 | 44 | account_id: column_1 | ||
91 | 45 | message_id: column_2 | ||
92 | 46 | stream: column_3 | ||
93 | 47 | sender: column_4 | ||
94 | 48 | sender_id: column_5 | ||
95 | 49 | sender_nick: column_6 | ||
96 | 50 | from_me: column_7 | ||
97 | 51 | timestamp: column_8 | ||
98 | 52 | message: column_9 | ||
99 | 53 | icon_uri: column_10 | ||
100 | 54 | url: column_11 | ||
101 | 55 | likes: column_12 | ||
102 | 56 | liked: column_13 | ||
103 | 57 | link_picture: column_14 | ||
104 | 58 | link_name: column_15 | ||
105 | 59 | link_url: column_16 | ||
106 | 60 | link_desc: column_17 | ||
107 | 61 | link_caption: column_18 | ||
108 | 62 | link_icon: column_19 | ||
109 | 63 | location: column_20 | ||
110 | 64 | latitude: column_21 | ||
111 | 65 | longitude: column_22 | ||
112 | 66 | */ | ||
113 | 67 | |||
114 | 68 | /* To get a model of all images */ | ||
115 | 69 | StreamModel { | ||
116 | 70 | stream: "images" | ||
117 | 71 | } | ||
118 | 72 | |||
119 | 73 | /* To get a model of content from twitter */ | ||
120 | 74 | StreamModel { | ||
121 | 75 | service: "twitter" | ||
122 | 76 | } | ||
123 | 77 | |||
124 | 78 | /* To get a model of content from accountId 2 */ | ||
125 | 79 | StreamModel { | ||
126 | 80 | account: 2 | ||
127 | 81 | } | ||
128 | 82 | |||
129 | 83 | /* To get a model of threads on a post */ | ||
130 | 84 | StreamModel { | ||
131 | 85 | stream: "reply_to/"+messageId | ||
132 | 86 | } | ||
133 | 87 | |||
134 | 88 | /* convenience function for converting timestamps into time delta | ||
135 | 89 | strings, like "2 hours ago" */ | ||
136 | 90 | FriendsUtils { | ||
137 | 91 | id: friendsUtils | ||
138 | 92 | } | ||
139 | 93 | |||
140 | 94 | friendsUtils.createTimeString(column_8) | ||
141 | 95 | |||
142 | 0 | 96 | ||
143 | === added file 'examples/streamview.qml' | |||
144 | --- examples/streamview.qml 1970-01-01 00:00:00 +0000 | |||
145 | +++ examples/streamview.qml 2013-03-20 13:31:31 +0000 | |||
146 | @@ -0,0 +1,128 @@ | |||
147 | 1 | /* | ||
148 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
149 | 3 | * | ||
150 | 4 | * This program is free software; you can redistribute it and/or modify | ||
151 | 5 | * it under the terms of the GNU General Public License as published by | ||
152 | 6 | * the Free Software Foundation; version 3. | ||
153 | 7 | * | ||
154 | 8 | * This program is distributed in the hope that it will be useful, | ||
155 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
156 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
157 | 11 | * GNU General Public License for more details. | ||
158 | 12 | * | ||
159 | 13 | * You should have received a copy of the GNU General Public License | ||
160 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
161 | 15 | */ | ||
162 | 16 | |||
163 | 17 | import QtQuick 2.0 | ||
164 | 18 | import Ubuntu.Components 0.1 | ||
165 | 19 | import Ubuntu.Components.ListItems 0.1 | ||
166 | 20 | import Friends 0.1 | ||
167 | 21 | |||
168 | 22 | MainView { | ||
169 | 23 | width: units.gu(50) | ||
170 | 24 | height: units.gu(100) | ||
171 | 25 | |||
172 | 26 | FriendsUtils { | ||
173 | 27 | id: friendsUtils | ||
174 | 28 | } | ||
175 | 29 | |||
176 | 30 | ListView { | ||
177 | 31 | id: listView | ||
178 | 32 | anchors { | ||
179 | 33 | fill: parent | ||
180 | 34 | } | ||
181 | 35 | snapMode: ListView.SnapToItem | ||
182 | 36 | /* Reverse ListView order */ | ||
183 | 37 | verticalLayoutDirection: ListView.BottomToTop | ||
184 | 38 | cacheBuffer: parent.height | ||
185 | 39 | model: StreamModel { | ||
186 | 40 | //stream: "messages" | ||
187 | 41 | //service: "facebook" | ||
188 | 42 | /* account Id from libaccounts */ | ||
189 | 43 | //account: 1 | ||
190 | 44 | } | ||
191 | 45 | populate: Transition { | ||
192 | 46 | ScriptAction { script: listView.positionViewAtEnd() } | ||
193 | 47 | } | ||
194 | 48 | |||
195 | 49 | delegate: Item { | ||
196 | 50 | id: tile | ||
197 | 51 | height: status_update_content.height | ||
198 | 52 | width: parent.width | ||
199 | 53 | anchors { | ||
200 | 54 | margins: units.gu(1) | ||
201 | 55 | } | ||
202 | 56 | |||
203 | 57 | UbuntuShape { | ||
204 | 58 | id: avatarImage | ||
205 | 59 | radius: "medium" | ||
206 | 60 | height: units.dp(48) | ||
207 | 61 | width: units.dp(48) | ||
208 | 62 | anchors { | ||
209 | 63 | left: parent.left | ||
210 | 64 | top: parent.top | ||
211 | 65 | leftMargin: units.gu(1) | ||
212 | 66 | topMargin: units.gu(1) | ||
213 | 67 | } | ||
214 | 68 | image: Image { | ||
215 | 69 | anchors.fill: parent | ||
216 | 70 | source: Qt.resolvedUrl(column_10) | ||
217 | 71 | asynchronous: true | ||
218 | 72 | fillMode: Image.PreserveAspectFit | ||
219 | 73 | } | ||
220 | 74 | } | ||
221 | 75 | |||
222 | 76 | Item { | ||
223 | 77 | id: status_update_content | ||
224 | 78 | anchors { | ||
225 | 79 | left: avatarImage.right | ||
226 | 80 | right: parent.right | ||
227 | 81 | top: parent.top | ||
228 | 82 | topMargin: units.gu(1) | ||
229 | 83 | leftMargin: units.gu(1) | ||
230 | 84 | bottomMargin: units.gu(1) | ||
231 | 85 | rightMargin: units.gu(1) | ||
232 | 86 | } | ||
233 | 87 | height: childrenRect.height + units.gu(2) | ||
234 | 88 | Column { | ||
235 | 89 | spacing: units.gu(1) | ||
236 | 90 | anchors { | ||
237 | 91 | left: parent.left; | ||
238 | 92 | right: parent.right | ||
239 | 93 | bottomMargin: units.gu(2) | ||
240 | 94 | } | ||
241 | 95 | Label { | ||
242 | 96 | id: sender | ||
243 | 97 | text: column_4 | ||
244 | 98 | fontSize: "medium" | ||
245 | 99 | font.bold: true | ||
246 | 100 | font.family: "Ubuntu" | ||
247 | 101 | width: parent.width | ||
248 | 102 | } | ||
249 | 103 | Label { | ||
250 | 104 | id: message | ||
251 | 105 | text: column_9 | ||
252 | 106 | wrapMode: Text.WrapAtWordBoundaryOrAnywhere | ||
253 | 107 | width: parent.width - units.gu(3) | ||
254 | 108 | font.family: "Ubuntu" | ||
255 | 109 | } | ||
256 | 110 | } | ||
257 | 111 | Row { | ||
258 | 112 | anchors.right: parent.right | ||
259 | 113 | anchors.rightMargin: units.gu(1) | ||
260 | 114 | anchors.top: parent.top | ||
261 | 115 | spacing: units.gu(1) | ||
262 | 116 | |||
263 | 117 | Label { | ||
264 | 118 | id: time | ||
265 | 119 | text: friendsUtils.createTimeString(column_8) | ||
266 | 120 | fontSize: "small" | ||
267 | 121 | font.family: "Ubuntu" | ||
268 | 122 | } | ||
269 | 123 | } | ||
270 | 124 | } | ||
271 | 125 | ThinDivider {} | ||
272 | 126 | } | ||
273 | 127 | } | ||
274 | 128 | } | ||
275 | 0 | 129 | ||
276 | === removed file 'examples/streamview.qml' | |||
277 | --- examples/streamview.qml 2013-03-08 15:19:38 +0000 | |||
278 | +++ examples/streamview.qml 1970-01-01 00:00:00 +0000 | |||
279 | @@ -1,121 +0,0 @@ | |||
280 | 1 | /* | ||
281 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
282 | 3 | * | ||
283 | 4 | * This program is free software; you can redistribute it and/or modify | ||
284 | 5 | * it under the terms of the GNU General Public License as published by | ||
285 | 6 | * the Free Software Foundation; version 3. | ||
286 | 7 | * | ||
287 | 8 | * This program is distributed in the hope that it will be useful, | ||
288 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
289 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
290 | 11 | * GNU General Public License for more details. | ||
291 | 12 | * | ||
292 | 13 | * You should have received a copy of the GNU General Public License | ||
293 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
294 | 15 | */ | ||
295 | 16 | |||
296 | 17 | import QtQuick 2.0 | ||
297 | 18 | import Ubuntu.Components 0.1 | ||
298 | 19 | import Ubuntu.Components.ListItems 0.1 | ||
299 | 20 | import Dee 3.0 | ||
300 | 21 | import Friends 0.1 | ||
301 | 22 | |||
302 | 23 | MainView { | ||
303 | 24 | width: units.gu(50) | ||
304 | 25 | height: units.gu(100) | ||
305 | 26 | |||
306 | 27 | FriendsUtils { | ||
307 | 28 | id: friendsUtils | ||
308 | 29 | } | ||
309 | 30 | |||
310 | 31 | ListView { | ||
311 | 32 | id: listView | ||
312 | 33 | anchors { | ||
313 | 34 | fill: parent | ||
314 | 35 | } | ||
315 | 36 | snapMode: ListView.SnapToItem | ||
316 | 37 | verticalLayoutDirection: ListView.BottomToTop | ||
317 | 38 | cacheBuffer: parent.height | ||
318 | 39 | |||
319 | 40 | model: DeeListModel { name: "com.canonical.Friends.Streams" } | ||
320 | 41 | |||
321 | 42 | delegate: Item { | ||
322 | 43 | id: tile | ||
323 | 44 | height: status_update_content.height | ||
324 | 45 | width: parent.width | ||
325 | 46 | anchors { | ||
326 | 47 | margins: units.gu(1) | ||
327 | 48 | } | ||
328 | 49 | |||
329 | 50 | UbuntuShape { | ||
330 | 51 | id: avatarImage | ||
331 | 52 | radius: "medium" | ||
332 | 53 | height: units.dp(48) | ||
333 | 54 | width: units.dp(48) | ||
334 | 55 | anchors { | ||
335 | 56 | left: parent.left | ||
336 | 57 | top: parent.top | ||
337 | 58 | leftMargin: units.gu(1) | ||
338 | 59 | topMargin: units.gu(1) | ||
339 | 60 | } | ||
340 | 61 | image: Image { | ||
341 | 62 | anchors.fill: parent | ||
342 | 63 | source: Qt.resolvedUrl(column_8) | ||
343 | 64 | asynchronous: true | ||
344 | 65 | fillMode: Image.PreserveAspectFit | ||
345 | 66 | } | ||
346 | 67 | } | ||
347 | 68 | |||
348 | 69 | Item { | ||
349 | 70 | id: status_update_content | ||
350 | 71 | anchors { | ||
351 | 72 | left: avatarImage.right | ||
352 | 73 | right: parent.right | ||
353 | 74 | top: parent.top | ||
354 | 75 | topMargin: units.gu(1) | ||
355 | 76 | leftMargin: units.gu(1) | ||
356 | 77 | bottomMargin: units.gu(1) | ||
357 | 78 | rightMargin: units.gu(1) | ||
358 | 79 | } | ||
359 | 80 | height: childrenRect.height + units.gu(2) | ||
360 | 81 | Column { | ||
361 | 82 | spacing: units.gu(1) | ||
362 | 83 | anchors { | ||
363 | 84 | left: parent.left; | ||
364 | 85 | right: parent.right | ||
365 | 86 | bottomMargin: units.gu(2) | ||
366 | 87 | } | ||
367 | 88 | Label { | ||
368 | 89 | id: sender | ||
369 | 90 | text: column_2 | ||
370 | 91 | fontSize: "medium" | ||
371 | 92 | font.bold: true | ||
372 | 93 | font.family: "Ubuntu" | ||
373 | 94 | width: parent.width | ||
374 | 95 | } | ||
375 | 96 | Label { | ||
376 | 97 | id: message | ||
377 | 98 | text: column_7 | ||
378 | 99 | wrapMode: Text.WrapAtWordBoundaryOrAnywhere | ||
379 | 100 | width: parent.width - units.gu(3) | ||
380 | 101 | font.family: "Ubuntu" | ||
381 | 102 | } | ||
382 | 103 | } | ||
383 | 104 | Row { | ||
384 | 105 | anchors.right: parent.right | ||
385 | 106 | anchors.rightMargin: units.gu(1) | ||
386 | 107 | anchors.top: parent.top | ||
387 | 108 | spacing: units.gu(1) | ||
388 | 109 | |||
389 | 110 | Label { | ||
390 | 111 | id: time | ||
391 | 112 | text: friendsUtils.createTimeString(column_6) | ||
392 | 113 | fontSize: "small" | ||
393 | 114 | font.family: "Ubuntu" | ||
394 | 115 | } | ||
395 | 116 | } | ||
396 | 117 | } | ||
397 | 118 | ThinDivider {} | ||
398 | 119 | } | ||
399 | 120 | } | ||
400 | 121 | } | ||
401 | 122 | 0 | ||
402 | === modified file 'friends.pro' | |||
403 | --- friends.pro 2013-01-15 19:49:40 +0000 | |||
404 | +++ friends.pro 2013-03-20 13:31:31 +0000 | |||
405 | @@ -15,3 +15,6 @@ | |||
406 | 15 | dist.depends = distclean | 15 | dist.depends = distclean |
407 | 16 | 16 | ||
408 | 17 | QMAKE_EXTRA_TARGETS += dist | 17 | QMAKE_EXTRA_TARGETS += dist |
409 | 18 | |||
410 | 19 | SUBDIRS += \ | ||
411 | 20 | tests | ||
412 | 18 | 21 | ||
413 | === modified file 'modules/Friends/plugin/friendsdispatcher.cpp' | |||
414 | --- modules/Friends/plugin/friendsdispatcher.cpp 2013-03-06 17:51:39 +0000 | |||
415 | +++ modules/Friends/plugin/friendsdispatcher.cpp 2013-03-20 13:31:31 +0000 | |||
416 | @@ -299,3 +299,11 @@ | |||
417 | 299 | &sendReplyCompleteCallback, (gpointer) this); | 299 | &sendReplyCompleteCallback, (gpointer) this); |
418 | 300 | } | 300 | } |
419 | 301 | 301 | ||
420 | 302 | void FriendsDispatcherQml::refresh() const | ||
421 | 303 | { | ||
422 | 304 | GError* error = NULL; | ||
423 | 305 | friends_dispatcher_refresh(m_dispatcher, &error); | ||
424 | 306 | |||
425 | 307 | if (error != NULL) | ||
426 | 308 | g_error_free (error); | ||
427 | 309 | } | ||
428 | 302 | 310 | ||
429 | === modified file 'modules/Friends/plugin/friendsdispatcher.h' | |||
430 | --- modules/Friends/plugin/friendsdispatcher.h 2013-02-14 15:26:37 +0000 | |||
431 | +++ modules/Friends/plugin/friendsdispatcher.h 2013-03-20 13:31:31 +0000 | |||
432 | @@ -46,6 +46,8 @@ | |||
433 | 46 | void likeAsync(const int& account_id, const QString& message_id) const; | 46 | void likeAsync(const int& account_id, const QString& message_id) const; |
434 | 47 | void unlike(const int& account_id, const QString& message_id) const; | 47 | void unlike(const int& account_id, const QString& message_id) const; |
435 | 48 | void unlikeAsync(const int& account_id, const QString& message_id) const; | 48 | void unlikeAsync(const int& account_id, const QString& message_id) const; |
436 | 49 | void refresh() const; | ||
437 | 50 | |||
438 | 49 | 51 | ||
439 | 50 | Q_SIGNALS: | 52 | Q_SIGNALS: |
440 | 51 | void uploadComplete(QString resultUrl, bool success, QString errorMessage); | 53 | void uploadComplete(QString resultUrl, bool success, QString errorMessage); |
441 | 52 | 54 | ||
442 | === modified file 'modules/Friends/plugin/friendsutils.cpp' | |||
443 | --- modules/Friends/plugin/friendsutils.cpp 2012-11-28 18:22:36 +0000 | |||
444 | +++ modules/Friends/plugin/friendsutils.cpp 2013-03-20 13:31:31 +0000 | |||
445 | @@ -17,9 +17,7 @@ | |||
446 | 17 | 17 | ||
447 | 18 | #include "friendsutils.h" | 18 | #include "friendsutils.h" |
448 | 19 | 19 | ||
449 | 20 | #include <QGuiApplication> | ||
450 | 21 | #include <QtQuick/QQuickView> | 20 | #include <QtQuick/QQuickView> |
451 | 22 | #include <QtQuick/QQuickItem> | ||
452 | 23 | 21 | ||
453 | 24 | #include <glib-object.h> | 22 | #include <glib-object.h> |
454 | 25 | 23 | ||
455 | 26 | 24 | ||
456 | === modified file 'modules/Friends/plugin/friendsutils.h' | |||
457 | --- modules/Friends/plugin/friendsutils.h 2012-11-28 18:22:36 +0000 | |||
458 | +++ modules/Friends/plugin/friendsutils.h 2013-03-20 13:31:31 +0000 | |||
459 | @@ -18,14 +18,9 @@ | |||
460 | 18 | #ifndef FRIENDSUTILS_H | 18 | #ifndef FRIENDSUTILS_H |
461 | 19 | #define FRIENDSUTILS_H | 19 | #define FRIENDSUTILS_H |
462 | 20 | 20 | ||
465 | 21 | #include <QtCore/QObject> | 21 | #include <QObject> |
464 | 22 | #include <QtQuick/QQuickView> | ||
466 | 23 | #include <friends.h> | 22 | #include <friends.h> |
467 | 24 | 23 | ||
468 | 25 | class QQuickItem; | ||
469 | 26 | class QQmlEngine; | ||
470 | 27 | class QJSEngine; | ||
471 | 28 | |||
472 | 29 | class FriendsUtilsQml : public QObject | 24 | class FriendsUtilsQml : public QObject |
473 | 30 | { | 25 | { |
474 | 31 | Q_OBJECT | 26 | Q_OBJECT |
475 | 32 | 27 | ||
476 | === modified file 'modules/Friends/plugin/plugin.cpp' | |||
477 | --- modules/Friends/plugin/plugin.cpp 2013-02-09 15:33:54 +0000 | |||
478 | +++ modules/Friends/plugin/plugin.cpp 2013-03-20 13:31:31 +0000 | |||
479 | @@ -14,25 +14,23 @@ | |||
480 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
481 | 15 | */ | 15 | */ |
482 | 16 | 16 | ||
483 | 17 | #include <QtQml> | ||
484 | 18 | #include <QtQml/QQmlContext> | ||
485 | 19 | |||
486 | 20 | #include "plugin.h" | ||
487 | 21 | #include "friendsutils.h" | 17 | #include "friendsutils.h" |
488 | 22 | #include "friendsdispatcher.h" | 18 | #include "friendsdispatcher.h" |
492 | 23 | 19 | #include "streammodel.h" | |
493 | 24 | #include <glib-object.h> | 20 | #include "plugin.h" |
494 | 25 | #include <friends.h> | 21 | |
495 | 22 | #include <QDebug> | ||
496 | 23 | #include <QQmlComponent> | ||
497 | 24 | |||
498 | 26 | 25 | ||
499 | 27 | void FriendsPlugin::registerTypes(const char *uri) | 26 | void FriendsPlugin::registerTypes(const char *uri) |
500 | 28 | { | 27 | { |
501 | 29 | Q_ASSERT(uri == QLatin1String("Friends")); | 28 | Q_ASSERT(uri == QLatin1String("Friends")); |
502 | 30 | 29 | ||
503 | 30 | qDebug() << Q_FUNC_INFO << uri; | ||
504 | 31 | |||
505 | 31 | qmlRegisterType<FriendsUtilsQml>(uri, 0, 1, "FriendsUtils"); | 32 | qmlRegisterType<FriendsUtilsQml>(uri, 0, 1, "FriendsUtils"); |
506 | 32 | qmlRegisterType<FriendsDispatcherQml>(uri, 0, 1, "FriendsDispatcher"); | 33 | qmlRegisterType<FriendsDispatcherQml>(uri, 0, 1, "FriendsDispatcher"); |
507 | 34 | qmlRegisterType<StreamModel>(uri, 0, 1, "StreamModel"); | ||
508 | 33 | } | 35 | } |
509 | 34 | 36 | ||
510 | 35 | void FriendsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) | ||
511 | 36 | { | ||
512 | 37 | QQmlExtensionPlugin::initializeEngine(engine, uri); | ||
513 | 38 | } | ||
514 | 39 | 37 | ||
515 | === modified file 'modules/Friends/plugin/plugin.h' | |||
516 | --- modules/Friends/plugin/plugin.h 2012-11-28 18:22:36 +0000 | |||
517 | +++ modules/Friends/plugin/plugin.h 2013-03-20 13:31:31 +0000 | |||
518 | @@ -17,8 +17,7 @@ | |||
519 | 17 | #ifndef FRIENDS_PLUGIN_H | 17 | #ifndef FRIENDS_PLUGIN_H |
520 | 18 | #define FRIENDS_PLUGIN_H | 18 | #define FRIENDS_PLUGIN_H |
521 | 19 | 19 | ||
524 | 20 | #include <QtQml/QQmlEngine> | 20 | #include <QQmlExtensionPlugin> |
523 | 21 | #include <QtQml/QQmlExtensionPlugin> | ||
525 | 22 | 21 | ||
526 | 23 | class FriendsPlugin : public QQmlExtensionPlugin | 22 | class FriendsPlugin : public QQmlExtensionPlugin |
527 | 24 | { | 23 | { |
528 | @@ -27,7 +26,7 @@ | |||
529 | 27 | 26 | ||
530 | 28 | public: | 27 | public: |
531 | 29 | void registerTypes(const char *uri); | 28 | void registerTypes(const char *uri); |
532 | 30 | void initializeEngine(QQmlEngine *engine, const char *uri); | ||
533 | 31 | }; | 29 | }; |
534 | 30 | |||
535 | 32 | #endif // FRIENDS_PLUGIN_H | 31 | #endif // FRIENDS_PLUGIN_H |
536 | 33 | 32 | ||
537 | 34 | 33 | ||
538 | === modified file 'modules/Friends/plugin/plugin.pro' | |||
539 | --- modules/Friends/plugin/plugin.pro 2013-02-09 15:33:54 +0000 | |||
540 | +++ modules/Friends/plugin/plugin.pro 2013-03-20 13:31:31 +0000 | |||
541 | @@ -2,26 +2,28 @@ | |||
542 | 2 | 2 | ||
543 | 3 | TEMPLATE = lib | 3 | TEMPLATE = lib |
544 | 4 | TARGET = ../Friends | 4 | TARGET = ../Friends |
546 | 5 | QT += qml quick | 5 | QT += qml |
547 | 6 | CONFIG += qt plugin no_keywords link_pkgconfig | 6 | CONFIG += qt plugin no_keywords link_pkgconfig |
550 | 7 | PKGCONFIG += friends-0.1 gobject-2.0 | 7 | PKGCONFIG += friends-0.1 gobject-2.0 libdee-qt5 |
549 | 8 | |||
551 | 9 | #comment in the following line to disable traces | 8 | #comment in the following line to disable traces |
552 | 10 | #DEFINES += QT_NO_DEBUG_OUTPUT | 9 | #DEFINES += QT_NO_DEBUG_OUTPUT |
553 | 11 | 10 | ||
554 | 11 | QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF | ||
555 | 12 | |||
556 | 12 | TARGET = $$qtLibraryTarget($$TARGET) | 13 | TARGET = $$qtLibraryTarget($$TARGET) |
557 | 13 | uri = Friends | 14 | uri = Friends |
558 | 14 | 15 | ||
559 | 15 | HEADERS += plugin.h \ | 16 | HEADERS += plugin.h \ |
560 | 16 | friendsutils.h \ | 17 | friendsutils.h \ |
562 | 17 | friendsdispatcher.h | 18 | friendsdispatcher.h \ |
563 | 19 | streammodel.h | ||
564 | 18 | 20 | ||
565 | 19 | SOURCES += plugin.cpp \ | 21 | SOURCES += plugin.cpp \ |
566 | 20 | friendsutils.cpp \ | 22 | friendsutils.cpp \ |
568 | 21 | friendsdispatcher.cpp | 23 | friendsdispatcher.cpp \ |
569 | 24 | streammodel.cpp | ||
570 | 22 | 25 | ||
571 | 23 | # deployment rules for the plugin | 26 | # deployment rules for the plugin |
572 | 24 | installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) | 27 | installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) |
573 | 25 | target.path = $$installPath | 28 | target.path = $$installPath |
574 | 26 | INSTALLS += target | 29 | INSTALLS += target |
575 | 27 | |||
576 | 28 | 30 | ||
577 | === added file 'modules/Friends/plugin/streammodel.cpp' | |||
578 | --- modules/Friends/plugin/streammodel.cpp 1970-01-01 00:00:00 +0000 | |||
579 | +++ modules/Friends/plugin/streammodel.cpp 2013-03-20 13:31:31 +0000 | |||
580 | @@ -0,0 +1,176 @@ | |||
581 | 1 | #include <glib-object.h> | ||
582 | 2 | #include "streammodel.h" | ||
583 | 3 | #include <QDebug> | ||
584 | 4 | #include <QProcessEnvironment> | ||
585 | 5 | |||
586 | 6 | class StreamModelPrivate: public DeeListModel | ||
587 | 7 | { | ||
588 | 8 | Q_DECLARE_PUBLIC(StreamModel) | ||
589 | 9 | |||
590 | 10 | public: | ||
591 | 11 | StreamModelPrivate(StreamModel *model); | ||
592 | 12 | ~StreamModelPrivate(); | ||
593 | 13 | static void onModelReady(GObject* parent, GParamSpec *pspec, StreamModelPrivate *q); | ||
594 | 14 | void updateResults(StreamModelPrivate *d); | ||
595 | 15 | |||
596 | 16 | private: | ||
597 | 17 | mutable StreamModel *q_ptr; | ||
598 | 18 | QString streamId = NULL; | ||
599 | 19 | QString serviceId = NULL; | ||
600 | 20 | uint accountId = 0; | ||
601 | 21 | DeeModel* m_resultsModel; | ||
602 | 22 | DeeModel* m_sharedModel; | ||
603 | 23 | DeeModel* m_sortedModel; | ||
604 | 24 | }; | ||
605 | 25 | |||
606 | 26 | StreamModelPrivate::StreamModelPrivate(StreamModel *model): | ||
607 | 27 | DeeListModel(model), | ||
608 | 28 | q_ptr(model) | ||
609 | 29 | { | ||
610 | 30 | qDebug() << Q_FUNC_INFO; | ||
611 | 31 | QString modelName = "com.canonical.Friends.Streams"; | ||
612 | 32 | /* read environment variables */ | ||
613 | 33 | QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); | ||
614 | 34 | if (environment.contains(QLatin1String("FRIENDS_STREAMS_MODEL"))) | ||
615 | 35 | { | ||
616 | 36 | modelName = environment.value(QLatin1String("FRIENDS_STREAMS_MODEL")); | ||
617 | 37 | } | ||
618 | 38 | |||
619 | 39 | qDebug() << "MODEL: " << modelName; | ||
620 | 40 | |||
621 | 41 | m_sharedModel = dee_shared_model_new (modelName.toUtf8()); | ||
622 | 42 | m_resultsModel = m_sharedModel; | ||
623 | 43 | m_sortedModel = dee_sequence_model_new (); | ||
624 | 44 | g_signal_connect(m_sharedModel, "notify::synchronized", G_CALLBACK(onModelReady), this); | ||
625 | 45 | } | ||
626 | 46 | |||
627 | 47 | void | ||
628 | 48 | StreamModelPrivate::onModelReady(GObject* parent __attribute__ ((unused)), GParamSpec *pspec, StreamModelPrivate *d) | ||
629 | 49 | { | ||
630 | 50 | qDebug() << Q_FUNC_INFO; | ||
631 | 51 | DeeModel *model = (DeeModel*)parent; | ||
632 | 52 | DeeFilter _sort_filter; | ||
633 | 53 | dee_filter_new_collator (8, &_sort_filter); | ||
634 | 54 | d->m_sortedModel = dee_filter_model_new (model, &_sort_filter); | ||
635 | 55 | qDebug() << Q_FUNC_INFO << " " << dee_model_get_n_rows (d->m_sortedModel); | ||
636 | 56 | d->updateResults(d); | ||
637 | 57 | } | ||
638 | 58 | |||
639 | 59 | void StreamModelPrivate::updateResults(StreamModelPrivate *d) | ||
640 | 60 | { | ||
641 | 61 | /* Only updateResults if the model is populated */ | ||
642 | 62 | if (dee_model_get_n_rows (d->m_sortedModel) < 1) return; | ||
643 | 63 | |||
644 | 64 | if (d->streamId != NULL) | ||
645 | 65 | { | ||
646 | 66 | DeeFilter _key_filter; | ||
647 | 67 | dee_filter_new_for_key_column (3, d->streamId.toUtf8().data(), &_key_filter); | ||
648 | 68 | d->m_resultsModel = dee_filter_model_new (d->m_sortedModel, &_key_filter); | ||
649 | 69 | } else | ||
650 | 70 | { | ||
651 | 71 | GRegex *regex; | ||
652 | 72 | regex = g_regex_new ("^((?!reply_to).)*$", G_REGEX_FIRSTLINE, G_REGEX_MATCH_PARTIAL, NULL); | ||
653 | 73 | DeeFilter _regex_filter; | ||
654 | 74 | dee_filter_new_regex (3, regex, &_regex_filter); | ||
655 | 75 | g_regex_unref (regex); | ||
656 | 76 | d->m_resultsModel = dee_filter_model_new (d->m_sortedModel, &_regex_filter); | ||
657 | 77 | } | ||
658 | 78 | qDebug () << "STREAM: " << d->streamId << " ROWS: " << dee_model_get_n_rows (d->m_resultsModel); | ||
659 | 79 | |||
660 | 80 | if (d->serviceId != NULL) | ||
661 | 81 | { | ||
662 | 82 | DeeFilter _service_filter; | ||
663 | 83 | dee_filter_new_for_key_column (0, d->serviceId.toUtf8().data(), &_service_filter); | ||
664 | 84 | d->m_resultsModel = dee_filter_model_new (d->m_resultsModel, &_service_filter); | ||
665 | 85 | } | ||
666 | 86 | qDebug () << "SERVICE: " << d->serviceId << " ROWS: " << dee_model_get_n_rows (d->m_resultsModel); | ||
667 | 87 | |||
668 | 88 | if (d->accountId != 0) | ||
669 | 89 | { | ||
670 | 90 | DeeFilter _account_filter; | ||
671 | 91 | dee_filter_new_for_any_column (1, g_variant_new_uint64(d->accountId), &_account_filter); | ||
672 | 92 | d->m_resultsModel = dee_filter_model_new (d->m_resultsModel, &_account_filter); | ||
673 | 93 | qDebug () << "ACCOUNT: " << d->accountId << " ROWS: " << dee_model_get_n_rows (d->m_resultsModel); | ||
674 | 94 | } | ||
675 | 95 | |||
676 | 96 | q_ptr->setModel(m_resultsModel); | ||
677 | 97 | Q_EMIT q_ptr->streamChanged(); | ||
678 | 98 | } | ||
679 | 99 | |||
680 | 100 | StreamModelPrivate::~StreamModelPrivate() | ||
681 | 101 | { | ||
682 | 102 | } | ||
683 | 103 | |||
684 | 104 | StreamModel::StreamModel(DeeListModel *parent) : | ||
685 | 105 | DeeListModel(parent), | ||
686 | 106 | d_ptr(new StreamModelPrivate(this)) | ||
687 | 107 | { | ||
688 | 108 | } | ||
689 | 109 | |||
690 | 110 | StreamModel::~StreamModel() | ||
691 | 111 | { | ||
692 | 112 | } | ||
693 | 113 | |||
694 | 114 | |||
695 | 115 | void StreamModel::classBegin() | ||
696 | 116 | { | ||
697 | 117 | } | ||
698 | 118 | |||
699 | 119 | void StreamModel::componentComplete() | ||
700 | 120 | { | ||
701 | 121 | } | ||
702 | 122 | |||
703 | 123 | void StreamModel::setStream(const QString& streamId) | ||
704 | 124 | { | ||
705 | 125 | Q_D(StreamModel); | ||
706 | 126 | if (streamId == d->streamId) return; | ||
707 | 127 | d->streamId = streamId; | ||
708 | 128 | d->updateResults(d); | ||
709 | 129 | } | ||
710 | 130 | |||
711 | 131 | /*! | ||
712 | 132 | * \qmlproperty string StreamModel::stream | ||
713 | 133 | * If set, the model will include only this stream | ||
714 | 134 | */ | ||
715 | 135 | QString StreamModel::stream() const | ||
716 | 136 | { | ||
717 | 137 | Q_D(const StreamModel); | ||
718 | 138 | return d->streamId; | ||
719 | 139 | } | ||
720 | 140 | |||
721 | 141 | void StreamModel::setService(const QString& serviceId) | ||
722 | 142 | { | ||
723 | 143 | Q_D(StreamModel); | ||
724 | 144 | if (serviceId == d->serviceId) return; | ||
725 | 145 | d->serviceId = serviceId; | ||
726 | 146 | d->updateResults(d); | ||
727 | 147 | } | ||
728 | 148 | |||
729 | 149 | /*! | ||
730 | 150 | * \qmlproperty string StreamModel::service | ||
731 | 151 | * If set, the model will include only this service | ||
732 | 152 | */ | ||
733 | 153 | QString StreamModel::service() const | ||
734 | 154 | { | ||
735 | 155 | Q_D(const StreamModel); | ||
736 | 156 | return d->serviceId; | ||
737 | 157 | } | ||
738 | 158 | |||
739 | 159 | void StreamModel::setAccount(uint account) | ||
740 | 160 | { | ||
741 | 161 | Q_D(StreamModel); | ||
742 | 162 | if (account == d->accountId) return; | ||
743 | 163 | d->accountId = account; | ||
744 | 164 | d->updateResults(d); | ||
745 | 165 | qDebug() << "Account: " << account; | ||
746 | 166 | } | ||
747 | 167 | |||
748 | 168 | /*! | ||
749 | 169 | * \qmlproperty string StreamModel::account | ||
750 | 170 | * If set, the model will include only this account | ||
751 | 171 | */ | ||
752 | 172 | uint StreamModel::account() const | ||
753 | 173 | { | ||
754 | 174 | Q_D(const StreamModel); | ||
755 | 175 | return d->accountId; | ||
756 | 176 | } | ||
757 | 0 | 177 | ||
758 | === added file 'modules/Friends/plugin/streammodel.h' | |||
759 | --- modules/Friends/plugin/streammodel.h 1970-01-01 00:00:00 +0000 | |||
760 | +++ modules/Friends/plugin/streammodel.h 2013-03-20 13:31:31 +0000 | |||
761 | @@ -0,0 +1,46 @@ | |||
762 | 1 | #ifndef StreamModel_H | ||
763 | 2 | #define StreamModel_H | ||
764 | 3 | |||
765 | 4 | |||
766 | 5 | #include <QObject> | ||
767 | 6 | #include <QString> | ||
768 | 7 | #include <QQmlParserStatus> | ||
769 | 8 | #include <QQmlListProperty> | ||
770 | 9 | #include "deelistmodel.h" | ||
771 | 10 | #include <dee-1.0/dee.h> | ||
772 | 11 | |||
773 | 12 | class StreamModelPrivate; | ||
774 | 13 | class StreamModel : public DeeListModel, public QQmlParserStatus | ||
775 | 14 | { | ||
776 | 15 | Q_OBJECT | ||
777 | 16 | Q_INTERFACES(QQmlParserStatus) | ||
778 | 17 | Q_PROPERTY(QString stream READ stream WRITE setStream NOTIFY streamChanged) | ||
779 | 18 | Q_PROPERTY(QString service READ service WRITE setService NOTIFY serviceChanged) | ||
780 | 19 | Q_PROPERTY(uint account READ account WRITE setAccount NOTIFY accountChanged) | ||
781 | 20 | |||
782 | 21 | public: | ||
783 | 22 | explicit StreamModel(DeeListModel *parent = 0); | ||
784 | 23 | ~StreamModel(); | ||
785 | 24 | |||
786 | 25 | void setStream(const QString& streamId); | ||
787 | 26 | QString stream() const; | ||
788 | 27 | void setService(const QString& serviceId); | ||
789 | 28 | QString service() const; | ||
790 | 29 | void setAccount(uint account); | ||
791 | 30 | uint account() const; | ||
792 | 31 | void classBegin(); | ||
793 | 32 | void componentComplete(); | ||
794 | 33 | |||
795 | 34 | |||
796 | 35 | Q_SIGNALS: | ||
797 | 36 | void streamChanged(); | ||
798 | 37 | void serviceChanged(); | ||
799 | 38 | void accountChanged(); | ||
800 | 39 | |||
801 | 40 | private: | ||
802 | 41 | StreamModelPrivate* const d_ptr; | ||
803 | 42 | Q_DECLARE_PRIVATE(StreamModel) | ||
804 | 43 | |||
805 | 44 | }; | ||
806 | 45 | |||
807 | 46 | #endif // StreamModel_H | ||
808 | 0 | 47 | ||
809 | === added directory 'tests' | |||
810 | === added file 'tests/tests.pro' | |||
811 | --- tests/tests.pro 1970-01-01 00:00:00 +0000 | |||
812 | +++ tests/tests.pro 2013-03-20 13:31:31 +0000 | |||
813 | @@ -0,0 +1,4 @@ | |||
814 | 1 | TEMPLATE = subdirs | ||
815 | 2 | |||
816 | 3 | SUBDIRS += \ | ||
817 | 4 | unit | ||
818 | 0 | 5 | ||
819 | === added directory 'tests/unit' | |||
820 | === added file 'tests/unit/main.cpp' | |||
821 | --- tests/unit/main.cpp 1970-01-01 00:00:00 +0000 | |||
822 | +++ tests/unit/main.cpp 2013-03-20 13:31:31 +0000 | |||
823 | @@ -0,0 +1,2 @@ | |||
824 | 1 | #include <QtQuickTest/quicktest.h> | ||
825 | 2 | QUICK_TEST_MAIN(unit) | ||
826 | 0 | 3 | ||
827 | === added file 'tests/unit/run.sh' | |||
828 | --- tests/unit/run.sh 1970-01-01 00:00:00 +0000 | |||
829 | +++ tests/unit/run.sh 2013-03-20 13:31:31 +0000 | |||
830 | @@ -0,0 +1,7 @@ | |||
831 | 1 | #!/bin/sh | ||
832 | 2 | |||
833 | 3 | export FRIENDS_STREAMS_MODEL=com.canonical.Friends.TestSharedModel | ||
834 | 4 | export QML2_IMPORT_PATH=../../modules | ||
835 | 5 | |||
836 | 6 | xvfb-run -a dbus-test-runner -t friends-dispatcher -p --test \ | ||
837 | 7 | --task-name FriendsService --ignore-return -t ./unit -m 120 | ||
838 | 0 | 8 | ||
839 | === added file 'tests/unit/tst_test.qml' | |||
840 | --- tests/unit/tst_test.qml 1970-01-01 00:00:00 +0000 | |||
841 | +++ tests/unit/tst_test.qml 2013-03-20 13:31:31 +0000 | |||
842 | @@ -0,0 +1,140 @@ | |||
843 | 1 | import QtQuick 2.0 | ||
844 | 2 | import QtTest 1.0 | ||
845 | 3 | import Friends 0.1 | ||
846 | 4 | |||
847 | 5 | // See more details @ http://qt-project.org/doc/qt-5.0/qtquick/qml-testcase.html | ||
848 | 6 | |||
849 | 7 | Item { | ||
850 | 8 | // The objects | ||
851 | 9 | |||
852 | 10 | FriendsDispatcher { | ||
853 | 11 | id: friends | ||
854 | 12 | } | ||
855 | 13 | |||
856 | 14 | SignalSpy { | ||
857 | 15 | id: signalSpy | ||
858 | 16 | target: friends | ||
859 | 17 | } | ||
860 | 18 | TestCase { | ||
861 | 19 | name: "testFriendsDispatcher" | ||
862 | 20 | |||
863 | 21 | function test_features () { | ||
864 | 22 | var input = ["facebook"] | ||
865 | 23 | var res = friends.featuresForProtocol (input[0]); | ||
866 | 24 | compare (res, input); | ||
867 | 25 | } | ||
868 | 26 | |||
869 | 27 | function test_uploadForAccountAsync () { | ||
870 | 28 | var acct = 1; | ||
871 | 29 | var uri = "file:///tmp/foo.png"; | ||
872 | 30 | var desc = "Something interesting to say"; | ||
873 | 31 | signalSpy.clear (); | ||
874 | 32 | signalSpy.signalName = "onUploadComplete" | ||
875 | 33 | friends.uploadForAccountAsync (acct, uri, desc) | ||
876 | 34 | signalSpy.wait (); | ||
877 | 35 | compare(1, signalSpy.count, "onUploadComplete emitted"); | ||
878 | 36 | } | ||
879 | 37 | |||
880 | 38 | function test_sendforAccountAsync () { | ||
881 | 39 | var acct = 1; | ||
882 | 40 | var msg = "Something interesting to say"; | ||
883 | 41 | signalSpy.clear (); | ||
884 | 42 | signalSpy.signalName = "onSendComplete" | ||
885 | 43 | friends.sendForAccountAsync (acct, msg) | ||
886 | 44 | signalSpy.wait (); | ||
887 | 45 | compare(1, signalSpy.count, "onSendComplete emitted"); | ||
888 | 46 | } | ||
889 | 47 | |||
890 | 48 | function test_sendAsync () { | ||
891 | 49 | var msg = "Something interesting to say"; | ||
892 | 50 | signalSpy.clear (); | ||
893 | 51 | signalSpy.signalName = "onSendComplete" | ||
894 | 52 | friends.sendAsync (msg) | ||
895 | 53 | signalSpy.wait (); | ||
896 | 54 | compare(1, signalSpy.count, "onSendComplete emitted"); | ||
897 | 55 | } | ||
898 | 56 | |||
899 | 57 | function test_sendReplyAsync () { | ||
900 | 58 | var acct = 1; | ||
901 | 59 | var msgId = "10"; | ||
902 | 60 | var msg = "Something interesting to say"; | ||
903 | 61 | signalSpy.clear (); | ||
904 | 62 | signalSpy.signalName = "onSendComplete" | ||
905 | 63 | friends.sendReplyAsync (acct, msgId, msg) | ||
906 | 64 | signalSpy.wait (); | ||
907 | 65 | compare(1, signalSpy.count, "onSendComplete emitted"); | ||
908 | 66 | } | ||
909 | 67 | |||
910 | 68 | function test_retweetAsync () { | ||
911 | 69 | var acct = 1; | ||
912 | 70 | var msgId = "10"; | ||
913 | 71 | signalSpy.clear (); | ||
914 | 72 | signalSpy.signalName = "onRetweetComplete" | ||
915 | 73 | friends.retweetAsync (acct, msgId) | ||
916 | 74 | signalSpy.wait (); | ||
917 | 75 | compare(1, signalSpy.count, "onRetweetComplete emitted"); | ||
918 | 76 | } | ||
919 | 77 | |||
920 | 78 | function test_likeAsync () { | ||
921 | 79 | var acct = 1; | ||
922 | 80 | var msgId = "10"; | ||
923 | 81 | signalSpy.clear (); | ||
924 | 82 | signalSpy.signalName = "onLikeComplete" | ||
925 | 83 | friends.likeAsync (acct, msgId) | ||
926 | 84 | signalSpy.wait (); | ||
927 | 85 | compare(1, signalSpy.count, "onLikeComplete emitted"); | ||
928 | 86 | } | ||
929 | 87 | |||
930 | 88 | function test_unlikeAsync () { | ||
931 | 89 | var acct = 1; | ||
932 | 90 | var msgId = "10"; | ||
933 | 91 | signalSpy.clear (); | ||
934 | 92 | signalSpy.signalName = "onUnlikeComplete" | ||
935 | 93 | friends.unlikeAsync (acct, msgId) | ||
936 | 94 | signalSpy.wait (); | ||
937 | 95 | compare(1, signalSpy.count, "onUnlikeComplete emitted"); | ||
938 | 96 | } | ||
939 | 97 | } | ||
940 | 98 | |||
941 | 99 | StreamModel { | ||
942 | 100 | id: streamModel | ||
943 | 101 | } | ||
944 | 102 | |||
945 | 103 | TestCase { | ||
946 | 104 | name: "testStreamModel" | ||
947 | 105 | |||
948 | 106 | function init() { | ||
949 | 107 | console.debug(">> init"); | ||
950 | 108 | console.debug("<< init"); | ||
951 | 109 | } | ||
952 | 110 | |||
953 | 111 | function cleanup() { | ||
954 | 112 | console.debug(">> cleanup"); | ||
955 | 113 | console.debug("<< cleanup"); | ||
956 | 114 | } | ||
957 | 115 | |||
958 | 116 | function initTestCase() { | ||
959 | 117 | console.debug(">> initTestCase"); | ||
960 | 118 | console.debug("<< initTestCase"); | ||
961 | 119 | } | ||
962 | 120 | |||
963 | 121 | function cleanupTestCase() { | ||
964 | 122 | console.debug(">> cleanupTestCase"); | ||
965 | 123 | console.debug("<< cleanupTestCase"); | ||
966 | 124 | } | ||
967 | 125 | |||
968 | 126 | function test_streamModelStream() { | ||
969 | 127 | streamModel.stream = "messages"; | ||
970 | 128 | compare(0, streamModel.count, "Test StreamModel row count filtered by stream"); | ||
971 | 129 | } | ||
972 | 130 | |||
973 | 131 | function test_streamModelService() { | ||
974 | 132 | streamModel.service = "twitter"; | ||
975 | 133 | compare(0, streamModel.count, "Test StreamModel row count filtered by service"); | ||
976 | 134 | } | ||
977 | 135 | function test_streamModelAccount() { | ||
978 | 136 | streamModel.account = 1; | ||
979 | 137 | compare(0, streamModel.count, "Test StreamModel row count filtered by account"); | ||
980 | 138 | } | ||
981 | 139 | } | ||
982 | 140 | } | ||
983 | 0 | 141 | ||
984 | === added file 'tests/unit/unit.pro' | |||
985 | --- tests/unit/unit.pro 1970-01-01 00:00:00 +0000 | |||
986 | +++ tests/unit/unit.pro 2013-03-20 13:31:31 +0000 | |||
987 | @@ -0,0 +1,13 @@ | |||
988 | 1 | TEMPLATE = app | ||
989 | 2 | QT += qml quick qmltest | ||
990 | 3 | CONFIG += no_keywords | ||
991 | 4 | |||
992 | 5 | TARGET = unit | ||
993 | 6 | SOURCES += main.cpp | ||
994 | 7 | |||
995 | 8 | OTHER_FILES += $$system(ls *.qml) | ||
996 | 9 | check.commands = "sh run.sh" | ||
997 | 10 | check.depends = $${TARGET} | ||
998 | 11 | QMAKE_EXTRA_TARGETS += check | ||
999 | 12 | |||
1000 | 13 | #system(cp $$PWD/*.qml $$OUT_PWD) |
These changes have been reviewed before merging into the raring branch