Debian Codegraph @

tests/click-hooks/online-accounts-hooks/tst_online_accounts_hooks.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2014 Canonical Ltd.
3 *
4 * Contact: Alberto Mardegan <[email protected]>
5 *
6 * This file is part of lomiri-online-accounts-ui
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include <Accounts/Account>
22 #include <Accounts/Manager>
23 #include <QDebug>
24 #include <QDir>
25 #include <QDomDocument>
26 #include <QDomElement>
27 #include <QFile>
28 #include <QProcess>
29 #include <QSignalSpy>
30 #include <QTest>
31 #include <sys/types.h>
32 #include <time.h>
33 #include <utime.h>
34
35 #define TEST_DIRcxx . . $ `tests/click-hooks/online-accounts-hooks/tst_online_accounts_hooks.cpp:35:9`! TMP_DIRcxx . . $ `<built-in>:482:9`! "/hooks-test"
36
37 class OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#: public QObjectcxx . . $ QObject#
38 {
39 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
40
41 public:
42 OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#OnlineAccountsHooksTest(49f6e7a06ebc5aa8).();
43
44 private Q_SLOTScxx . . $ `<external>/1208926524888476972/qobjectdefs.h:92:10`!:
45 void initTestCasecxx . . $ OnlineAccountsHooksTest#initTestCase(49f6e7a06ebc5aa8).();
46 void testNoFilescxx . . $ OnlineAccountsHooksTest#testNoFiles(49f6e7a06ebc5aa8).();
47 void testValidHooks_datacxx . . $ OnlineAccountsHooksTest#testValidHooks_data(49f6e7a06ebc5aa8).();
48 void testValidHookscxx . . $ OnlineAccountsHooksTest#testValidHooks(49f6e7a06ebc5aa8).();
49 void testRemovalcxx . . $ OnlineAccountsHooksTest#testRemoval(49f6e7a06ebc5aa8).();
50 void testAccountRemovalcxx . . $ OnlineAccountsHooksTest#testAccountRemoval(49f6e7a06ebc5aa8).();
51 void testUpdatecxx . . $ OnlineAccountsHooksTest#testUpdate(49f6e7a06ebc5aa8).();
52 void testDesktopEntry_datacxx . . $ OnlineAccountsHooksTest#testDesktopEntry_data(49f6e7a06ebc5aa8).();
53 void testDesktopEntrycxx . . $ OnlineAccountsHooksTest#testDesktopEntry(49f6e7a06ebc5aa8).();
54 void testServiceType_datacxx . . $ OnlineAccountsHooksTest#testServiceType_data(49f6e7a06ebc5aa8).();
55 void testServiceTypecxx . . $ OnlineAccountsHooksTest#testServiceType(49f6e7a06ebc5aa8).();
56
57 private:
58 void clearHooksDircxx . . $ OnlineAccountsHooksTest#clearHooksDir(49f6e7a06ebc5aa8).();
59 void clearInstallDircxx . . $ OnlineAccountsHooksTest#clearInstallDir(49f6e7a06ebc5aa8).();
60 bool runHookProcesscxx . . $ OnlineAccountsHooksTest#runHookProcess(c9857a73d68e59ba).();
61 void writeHookFilecxx . . $ OnlineAccountsHooksTest#writeHookFile(c1427772cd1877b0).(const QStringcxx . . $ QString# &name, const QStringcxx . . $ QString# &contents);
62 void writeInstalledFilecxx . . $ OnlineAccountsHooksTest#writeInstalledFile(c1427772cd1877b0).(const QStringcxx . . $ QString# &name, const QStringcxx . . $ QString# &contents);
63 void writePackageFilecxx . . $ OnlineAccountsHooksTest#writePackageFile(c1427772cd1877b0).(const QStringcxx . . $ QString# &name,
64 const QStringcxx . . $ QString# &contents = QStringcxx . . $ QString#QString(ced63f7c635d850d).());
65
66 private:
67 QDircxx . . $ QDir# m_testDircxx . . $ OnlineAccountsHooksTest#m_testDir.;
68 QDircxx . . $ QDir# m_hooksDircxx . . $ OnlineAccountsHooksTest#m_hooksDir.;
69 QDircxx . . $ QDir# m_installDircxx . . $ OnlineAccountsHooksTest#m_installDir.;
70 QDircxx . . $ QDir# m_packageDircxx . . $ OnlineAccountsHooksTest#m_packageDir.;
71 };
72
73 OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#OnlineAccountsHooksTest(49f6e7a06ebc5aa8).():
74 QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(0),
75 m_testDircxx . . $ OnlineAccountsHooksTest#m_testDir.(TEST_DIRcxx . . $ `tests/click-hooks/online-accounts-hooks/tst_online_accounts_hooks.cpp:35:9`!),
76 m_hooksDircxx . . $ OnlineAccountsHooksTest#m_hooksDir.(TEST_DIRcxx . . $ `tests/click-hooks/online-accounts-hooks/tst_online_accounts_hooks.cpp:35:9`! "/lomiri-online-accounts-hooks"),
77 m_installDircxx . . $ OnlineAccountsHooksTest#m_installDir.(TEST_DIRcxx . . $ `tests/click-hooks/online-accounts-hooks/tst_online_accounts_hooks.cpp:35:9`! "/accounts"),
78 m_packageDircxx . . $ OnlineAccountsHooksTest#m_packageDir.(TEST_DIRcxx . . $ `tests/click-hooks/online-accounts-hooks/tst_online_accounts_hooks.cpp:35:9`! "/package")
79 {
80 }
81
82 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::clearHooksDircxx . . $ OnlineAccountsHooksTest#clearHooksDir(49f6e7a06ebc5aa8).()
83 {
84 m_hooksDircxx . . $ OnlineAccountsHooksTest#m_hooksDir..removeRecursivelycxx . . $ QDir#removeRecursively(c9857a73d68e59ba).();
85 m_hooksDircxx . . $ OnlineAccountsHooksTest#m_hooksDir..mkpathcxx . . $ QDir#mkpath(f3b39adf77d9c36c).("."cxx . . $ QString#QString(85c52e162fed56f9).);
86 }
87
88 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::clearInstallDircxx . . $ OnlineAccountsHooksTest#clearInstallDir(49f6e7a06ebc5aa8).()
89 {
90 m_installDircxx . . $ OnlineAccountsHooksTest#m_installDir..removeRecursivelycxx . . $ QDir#removeRecursively(c9857a73d68e59ba).();
91 m_installDircxx . . $ OnlineAccountsHooksTest#m_installDir..mkpathcxx . . $ QDir#mkpath(f3b39adf77d9c36c).("."cxx . . $ QString#QString(85c52e162fed56f9).);
92 }
93
94 bool OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::runHookProcesscxx . . $ OnlineAccountsHooksTest#runHookProcess(c9857a73d68e59ba).()
95 {
96 QProcesscxx . . $ QProcess# processcxx . . $ QProcess#QProcess(749de1b6ae65bddd).;
97 process.setProcessChannelModecxx . . $ QProcess#setProcessChannelMode(325e95cd0c77e646).(QProcesscxx . . $ QProcess#::ForwardedChannelscxx . . $ QProcess#ForwardedChannels.);
98 process.startcxx . . $ QProcess#start(8f4bc4a0c00c3d3f).(HOOK_PROCESScxx . . $ `<built-in>:476:9`!);
99 if (!process.waitForFinishedcxx . . $ QProcess#waitForFinished(83c267b20bac841a).()) return false;
100
101 return process.exitCodecxx . . $ QProcess#exitCode(455f465bc33b4cdf).() == EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:93:9`!;
102 }
103
104 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::writeHookFilecxx . . $ OnlineAccountsHooksTest#writeHookFile(c1427772cd1877b0).(const QStringcxx . . $ QString# &name,
105 const QStringcxx . . $ QString# &contents)
106 {
107 QFilecxx . . $ QFile# filecxx . . $ QFile#QFile(3520e46b33348bf6).(m_hooksDircxx . . $ OnlineAccountsHooksTest#m_hooksDir..filePathcxx . . $ QDir#filePath(5555d9024dcf93fb).(name));
108 if (!file.opencxx . . $ QFile#open(dca164408be960c8).(QIODevicecxx . . $ QIODevice#::WriteOnlycxx . . $ QIODevice#WriteOnly. |cxx . . $ `operator|`(c9e45f682471e48d). QIODevicecxx . . $ QIODevice#::Textcxx . . $ QIODevice#Text.)) {
109 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Could not write file" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). name;
110 return;
111 }
112
113 file.writecxx . . $ QIODevice#write(4ee2750a0be83987).(contents.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).());
114 }
115
116 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::writeInstalledFilecxx . . $ OnlineAccountsHooksTest#writeInstalledFile(c1427772cd1877b0).(const QStringcxx . . $ QString# &name,
117 const QStringcxx . . $ QString# &contents)
118 {
119 QFileInfocxx . . $ QFileInfo# fileInfocxx . . $ QFileInfo#QFileInfo(3520e46b33348bf6).(name);
120 m_installDircxx . . $ OnlineAccountsHooksTest#m_installDir..mkpathcxx . . $ QDir#mkpath(f3b39adf77d9c36c).(fileInfo.pathcxx . . $ QFileInfo#path(6ef7b6c27b00b43d).());
121 QFilecxx . . $ QFile# filecxx . . $ QFile#QFile(3520e46b33348bf6).(m_installDircxx . . $ OnlineAccountsHooksTest#m_installDir..filePathcxx . . $ QDir#filePath(5555d9024dcf93fb).(name));
122 if (!file.opencxx . . $ QFile#open(dca164408be960c8).(QIODevicecxx . . $ QIODevice#::WriteOnlycxx . . $ QIODevice#WriteOnly. |cxx . . $ `operator|`(c9e45f682471e48d). QIODevicecxx . . $ QIODevice#::Textcxx . . $ QIODevice#Text.)) {
123 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Could not write file" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). name;
124 return;
125 }
126
127 file.writecxx . . $ QIODevice#write(4ee2750a0be83987).(contents.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).());
128 }
129
130 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::writePackageFilecxx . . $ OnlineAccountsHooksTest#writePackageFile(c1427772cd1877b0).(const QStringcxx . . $ QString# &name,
131 const QStringcxx . . $ QString# &contents)
132 {
133 QFileInfocxx . . $ QFileInfo# fileInfocxx . . $ QFileInfo#QFileInfo(3520e46b33348bf6).(name);
134 m_packageDircxx . . $ OnlineAccountsHooksTest#m_packageDir..mkpathcxx . . $ QDir#mkpath(f3b39adf77d9c36c).(fileInfo.pathcxx . . $ QFileInfo#path(6ef7b6c27b00b43d).());
135 QFilecxx . . $ QFile# filecxx . . $ QFile#QFile(3520e46b33348bf6).(m_packageDircxx . . $ OnlineAccountsHooksTest#m_packageDir..filePathcxx . . $ QDir#filePath(5555d9024dcf93fb).(name));
136 if (!file.opencxx . . $ QFile#open(dca164408be960c8).(QIODevicecxx . . $ QIODevice#::WriteOnlycxx . . $ QIODevice#WriteOnly. |cxx . . $ `operator|`(c9e45f682471e48d). QIODevicecxx . . $ QIODevice#::Textcxx . . $ QIODevice#Text.)) {
137 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Could not write file" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). name;
138 return;
139 }
140
141 file.writecxx . . $ QIODevice#write(4ee2750a0be83987).(contents.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).());
142 }
143
144 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::initTestCasecxx . . $ OnlineAccountsHooksTest#initTestCase(49f6e7a06ebc5aa8).()
145 {
146 qputenvcxx . . $ qputenv(d42e8231112a1b5b).("XDG_DATA_HOME", TEST_DIRcxx . . $ `tests/click-hooks/online-accounts-hooks/tst_online_accounts_hooks.cpp:35:9`!);
147 qputenvcxx . . $ qputenv(d42e8231112a1b5b).("OAH_CLICK_DIR", m_packageDircxx . . $ OnlineAccountsHooksTest#m_packageDir..pathcxx . . $ QDir#path(6ef7b6c27b00b43d).().toUtf8cxx . . $ QString#toUtf8(7c2073558a834e49).());
148 qputenvcxx . . $ qputenv(d42e8231112a1b5b).("ACCOUNTS", TEST_DIRcxx . . $ `tests/click-hooks/online-accounts-hooks/tst_online_accounts_hooks.cpp:35:9`!);
149
150 // The hook must be able to run without a D-Bus session
151 qunsetenvcxx . . $ qunsetenv(c5f7da30cbc0f4e9).("DBUS_SESSION_BUS_ADDRESS");
152
153 clearHooksDircxx . . $ OnlineAccountsHooksTest#clearHooksDir(49f6e7a06ebc5aa8).();
154 clearInstallDircxx . . $ OnlineAccountsHooksTest#clearInstallDir(49f6e7a06ebc5aa8).();
155 }
156
157 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::testNoFilescxx . . $ OnlineAccountsHooksTest#testNoFiles(49f6e7a06ebc5aa8).()
158 {
159 clearHooksDircxx . . $ OnlineAccountsHooksTest#clearHooksDir(49f6e7a06ebc5aa8).();
160 clearInstallDircxx . . $ OnlineAccountsHooksTest#clearInstallDir(49f6e7a06ebc5aa8).();
161
162 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(runHookProcess());
163 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(m_hooksDir.entryList(QDir::Files).isEmpty());
164 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(m_installDir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty());
165
166 /* Create an unsupported hook file */
167 writeHookFilecxx . . $ OnlineAccountsHooksTest#writeHookFile(c1427772cd1877b0).("file.unsupported"cxx . . $ QString#QString(85c52e162fed56f9).,
168 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"cxx . . $ QString#QString(85c52e162fed56f9).
169 "<service></service>");
170 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!m_hooksDir.entryList(QDir::Files).isEmpty());
171
172 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(runHookProcess());
173 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(m_installDir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty());
174 }
175
176 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::testValidHooks_datacxx . . $ OnlineAccountsHooksTest#testValidHooks_data(49f6e7a06ebc5aa8).()
177 {
178 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("hookName");
179 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("contents");
180 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("installedName");
181 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("profile");
182 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("icon");
183 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<bool>("isValid");
184
185 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("service") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
186 "com.lomiri.test_MyApp_0.1.service" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
187 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
188 "<service>\n"
189 " <type>some type</type>\n"
190 " <name>my app service</name>\n"
191 " <provider>example</provider>\n"
192 "</service>" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
193 "services/com.lomiri.test_MyApp.service" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
194 "com.lomiri.test_MyApp_0.1" <<cxx . . $ `operator<<`(61fb880f51a53ddf).
195 QStringcxx . . $ QString#QString(ced63f7c635d850d).() <<cxx . . $ `operator<<`(61fb880f51a53ddf).
196 true;
197
198 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("application") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
199 "com.lomiri.test_MyApp_0.2.application" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
200 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
201 "<application>\n"
202 " <description>My application</description>\n"
203 " <service-types>\n"
204 " <service-type>some type</service-type>\n"
205 " </service-types>\n"
206 "</application>" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
207 "applications/com.lomiri.test_MyApp.application" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
208 "com.lomiri.test_MyApp_0.2" <<cxx . . $ `operator<<`(61fb880f51a53ddf).
209 QStringcxx . . $ QString#QString(ced63f7c635d850d).() <<cxx . . $ `operator<<`(61fb880f51a53ddf).
210 true;
211
212 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("provider") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
213 "com.lomiri.test_Plugin_0.1.provider" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
214 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
215 "<provider>\n"
216 " <name>My provider</name>\n"
217 "</provider>" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
218 "providers/com.lomiri.test_Plugin.provider" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
219 "com.lomiri.test_Plugin_0.1" <<cxx . . $ `operator<<`(61fb880f51a53ddf).
220 QStringcxx . . $ QString#QString(ced63f7c635d850d).() <<cxx . . $ `operator<<`(61fb880f51a53ddf).
221 true;
222
223 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("provider-with-icon") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
224 "com.lomiri.test_Plugin2_0.1.provider" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
225 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
226 "<provider>\n"
227 " <name>My provider</name>\n"
228 " <icon>MyApp.svg</icon>\n"
229 "</provider>" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
230 "providers/com.lomiri.test_Plugin2.provider" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
231 "com.lomiri.test_Plugin2_0.1" <<cxx . . $ `operator<<`(61fb880f51a53ddf).
232 m_packageDircxx . . $ OnlineAccountsHooksTest#m_packageDir..filePathcxx . . $ QDir#filePath(5555d9024dcf93fb).("MyApp.svg"cxx . . $ QString#QString(85c52e162fed56f9).) <<cxx . . $ `operator<<`(61fb880f51a53ddf).
233 true;
234
235 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("provider-with-wrong-icon") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
236 "com.lomiri.test_Plugin3_0.1.provider" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
237 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
238 "<provider>\n"
239 " <name>My provider</name>\n"
240 " <icon>NonExisting.svg</icon>\n"
241 "</provider>" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
242 "providers/com.lomiri.test_Plugin3.provider" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
243 "com.lomiri.test_Plugin3_0.1" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
244 "NonExisting.svg" <<cxx . . $ `operator<<`(61fb880f51a53ddf).
245 true;
246
247 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("provider-with-icon-subdir") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
248 "com.lomiri.test_Plugin4_0.1.provider" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
249 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
250 "<provider>\n"
251 " <name>My provider</name>\n"
252 " <icon>subdir/pict.png</icon>\n"
253 "</provider>" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
254 "providers/com.lomiri.test_Plugin4.provider" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
255 "com.lomiri.test_Plugin4_0.1" <<cxx . . $ `operator<<`(61fb880f51a53ddf).
256 m_packageDircxx . . $ OnlineAccountsHooksTest#m_packageDir..filePathcxx . . $ QDir#filePath(5555d9024dcf93fb).("subdir/pict.png"cxx . . $ QString#QString(85c52e162fed56f9).) <<cxx . . $ `operator<<`(61fb880f51a53ddf).
257 true;
258
259 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("invalid application") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
260 "com.lomiri.test_Invalid_0.1.application" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
261 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
262 "<application>\n"
263 " <description>My application</description>\n"
264 " <service-types>\n"
265 " <service-type>some type</service-type>\n"
266 " </service-types>\n"
267 "</application /* invalid XML!" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
268 "applications/com.lomiri.test_Invalid.application" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
269 "com.lomiri.test_Invalid_0.1" <<cxx . . $ `operator<<`(61fb880f51a53ddf).
270 QStringcxx . . $ QString#QString(ced63f7c635d850d).() <<cxx . . $ `operator<<`(61fb880f51a53ddf).
271 false;
272
273 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("application with wrong id") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
274 "com.lomiri.test_MyAppId_0.1.application" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
275 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
276 "<application id=\"wrongid\">\n"
277 " <description>My application</description>\n"
278 " <service-types>\n"
279 " <service-type>some type</service-type>\n"
280 " </service-types>\n"
281 "</application>" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
282 "applications/com.lomiri.test_MyAppId.application" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
283 "com.lomiri.test_MyAppId_0.1" <<cxx . . $ `operator<<`(61fb880f51a53ddf).
284 QStringcxx . . $ QString#QString(ced63f7c635d850d).() <<cxx . . $ `operator<<`(61fb880f51a53ddf).
285 true;
286 }
287
288 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::testValidHookscxx . . $ OnlineAccountsHooksTest#testValidHooks(49f6e7a06ebc5aa8).()
289 {
290 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, hookName);
291 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, contents);
292 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, installedName);
293 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, profile);
294 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, icon);
295 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(bool, isValid);
296
297 /* Create the needed files in the package directory */
298 writePackageFilecxx . . $ OnlineAccountsHooksTest#writePackageFile(c1427772cd1877b0).("MyApp.svg"cxx . . $ QString#QString(85c52e162fed56f9).);
299 writePackageFilecxx . . $ OnlineAccountsHooksTest#writePackageFile(c1427772cd1877b0).("subdir/pict.png"cxx . . $ QString#QString(85c52e162fed56f9).);
300
301 writeHookFilecxx . . $ OnlineAccountsHooksTest#writeHookFile(c1427772cd1877b0).(hookName, contents);
302 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(runHookProcess());
303
304 // check that the file has been created, if the file was valid
305 QFileInfocxx . . $ QFileInfo# fileInfocxx . . $ QFileInfo#QFileInfo(3520e46b33348bf6).(m_installDircxx . . $ OnlineAccountsHooksTest#m_installDir..absoluteFilePathcxx . . $ QDir#absoluteFilePath(5555d9024dcf93fb).(installedName));
306 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(fileInfo.exists(), isValid);
307
308 if (!isValid) return;
309
310 QFilecxx . . $ QFile# filecxx . . $ QFile#QFile(3520e46b33348bf6).(fileInfo.absoluteFilePathcxx . . $ QFileInfo#absoluteFilePath(6ef7b6c27b00b43d).());
311 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(file.open(QIODevice::ReadOnly));
312
313 // check that's a valid XML file
314 QDomDocumentcxx . . $ QDomDocument# doccxx . . $ QDomDocument#QDomDocument(49f6e7a06ebc5aa8).;
315 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(doc.setContent(&file));
316
317 // Check that the "id" attribute matches the file name
318 QDomElementcxx . . $ QDomElement# root = doc.documentElementcxx . . $ QDomDocument#documentElement(654df8c29726cab1).();
319 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(root.attribute("id"), fileInfo.completeBaseName());
320
321 /* Check that a "profile" element has been added and that matches the
322 * expected profile. */
323 QDomElementcxx . . $ QDomElement# profileElement = root.firstChildElementcxx . . $ QDomNode#firstChildElement(d563d9084a4b323c).("profile"cxx . . $ QString#QString(85c52e162fed56f9).);
324 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!profileElement.isNull());
325 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(profileElement.text(), profile);
326
327 /* Check that the icon is correct */
328 QDomElementcxx . . $ QDomElement# iconElement = root.firstChildElementcxx . . $ QDomNode#firstChildElement(d563d9084a4b323c).("icon"cxx . . $ QString#QString(85c52e162fed56f9).);
329 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(iconElement.text(), icon);
330 }
331
332 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::testRemovalcxx . . $ OnlineAccountsHooksTest#testRemoval(49f6e7a06ebc5aa8).()
333 {
334 clearHooksDircxx . . $ OnlineAccountsHooksTest#clearHooksDir(49f6e7a06ebc5aa8).();
335 clearInstallDircxx . . $ OnlineAccountsHooksTest#clearInstallDir(49f6e7a06ebc5aa8).();
336
337 QStringcxx . . $ QString# stillInstalledcxx . . $ QString#QString(85c52e162fed56f9).("applications/com.lomiri.test_StillInstalled.application");
338 writeInstalledFilecxx . . $ OnlineAccountsHooksTest#writeInstalledFile(c1427772cd1877b0).(stillInstalled,
339 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"cxx . . $ QString#QString(85c52e162fed56f9).
340 "<!--this file is auto-generated by lomiri-online-accounts-hooks; do not modify-->\n"
341 "<application>\n"
342 " <description>My application</description>\n"
343 " <service-types>\n"
344 " <service-type>some type</service-type>\n"
345 " </service-types>\n"
346 " <profile>com-lomiri.test_StillInstalled_2.0</profile>\n"
347 "</application>");
348 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(m_installDir.exists(stillInstalled));
349
350 QStringcxx . . $ QString# myAppcxx . . $ QString#QString(85c52e162fed56f9).("applications/com.lomiri.test_MyApp.application");
351 writeInstalledFilecxx . . $ OnlineAccountsHooksTest#writeInstalledFile(c1427772cd1877b0).(myApp,
352 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"cxx . . $ QString#QString(85c52e162fed56f9).
353 "<!--this file is auto-generated by lomiri-online-accounts-hooks; do not modify-->\n"
354 "<application>\n"
355 " <description>My application</description>\n"
356 " <service-types>\n"
357 " <service-type>some type</service-type>\n"
358 " </service-types>\n"
359 " <profile>com-lomiri.test_MyApp_3.0</profile>\n"
360 "</application>");
361 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(m_installDir.exists(myApp));
362
363 QStringcxx . . $ QString# noProfilecxx . . $ QString#QString(85c52e162fed56f9).("applications/com.lomiri.test_NoProfile.application");
364 writeInstalledFilecxx . . $ OnlineAccountsHooksTest#writeInstalledFile(c1427772cd1877b0).(noProfile,
365 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"cxx . . $ QString#QString(85c52e162fed56f9).
366 "<application>\n"
367 " <description>My application</description>\n"
368 " <service-types>\n"
369 " <service-type>some type</service-type>\n"
370 " </service-types>\n"
371 "</application>");
372 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(m_installDir.exists(noProfile));
373
374 QStringcxx . . $ QString# notOurscxx . . $ QString#QString(85c52e162fed56f9).("applications/com.lomiri.test_NotOurs.application");
375 writeInstalledFilecxx . . $ OnlineAccountsHooksTest#writeInstalledFile(c1427772cd1877b0).(notOurs,
376 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"cxx . . $ QString#QString(85c52e162fed56f9).
377 "<!--this file is auto-generated by lomiri-online-accounts-hooks2; do not modify-->\n"
378 "<application>\n"
379 " <description>My application</description>\n"
380 " <service-types>\n"
381 " <service-type>some type</service-type>\n"
382 " </service-types>\n"
383 " <profile>com-lomiri.test_NotOurs_0.1.0</profile>\n"
384 "</application>");
385 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(m_installDir.exists(notOurs));
386
387 writeHookFilecxx . . $ OnlineAccountsHooksTest#writeHookFile(c1427772cd1877b0).("com-lomiri.test_StillInstalled_2.0.application"cxx . . $ QString#QString(85c52e162fed56f9).,
388 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"cxx . . $ QString#QString(85c52e162fed56f9).
389 "<application>\n"
390 " <description>My application</description>\n"
391 " <service-types>\n"
392 " <service-type>some type</service-type>\n"
393 " </service-types>\n"
394 "</application>");
395
396 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(runHookProcess());
397
398 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(m_installDir.exists(stillInstalled));
399 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!m_installDir.exists(myApp));
400 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(m_installDir.exists(noProfile));
401 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(m_installDir.exists(noProfile));
402 }
403
404 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::testAccountRemovalcxx . . $ OnlineAccountsHooksTest#testAccountRemoval(49f6e7a06ebc5aa8).()
405 {
406 clearHooksDircxx . . $ OnlineAccountsHooksTest#clearHooksDir(49f6e7a06ebc5aa8).();
407 clearInstallDircxx . . $ OnlineAccountsHooksTest#clearInstallDir(49f6e7a06ebc5aa8).();
408
409 Accountscxx . . $ Accounts/::Managercxx . . $ Accounts/Manager# *manager =
410 new Accountscxx . . $ Accounts/::Managercxx . . $ Accounts/Manager#(Accountscxx . . $ QFlags#QFlags(93d577a3e9528307).::Managercxx . . $ Accounts/Manager#::DisableNotificationscxx . . $ Accounts/Manager#DisableNotifications.);
411
412 QStringcxx . . $ QString# stillInstalledcxx . . $ QString#QString(85c52e162fed56f9).("providers/com.lomiri.test_StillInstalled.provider");
413 writeInstalledFilecxx . . $ OnlineAccountsHooksTest#writeInstalledFile(c1427772cd1877b0).(stillInstalled,
414 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"cxx . . $ QString#QString(85c52e162fed56f9).
415 "<!--this file is auto-generated by lomiri-online-accounts-hooks; do not modify-->\n"
416 "<provider>\n"
417 " <profile>com-lomiri.test_StillInstalled_2.0</profile>\n"
418 "</provider>");
419 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(m_installDir.exists(stillInstalled));
420
421 /* Write a newer version of the hook, to make sure that accounts created
422 * with older versions of the app are preserved */
423 writeHookFilecxx . . $ OnlineAccountsHooksTest#writeHookFile(c1427772cd1877b0).("com-lomiri.test_StillInstalled_3.0.provider"cxx . . $ QString#QString(85c52e162fed56f9).,
424 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"cxx . . $ QString#QString(85c52e162fed56f9).
425 "<provider>\n"
426 "</provider>");
427
428 Accountscxx . . $ Accounts/::Accountcxx . . $ Accounts/Account# *account =
429 manager->createAccountcxx . . $ Accounts/Manager#createAccount(c883e1f1d6ec9995).("com.lomiri.test_StillInstalled"cxx . . $ QString#QString(85c52e162fed56f9).);
430 account->setDisplayNamecxx . . $ Accounts/Account#setDisplayName(3520e46b33348bf6).("Still alive"cxx . . $ QString#QString(85c52e162fed56f9).);
431 account->syncAndBlockcxx . . $ Accounts/Account#syncAndBlock(c9857a73d68e59ba).();
432 Accountscxx . . $ Accounts/::AccountIdcxx . . $ Accounts/AccountId# idPreserved = account->idcxx . . $ Accounts/Account#id(ddd8539a2fcdd4ce).();
433 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(idPreserved > 0);
434
435 QStringcxx . . $ QString# myProvidercxx . . $ QString#QString(85c52e162fed56f9).("providers/com.lomiri.test_MyProvider.provider");
436 writeInstalledFilecxx . . $ OnlineAccountsHooksTest#writeInstalledFile(c1427772cd1877b0).(myProvider,
437 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"cxx . . $ QString#QString(85c52e162fed56f9).
438 "<!--this file is auto-generated by lomiri-online-accounts-hooks; do not modify-->\n"
439 "<provider>\n"
440 " <profile>com-lomiri.test_MyProvider_3.0</profile>\n"
441 "</provider>");
442 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(m_installDir.exists(myProvider));
443
444 account = manager->createAccountcxx . . $ Accounts/Manager#createAccount(c883e1f1d6ec9995).("com.lomiri.test_MyProvider"cxx . . $ QString#QString(85c52e162fed56f9).);
445 account->setDisplayNamecxx . . $ Accounts/Account#setDisplayName(3520e46b33348bf6).("Must die"cxx . . $ QString#QString(85c52e162fed56f9).);
446 account->syncAndBlockcxx . . $ Accounts/Account#syncAndBlock(c9857a73d68e59ba).();
447 Accountscxx . . $ Accounts/::AccountIdcxx . . $ Accounts/AccountId# idRemoved = account->idcxx . . $ Accounts/Account#id(ddd8539a2fcdd4ce).();
448 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(idRemoved > 0);
449
450 delete manager;
451
452 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(runHookProcess());
453
454 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(m_installDir.exists(stillInstalled));
455 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!m_installDir.exists(myProvider));
456
457 manager = new Accountscxx . . $ Accounts/::Managercxx . . $ Accounts/Manager#(Accountscxx . . $ QFlags#QFlags(93d577a3e9528307).::Managercxx . . $ Accounts/Manager#::DisableNotificationscxx . . $ Accounts/Manager#DisableNotifications.);
458 account = manager->accountcxx . . $ Accounts/Manager#account(e94dad5fac3d2066).(idPreserved);
459 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(account != 0);
460 account = manager->accountcxx . . $ Accounts/Manager#account(e94dad5fac3d2066).(idRemoved);
461 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(account == 0);
462
463 delete manager;
464 }
465
466 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::testUpdatecxx . . $ OnlineAccountsHooksTest#testUpdate(49f6e7a06ebc5aa8).()
467 {
468 clearHooksDircxx . . $ OnlineAccountsHooksTest#clearHooksDir(49f6e7a06ebc5aa8).();
469 clearInstallDircxx . . $ OnlineAccountsHooksTest#clearInstallDir(49f6e7a06ebc5aa8).();
470
471 time_t oldTime = time(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) - 3;
472
473 writeHookFilecxx . . $ OnlineAccountsHooksTest#writeHookFile(c1427772cd1877b0).("com-lomiri.test_MyApp_1.0.application"cxx . . $ QString#QString(85c52e162fed56f9).,
474 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"cxx . . $ QString#QString(85c52e162fed56f9).
475 "<application>\n"
476 " <description>My application</description>\n"
477 " <service-types>\n"
478 " <service-type>some type</service-type>\n"
479 " </service-types>\n"
480 "</application>");
481
482 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(runHookProcess());
483
484 QStringcxx . . $ QString# installedNamecxx . . $ QString#QString(85c52e162fed56f9).("applications/com-lomiri.test_MyApp.application");
485
486 // check that the file has been created, and with the correct profile
487 QFilecxx . . $ QFile# filecxx . . $ QFile#QFile(3520e46b33348bf6).(m_installDircxx . . $ OnlineAccountsHooksTest#m_installDir..absoluteFilePathcxx . . $ QDir#absoluteFilePath(5555d9024dcf93fb).(installedName));
488 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(file.open(QIODevice::ReadOnly));
489
490 // check that's a valid XML file
491 QDomDocumentcxx . . $ QDomDocument# doccxx . . $ QDomDocument#QDomDocument(49f6e7a06ebc5aa8).;
492 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(doc.setContent(&file));
493 QDomElementcxx . . $ QDomElement# root = doc.documentElementcxx . . $ QDomDocument#documentElement(654df8c29726cab1).();
494 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(root.firstChildElement("profile").text(),
495 QString("com-lomiri.test_MyApp_1.0"));
496
497 /* Now remove the hook file and write a newer version of it */
498 clearHooksDircxx . . $ OnlineAccountsHooksTest#clearHooksDir(49f6e7a06ebc5aa8).();
499 QTestcxx . . $ QTest/::qWaitcxx . . $ QTest/qWait(d4f767463ce0a6b3).(1500); // make sure that the timestamp is newer
500 writeHookFilecxx . . $ OnlineAccountsHooksTest#writeHookFile(c1427772cd1877b0).("com-lomiri.test_MyApp_1.1.application"cxx . . $ QString#QString(85c52e162fed56f9).,
501 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"cxx . . $ QString#QString(85c52e162fed56f9).
502 "<application>\n"
503 " <description>My application</description>\n"
504 " <service-types>\n"
505 " <service-type>some type</service-type>\n"
506 " </service-types>\n"
507 "</application>");
508
509 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(runHookProcess());
510
511 // check that the file has been updated with the correct profile
512 file.closecxx . . $ QFileDevice#close(49f6e7a06ebc5aa8).();
513 file.setFileNamecxx . . $ QFile#setFileName(3520e46b33348bf6).(m_installDircxx . . $ OnlineAccountsHooksTest#m_installDir..absoluteFilePathcxx . . $ QDir#absoluteFilePath(5555d9024dcf93fb).(installedName));
514 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(file.open(QIODevice::ReadOnly));
515 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(doc.setContent(&file));
516 root =cxx . . $ QDomElement#`operator=`(b7fc97416e752cd8). doc.documentElementcxx . . $ QDomDocument#documentElement(654df8c29726cab1).();
517 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(root.firstChildElement("profile").text(),
518 QString("com-lomiri.test_MyApp_1.1"));
519
520 // Create an *older* file
521 clearHooksDircxx . . $ OnlineAccountsHooksTest#clearHooksDir(49f6e7a06ebc5aa8).();
522 QStringcxx . . $ QString# fileNamecxx . . $ QString#QString(85c52e162fed56f9).("com-lomiri.test_MyApp_1.2.application");
523 writeHookFilecxx . . $ OnlineAccountsHooksTest#writeHookFile(c1427772cd1877b0).(fileName,
524 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"cxx . . $ QString#QString(85c52e162fed56f9).
525 "<application>\n"
526 " <description>My application</description>\n"
527 " <service-types>\n"
528 " <service-type>some type</service-type>\n"
529 " </service-types>\n"
530 "</application>");
531 struct utimbuf sourceTime;
532 sourceTime.actime = sourceTime.modtime = oldTime;
533 utime(m_hooksDircxx . . $ OnlineAccountsHooksTest#m_hooksDir..filePathcxx . . $ QDir#filePath(5555d9024dcf93fb).(fileName).toUtf8cxx . . $ QString#toUtf8(7c2073558a834e49).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), &sourceTime);
534
535 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(runHookProcess());
536
537 // check that the file has been updated with the correct profile
538 file.closecxx . . $ QFileDevice#close(49f6e7a06ebc5aa8).();
539 file.setFileNamecxx . . $ QFile#setFileName(3520e46b33348bf6).(m_installDircxx . . $ OnlineAccountsHooksTest#m_installDir..absoluteFilePathcxx . . $ QDir#absoluteFilePath(5555d9024dcf93fb).(installedName));
540 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(file.open(QIODevice::ReadOnly));
541 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(doc.setContent(&file));
542 root =cxx . . $ QDomElement#`operator=`(b7fc97416e752cd8). doc.documentElementcxx . . $ QDomDocument#documentElement(654df8c29726cab1).();
543 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(root.firstChildElement("profile").text(),
544 QString("com-lomiri.test_MyApp_1.2"));
545 }
546
547 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::testDesktopEntry_datacxx . . $ OnlineAccountsHooksTest#testDesktopEntry_data(49f6e7a06ebc5aa8).()
548 {
549 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("hookName");
550 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("contents");
551 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("installedName");
552 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("expectedDesktopEntry");
553
554 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("no-entry") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
555 "com.lomiri.test_MyApp_0.2.application" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
556 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
557 "<application>\n"
558 " <description>My application</description>\n"
559 " <service-types>\n"
560 " <service-type>some type</service-type>\n"
561 " </service-types>\n"
562 "</application>" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
563 "applications/com.lomiri.test_MyApp.application" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
564 "com.lomiri.test_MyApp_0.2";
565
566 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("with-desktop-entry") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
567 "com.lomiri.test_Desktop_0.1.application" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
568 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
569 "<application>\n"
570 " <description>My application</description>\n"
571 " <desktop-entry>something here</desktop-entry>\n"
572 " <service-types>\n"
573 " <service-type>some type</service-type>\n"
574 " </service-types>\n"
575 "</application>" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
576 "applications/com.lomiri.test_Desktop.application" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
577 "something here";
578 }
579
580 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::testDesktopEntrycxx . . $ OnlineAccountsHooksTest#testDesktopEntry(49f6e7a06ebc5aa8).()
581 {
582 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, hookName);
583 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, contents);
584 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, installedName);
585 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, expectedDesktopEntry);
586
587 writeHookFilecxx . . $ OnlineAccountsHooksTest#writeHookFile(c1427772cd1877b0).(hookName, contents);
588 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(runHookProcess());
589
590 // check that the file has been created, if the file was valid
591 QFileInfocxx . . $ QFileInfo# fileInfocxx . . $ QFileInfo#QFileInfo(3520e46b33348bf6).(m_installDircxx . . $ OnlineAccountsHooksTest#m_installDir..absoluteFilePathcxx . . $ QDir#absoluteFilePath(5555d9024dcf93fb).(installedName));
592 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(fileInfo.exists());
593
594 QFilecxx . . $ QFile# filecxx . . $ QFile#QFile(3520e46b33348bf6).(fileInfo.absoluteFilePathcxx . . $ QFileInfo#absoluteFilePath(6ef7b6c27b00b43d).());
595 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(file.open(QIODevice::ReadOnly));
596
597 // check that's a valid XML file
598 QDomDocumentcxx . . $ QDomDocument# doccxx . . $ QDomDocument#QDomDocument(49f6e7a06ebc5aa8).;
599 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(doc.setContent(&file));
600
601 QDomElementcxx . . $ QDomElement# root = doc.documentElementcxx . . $ QDomDocument#documentElement(654df8c29726cab1).();
602
603 /* Check that a "desktop-entry" element has been added and that matches the
604 * expected value. */
605 QDomElementcxx . . $ QDomElement# desktopEntryElement = root.firstChildElementcxx . . $ QDomNode#firstChildElement(d563d9084a4b323c).("desktop-entry"cxx . . $ QString#QString(85c52e162fed56f9).);
606 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(desktopEntryElement.text(), expectedDesktopEntry);
607 }
608
609 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::testServiceType_datacxx . . $ OnlineAccountsHooksTest#testServiceType_data(49f6e7a06ebc5aa8).()
610 {
611 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("hookName");
612 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("contents");
613 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("installedName");
614 QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("expectedServiceType");
615
616 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("no type") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
617 "com.lomiri.test_MyApp_0.2.service" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
618 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
619 "<service>\n"
620 " <provider>google</provider>\n"
621 "</service>" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
622 "services/com.lomiri.test_MyApp.service" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
623 "com.lomiri.test_MyApp";
624
625 QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("with service type") <<cxx . . $ `operator<<`(1c43a92f59c6a770).
626 "com.lomiri.test_Desktop_0.1.service" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
627 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
628 "<service>\n"
629 " <provider>facebook</provider>\n"
630 " <type>a random type</type>\n"
631 "</service>" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
632 "services/com.lomiri.test_Desktop.service" <<cxx . . $ `operator<<`(1c43a92f59c6a770).
633 "a random type";
634 }
635
636 void OnlineAccountsHooksTestcxx . . $ OnlineAccountsHooksTest#::testServiceTypecxx . . $ OnlineAccountsHooksTest#testServiceType(49f6e7a06ebc5aa8).()
637 {
638 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, hookName);
639 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, contents);
640 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, installedName);
641 QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, expectedServiceType);
642
643 writeHookFilecxx . . $ OnlineAccountsHooksTest#writeHookFile(c1427772cd1877b0).(hookName, contents);
644 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(runHookProcess());
645
646 // check that the file has been created, if the file was valid
647 QFileInfocxx . . $ QFileInfo# fileInfocxx . . $ QFileInfo#QFileInfo(3520e46b33348bf6).(m_installDircxx . . $ OnlineAccountsHooksTest#m_installDir..absoluteFilePathcxx . . $ QDir#absoluteFilePath(5555d9024dcf93fb).(installedName));
648 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(fileInfo.exists());
649
650 QFilecxx . . $ QFile# filecxx . . $ QFile#QFile(3520e46b33348bf6).(fileInfo.absoluteFilePathcxx . . $ QFileInfo#absoluteFilePath(6ef7b6c27b00b43d).());
651 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(file.open(QIODevice::ReadOnly));
652
653 // check that's a valid XML file
654 QDomDocumentcxx . . $ QDomDocument# doccxx . . $ QDomDocument#QDomDocument(49f6e7a06ebc5aa8).;
655 QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(doc.setContent(&file));
656
657 QDomElementcxx . . $ QDomElement# root = doc.documentElementcxx . . $ QDomDocument#documentElement(654df8c29726cab1).();
658
659 /* Check that a "type" element has been added and that matches the
660 * expected value. */
661 QDomElementcxx . . $ QDomElement# serviceTypeElement = root.firstChildElementcxx . . $ QDomNode#firstChildElement(d563d9084a4b323c).("type"cxx . . $ QString#QString(85c52e162fed56f9).);
662 QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(serviceTypeElement.text(), expectedServiceType);
663 }
664
665 QTEST_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:508:9`!(OnlineAccountsHooksTest);
666
667 #include "tst_online_accounts_hooks.moc"cxx . . $ `<file>/build/tests/click-hooks/online-accounts-hooks/tst_online-accounts-hooks_autogen/include/tst_online_accounts_hooks.moc`/