Merge lp:~kalikiana/dee-qt/deevarianttext into lp:dee-qt

Proposed by Michał Sawicz
Status: Superseded
Proposed branch: lp:~kalikiana/dee-qt/deevarianttext
Merge into: lp:dee-qt
Prerequisite: lp:~saviq/dee-qt/rename-libs
Diff against target: 1021 lines (+608/-48) (has conflicts)
18 files modified
.bzrignore (+15/-2)
CMakeLists.txt (+12/-1)
deelistmodel.cpp (+70/-13)
deelistmodel.h (+7/-2)
deeprivate.h (+23/-0)
deevarianttext.cpp (+72/-0)
deevarianttext.h (+49/-0)
modules/Dee/CMakeLists.txt (+7/-1)
modules/Dee/plugin.cpp (+2/-0)
tests/CMakeLists.txt (+29/-1)
tests/conversiontest.cpp (+1/-0)
tests/deelistmodeltest.cpp (+40/-2)
tests/deevarianttexttest.cpp (+58/-0)
tests/qtquick1plugintest.cpp (+48/-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)
Text conflict in CMakeLists.txt
Text conflict in deelistmodel.cpp
Text conflict in modules/Dee/CMakeLists.txt
To merge this branch: bzr merge lp:~kalikiana/dee-qt/deevarianttext
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Needs Fixing
Cris Dywan (community) Abstain
PS Jenkins bot (community) continuous-integration Needs Fixing
Michał Sawicz Pending
Review via email: mp+153458@code.launchpad.net

This proposal supersedes a proposal from 2012-12-04.

This proposal has been superseded by a proposal from 2013-03-15.

Commit message

Drop delegate test, the approach is wrong

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 :

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)
Revision history for this message
Cris Dywan (kalikiana) :
review: Approve
Revision history for this message
Cris Dywan (kalikiana) :
review: Abstain
Revision history for this message
Albert Astals Cid (aacid) wrote :

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 :

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

Unmerged revisions

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.

101. By Cris Dywan

Use QSignalSpy instead of manual callbacks to verify signals

100. By Cris Dywan

Fixup insertRemoveTest

99. By Cris Dywan

Add insertRemoveTest (needs improvement)

98. By Cris Dywan

Fix running deevarianttexttest

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

Subscribers

People subscribed via source and target branches

to all changes: