| 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 <LomiriOnlineAccountsClient/Setup>cxx . . $ `<file>/online-accounts-client/lib/LomiriOnlineAccountsClient/Setup`/ |
| 26 | #include <QDBusConnection> |
| 27 | #include <QDBusContext> |
| 28 | #include <QDebug> |
| 29 | #include <QFile> |
| 30 | #include <QProcessEnvironment> |
| 31 | #include <QSignalSpy> |
| 32 | #include <QTest> |
| 33 | |
| 34 | using namespace OnlineAccountsClient; |
| 35 | |
| 36 | class Servicecxx . . $ Service#: public QObjectcxx . . $ QObject#, QDBusContextcxx . . $ QDBusContext# |
| 37 | { |
| 38 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 39 | Q_CLASSINFOcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:100:10`!("D-Bus Interface", |
| 40 | "com.lomiri.OnlineAccountsUi") |
| 41 | |
| 42 | public: |
| 43 | Servicecxx . . $ Service#Service(49f6e7a06ebc5aa8).(): QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).() {} |
| 44 | QVariantMapcxx . . $ QVariantMap# optionscxx . . $ Service#options(87f780dbe64191c4).() const { return m_optionscxx . . $ QMap#QMap(21739d87639e1d56).; } |
| 45 | |
| 46 | void setErrorcxx . . $ Service#setError(3520e46b33348bf6).(const QStringcxx . . $ QString# &name) { m_errorNamecxx . . $ Service#m_errorName. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). name; } |
| 47 | |
| 48 | public Q_SLOTScxx . . $ `<external>/1208926524888476972/qobjectdefs.h:92:10`!: |
| 49 | QVariantMapcxx . . $ QVariantMap# requestAccesscxx . . $ Service#requestAccess(52377bf93f9fc760).(const QVariantMapcxx . . $ QVariantMap# &options) { |
| 50 | m_optionscxx . . $ Service#m_options. =cxx . . $ QMap#`operator=`(9a30e17cbbb0999d). options; |
| 51 | if (!m_errorNamecxx . . $ Service#m_errorName..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 52 | sendErrorReplycxx . . $ QDBusContext#sendErrorReply(b5b78ffdab614c30).(m_errorNamecxx . . $ Service#m_errorName., "Some error"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 53 | m_errorNamecxx . . $ Service#m_errorName. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(ced63f7c635d850d).(); |
| 54 | } |
| 55 | return QVariantMapcxx . . $ QMap#QMap(ced63f7c635d850d).(); |
| 56 | } |
| 57 | |
| 58 | private: |
| 59 | QVariantMapcxx . . $ QVariantMap# m_optionscxx . . $ Service#m_options.; |
| 60 | QStringcxx . . $ QString# m_errorNamecxx . . $ Service#m_errorName.; |
| 61 | }; |
| 62 | |
| 63 | class SetupTestcxx . . $ SetupTest#: public QObjectcxx . . $ QObject# |
| 64 | { |
| 65 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 66 | |
| 67 | public: |
| 68 | SetupTestcxx . . $ SetupTest#SetupTest(49f6e7a06ebc5aa8).(); |
| 69 | QVariantMapcxx . . $ QVariantMap# optionscxx . . $ SetupTest#options(87f780dbe64191c4).() const { return m_servicecxx . . $ SetupTest#m_service..optionscxx . . $ Service#options(87f780dbe64191c4).(); } |
| 70 | |
| 71 | private Q_SLOTScxx . . $ `<external>/1208926524888476972/qobjectdefs.h:92:10`!: |
| 72 | void initTestCasecxx . . $ SetupTest#initTestCase(49f6e7a06ebc5aa8).(); |
| 73 | void testPropertiescxx . . $ SetupTest#testProperties(49f6e7a06ebc5aa8).(); |
| 74 | void testExeccxx . . $ SetupTest#testExec(49f6e7a06ebc5aa8).(); |
| 75 | void testExecWithProvidercxx . . $ SetupTest#testExecWithProvider(49f6e7a06ebc5aa8).(); |
| 76 | void testExecWithServiceTypecxx . . $ SetupTest#testExecWithServiceType(49f6e7a06ebc5aa8).(); |
| 77 | void testExecWithApplicationcxx . . $ SetupTest#testExecWithApplication(49f6e7a06ebc5aa8).(); |
| 78 | void testErrorcxx . . $ SetupTest#testError(49f6e7a06ebc5aa8).(); |
| 79 | void testWindowIdcxx . . $ SetupTest#testWindowId(49f6e7a06ebc5aa8).(); |
| 80 | |
| 81 | private: |
| 82 | Servicecxx . . $ Service# m_servicecxx . . $ SetupTest#m_service.; |
| 83 | }; |
| 84 | |
| 85 | SetupTestcxx . . $ SetupTest#::SetupTestcxx . . $ SetupTest#SetupTest(49f6e7a06ebc5aa8).(): |
| 86 | QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(0) |
| 87 | { |
| 88 | } |
| 89 | |
| 90 | void SetupTestcxx . . $ SetupTest#::initTestCasecxx . . $ SetupTest#initTestCase(49f6e7a06ebc5aa8).() |
| 91 | { |
| 92 | QDBusConnectioncxx . . $ QDBusConnection# connection = QDBusConnectioncxx . . $ QDBusConnection#::sessionBuscxx . . $ QDBusConnection#sessionBus(45d475f1888103b2).(); |
| 93 | connection.registerObjectcxx . . $ QDBusConnection#registerObject(3ca2fdce2ef96dc8).(OAU_OBJECT_PATHcxx . . $ `online-accounts-common/globals.h:26:9`!, &m_servicecxx . . $ SetupTest#m_service., |
| 94 | QDBusConnectioncxx . . $ QFlags#QFlags(93d577a3e9528307).::ExportAllContentscxx . . $ QDBusConnection#ExportAllContents.); |
| 95 | connection.registerServicecxx . . $ QDBusConnection#registerService(e1defb592416720d).(OAU_SERVICE_NAMEcxx . . $ `online-accounts-common/globals.h:25:9`!); |
| 96 | } |
| 97 | |
| 98 | void SetupTestcxx . . $ SetupTest#::testPropertiescxx . . $ SetupTest#testProperties(49f6e7a06ebc5aa8).() |
| 99 | { |
| 100 | Setupcxx . . $ OnlineAccountsClient/Setup# setupcxx . . $ OnlineAccountsClient/Setup#Setup(749de1b6ae65bddd).; |
| 101 | |
| 102 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(setup.applicationId(), QString()); |
| 103 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(setup.providerId(), QString()); |
| 104 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(setup.serviceTypeId(), QString()); |
| 105 | |
| 106 | setup.setApplicationIdcxx . . $ OnlineAccountsClient/Setup#setApplicationId(3520e46b33348bf6).("hi!"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 107 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(setup.applicationId(), QString("hi!")); |
| 108 | |
| 109 | setup.setProviderIdcxx . . $ OnlineAccountsClient/Setup#setProviderId(3520e46b33348bf6).("ciao"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 110 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(setup.providerId(), QString("ciao")); |
| 111 | |
| 112 | setup.setServiceTypeIdcxx . . $ OnlineAccountsClient/Setup#setServiceTypeId(3520e46b33348bf6).("hello"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 113 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(setup.serviceTypeId(), QString("hello")); |
| 114 | } |
| 115 | |
| 116 | void SetupTestcxx . . $ SetupTest#::testExeccxx . . $ SetupTest#testExec(49f6e7a06ebc5aa8).() |
| 117 | { |
| 118 | Setupcxx . . $ OnlineAccountsClient/Setup# setupcxx . . $ OnlineAccountsClient/Setup#Setup(749de1b6ae65bddd).; |
| 119 | |
| 120 | QSignalSpycxx . . $ QSignalSpy# finishedcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(&setup, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(finished(QVariantMap))); |
| 121 | setup.execcxx . . $ OnlineAccountsClient/Setup#exec(49f6e7a06ebc5aa8).(); |
| 122 | |
| 123 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(finished.wait(10000)); |
| 124 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(options().contains(OAU_KEY_APPLICATIONcxx . . $ `online-accounts-common/globals.h:29:9`!), false); |
| 125 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(options().contains(OAU_KEY_PROVIDERcxx . . $ `online-accounts-common/globals.h:30:9`!), false); |
| 126 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(options().contains(OAU_KEY_SERVICE_TYPEcxx . . $ `online-accounts-common/globals.h:32:9`!), false); |
| 127 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(options().contains(OAU_KEY_WINDOW_IDcxx . . $ `online-accounts-common/globals.h:33:9`!), false); |
| 128 | } |
| 129 | |
| 130 | void SetupTestcxx . . $ SetupTest#::testExecWithProvidercxx . . $ SetupTest#testExecWithProvider(49f6e7a06ebc5aa8).() |
| 131 | { |
| 132 | Setupcxx . . $ OnlineAccountsClient/Setup# setupcxx . . $ OnlineAccountsClient/Setup#Setup(749de1b6ae65bddd).; |
| 133 | setup.setProviderIdcxx . . $ OnlineAccountsClient/Setup#setProviderId(3520e46b33348bf6).("lethal-provider"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 134 | |
| 135 | QSignalSpycxx . . $ QSignalSpy# finishedcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(&setup, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(finished(QVariantMap))); |
| 136 | setup.execcxx . . $ OnlineAccountsClient/Setup#exec(49f6e7a06ebc5aa8).(); |
| 137 | |
| 138 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(finished.wait(10000)); |
| 139 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(options().value(OAU_KEY_PROVIDERcxx . . $ `online-accounts-common/globals.h:30:9`!).toString(), |
| 140 | QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("lethal-provider")); |
| 141 | } |
| 142 | |
| 143 | void SetupTestcxx . . $ SetupTest#::testExecWithServiceTypecxx . . $ SetupTest#testExecWithServiceType(49f6e7a06ebc5aa8).() |
| 144 | { |
| 145 | Setupcxx . . $ OnlineAccountsClient/Setup# setupcxx . . $ OnlineAccountsClient/Setup#Setup(749de1b6ae65bddd).; |
| 146 | setup.setServiceTypeIdcxx . . $ OnlineAccountsClient/Setup#setServiceTypeId(3520e46b33348bf6).("e-mail"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 147 | |
| 148 | QSignalSpycxx . . $ QSignalSpy# finishedcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(&setup, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(finished(QVariantMap))); |
| 149 | setup.execcxx . . $ OnlineAccountsClient/Setup#exec(49f6e7a06ebc5aa8).(); |
| 150 | |
| 151 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(finished.wait(10000)); |
| 152 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(options().value(OAU_KEY_SERVICE_TYPEcxx . . $ `online-accounts-common/globals.h:32:9`!).toString(), |
| 153 | QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("e-mail")); |
| 154 | } |
| 155 | |
| 156 | void SetupTestcxx . . $ SetupTest#::testExecWithApplicationcxx . . $ SetupTest#testExecWithApplication(49f6e7a06ebc5aa8).() |
| 157 | { |
| 158 | Setupcxx . . $ OnlineAccountsClient/Setup# setupcxx . . $ OnlineAccountsClient/Setup#Setup(749de1b6ae65bddd).; |
| 159 | setup.setApplicationIdcxx . . $ OnlineAccountsClient/Setup#setApplicationId(3520e46b33348bf6).("MyApp"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 160 | |
| 161 | QSignalSpycxx . . $ QSignalSpy# finishedcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(&setup, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(finished(QVariantMap))); |
| 162 | setup.execcxx . . $ OnlineAccountsClient/Setup#exec(49f6e7a06ebc5aa8).(); |
| 163 | |
| 164 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(finished.wait(10000)); |
| 165 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(options().value(OAU_KEY_APPLICATIONcxx . . $ `online-accounts-common/globals.h:29:9`!).toString(), |
| 166 | QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("MyApp")); |
| 167 | } |
| 168 | |
| 169 | void SetupTestcxx . . $ SetupTest#::testWindowIdcxx . . $ SetupTest#testWindowId(49f6e7a06ebc5aa8).() |
| 170 | { |
| 171 | Setupcxx . . $ OnlineAccountsClient/Setup# setupcxx . . $ OnlineAccountsClient/Setup#Setup(749de1b6ae65bddd).; |
| 172 | |
| 173 | QWindowcxx . . $ QWindow# windowcxx . . $ QWindow#QWindow(484cbc3bdb260bbf).; |
| 174 | QSignalSpycxx . . $ QSignalSpy# finishedcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(&setup, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(finished(QVariantMap))); |
| 175 | setup.execcxx . . $ OnlineAccountsClient/Setup#exec(49f6e7a06ebc5aa8).(); |
| 176 | |
| 177 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(finished.wait()); |
| 178 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(options().value(OAU_KEY_WINDOW_IDcxx . . $ `online-accounts-common/globals.h:33:9`!).toUInt(), |
| 179 | uint(window.winId())); |
| 180 | } |
| 181 | |
| 182 | void SetupTestcxx . . $ SetupTest#::testErrorcxx . . $ SetupTest#testError(49f6e7a06ebc5aa8).() |
| 183 | { |
| 184 | m_servicecxx . . $ SetupTest#m_service..setErrorcxx . . $ Service#setError(3520e46b33348bf6).("com.lomiri.SomeError"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 185 | |
| 186 | Setupcxx . . $ OnlineAccountsClient/Setup# setupcxx . . $ OnlineAccountsClient/Setup#Setup(749de1b6ae65bddd).; |
| 187 | |
| 188 | QSignalSpycxx . . $ QSignalSpy# finishedcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(&setup, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(finished(QVariantMap))); |
| 189 | setup.execcxx . . $ OnlineAccountsClient/Setup#exec(49f6e7a06ebc5aa8).(); |
| 190 | |
| 191 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(finished.wait(10000)); |
| 192 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(finished.count(), 1); |
| 193 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(finished.at(0).at(0).toMap().value("errorName").toString(), |
| 194 | QString("com.lomiri.SomeError")); |
| 195 | } |
| 196 | |
| 197 | QTEST_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:508:9`!(SetupTest); |
| 198 | |
| 199 | #include "tst_client.moc"cxx . . $ `<file>/build/tests/online-accounts-client/lib/tst_client/tst_client_autogen/include/tst_client.moc`/ |