Debian Codegraph @

tests/online-accounts-client/lib/tst_qml_client/tst_qml_client.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2013 Canonical Ltd.
3 *
4 * Contact: Alberto Mardegan <[email protected]>
5 *
6 * This file is part of OnlineAccountsClient.
7 *
8 * OnlineAccountsClient is free software: you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License as
10 * published by the Free Software Foundation, either version 3 of the
11 * License, or (at your option) any later version.
12 *
13 * OnlineAccountsClient is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with OnlineAccountsClient. If not, see
20 * <http://www.gnu.org/licenses/>.
21 */
22
23 #include <online-accounts-common/globals.h>cxx . . $ `<file>/online-accounts-common/globals.h`/
24
25 #include <QDBusConnection>
26 #include <QDebug>
27 #include <QQmlComponent>
28 #include <QQmlContext>
29 #include <QQmlEngine>
30 #include <QQmlError>
31 #include <QSignalSpy>
32 #include <QTest>
33
34 class Servicecxx . . $ Service#: public QObjectcxx . . $ QObject#
35 {
36 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
37 Q_CLASSINFOcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:100:10`!("D-Bus Interface",
38 "com.lomiri.OnlineAccountsUi")
39
40 public:
41 Servicecxx . . $ Service#Service(49f6e7a06ebc5aa8).(): QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).() {}
42 QVariantMapcxx . . $ QVariantMap# optionscxx . . $ Service#options(87f780dbe64191c4).() const { return m_optionscxx . . $ QMap#QMap(21739d87639e1d56).; }
43
44 public Q_SLOTScxx . . $ `<external>/1208926524888476972/qobjectdefs.h:92:10`!:
45 QVariantMapcxx . . $ QVariantMap# requestAccesscxx . . $ Service#requestAccess(52377bf93f9fc760).(const QVariantMapcxx . . $ QVariantMap# &options) {
46 m_optionscxx . . $ Service#m_options. =cxx . . $ QMap#`operator=`(9a30e17cbbb0999d). options;
47 return QVariantMapcxx . . $ QMap#QMap(ced63f7c635d850d).();
48 }
49
50 private:
51 QVariantMapcxx . . $ QVariantMap# m_optionscxx . . $ Service#m_options.;
52 };
53
54 class SetupTestcxx . . $ SetupTest#: public QObjectcxx . . $ QObject#
55 {
56 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
57
58 public:
59 SetupTestcxx . . $ SetupTest#SetupTest(49f6e7a06ebc5aa8).();
60 QVariantMapcxx . . $ QVariantMap# optionscxx . . $ SetupTest#options(87f780dbe64191c4).() const { return m_servicecxx . . $ SetupTest#m_service..optionscxx . . $ Service#options(87f780dbe64191c4).(); }
61
62 private Q_SLOTScxx . . $ `<external>/1208926524888476972/qobjectdefs.h:92:10`!:
63 void initTestCasecxx . . $ SetupTest#initTestCase(49f6e7a06ebc5aa8).();
64 void testLoadPlugincxx . . $ SetupTest#testLoadPlugin(49f6e7a06ebc5aa8).();
65 void testPropertiescxx . . $ SetupTest#testProperties(49f6e7a06ebc5aa8).();
66 void testVersions_datacxx . . $ SetupTest#testVersions_data(49f6e7a06ebc5aa8).();
67 void testVersionscxx . . $ SetupTest#testVersions(49f6e7a06ebc5aa8).();
68 void testExeccxx . . $ SetupTest#testExec(49f6e7a06ebc5aa8).();
69 void testExecWithServiceTypecxx . . $ SetupTest#testExecWithServiceType(49f6e7a06ebc5aa8).();
70
71 private:
72 Servicecxx . . $ Service# m_servicecxx . . $ SetupTest#m_service.;
73 };
74
75 SetupTestcxx . . $ SetupTest#::SetupTestcxx . . $ SetupTest#SetupTest(49f6e7a06ebc5aa8).():
76 QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(0)
77 {
78 }
79
80 void SetupTestcxx . . $ SetupTest#::initTestCasecxx . . $ SetupTest#initTestCase(49f6e7a06ebc5aa8).()
81 {
82 qputenvcxx . . $ qputenv(d42e8231112a1b5b).("QML2_IMPORT_PATH", PLUGIN_PATHcxx . . $ `<built-in>:476:9`!);
83 QDBusConnectioncxx . . $ QDBusConnection# connection = QDBusConnectioncxx . . $ QDBusConnection#::sessionBuscxx . . $ QDBusConnection#sessionBus(45d475f1888103b2).();
84 connection.registerObjectcxx . . $ QDBusConnection#registerObject(3ca2fdce2ef96dc8).(OAU_OBJECT_PATHcxx . . $ `online-accounts-common/globals.h:26:9`!, &m_servicecxx . . $ SetupTest#m_service.,
85 QDBusConnectioncxx . . $ QFlags#QFlags(93d577a3e9528307).::ExportAllContentscxx . . $ QDBusConnection#ExportAllContents.);
86 connection.registerServicecxx . . $ QDBusConnection#registerService(e1defb592416720d).(OAU_SERVICE_NAMEcxx . . $ `online-accounts-common/globals.h:25:9`!);
87 }
88
89 void SetupTestcxx . . $ SetupTest#::testLoadPlugincxx . . $ SetupTest#testLoadPlugin(49f6e7a06ebc5aa8).()
90 {
91 QQmlEnginecxx . . $ QQmlEngine# enginecxx . . $ QQmlEngine#QQmlEngine(749de1b6ae65bddd).;
92 QQmlComponentcxx . . $ QQmlComponent# componentcxx . . $ QQmlComponent#QQmlComponent(1ee7362edd1472d8).(&engine);
93 component.setDatacxx . . $ QQmlComponent#setData(5306e72aa2a49a1c).("import Lomiri.OnlineAccounts.Client 0.1\n"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).
94 "Setup {}",
95 QUrlcxx . . $ QUrl#QUrl(49f6e7a06ebc5aa8).());
96 QObjectcxx . . $ QObject# *object = component.createcxx . . $ QQmlComponent#create(1adc5df52fdd8588).();
97 if (component.isErrorcxx . . $ QQmlComponent#isError(50ce9a9e25b4a850).()) {
98 Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(const QQmlError &error, component.errors()) {
99 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ `operator<<`(a29fb1dce5b33336). error;
100 }
101 }
102 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(object != 0);
103 delete object;
104 }
105
106 void SetupTestcxx . . $ SetupTest#::testPropertiescxx . . $ SetupTest#testProperties(49f6e7a06ebc5aa8).()
107 {
108 QQmlEnginecxx . . $ QQmlEngine# enginecxx . . $ QQmlEngine#QQmlEngine(749de1b6ae65bddd).;
109 QQmlComponentcxx . . $ QQmlComponent# componentcxx . . $ QQmlComponent#QQmlComponent(1ee7362edd1472d8).(&engine);
110 component.setDatacxx . . $ QQmlComponent#setData(5306e72aa2a49a1c).("import Lomiri.OnlineAccounts.Client 0.2\n"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).
111 "Setup { providerId: \"hello\" }",
112 QUrlcxx . . $ QUrl#QUrl(49f6e7a06ebc5aa8).());
113 QObjectcxx . . $ QObject# *object = component.createcxx . . $ QQmlComponent#create(1adc5df52fdd8588).();
114 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(object != 0);
115
116 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(object->property("providerId").toString(), QString("hello"));
117 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(object->property("serviceTypeId").toString(), QString());
118
119 object->setPropertycxx . . $ QObject#setProperty(395943cdf6cf5058).("providerId", QStringcxx . . $ QVariant#QVariant(3520e46b33348bf6).("ciao"));
120 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(object->property("providerId").toString(), QString("ciao"));
121
122 object->setPropertycxx . . $ QObject#setProperty(395943cdf6cf5058).("serviceTypeId", QStringcxx . . $ QVariant#QVariant(3520e46b33348bf6).("hi"));
123 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(object->property("serviceTypeId").toString(), QString("hi"));
124
125 object->setPropertycxx . . $ QObject#setProperty(395943cdf6cf5058).("serviceId", QStringcxx . . $ QVariant#QVariant(3520e46b33348bf6).("bonjour"));
126 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(object->property("serviceId").toString(), QString("bonjour"));
127
128 delete object;
129 }
130
131 void SetupTestcxx . . $ SetupTest#::testVersions_datacxx . . $ SetupTest#testVersions_data(49f6e7a06ebc5aa8).()
132 {
133 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("qmlCode");
134 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<bool>("mustBuild");
135
136 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("0.1, regular") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
137 "import Lomiri.OnlineAccounts.Client 0.1\n"
138 "Setup {\n"
139 " providerId: \"hello\"\n"
140 " serviceTypeId: \"something\"\n"
141 "}" <<cxx . . $ `operator<<`(61fb880f51a53ddf).
142 true;
143
144 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("0.1, newer prop") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
145 "import Lomiri.OnlineAccounts.Client 0.1\n"
146 "Setup {\n"
147 " providerId: \"hello\"\n"
148 " serviceTypeId: \"something\"\n"
149 " serviceId: \"wishful\"\n"
150 "}" <<cxx . . $ `operator<<`(61fb880f51a53ddf).
151 false;
152
153 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("0.2, newer prop") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
154 "import Lomiri.OnlineAccounts.Client 0.2\n"
155 "Setup {\n"
156 " providerId: \"hello\"\n"
157 " serviceTypeId: \"something\"\n"
158 " serviceId: \"yes we can\"\n"
159 "}" <<cxx . . $ `operator<<`(61fb880f51a53ddf).
160 true;
161 }
162
163 void SetupTestcxx . . $ SetupTest#::testVersionscxx . . $ SetupTest#testVersions(49f6e7a06ebc5aa8).()
164 {
165 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, qmlCode);
166 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(bool, mustBuild);
167
168 if (!mustBuild) {
169 QTestcxx . . $ QTest/::ignoreMessagecxx . . $ QTest/ignoreMessage(fe94d6192f2696f8).(QtWarningMsgcxx . . $ QtWarningMsg.,
170 "QQmlComponent: Component is not ready");
171 }
172
173 QQmlEnginecxx . . $ QQmlEngine# enginecxx . . $ QQmlEngine#QQmlEngine(749de1b6ae65bddd).;
174 QQmlComponentcxx . . $ QQmlComponent# componentcxx . . $ QQmlComponent#QQmlComponent(1ee7362edd1472d8).(&engine);
175 component.setDatacxx . . $ QQmlComponent#setData(5306e72aa2a49a1c).(qmlCode.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).(), QUrlcxx . . $ QUrl#QUrl(49f6e7a06ebc5aa8).());
176 QObjectcxx . . $ QObject# *object = component.createcxx . . $ QQmlComponent#create(1adc5df52fdd8588).();
177 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(object != 0, mustBuild);
178
179 delete object;
180 }
181
182 void SetupTestcxx . . $ SetupTest#::testExeccxx . . $ SetupTest#testExec(49f6e7a06ebc5aa8).()
183 {
184 QQmlEnginecxx . . $ QQmlEngine# enginecxx . . $ QQmlEngine#QQmlEngine(749de1b6ae65bddd).;
185 QQmlComponentcxx . . $ QQmlComponent# componentcxx . . $ QQmlComponent#QQmlComponent(1ee7362edd1472d8).(&engine);
186 component.setDatacxx . . $ QQmlComponent#setData(5306e72aa2a49a1c).("import Lomiri.OnlineAccounts.Client 0.1\n"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).
187 "Setup {}",
188 QUrlcxx . . $ QUrl#QUrl(49f6e7a06ebc5aa8).());
189 QObjectcxx . . $ QObject# *object = component.createcxx . . $ QQmlComponent#create(1adc5df52fdd8588).();
190 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(object != 0);
191
192 QSignalSpycxx . . $ QSignalSpy# finishedcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(object, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(finished(QVariantMap)));
193 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(QMetaObject::invokeMethod(object, "exec"));
194
195 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(finished.wait());
196 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(options().contains(OAU_KEY_PROVIDERcxx . . $ `online-accounts-common/globals.h:30:9`!), false);
197 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(options().contains(OAU_KEY_SERVICE_TYPEcxx . . $ `online-accounts-common/globals.h:32:9`!), false);
198 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(options().contains(OAU_KEY_SERVICE_IDcxx . . $ `online-accounts-common/globals.h:31:9`!), false);
199 }
200
201 void SetupTestcxx . . $ SetupTest#::testExecWithServiceTypecxx . . $ SetupTest#testExecWithServiceType(49f6e7a06ebc5aa8).()
202 {
203 QQmlEnginecxx . . $ QQmlEngine# enginecxx . . $ QQmlEngine#QQmlEngine(749de1b6ae65bddd).;
204 QQmlComponentcxx . . $ QQmlComponent# componentcxx . . $ QQmlComponent#QQmlComponent(1ee7362edd1472d8).(&engine);
205 component.setDatacxx . . $ QQmlComponent#setData(5306e72aa2a49a1c).("import Lomiri.OnlineAccounts.Client 0.1\n"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).
206 "Setup { serviceTypeId: \"e-mail\" }",
207 QUrlcxx . . $ QUrl#QUrl(49f6e7a06ebc5aa8).());
208 QObjectcxx . . $ QObject# *object = component.createcxx . . $ QQmlComponent#create(1adc5df52fdd8588).();
209 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(object != 0);
210
211 QSignalSpycxx . . $ QSignalSpy# finishedcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(object, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(finished(QVariantMap)));
212 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(QMetaObject::invokeMethod(object, "exec"));
213
214 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(finished.wait());
215 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(options().value(OAU_KEY_SERVICE_TYPEcxx . . $ `online-accounts-common/globals.h:32:9`!).toString(),
216 QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("e-mail"));
217 }
218
219 QTEST_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:508:9`!(SetupTest);
220
221 #include "tst_qml_client.moc"cxx . . $ `<file>/build/tests/online-accounts-client/lib/tst_qml_client/tst_qml_client_autogen/include/tst_qml_client.moc`/