| 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 <online-accounts-common/debug.h>cxx . . $ `<file>/online-accounts-common/debug.h`/ |
| 22 | #include <online-accounts-common/globals.h>cxx . . $ `<file>/online-accounts-common/globals.h`/ |
| 23 | #include "mock/application-manager-mock.h"cxx . . $ `<file>/tests/online-accounts-ui/mock/application-manager-mock.h`/ |
| 24 | #include "mock/request-mock.h"cxx . . $ `<file>/tests/online-accounts-ui/mock/request-mock.h`/ |
| 25 | #include "mock/ui-server-mock.h"cxx . . $ `<file>/tests/online-accounts-ui/mock/ui-server-mock.h`/ |
| 26 | #include "provider-request.h"cxx . . $ `<file>/online-accounts-ui/src/provider-request.h`/ |
| 27 | |
| 28 | #include <QDebug> |
| 29 | #include <QJsonDocument> |
| 30 | #include <QJsonObject> |
| 31 | #include <QQmlContext> |
| 32 | #include <QQmlEngine> |
| 33 | #include <QQuickView> |
| 34 | #include <QSignalSpy> |
| 35 | #include <QTest> |
| 36 | |
| 37 | using namespace OnlineAccountsUi; |
| 38 | |
| 39 | namespace QTestcxx . . $ QTest/ { |
| 40 | template<> |
| 41 | char *toStringcxx . . $ QTest/toString(40c3e2c6db4df9d1).(const QVariantMapcxx . . $ QVariantMap# &p) |
| 42 | { |
| 43 | QJsonDocumentcxx . . $ QJsonDocument# doccxx . . $ QJsonDocument#QJsonDocument(6b379e5d051a9fe4).(QJsonObjectcxx . . $ QJsonObject#::fromVariantMapcxx . . $ QJsonObject#fromVariantMap(3a49b2b7865f4928).(p)); |
| 44 | QByteArraycxx . . $ QByteArray# ba = doc.toJsoncxx . . $ QJsonDocument#toJson(6b49539da79a45f0).(QJsonDocumentcxx . . $ QJsonDocument#::Compactcxx . . $ QJsonDocument#Compact.); |
| 45 | return qstrdupcxx . . $ qstrdup(a8b8e32347182212).(ba.datacxx . . $ QByteArray#data(41208ce6ca65dd58).()); |
| 46 | } |
| 47 | } // QTest namespace |
| 48 | |
| 49 | class TestRequestcxx . . $ TestRequest#: public ProviderRequestcxx . . $ OnlineAccountsUi/ProviderRequest# |
| 50 | { |
| 51 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 52 | |
| 53 | public: |
| 54 | TestRequestcxx . . $ TestRequest#TestRequest(768e9709461039cf).(const QVariantMapcxx . . $ QVariantMap# ¶meters, const QStringcxx . . $ QString# &profile, |
| 55 | QObjectcxx . . $ QObject# *parent = 0): |
| 56 | ProviderRequestcxx . . $ OnlineAccountsUi/ProviderRequest#("interface"cxx . . $ QString#QString(85c52e162fed56f9)., 0, profile, parameters, parent) |
| 57 | { |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | class ProviderRequestTestcxx . . $ ProviderRequestTest#: public QObjectcxx . . $ QObject# |
| 62 | { |
| 63 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 64 | |
| 65 | public: |
| 66 | ProviderRequestTestcxx . . $ ProviderRequestTest#ProviderRequestTest(49f6e7a06ebc5aa8).(); |
| 67 | |
| 68 | private Q_SLOTScxx . . $ `<external>/1208926524888476972/qobjectdefs.h:92:10`!: |
| 69 | void initTestCasecxx . . $ ProviderRequestTest#initTestCase(49f6e7a06ebc5aa8).(); |
| 70 | void testParameters_datacxx . . $ ProviderRequestTest#testParameters_data(49f6e7a06ebc5aa8).(); |
| 71 | void testParameterscxx . . $ ProviderRequestTest#testParameters(49f6e7a06ebc5aa8).(); |
| 72 | |
| 73 | private: |
| 74 | UiServercxx . . $ OnlineAccountsUi/UiServer# m_uiServercxx . . $ ProviderRequestTest#m_uiServer.; |
| 75 | }; |
| 76 | |
| 77 | ProviderRequestTestcxx . . $ ProviderRequestTest#::ProviderRequestTestcxx . . $ ProviderRequestTest#ProviderRequestTest(49f6e7a06ebc5aa8).(): |
| 78 | QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(), |
| 79 | m_uiServercxx . . $ ProviderRequestTest#m_uiServer.("fake"cxx . . $ QString#QString(85c52e162fed56f9).) |
| 80 | { |
| 81 | } |
| 82 | |
| 83 | void ProviderRequestTestcxx . . $ ProviderRequestTest#::initTestCasecxx . . $ ProviderRequestTest#initTestCase(49f6e7a06ebc5aa8).() |
| 84 | { |
| 85 | qputenvcxx . . $ qputenv(d42e8231112a1b5b).("ACCOUNTS", TMP_DIRcxx . . $ `<built-in>:489:9`! "/"); |
| 86 | qputenvcxx . . $ qputenv(d42e8231112a1b5b).("AG_APPLICATIONS", TEST_DATA_DIRcxx . . $ `<built-in>:488:9`!); |
| 87 | qputenvcxx . . $ qputenv(d42e8231112a1b5b).("AG_SERVICES", TEST_DATA_DIRcxx . . $ `<built-in>:488:9`!); |
| 88 | qputenvcxx . . $ qputenv(d42e8231112a1b5b).("AG_SERVICE_TYPES", TEST_DATA_DIRcxx . . $ `<built-in>:488:9`!); |
| 89 | qputenvcxx . . $ qputenv(d42e8231112a1b5b).("AG_PROVIDERS", TEST_DATA_DIRcxx . . $ `<built-in>:488:9`!); |
| 90 | qputenvcxx . . $ qputenv(d42e8231112a1b5b).("XDG_DATA_HOME", TEST_DATA_DIRcxx . . $ `<built-in>:488:9`!); |
| 91 | } |
| 92 | |
| 93 | void ProviderRequestTestcxx . . $ ProviderRequestTest#::testParameters_datacxx . . $ ProviderRequestTest#testParameters_data(49f6e7a06ebc5aa8).() |
| 94 | { |
| 95 | QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QVariantMapcxx . . $ QVariantMap#>("parameters"); |
| 96 | QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("profile"); |
| 97 | QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("providerId"); |
| 98 | QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QVariantMapcxx . . $ QVariantMap#>("providerInfo"); |
| 99 | QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QVariantMapcxx . . $ QVariantMap#>("applicationInfo"); |
| 100 | QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("errorName"); |
| 101 | |
| 102 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("empty") <<cxx . . $ `operator<<`(61fb880f51a53ddf). |
| 103 | QVariantMapcxx . . $ QMap#QMap(ced63f7c635d850d).() <<cxx . . $ `operator<<`(61fb880f51a53ddf). |
| 104 | QStringcxx . . $ QString#QString(ced63f7c635d850d).() <<cxx . . $ `operator<<`(61fb880f51a53ddf). |
| 105 | QStringcxx . . $ QString#QString(ced63f7c635d850d).() <<cxx . . $ `operator<<`(61fb880f51a53ddf). |
| 106 | QVariantMapcxx . . $ QMap#QMap(ced63f7c635d850d).() <<cxx . . $ `operator<<`(61fb880f51a53ddf). |
| 107 | QVariantMapcxx . . $ QMap#QMap(ced63f7c635d850d).() <<cxx . . $ `operator<<`(61fb880f51a53ddf). |
| 108 | OAU_ERROR_INVALID_APPLICATIONcxx . . $ `online-accounts-common/globals.h:43:9`!; |
| 109 | |
| 110 | QVariantMapcxx . . $ QVariantMap# parameterscxx . . $ QMap#QMap(ced63f7c635d850d).; |
| 111 | QVariantMapcxx . . $ QVariantMap# providerInfocxx . . $ QMap#QMap(ced63f7c635d850d).; |
| 112 | QVariantMapcxx . . $ QVariantMap# applicationInfocxx . . $ QMap#QMap(ced63f7c635d850d).; |
| 113 | |
| 114 | parameters.insertcxx . . $ QMap#insert(929a1ed410fe8423).(OAU_KEY_APPLICATIONcxx . . $ `online-accounts-common/globals.h:29:9`!, "Gallery"cxx . . $ QVariant#QVariant(85c52e162fed56f9).); |
| 115 | parameters.insertcxx . . $ QMap#insert(929a1ed410fe8423).(OAU_KEY_PROVIDERcxx . . $ `online-accounts-common/globals.h:30:9`!, "my provider"cxx . . $ QVariant#QVariant(85c52e162fed56f9).); |
| 116 | providerInfo.insertcxx . . $ QMap#insert(929a1ed410fe8423).("some"cxx . . $ QString#QString(85c52e162fed56f9)., "value"cxx . . $ QVariant#QVariant(85c52e162fed56f9).); |
| 117 | applicationInfo.insertcxx . . $ QMap#insert(929a1ed410fe8423).("one"cxx . . $ QString#QString(85c52e162fed56f9)., "two"cxx . . $ QVariant#QVariant(85c52e162fed56f9).); |
| 118 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("confined app") <<cxx . . $ `operator<<`(61fb880f51a53ddf). |
| 119 | parameters <<cxx . . $ `operator<<`(1c43a92f59c6a770). |
| 120 | "my-app" <<cxx . . $ `operator<<`(1c43a92f59c6a770). |
| 121 | "my provider" <<cxx . . $ `operator<<`(61fb880f51a53ddf). |
| 122 | providerInfo <<cxx . . $ `operator<<`(61fb880f51a53ddf). |
| 123 | applicationInfo <<cxx . . $ `operator<<`(1c43a92f59c6a770). |
| 124 | ""; |
| 125 | parameters.clearcxx . . $ QMap#clear(49f6e7a06ebc5aa8).(); |
| 126 | providerInfo.clearcxx . . $ QMap#clear(49f6e7a06ebc5aa8).(); |
| 127 | applicationInfo.clearcxx . . $ QMap#clear(49f6e7a06ebc5aa8).(); |
| 128 | |
| 129 | parameters.insertcxx . . $ QMap#insert(929a1ed410fe8423).(OAU_KEY_APPLICATIONcxx . . $ `online-accounts-common/globals.h:29:9`!, "Gallery"cxx . . $ QVariant#QVariant(85c52e162fed56f9).); |
| 130 | parameters.insertcxx . . $ QMap#insert(929a1ed410fe8423).(OAU_KEY_SERVICE_IDcxx . . $ `online-accounts-common/globals.h:31:9`!, "coolmail"cxx . . $ QVariant#QVariant(85c52e162fed56f9).); |
| 131 | providerInfo.insertcxx . . $ QMap#insert(929a1ed410fe8423).("name"cxx . . $ QString#QString(85c52e162fed56f9)., "cool"cxx . . $ QVariant#QVariant(85c52e162fed56f9).); |
| 132 | applicationInfo.insertcxx . . $ QMap#insert(929a1ed410fe8423).("one"cxx . . $ QString#QString(85c52e162fed56f9)., "two"cxx . . $ QVariant#QVariant(85c52e162fed56f9).); |
| 133 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("by service ID") <<cxx . . $ `operator<<`(61fb880f51a53ddf). |
| 134 | parameters <<cxx . . $ `operator<<`(1c43a92f59c6a770). |
| 135 | "my-app" <<cxx . . $ `operator<<`(1c43a92f59c6a770). |
| 136 | "cool" <<cxx . . $ `operator<<`(61fb880f51a53ddf). |
| 137 | providerInfo <<cxx . . $ `operator<<`(61fb880f51a53ddf). |
| 138 | applicationInfo <<cxx . . $ `operator<<`(1c43a92f59c6a770). |
| 139 | ""; |
| 140 | parameters.clearcxx . . $ QMap#clear(49f6e7a06ebc5aa8).(); |
| 141 | providerInfo.clearcxx . . $ QMap#clear(49f6e7a06ebc5aa8).(); |
| 142 | applicationInfo.clearcxx . . $ QMap#clear(49f6e7a06ebc5aa8).(); |
| 143 | } |
| 144 | |
| 145 | void ProviderRequestTestcxx . . $ ProviderRequestTest#::testParameterscxx . . $ ProviderRequestTest#testParameters(49f6e7a06ebc5aa8).() |
| 146 | { |
| 147 | QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QVariantMap, parameters); |
| 148 | QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, profile); |
| 149 | QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, providerId); |
| 150 | QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QVariantMap, providerInfo); |
| 151 | QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QVariantMap, applicationInfo); |
| 152 | QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, errorName); |
| 153 | |
| 154 | TestRequestcxx . . $ TestRequest# requestcxx . . $ TestRequest#TestRequest(768e9709461039cf).(parameters, profile); |
| 155 | RequestPrivatecxx . . $ OnlineAccountsUi/RequestPrivate# *mockedRequest = RequestPrivatecxx . . $ OnlineAccountsUi/RequestPrivate#::mockedcxx . . $ OnlineAccountsUi/RequestPrivate#mocked(6ea5f55120ff487).(&request); |
| 156 | QSignalSpycxx . . $ QSignalSpy# setWindowCalledcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(mockedRequest, |
| 157 | SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(setWindowCalled(QWindow*))); |
| 158 | QSignalSpycxx . . $ QSignalSpy# failCalledcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(mockedRequest, |
| 159 | SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(failCalled(const QString&, const QString&))); |
| 160 | |
| 161 | ApplicationManagercxx . . $ OnlineAccountsUi/ApplicationManager# *appManager = ApplicationManagercxx . . $ OnlineAccountsUi/ApplicationManager#::instancecxx . . $ OnlineAccountsUi/ApplicationManager#instance(e61827766a1125e9).(); |
| 162 | ApplicationManagerPrivatecxx . . $ OnlineAccountsUi/ApplicationManagerPrivate# *mockedAppManager = |
| 163 | ApplicationManagerPrivatecxx . . $ OnlineAccountsUi/ApplicationManagerPrivate#::mockedcxx . . $ OnlineAccountsUi/ApplicationManagerPrivate#mocked(3d28fd72a64f59bc).(appManager); |
| 164 | mockedAppManager->setApplicationInfocxx . . $ OnlineAccountsUi/ApplicationManagerPrivate#setApplicationInfo(dac83e64e8e6a438).(parameters[cxx . . $ QMap#`operator[]`(bbd415b616967878).OAU_KEY_APPLICATIONcxx . . $ `online-accounts-common/globals.h:29:9`!].toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).(), |
| 165 | applicationInfo); |
| 166 | mockedAppManager->setProviderInfocxx . . $ OnlineAccountsUi/ApplicationManagerPrivate#setProviderInfo(dac83e64e8e6a438).(providerId, providerInfo); |
| 167 | QSignalSpycxx . . $ QSignalSpy# applicationInfoCalledcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(mockedAppManager, |
| 168 | SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(applicationInfoCalled(QString,QString))); |
| 169 | |
| 170 | request.startcxx . . $ OnlineAccountsUi/ProviderRequest#start(49f6e7a06ebc5aa8).(); |
| 171 | |
| 172 | if (errorName.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 173 | QTRY_COMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:185:9`!(setWindowCalled.count(), 1); |
| 174 | QQuickViewcxx . . $ QQuickView# *view = static_cast<QQuickViewcxx . . $ QQuickView#*>(setWindowCalled.atcxx . . $ QList#at(e2681f9bb6b2f357).(0).atcxx . . $ QList#at(e2681f9bb6b2f357).(0).valuecxx . . $ QVariant#value(8f5363d873dd4781).<QWindowcxx . . $ QWindow#*>()); |
| 175 | QQmlContextcxx . . $ QQmlContext# *context = view->enginecxx . . $ QQuickView#engine(a2abd829983e1876).()->rootContextcxx . . $ QQmlEngine#rootContext(84d4a38f80cd3330).(); |
| 176 | QObjectcxx . . $ QObject# *request = context->contextPropertycxx . . $ QQmlContext#contextProperty(f6a024953685a9e0).("request"cxx . . $ QString#QString(85c52e162fed56f9).).valuecxx . . $ QVariant#value(8f5363d873dd4781).<QObjectcxx . . $ QObject#*>(); |
| 177 | |
| 178 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(applicationInfoCalled.count(), 1); |
| 179 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(applicationInfoCalled.at(0).at(1).toString(), profile); |
| 180 | |
| 181 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(request->property("provider").toMap(), providerInfo); |
| 182 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(request->property("application").toMap(), applicationInfo); |
| 183 | } else { |
| 184 | QTRY_COMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:185:9`!(failCalled.count(), 1); |
| 185 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(failCalled.at(0).at(0).toString(), errorName); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | QTEST_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:508:9`!(ProviderRequestTest); |
| 190 | |
| 191 | #include "tst_provider_request.moc"cxx . . $ `<file>/build/tests/online-accounts-ui/tst_provider_request/tst_provider_request_autogen/include/tst_provider_request.moc`/ |