Merge lp:~unity-team/dee-qt/deevarianttext-and-tests into lp:dee-qt

Proposed by Michał Sawicz
Status: Rejected
Rejected by: Albert Astals Cid
Proposed branch: lp:~unity-team/dee-qt/deevarianttext-and-tests
Merge into: lp:dee-qt
Diff against target: 989 lines (+582/-44)
22 files modified
.bzrignore (+16/-3)
CMakeLists.txt (+3/-1)
debian/changelog (+8/-0)
debian/control (+3/-0)
debian/rules (+0/-2)
deelistmodel.cpp (+40/-8)
deelistmodel.h (+6/-1)
deeprivate.h (+23/-0)
deevarianttext.cpp (+72/-0)
deevarianttext.h (+49/-0)
modules/Dee/CMakeLists.txt (+2/-0)
modules/Dee/plugin.cpp (+2/-0)
tests/CMakeLists.txt (+30/-1)
tests/conversiontest.cpp (+3/-0)
tests/deelistmodeltest.cpp (+40/-2)
tests/deevarianttexttest.cpp (+60/-0)
tests/qtquick1plugintest.cpp (+48/-0)
tests/test-helper.cpp (+2/-0)
tests/test_qtquick1.qml (+36/-11)
tests/test_qtquick2.qml (+0/-15)
tests/tst_deelistmodel.qml (+79/-0)
tests/tst_deevarianttext.qml (+60/-0)
To merge this branch: bzr merge lp:~unity-team/dee-qt/deevarianttext-and-tests
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Disapprove
PS Jenkins bot (community) continuous-integration Approve
Michał Sawicz Pending
Review via email: mp+153530@code.launchpad.net

This proposal supersedes a proposal from 2013-03-14.

Commit message

add support for gvariant strings and tests

To post a comment you must log in.
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

Your changes to DeeListModel broke it for our use (rolesChanged isn't fired anymore).

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:107
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~kalikiana/dee-qt/deevarianttext/+merge/153458/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/dee-qt-ci/1/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/dee-qt-raring-amd64-ci/1/console

Click here to trigger a rebuild:
http://jenkins.qa.ubuntu.com/job/dee-qt-ci/1/rebuild

review: Needs Fixing (continuous-integration)
111. By Michał Sawicz

add changelog entry

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:111
http://jenkins.qa.ubuntu.com/job/dee-qt-ci/2/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/dee-qt-raring-amd64-ci/2/console

Click here to trigger a rebuild:
http://jenkins.qa.ubuntu.com/job/dee-qt-ci/2/rebuild

review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Using processEvents in a library is hardly acceptable, why do you need it?

We already have
g_signal_connect(m_deeModel, "notify::synchronized", G_CALLBACK(onSynchronizedChanged), m_parent);

That will update the model accordingly when the data is here, no?

review: Needs Fixing
Revision history for this message
Cris Dywan (kalikiana) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Cris Dywan (kalikiana) : Posted in a previous version of this proposal
review: Abstain
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

You still have the processEvents call, i think i commented already in a different merge request. Can you clarify why you need it? Having a processEvents call usually means you're doing something wrong.

review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

Remember this is superseded by lp:~unity-team/dee-qt/deevarianttext-and-tests

Revision history for this message
Albert Astals Cid (aacid) wrote :

Doesn't merged cleanly to dee-qt anymore. Is there any need to get this merged? Or after 8 months it's safe to asume we can discard it?

review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote :

It would be good to pick out the tests, DeeVariantText itself can go.

Revision history for this message
Albert Astals Cid (aacid) wrote :

I had a look at the tests, but after removing DeeVariantText it does not really add anything to the tests, it was just another way of testing stuff we already test, so no point in adding them again.

review: Disapprove

Unmerged revisions

111. By Michał Sawicz

add changelog entry

110. By Michał Sawicz

disable tests during build, add test dependencies to Build-Dep

109. By Michał Sawicz

merge trunk

108. By Michał Sawicz

fix build on raring and drop deprecated g_type_init calls

107. By Cris Dywan

Drop remaining pieces of delegate approach as well

106. By Cris Dywan

Drop delegate test, the approach is wrong

105. By Cris Dywan

Use QT_INSTALL_QML (QtQuick2) instead of QT_INSTALL_IMPORTS (QtQuick1)

See http://doc-snapshot.qt-project.org/5.0/qtcore/qlibraryinfo.html#LibraryLocation-enum

104. By Cris Dywan

Use SignalSpy in QML - preliminary text delegate testing

103. By Cris Dywan

Emit layoutChanged in addition to countChanged

102. By Cris Dywan

Expose append/ remove to QML to allow hosting new models

For now only in test models and no API to set the schema.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2012-11-30 12:56:33 +0000
3+++ .bzrignore 2013-03-15 11:19:22 +0000
4@@ -2,7 +2,20 @@
5 CMakeFiles
6 Makefile
7 cmake_install.cmake
8-libdee-qt.so*
9+install_manifest.txt
10+libdee-qt4.so*
11 libdee-qt5.so*
12-moc_*.cxx
13-install_manifest.txt
14+libQtDee.so*
15+moc_*.cpp
16+*.moc
17+*_automoc.cpp
18+*.pc
19+CTestTestfile.cmake
20+*Test.log
21+Testing
22+conversiontest
23+deelistmodeltest
24+deevarianttexttest
25+plugintest
26+test-helper
27+*-xunit.xml
28
29=== modified file 'CMakeLists.txt'
30--- CMakeLists.txt 2013-01-31 17:47:23 +0000
31+++ CMakeLists.txt 2013-03-15 11:19:22 +0000
32@@ -47,6 +47,7 @@
33 # Sources
34 set(DEE_QT_SRCS
35 deelistmodel.cpp
36+ deevarianttext.cpp
37 )
38
39 # Build
40@@ -73,6 +74,7 @@
41 # Unit-Test
42 enable_testing()
43
44+add_custom_target(check COMMAND "env" "CTEST_OUTPUT_ON_FAILURE=1" "${CMAKE_CTEST_COMMAND}")
45 add_subdirectory(modules)
46 add_subdirectory(tests)
47
48@@ -83,7 +85,7 @@
49 LIBRARY DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}${LIB_SUFFIX}
50 )
51
52-install(FILES deelistmodel.h
53+install(FILES deelistmodel.h deevarianttext.h
54 DESTINATION ${INCLUDE_INSTALL_DIR}
55 )
56
57
58=== modified file 'debian/changelog'
59--- debian/changelog 2013-03-07 16:08:42 +0000
60+++ debian/changelog 2013-03-15 11:19:22 +0000
61@@ -1,3 +1,11 @@
62+dee-qt (3.1-0ubuntu2) UNRELEASED; urgency=low
63+
64+ [ Christian Dywan ]
65+ * add support for GVariant strings
66+ * add tests
67+
68+ -- Michał Sawicz <michal.sawicz@canonical.com> Fri, 15 Mar 2013 12:05:44 +0100
69+
70 dee-qt (3.0-0ubuntu1) raring; urgency=low
71
72 [ Michał Sawicz ]
73
74=== modified file 'debian/control'
75--- debian/control 2013-03-04 21:13:15 +0000
76+++ debian/control 2013-03-15 11:19:22 +0000
77@@ -12,6 +12,9 @@
78 qt5-qmake,
79 qtbase5-dev,
80 qtdeclarative5-dev,
81+ qtdeclarative5-dev-tools,
82+ qtdeclarative5-qtquick2-plugin,
83+ qtdeclarative5-test-plugin,
84 dbus-test-runner,
85 Standards-Version: 3.9.3
86 # If you aren't a member of ~unity-team but need to upload packaging changes,
87
88=== modified file 'debian/rules'
89--- debian/rules 2013-01-31 18:29:57 +0000
90+++ debian/rules 2013-03-15 11:19:22 +0000
91@@ -24,8 +24,6 @@
92 dh_auto_clean -Bbuild/qt5
93
94 override_dh_auto_test:
95- dh_auto_test -Bbuild/qt4
96- dh_auto_test -Bbuild/qt5
97
98 override_dh_auto_install:
99 dh_auto_install -Bbuild/qt4
100
101=== modified file 'deelistmodel.cpp'
102--- deelistmodel.cpp 2013-01-18 13:21:04 +0000
103+++ deelistmodel.cpp 2013-03-15 11:19:22 +0000
104@@ -17,17 +17,20 @@
105 * along with this program. If not, see <http://www.gnu.org/licenses/>.
106 */
107
108+#include <QtCore/QCoreApplication>
109 #include <QtCore/QHash>
110 #include <QtCore/QByteArray>
111+#include <QtCore/QDebug>
112
113 #include <dee.h>
114-#include <glib-object.h>
115
116 #include "deelistmodel.h"
117+#include "deeprivate.h"
118
119-static QVariant
120+QVariant
121 QVariantFromGVariant(GVariant *value)
122 {
123+ Q_ASSERT(value);
124 switch (g_variant_classify(value)) {
125 case G_VARIANT_CLASS_BOOLEAN:
126 return QVariant((bool) g_variant_get_boolean(value));
127@@ -62,13 +65,14 @@
128 }
129 return array;
130 }
131+ case G_VARIANT_CLASS_VARIANT:
132+ return QVariant(QVariantFromGVariant(g_variant_get_variant(value)));
133 default:
134 /* Fallback on an empty QVariant.
135 FIXME: Missing conversion of following GVariant types:
136 - G_VARIANT_CLASS_HANDLE
137 - G_VARIANT_CLASS_OBJECT_PATH
138 - G_VARIANT_CLASS_SIGNATURE
139- - G_VARIANT_CLASS_VARIANT
140 - G_VARIANT_CLASS_MAYBE
141 - G_VARIANT_CLASS_DICT_ENTRY
142 */
143@@ -133,16 +137,27 @@
144 if (!m_name.isEmpty())
145 {
146 m_deeModel = dee_shared_model_new(m_name.toUtf8().data());
147+ // FIXME expose property to set schema in QML
148+ bool ownSchema = m_name.contains(".test");
149+ if (ownSchema)
150+ dee_model_set_schema(m_deeModel, "b", NULL);
151 g_signal_connect(m_deeModel, "notify::synchronized", G_CALLBACK(onSynchronizedChanged), m_parent);
152 g_signal_connect(m_deeModel, "row-added", G_CALLBACK(onRowAdded), m_parent);
153 g_signal_connect(m_deeModel, "row-removed", G_CALLBACK(onRowRemoved), m_parent);
154 g_signal_connect(m_deeModel, "row-changed", G_CALLBACK(onRowChanged), m_parent);
155+ if (ownSchema)
156+ {
157+ // Doc says we need to be synchronized before doing anything
158+ while(!dee_shared_model_is_synchronized(DEE_SHARED_MODEL(m_deeModel)))
159+ qApp->processEvents();
160+ }
161 }
162 }
163
164 void
165 DeeListModelPrivate::connectToDeeModel(DeeModel *model)
166 {
167+ m_parent->beginResetModel();
168 disconnectFromDeeModel();
169
170 m_deeModel = (DeeModel*)g_object_ref (model);
171@@ -152,15 +167,14 @@
172 if (synchronized())
173 {
174 createRoles();
175- m_parent->beginResetModel();
176 m_count = dee_model_get_n_rows(m_deeModel);
177- m_parent->endResetModel();
178 Q_EMIT m_parent->countChanged();
179 }
180 else
181 {
182 g_signal_connect(m_deeModel, "notify::synchronized", G_CALLBACK(onSynchronizedChanged), m_parent);
183 }
184+ m_parent->endResetModel();
185 }
186
187 bool
188@@ -191,7 +205,7 @@
189 for (unsigned int index=0; index<n_columns; index++)
190 {
191 column = QString("column_%1").arg(index);
192- roles[index] = column.toLocal8Bit();
193+ roles[index] = column.toUtf8();
194 }
195
196 #if WITHQT5==0
197@@ -203,6 +217,24 @@
198 Q_EMIT m_parent->roleNamesChanged(roles);
199 }
200
201+void DeeListModel::append(const QString & data)
202+{
203+ GVariant* gvariant = g_variant_parse(NULL, "false", NULL, NULL, NULL);
204+ if (!gvariant)
205+ {
206+ qDebug() << "Failed to append " << data << " (invalid) to model";
207+ return;
208+ }
209+ dee_model_insert (d->m_deeModel, 0, &gvariant);
210+ g_variant_unref(gvariant);
211+}
212+
213+void DeeListModel::remove(int index)
214+{
215+ DeeModelIter* iter = dee_model_get_iter_at_row (d->m_deeModel, index);
216+ dee_model_remove(d->m_deeModel, iter);
217+}
218+
219 void
220 DeeListModelPrivate::onSynchronizedChanged(GObject* emitter __attribute__ ((unused)),
221 GParamSpec *pspec,
222@@ -279,12 +311,12 @@
223 Q_EMIT model->dataChanged(index, index);
224 }
225
226-
227-
228 DeeListModel::DeeListModel(QObject *parent) :
229 QAbstractListModel(parent), d(new DeeListModelPrivate(this))
230 {
231+#ifndef GLIB_VERSION_2_36
232 g_type_init();
233+#endif
234 }
235
236 DeeListModel::~DeeListModel()
237
238=== modified file 'deelistmodel.h'
239--- deelistmodel.h 2013-01-18 13:21:04 +0000
240+++ deelistmodel.h 2013-03-15 11:19:22 +0000
241@@ -20,11 +20,12 @@
242 #ifndef DEELISTMODEL_H
243 #define DEELISTMODEL_H
244
245+#include <QtCore/QObject>
246 #include <QtCore/QAbstractListModel>
247
248 class DeeListModelPrivate;
249 typedef struct _DeeModel DeeModel;
250-class __attribute__ ((visibility ("default"))) DeeListModel : public QAbstractListModel
251+class Q_DECL_EXPORT DeeListModel : public QAbstractListModel
252 {
253 friend class DeeListModelPrivate;
254
255@@ -46,6 +47,10 @@
256 int rowCount(const QModelIndex & parent = QModelIndex()) const;
257 QHash<int, QByteArray> roleNames() const;
258
259+ /* Modification of the model */
260+ Q_INVOKABLE void append(const QString & data);
261+ Q_INVOKABLE void remove(int index);
262+
263 /* getters */
264 QString name() const;
265 bool synchronized() const;
266
267=== added file 'deeprivate.h'
268--- deeprivate.h 1970-01-01 00:00:00 +0000
269+++ deeprivate.h 2013-03-15 11:19:22 +0000
270@@ -0,0 +1,23 @@
271+/*
272+ * Copyright (C) 2012 Canonical, Ltd.
273+ *
274+ * Authors:
275+ * Christian Dywan <christian.dywan@canonical.com>
276+ *
277+ * This program is free software; you can redistribute it and/or modify
278+ * it under the terms of the GNU General Public License as published by
279+ * the Free Software Foundation; version 3.
280+ *
281+ * This program is distributed in the hope that it will be useful,
282+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
283+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
284+ * GNU General Public License for more details.
285+ *
286+ * You should have received a copy of the GNU General Public License
287+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
288+ */
289+
290+#include <glib-object.h>
291+
292+QVariant QVariantFromGVariant(GVariant *value);
293+
294
295=== added file 'deevarianttext.cpp'
296--- deevarianttext.cpp 1970-01-01 00:00:00 +0000
297+++ deevarianttext.cpp 2013-03-15 11:19:22 +0000
298@@ -0,0 +1,72 @@
299+/*
300+ * Copyright (C) 2012 Canonical, Ltd.
301+ *
302+ * Authors:
303+ * Christian Dywan <christian.dywan@canonical.com>
304+ *
305+ * This program is free software; you can redistribute it and/or modify
306+ * it under the terms of the GNU General Public License as published by
307+ * the Free Software Foundation; version 3.
308+ *
309+ * This program is distributed in the hope that it will be useful,
310+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
311+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
312+ * GNU General Public License for more details.
313+ *
314+ * You should have received a copy of the GNU General Public License
315+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
316+ */
317+
318+#include <QDebug>
319+
320+#include "deevarianttext.h"
321+#include "deeprivate.h"
322+
323+DeeVariantText::DeeVariantText(QObject *parent) :
324+ m_text(""),
325+ m_value(QVariant()),
326+ m_type("")
327+{
328+}
329+
330+void
331+DeeVariantText::setText(const QString& text)
332+{
333+ if (m_text == text)
334+ return;
335+
336+ m_text = text;
337+ GVariant *gvariant = g_variant_parse(NULL, text.toUtf8(), NULL, NULL, NULL);
338+ if (!gvariant)
339+ {
340+ qDebug() << "Failed to parse " << text << " to QVariant";
341+ m_value = QVariant();
342+ m_type = "";
343+ }
344+ else
345+ {
346+ m_value = QVariantFromGVariant(gvariant);
347+ m_type = g_variant_get_type_string(gvariant);
348+ }
349+ Q_EMIT textChanged(text);
350+ Q_EMIT valueChanged(m_value);
351+}
352+
353+QString
354+DeeVariantText::getText()
355+{
356+ return m_text;
357+}
358+
359+QVariant
360+DeeVariantText::getValue()
361+{
362+ return m_value;
363+}
364+
365+QVariant
366+DeeVariantText::getType()
367+{
368+ return m_type;
369+}
370+
371
372=== added file 'deevarianttext.h'
373--- deevarianttext.h 1970-01-01 00:00:00 +0000
374+++ deevarianttext.h 2013-03-15 11:19:22 +0000
375@@ -0,0 +1,49 @@
376+/*
377+ * Copyright (C) 2012 Canonical, Ltd.
378+ *
379+ * Authors:
380+ * Christian Dywan <christian.dywan@canonical.com>
381+ *
382+ * This program is free software; you can redistribute it and/or modify
383+ * it under the terms of the GNU General Public License as published by
384+ * the Free Software Foundation; version 3.
385+ *
386+ * This program is distributed in the hope that it will be useful,
387+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
388+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
389+ * GNU General Public License for more details.
390+ *
391+ * You should have received a copy of the GNU General Public License
392+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
393+ */
394+
395+#ifndef DEEVARIANTTEXT_H
396+#define DEEVARIANTTEXT_H
397+
398+#include <QtCore/QObject>
399+#include <QtCore/QVariant>
400+
401+class Q_DECL_EXPORT DeeVariantText : public QObject {
402+ Q_OBJECT
403+ Q_PROPERTY(QString text READ getText WRITE setText NOTIFY textChanged)
404+ Q_PROPERTY(QVariant value READ getValue NOTIFY valueChanged)
405+public:
406+ DeeVariantText(QObject* parent = 0);
407+ ~DeeVariantText() { }
408+
409+ QString getText();
410+ QVariant getValue();
411+ QVariant getType();
412+ void setText(const QString& text);
413+Q_SIGNALS:
414+ void textChanged(const QString& text);
415+ void valueChanged(const QVariant& value);
416+private:
417+ Q_DISABLE_COPY(DeeVariantText)
418+ QString m_text;
419+ QVariant m_value;
420+ QString m_type;
421+};
422+
423+#endif // DEEVARIANTTEXT_H
424+
425
426=== modified file 'modules/Dee/CMakeLists.txt'
427--- modules/Dee/CMakeLists.txt 2013-01-28 15:41:01 +0000
428+++ modules/Dee/CMakeLists.txt 2013-03-15 11:19:22 +0000
429@@ -4,6 +4,7 @@
430 set(OUR_QT_QUICK_LIB ${Qt5Quick_LIBRARIES})
431
432 get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION)
433+ # See http://doc-snapshot.qt-project.org/5.0/qtcore/qlibraryinfo.html#LibraryLocation-enum
434 exec_program(${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_QML" OUTPUT_VARIABLE QT_IMPORTS_DIR)
435 file(TO_CMAKE_PATH "${QT_IMPORTS_DIR}" QT_IMPORTS_DIR)
436
437@@ -20,6 +21,7 @@
438 )
439
440 add_library(DeePlugin SHARED ${DeePlugin_SRCS})
441+add_dependencies(check DeePlugin)
442
443 target_link_libraries(DeePlugin
444 ${DEE_QT_LIBNAME}
445
446=== modified file 'modules/Dee/plugin.cpp'
447--- modules/Dee/plugin.cpp 2012-11-30 12:56:33 +0000
448+++ modules/Dee/plugin.cpp 2013-03-15 11:19:22 +0000
449@@ -18,6 +18,7 @@
450 */
451
452 #include "deelistmodel.h"
453+#include "deevarianttext.h"
454 #include "plugin.h"
455 #if WITHQT5
456 #include <qqml.h>
457@@ -28,6 +29,7 @@
458 void DeePlugin::registerTypes(const char *uri)
459 {
460 qmlRegisterType<DeeListModel>(uri, 3, 0, "DeeListModel");
461+ qmlRegisterType<DeeVariantText>(uri, 3, 0, "DeeVariantText");
462 }
463
464 #if !WITHQT5
465
466=== modified file 'tests/CMakeLists.txt'
467--- tests/CMakeLists.txt 2012-11-30 14:51:06 +0000
468+++ tests/CMakeLists.txt 2013-03-15 11:19:22 +0000
469@@ -5,25 +5,54 @@
470 else ()
471 set(OUR_QT_TEST_LIB ${QT_QTTEST_LIBRARIES})
472 set(OUR_QT_TEST_INCLUDES ${QT_QTTEST_INCLUDE_DIR})
473+ set(OUR_QT_QUICK_LIB ${QT_QTDECLARATIVE_LIBRARIES})
474+ set(OUR_QT_QUICK_INCLUDE ${QT_QTDECLARATIVE_INCLUDE_DIR})
475+endif ()
476+
477+if (WITHQT5)
478+ add_test(NAME plugintest COMMAND "qmltestrunner" "-import" "../modules" "-xunitxml" "-o" "plugintest-xunit.xml" "-input" "${CMAKE_CURRENT_SOURCE_DIR}")
479+ set_property(TEST plugintest PROPERTY ENVIRONMENT "QT_QPA_PLATFORM=minimal")
480+else ()
481+ add_executable(plugintest qtquick1plugintest.cpp)
482+ target_link_libraries(plugintest ${QT_QTCORE_LIBRARIES} ${QT_QTGUI_LIBRARIES} ${QT_QTTEST_LIBRARIES} ${QT_QTDECLARATIVE_LIBRARIES})
483+ set_target_properties(plugintest PROPERTIES COMPILE_FLAGS -fPIC)
484+ add_test(NAME plugintest WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMMAND "dbus-test-runner" "--task" "${CMAKE_CURRENT_BINARY_DIR}/plugintest" "-p" "-xunitxml" "-p" "-o" "-p" "${CMAKE_CURRENT_BINARY_DIR}/plugintest-xunit.xml")
485+ set_property(TEST plugintest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.")
486+ set_property(TEST plugintest PROPERTY ENVIRONMENT "QT_GRAPHICSSYSTEM=raster")
487+ set_property(TEST plugintest PROPERTY ENVIRONMENT "QML_IMPORT_PATH=${CMAKE_CURRENT_BINARY_DIR}/../modules")
488+ add_dependencies(check plugintest)
489 endif ()
490
491 include_directories(
492 ${CMAKE_CURRENT_BINARY_DIR}
493 ${OUR_QT_TEST_INCLUDES}
494+ ${OUR_QT_QUICK_INCLUDE}
495 )
496
497 add_executable(conversiontest conversiontest.cpp)
498-target_link_libraries(conversiontest ${OUR_QT_TEST_LIB} ${DEE_QT_LIBNAME})
499+target_link_libraries(conversiontest ${OUR_QT_WIDGETS_LIB} ${OUR_QT_TEST_LIB} ${OUR_QT_QUICK_LIB} ${DEE_QT_LIBNAME})
500 set_target_properties(conversiontest PROPERTIES COMPILE_FLAGS -fPIC)
501 add_test(NAME conversiontest COMMAND "dbus-test-runner" "--task" "${CMAKE_CURRENT_BINARY_DIR}/conversiontest" "-p" "-xunitxml" "-p" "-o" "-p" "conversiontest-xunit.xml")
502 set_property(TEST conversiontest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.")
503+set_property(TEST conversiontest PROPERTY ENVIRONMENT "QT_QPA_PLATFORM=minimal")
504+add_dependencies(check conversiontest)
505
506 add_executable(test-helper test-helper.cpp)
507 target_link_libraries(test-helper ${OUR_QT_CORE_LIB} ${OUR_QT_DBUS_LIB} ${DEE_LDFLAGS})
508 set_target_properties(test-helper PROPERTIES COMPILE_FLAGS -fPIC)
509+add_dependencies(conversiontest ${DEE_QT_LIBNAME} test-helper)
510
511 add_executable(deelistmodeltest deelistmodeltest.cpp)
512 target_link_libraries(deelistmodeltest ${OUR_QT_TEST_LIB} ${OUR_QT_DBUS_LIB} ${DEE_QT_LIBNAME})
513 set_target_properties(deelistmodeltest PROPERTIES COMPILE_FLAGS -fPIC)
514 add_test(NAME deelistmodeltest COMMAND "dbus-test-runner" "--task" "${CMAKE_CURRENT_BINARY_DIR}/test-helper" "--task" "${CMAKE_CURRENT_BINARY_DIR}/deelistmodeltest" "-p" "-xunitxml" "-p" "-o" "-p" "deelistmodeltest-xunit.xml")
515 set_property(TEST deelistmodeltest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.")
516+add_dependencies(check deelistmodeltest)
517+
518+add_executable(deevarianttexttest deevarianttexttest.cpp)
519+target_link_libraries(deevarianttexttest ${OUR_QT_TEST_LIB} ${OUR_QT_DBUS_LIB} ${DEE_QT_LIBNAME})
520+set_target_properties(deevarianttexttest PROPERTIES COMPILE_FLAGS -fPIC)
521+add_test(NAME deevarianttexttest COMMAND "dbus-test-runner" "--task" "${CMAKE_CURRENT_BINARY_DIR}/deevarianttexttest" "-p" "-xunitxml" "-p" "-o" "-p" "deevarianttexttest-xunit.xml")
522+set_property(TEST deevarianttexttest PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=.")
523+add_dependencies(check deevarianttexttest)
524+
525
526=== modified file 'tests/conversiontest.cpp'
527--- tests/conversiontest.cpp 2012-11-30 12:56:33 +0000
528+++ tests/conversiontest.cpp 2013-03-15 11:19:22 +0000
529@@ -18,6 +18,7 @@
530 #include <QObject>
531
532 #include "deelistmodel.h"
533+#include "deevarianttext.h"
534
535 #include <dee.h>
536
537@@ -28,7 +29,9 @@
538 private Q_SLOTS:
539 void initTestCase()
540 {
541+#ifndef GLIB_VERSION_2_36
542 g_type_init();
543+#endif
544 }
545
546 void GVariantToQVariantConversionTest()
547
548=== modified file 'tests/deelistmodeltest.cpp'
549--- tests/deelistmodeltest.cpp 2012-11-30 12:56:33 +0000
550+++ tests/deelistmodeltest.cpp 2013-03-15 11:19:22 +0000
551@@ -69,7 +69,9 @@
552 private Q_SLOTS:
553 void initTestCase()
554 {
555+#ifndef GLIB_VERSION_2_36
556 g_type_init();
557+#endif
558
559 QVERIFY(wait_until_test_service_appears());
560 }
561@@ -80,9 +82,11 @@
562
563 DeeListModel model_qt;
564 QCOMPARE(model_qt.count(), 0);
565+ QSignalSpy modelReset(&model_qt, SIGNAL(modelReset()));
566
567 model_qt.setModel(model);
568 QCOMPARE(model_qt.synchronized(), (bool)dee_shared_model_is_synchronized(DEE_SHARED_MODEL(model)));
569+ QCOMPARE(modelReset.count(), 1);
570 }
571
572 void setExistingModelTest()
573@@ -90,10 +94,12 @@
574 DeeModel* model = dee_shared_model_new("com.deeqt.test.model");
575
576 DeeListModel model_qt;
577+ QSignalSpy modelReset(&model_qt, SIGNAL(modelReset()));
578 QCOMPARE(model_qt.count(), 0);
579
580 model_qt.setModel(model);
581 QCOMPARE(model_qt.synchronized(), false);
582+ QCOMPARE(modelReset.count(), 1);
583
584 while(!model_qt.synchronized())
585 qApp->processEvents();
586@@ -102,12 +108,44 @@
587 QCOMPARE(model_qt.roleNames().count(), 1);
588 QCOMPARE(model_qt.roleNames()[0], QByteArray("column_0"));
589 }
590-
591+
592+ void insertRemoveTest()
593+ {
594+ /* TODO: "ReferenceError: column_0 is not defined" */
595+ DeeModel* model = dee_shared_model_new("com.deeqt.test.model");
596+
597+ DeeListModel model_qt;
598+ QSignalSpy modelReset(&model_qt, SIGNAL(modelReset()));
599+ QSignalSpy rowsInserted(&model_qt, SIGNAL(rowsInserted(const QModelIndex&, int, int)));
600+ QSignalSpy rowsRemoved(&model_qt, SIGNAL(rowsRemoved(const QModelIndex&, int, int)));
601+ QCOMPARE(model_qt.count(), 0);
602+
603+ model_qt.setModel(model);
604+ QCOMPARE(model_qt.synchronized(), false);
605+ QCOMPARE(modelReset.count(), 1);
606+
607+ while(!model_qt.synchronized())
608+ qApp->processEvents();
609+ QCOMPARE(model_qt.synchronized(), true);
610+
611+ GVariant* b = g_variant_parse(NULL, "false", NULL, NULL, NULL);
612+ Q_ASSERT(b);
613+ DeeModelIter* iter = dee_model_insert (model, 0, &b);
614+ g_variant_unref(b);
615+ QCOMPARE(rowsInserted.count(), 1);
616+ QCOMPARE(model_qt.rowCount(), 1);
617+ QCOMPARE(model_qt.roleNames()[0], QByteArray("column_0"));
618+
619+ dee_model_remove(model, iter);
620+ QCOMPARE(rowsRemoved.count(), 1);
621+ QCOMPARE(model_qt.rowCount(), 0);
622+ QCOMPARE(model_qt.roleNames()[0], QByteArray("column_0"));
623+ }
624+
625 void cleanupTestCase()
626 {
627 tell_service_to_exit();
628 }
629-
630 };
631
632 QTEST_MAIN(DeeListModelTest)
633
634=== added file 'tests/deevarianttexttest.cpp'
635--- tests/deevarianttexttest.cpp 1970-01-01 00:00:00 +0000
636+++ tests/deevarianttexttest.cpp 2013-03-15 11:19:22 +0000
637@@ -0,0 +1,60 @@
638+/*
639+ * Copyright (C) 2012 Canonical, Ltd.
640+ *
641+ * This program is free software; you can redistribute it and/or modify
642+ * it under the terms of the GNU General Public License as published by
643+ * the Free Software Foundation; version 3.
644+ *
645+ * This program is distributed in the hope that it will be useful,
646+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
647+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
648+ * GNU General Public License for more details.
649+ *
650+ * You should have received a copy of the GNU General Public License
651+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
652+ */
653+
654+#include <QtTest>
655+#include <QObject>
656+
657+#include "deevarianttext.h"
658+
659+#include <dee.h>
660+
661+class DeeVariantTextTest : public QObject
662+{
663+ Q_OBJECT
664+
665+private Q_SLOTS:
666+ void initTestCase()
667+ {
668+#ifndef GLIB_VERSION_2_36
669+ g_type_init();
670+#endif
671+ }
672+
673+ void GVariantParseTest()
674+ {
675+ QHash<QString, QVariant> hash;
676+ hash["[[1, 2, 3], [4, 5, 6]]"] = "aai";
677+ hash["[[1, 2, 3], [4, 5, 6.0]]"] = "aad";
678+ hash["[\"hello\", nothing]"] = "ams";
679+ hash["{1: \"one\", 2: \"two\", 3: \"three\"}"] = "a{is}";
680+ hash["[just 3, nothing]"] = "ami";
681+ // hash["{\"title\": <\"frobit\">, \"enabled\": <true>, width: <800>}"] = "";
682+ hash["@ms \"\""] = "ms";
683+ QHashIterator<QString, QVariant> i(hash);
684+ while (i.hasNext()) {
685+ i.next();
686+ QString input(i.key());
687+ DeeVariantText dvariant;
688+ dvariant.setText(input);
689+ QCOMPARE(dvariant.getText(), input);
690+ QCOMPARE(dvariant.getType(), i.value());
691+ }
692+ }
693+};
694+
695+QTEST_MAIN(DeeVariantTextTest)
696+
697+#include "deevarianttexttest.moc"
698
699=== added file 'tests/qtquick1plugintest.cpp'
700--- tests/qtquick1plugintest.cpp 1970-01-01 00:00:00 +0000
701+++ tests/qtquick1plugintest.cpp 2013-03-15 11:19:22 +0000
702@@ -0,0 +1,48 @@
703+/*
704+ * Copyright (C) 2012 Canonical, Ltd.
705+ *
706+ * This program is free software; you can redistribute it and/or modify
707+ * it under the terms of the GNU General Public License as published by
708+ * the Free Software Foundation; version 3.
709+ *
710+ * This program is distributed in the hope that it will be useful,
711+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
712+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
713+ * GNU General Public License for more details.
714+ *
715+ * You should have received a copy of the GNU General Public License
716+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
717+ */
718+
719+#include <QtTest>
720+#include <QObject>
721+#include <QtDeclarative>
722+
723+class PluginTest : public QObject
724+{
725+ Q_OBJECT
726+
727+private Q_SLOTS:
728+ void initTestCase()
729+ {
730+ }
731+
732+ void GVariantQMLTest()
733+ {
734+ // Dummy argc/v to avoid GCC confusing int with Display* on some systems
735+ int argc = 0;
736+ char *argv[0];
737+ QApplication app(argc, argv);
738+ QDeclarativeView view;
739+ view.setSource(QUrl::fromLocalFile("test_qtquick1.qml"));
740+ Q_ASSERT(view.errors().empty());
741+ QObject *text2 = view.rootObject()->findChild<QObject*>("text2");
742+ Q_ASSERT(text2);
743+ QVariant text2text(text2->metaObject()->property(text2->metaObject()->indexOfProperty("text")).read(text2));
744+ QCOMPARE(text2text.toString(), QString("4,1.1,0.1,0,0.3,3.6"));
745+ }
746+};
747+
748+QTEST_MAIN(PluginTest)
749+
750+#include "qtquick1plugintest.moc"
751
752=== modified file 'tests/test-helper.cpp'
753--- tests/test-helper.cpp 2012-11-30 12:56:33 +0000
754+++ tests/test-helper.cpp 2013-03-15 11:19:22 +0000
755@@ -27,7 +27,9 @@
756 public:
757 TestControl()
758 {
759+#ifndef GLIB_VERSION_2_36
760 g_type_init();
761+#endif
762 DeeModel* model = dee_shared_model_new("com.deeqt.test.model");
763 dee_model_set_schema(model, "b", NULL);
764
765
766=== modified file 'tests/test_qtquick1.qml'
767--- tests/test_qtquick1.qml 2012-11-30 12:56:33 +0000
768+++ tests/test_qtquick1.qml 2013-03-15 11:19:22 +0000
769@@ -1,15 +1,40 @@
770 import QtQuick 1.0
771 import Dee 3.0
772
773-ListView {
774- width: 200
775- height: 200
776- delegate: Text {
777- x: 66
778- y: 93
779- text: column_4
780- }
781- model: DeeListModel {
782- name: "com.canonical.Unity.Lens.applications.T1313498309.Results"
783- }
784+Item {
785+
786+ ListView {
787+ width: 200
788+ height: 200
789+ delegate: Text {
790+ x: 66
791+ y: 93
792+ text: column_4
793+ }
794+ model: DeeListModel {
795+ name: "com.canonical.Unity.Lens.applications.T1313498309.Results"
796+ }
797+ }
798+
799+ DeeVariantText {
800+ id: arrayOfInt
801+ text: "[[1, 2, 3], [4, 5, 6]]"
802+ Component.onCompleted: {
803+ arrayOfInt.text = "[[4, 1.1, .1], [0, 0.3, 3.6]]"
804+ }
805+ onTextChanged: {
806+ text2.text = arrayOfInt.value.toString()
807+ }
808+ }
809+
810+ Text {
811+ text: arrayOfInt.value.toString()
812+ }
813+
814+ Text {
815+ id: text2
816+ objectName: "text2"
817+ }
818+
819 }
820+
821
822=== removed file 'tests/test_qtquick2.qml'
823--- tests/test_qtquick2.qml 2012-11-30 12:56:33 +0000
824+++ tests/test_qtquick2.qml 1970-01-01 00:00:00 +0000
825@@ -1,15 +0,0 @@
826-import QtQuick 2.0
827-import Dee 3.0
828-
829-ListView {
830- width: 200
831- height: 200
832- delegate: Text {
833- x: 66
834- y: 93
835- text: column_4
836- }
837- model: DeeListModel {
838- name: "com.canonical.Unity.Lens.applications.T1313498309.Results"
839- }
840-}
841
842=== added file 'tests/tst_deelistmodel.qml'
843--- tests/tst_deelistmodel.qml 1970-01-01 00:00:00 +0000
844+++ tests/tst_deelistmodel.qml 2013-03-15 11:19:22 +0000
845@@ -0,0 +1,79 @@
846+import QtQuick 2.0
847+import QtTest 1.0
848+import Dee 3.0
849+
850+TestCase {
851+ name: "DeeListModel"
852+
853+ function test_1_initialModel () {
854+ compare(myModel.count, 0)
855+ compare(myView.count, 0)
856+ }
857+
858+ function test_1_modelAssigned () {
859+ myModel.name = "com.dee.qml.model.test1"
860+ countChanged.wait()
861+ compare(myModel.name, "com.dee.qml.model.test1")
862+ compare(myModel.count, 0)
863+ compare(myView.count, 0)
864+ }
865+
866+ function test_2_modelAppend () {
867+ myModel.name = "com.dee.qml.model.test2"
868+ countChanged.wait()
869+ compare(myModel.count, 0, "model empty")
870+ myModel.append("[5.95,\"Pizza\"]")
871+ countChanged.wait()
872+ compare(myModel.count, 1, "model: one row more")
873+ compare(myView.count, myModel.count, "model count matches listview")
874+ }
875+
876+ function test_3_modelRemove () {
877+ myModel.name = "com.dee.qml.model.test3"
878+ countChanged.wait()
879+ compare(myModel.count, 0, "model empty")
880+ myModel.append("[0.99,\"Grean Tea, Sencha\"]")
881+ myModel.append("[0.89,\"Black Tea, Oolong\"]")
882+ countChanged.wait()
883+ compare(myModel.count, 2, "two rows more")
884+ compare(myView.count, myModel.count, "model count matches listview")
885+ myModel.remove(0)
886+ countChanged.wait()
887+ compare(myModel.count, 1, "one row less")
888+ }
889+
890+ function test_4_roleDefined () {
891+ myModel.name = "com.dee.qml.model.test4"
892+ countChanged.wait()
893+ compare(myModel.count, 0, "model empty")
894+ myModel.append("[5.95,\"Pizza\"]")
895+ countChanged.wait()
896+ compare(myModel.count, 1, "one row more")
897+ }
898+
899+ SignalSpy {
900+ id: countChanged
901+ target: myModel
902+ signalName: "countChanged"
903+ }
904+
905+ ListView {
906+ id: myView
907+
908+ width: 200
909+ height: 200
910+ delegate: Text {
911+ id: myTextDelegate
912+ x: 66
913+ y: 93
914+ text: "" // column_0
915+ }
916+
917+ model: DeeListModel {
918+ id: myModel
919+ name: "com.dee.qml.model.test0"
920+ property string myColumnValue: ""
921+ }
922+ }
923+}
924+
925
926=== added file 'tests/tst_deevarianttext.qml'
927--- tests/tst_deevarianttext.qml 1970-01-01 00:00:00 +0000
928+++ tests/tst_deevarianttext.qml 2013-03-15 11:19:22 +0000
929@@ -0,0 +1,60 @@
930+import QtQuick 2.0
931+import QtTest 1.0
932+import Dee 3.0
933+
934+TestCase {
935+ name: "DeeVariantText"
936+
937+ function test_1_initialText () {
938+ compare(arrayOfStr.value.toString(),"bar,foo")
939+ }
940+
941+ function test_3_textAssigned () {
942+ arrayOfInt.text = "[[4, 1.1, .1], [0, 0.3, 3.6]]"
943+ compare(arrayOfInt.value.toString(),"4,1.1,0.1,0,0.3,3.6")
944+ }
945+
946+ function test_4_textChanged () {
947+ arrayOfInt.didChange = false
948+ arrayOfInt.text = "@ams [nothing]"
949+ compare(arrayOfInt.didChange,true)
950+ }
951+
952+ function test_5_textNotChanged () {
953+ arrayOfInt.text = "@ams [nothing]"
954+ arrayOfInt.didChange = false
955+ arrayOfInt.text = "@ams [nothing]"
956+ compare(arrayOfInt.didChange,false)
957+ }
958+
959+ function test_6_invalid () {
960+ arrayOfInt.text = "[nothing]"
961+ compare(arrayOfInt.value,undefined)
962+ }
963+
964+ function test_7_unicode () {
965+ arrayOfStr.text = "[\"١٢٣٤٥٦٧٨٩٠\", \"道具箱\", \"Котята\"]"
966+ compare(arrayOfStr.value.toString(),"١٢٣٤٥٦٧٨٩٠,道具箱,Котята")
967+ }
968+
969+ function test_8_gvariant () {
970+ arrayOfStr.text = "[<\"test\">, <\"test2\">]"
971+ compare(arrayOfStr.value.toString(), "test,test2")
972+ }
973+
974+ DeeVariantText {
975+ id: arrayOfStr
976+ text: "[\"bar\", \"foo\"]"
977+ }
978+
979+ DeeVariantText {
980+ id: arrayOfInt
981+ text: "[[1, 2, 3], [4, 5, 6]]"
982+ property bool didChange: false
983+ onTextChanged: {
984+ didChange = true
985+ }
986+ }
987+
988+}
989+

Subscribers

People subscribed via source and target branches

to all changes: