| 1 | /* |
| 2 | * Copyright 2014 Canonical Ltd. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU Lesser General Public License as published by |
| 6 | * the Free Software Foundation; version 3. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU Lesser General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU Lesser General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ |
| 16 | |
| 17 | #include <QtCore/QDebug> |
| 18 | #include <QtCore/QFile> |
| 19 | #include <QtCore/QRegularExpression> |
| 20 | #include <QtCore/QString> |
| 21 | #include <QtTest/QSignalSpy> |
| 22 | #include <QtTest/QTest> |
| 23 | #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= QT_VERSION_CHECKcxx . . $ `<external>/15045578679651060896/qglobal.h:61:9`!(6, 0, 0) |
| 24 | #include <LomiriToolkit-Qt6/private/ucserviceproperties_p_p.h> |
| 25 | #else |
| 26 | #include <LomiriToolkit/private/ucserviceproperties_p_p.h>cxx . . $ `<file>/include/LomiriToolkit/5.5.0/LomiriToolkit/private/ucserviceproperties_p_p.h`/ |
| 27 | #endif |
| 28 | |
| 29 | #include "qstringliteral.h" |
| 30 | #include "uctestcase.h"cxx . . $ `<file>/src/imports/Test/plugin/uctestcase.h`/ |
| 31 | |
| 32 | UT_USE_NAMESPACEcxx . . $ `src/LomiriToolkit/lomiritoolkitglobal.h:55:9`! |
| 33 | |
| 34 | class tst_ServicePropertiescxx . . $ tst_ServiceProperties# : public QObjectcxx . . $ QObject# |
| 35 | { |
| 36 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 37 | |
| 38 | public: |
| 39 | tst_ServicePropertiescxx . . $ tst_ServiceProperties#tst_ServiceProperties(49f6e7a06ebc5aa8).() {} |
| 40 | |
| 41 | private: |
| 42 | |
| 43 | QStringcxx . . $ QString# errorcxx . . $ tst_ServiceProperties#error.; |
| 44 | |
| 45 | // FIXME use LomiriTestCase::ignoreWaring in Vivid |
| 46 | void ignoreWarningcxx . . $ tst_ServiceProperties#ignoreWarning(b4044705ef85da45).(const QStringcxx . . $ QString#& fileName, uintcxx . . $ uint# line, uintcxx . . $ uint# column, const QStringcxx . . $ QString#& message, uintcxx . . $ uint# occurences=1) |
| 47 | { |
| 48 | for (uintcxx . . $ uint# i = 0; i < occurences; i++) { |
| 49 | QStringcxx . . $ QString# urlcxx . . $ QString#QString(45672f3c6961a244).(QUrlcxx . . $ QUrl#::fromLocalFilecxx . . $ QUrl#fromLocalFile(daf4b0201622af21).(QFileInfocxx . . $ QFileInfo#(fileName).absoluteFilePathcxx . . $ QFileInfo#absoluteFilePath(6ef7b6c27b00b43d).()).toEncodedcxx . . $ QUrl#toEncoded(7c604b7f5c0e832f).()); |
| 50 | QStringcxx . . $ QString# warning(QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1:%2:%3: %4").argcxx . . $ QString#arg(bc823072288cbbb5).(url).argcxx . . $ QString#arg(173a29139b43af1f).(line).argcxx . . $ QString#arg(173a29139b43af1f).(column).argcxx . . $ QString#arg(bc823072288cbbb5).(message)); |
| 51 | QTestcxx . . $ QTest/::ignoreMessagecxx . . $ QTest/ignoreMessage(fe94d6192f2696f8).(QtWarningMsgcxx . . $ QtWarningMsg., warning.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).()); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | |
| 56 | private Q_SLOTScxx . . $ `<external>/1208926524888476972/qobjectdefs.h:92:10`!: |
| 57 | |
| 58 | void initTestCasecxx . . $ tst_ServiceProperties#initTestCase(49f6e7a06ebc5aa8).() |
| 59 | { |
| 60 | // The test uses this schema, which might not be available on non-Ubuntu |
| 61 | // distros even though the AccountsService is available. |
| 62 | if (!QFilecxx . . $ QFile#::existscxx . . $ QFile#exists(e1defb592416720d).( |
| 63 | QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("/usr/share/accountsservice/interfaces/com.lomiri.touch.AccountsService.Sound.xml"))) { |
| 64 | errorcxx . . $ tst_ServiceProperties#error. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("Skip test: required schema not installed."); |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | // check if the connection is possible, otherwise we must skip all tests |
| 69 | QScopedPointercxx . . $ QScopedPointer#<LomiriTestCasecxx . . $ LomiriTestCase#> testcxx . . $ QScopedPointer#QScopedPointer(6f97683fca3ece44).(new LomiriTestCasecxx . . $ LomiriTestCase#("IncomingCallVibrateWatcher.qml"cxx . . $ QString#QString(85c52e162fed56f9).)); |
| 70 | UCServicePropertiescxx . . $ UCServiceProperties# *watcher = static_cast<UCServicePropertiescxx . . $ UCServiceProperties#*>(test->cxx . . $ QScopedPointer#`operator->`(34d6acfd341ba7ab).rootObjectcxx . . $ QQuickView#rootObject(e7eee0192cff5fb0).()->propertycxx . . $ QObject#property(950ff6813be46b58).("service").valuecxx . . $ QVariant#value(8f5363d873dd4781).<QObjectcxx . . $ QObject#*>()); |
| 71 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(watcher); |
| 72 | if (watcher->statuscxx . . $ UCServiceProperties#status(8646b725227fa3fc).() == UCServicePropertiescxx . . $ UCServiceProperties#::Synchronizingcxx . . $ UCServiceProperties#Synchronizing. || |
| 73 | watcher->statuscxx . . $ UCServiceProperties#status(8646b725227fa3fc).() == UCServicePropertiescxx . . $ UCServiceProperties#::Inactivecxx . . $ UCServiceProperties#Inactive.) { |
| 74 | QSignalSpycxx . . $ QSignalSpy# waitcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(watcher, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(statusChanged())); |
| 75 | wait.waitcxx . . $ QSignalSpy#wait(83c267b20bac841a).(); |
| 76 | } |
| 77 | if (watcher->statuscxx . . $ UCServiceProperties#status(8646b725227fa3fc).() == UCServicePropertiescxx . . $ UCServiceProperties#::ConnectionErrorcxx . . $ UCServiceProperties#ConnectionError.) { |
| 78 | errorcxx . . $ tst_ServiceProperties#error. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). "Skip test: " +cxx . . $ operator+(c75c3ae4eb9af1a8). watcher->errorcxx . . $ UCServiceProperties#error(4365c3963150523e).(); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | void cleanupcxx . . $ tst_ServiceProperties#cleanup(49f6e7a06ebc5aa8).() |
| 83 | { |
| 84 | // restore env var setting |
| 85 | qputenvcxx . . $ qputenv(d42e8231112a1b5b).("SHOW_SERVICEPROPERTIES_WARNINGS", QByteArraycxx . . $ QByteArray#QByteArray(ced63f7c635d850d).()); |
| 86 | } |
| 87 | |
| 88 | void test_change_propertycxx . . $ tst_ServiceProperties#test_change_property(49f6e7a06ebc5aa8).() |
| 89 | { |
| 90 | if (!errorcxx . . $ tst_ServiceProperties#error..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 91 | QSKIPcxx . . $ `<external>/8602788698586413231/qtestcase.h:193:9`!(qPrintablecxx . . $ `<external>/15045578679651060896/qglobal.h:831:11`!(error)); |
| 92 | } |
| 93 | QScopedPointercxx . . $ QScopedPointer#<LomiriTestCasecxx . . $ LomiriTestCase#> testcxx . . $ QScopedPointer#QScopedPointer(6f97683fca3ece44).(new LomiriTestCasecxx . . $ LomiriTestCase#("IncomingCallVibrateWatcher.qml"cxx . . $ QString#QString(85c52e162fed56f9).)); |
| 94 | UCServicePropertiescxx . . $ UCServiceProperties# *watcher = static_cast<UCServicePropertiescxx . . $ UCServiceProperties#*>(test->cxx . . $ QScopedPointer#`operator->`(34d6acfd341ba7ab).rootObjectcxx . . $ QQuickView#rootObject(e7eee0192cff5fb0).()->propertycxx . . $ QObject#property(950ff6813be46b58).("service").valuecxx . . $ QVariant#value(8f5363d873dd4781).<QObjectcxx . . $ QObject#*>()); |
| 95 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(watcher); |
| 96 | |
| 97 | bool backup = watcher->propertycxx . . $ QObject#property(950ff6813be46b58).("incomingCallVibrate").toBoolcxx . . $ QVariant#toBool(50ce9a9e25b4a850).(); |
| 98 | UCServicePropertiesPrivatecxx . . $ UCServicePropertiesPrivate# *pWatcher = UCServicePropertiesPrivatecxx . . $ UCServicePropertiesPrivate#::getcxx . . $ UCServicePropertiesPrivate#get(e79cfc62acad238f).(watcher); |
| 99 | QSignalSpycxx . . $ QSignalSpy# spycxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(watcher, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(incomingCallVibrateChanged())); |
| 100 | pWatcher->testPropertycxx . . $ UCServicePropertiesPrivate#testProperty(70982970542b5878).("IncomingCallVibrate"cxx . . $ QString#QString(85c52e162fed56f9)., !cxx . . $ QVariant#QVariant(b45ddcbc8423892c).backup); |
| 101 | spy.waitcxx . . $ QSignalSpy#wait(83c267b20bac841a).(400); |
| 102 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(spy.count(), 1); |
| 103 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(watcher->property("incomingCallVibrate").toBool(), !backup); |
| 104 | |
| 105 | // restore value |
| 106 | spy.clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).(); |
| 107 | pWatcher->testPropertycxx . . $ UCServicePropertiesPrivate#testProperty(70982970542b5878).("IncomingCallVibrate"cxx . . $ QString#QString(85c52e162fed56f9)., backupcxx . . $ QVariant#QVariant(b45ddcbc8423892c).); |
| 108 | spy.waitcxx . . $ QSignalSpy#wait(83c267b20bac841a).(400); |
| 109 | } |
| 110 | |
| 111 | void test_environment_variable_datacxx . . $ tst_ServiceProperties#test_environment_variable_data(49f6e7a06ebc5aa8).() |
| 112 | { |
| 113 | QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QByteArraycxx . . $ QByteArray#>("value"); |
| 114 | QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<bool>("warning"); |
| 115 | |
| 116 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("empty string, no warning") <<cxx . . $ `operator<<`(61fb880f51a53ddf). QByteArraycxx . . $ QByteArray#QByteArray(ced63f7c635d850d).() <<cxx . . $ `operator<<`(61fb880f51a53ddf). false; |
| 117 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("0 integer, no warning") <<cxx . . $ `operator<<`(61fb880f51a53ddf). QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("0") <<cxx . . $ `operator<<`(61fb880f51a53ddf). false; |
| 118 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("boolean false, no warning") <<cxx . . $ `operator<<`(61fb880f51a53ddf). QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("false") <<cxx . . $ `operator<<`(61fb880f51a53ddf). false; |
| 119 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("boolean FALSE, no warning") <<cxx . . $ `operator<<`(61fb880f51a53ddf). QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("false") <<cxx . . $ `operator<<`(61fb880f51a53ddf). false; |
| 120 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("1 integer, warning") <<cxx . . $ `operator<<`(61fb880f51a53ddf). QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("1") <<cxx . . $ `operator<<`(61fb880f51a53ddf). true; |
| 121 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("boolean true, warning") <<cxx . . $ `operator<<`(61fb880f51a53ddf). QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("true") <<cxx . . $ `operator<<`(61fb880f51a53ddf). true; |
| 122 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("boolean TRUE, warning") <<cxx . . $ `operator<<`(61fb880f51a53ddf). QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("true") <<cxx . . $ `operator<<`(61fb880f51a53ddf). true; |
| 123 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("positive integer, no warning") <<cxx . . $ `operator<<`(61fb880f51a53ddf). QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("5") <<cxx . . $ `operator<<`(61fb880f51a53ddf). false; |
| 124 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("invalid integral value, no warning") <<cxx . . $ `operator<<`(61fb880f51a53ddf). QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("whatever") <<cxx . . $ `operator<<`(61fb880f51a53ddf). false; |
| 125 | } |
| 126 | |
| 127 | void test_environment_variablecxx . . $ tst_ServiceProperties#test_environment_variable(49f6e7a06ebc5aa8).() |
| 128 | { |
| 129 | if (!errorcxx . . $ tst_ServiceProperties#error..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 130 | QSKIPcxx . . $ `<external>/8602788698586413231/qtestcase.h:193:9`!(qPrintablecxx . . $ `<external>/15045578679651060896/qglobal.h:831:11`!(error)); |
| 131 | } |
| 132 | QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QByteArray, value); |
| 133 | QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(bool, warning); |
| 134 | qputenvcxx . . $ qputenv(d42e8231112a1b5b).("SHOW_SERVICEPROPERTIES_WARNINGS", value); |
| 135 | if (warning) { |
| 136 | // \u201C is a "Left Double Quotation Mark", and \u201D is "Right Double Quotation Mark" |
| 137 | QRegularExpressioncxx . . $ QRegularExpression# warningRecxx . . $ QRegularExpression#QRegularExpression(4279d2539df7cd4a).(QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!(u" QML ServiceProperties: No such property ['\u201C]ThisIsAnInvalidPropertyToWatch['\u201D]$")); |
| 138 | QTestcxx . . $ QTest/::ignoreMessagecxx . . $ QTest/ignoreMessage(f69cfd74466c3965).(QtWarningMsgcxx . . $ QtWarningMsg., warningRe); |
| 139 | |
| 140 | } |
| 141 | QScopedPointercxx . . $ QScopedPointer#<LomiriTestCasecxx . . $ LomiriTestCase#> testcxx . . $ QScopedPointer#QScopedPointer(6f97683fca3ece44).(new LomiriTestCasecxx . . $ LomiriTestCase#("InvalidPropertyWatcher.qml"cxx . . $ QString#QString(85c52e162fed56f9).)); |
| 142 | UCServicePropertiescxx . . $ UCServiceProperties# *watcher = static_cast<UCServicePropertiescxx . . $ UCServiceProperties#*>(test->cxx . . $ QScopedPointer#`operator->`(34d6acfd341ba7ab).rootObjectcxx . . $ QQuickView#rootObject(e7eee0192cff5fb0).()->propertycxx . . $ QObject#property(950ff6813be46b58).("service").valuecxx . . $ QVariant#value(8f5363d873dd4781).<QObjectcxx . . $ QObject#*>()); |
| 143 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(watcher); |
| 144 | // error should contain the warning |
| 145 | // \u201C is a "Left Double Quotation Mark", and \u201D is "Right Double Quotation Mark" |
| 146 | // And sometimes they appear as '?' for some reason. However, that's beside the point of the test. |
| 147 | QRegularExpressioncxx . . $ QRegularExpression# errorRecxx . . $ QRegularExpression#QRegularExpression(4279d2539df7cd4a).(QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!(u"^No such property ['\u201C?]ThisIsAnInvalidPropertyToWatch['\u201D?]$")); |
| 148 | QTRY_VERIFY2cxx . . $ `<external>/8602788698586413231/qtestcase.h:176:9`!(errorRe.match(watcher->property("error").toString()).hasMatch(), |
| 149 | qPrintablecxx . . $ `<external>/15045578679651060896/qglobal.h:831:11`!(QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("The content of the \"error\" property is \"%1\"") |
| 150 | .arg(watcher->property("error").toString()))); |
| 151 | } |
| 152 | |
| 153 | void test_invalid_property_datacxx . . $ tst_ServiceProperties#test_invalid_property_data(49f6e7a06ebc5aa8).() |
| 154 | { |
| 155 | QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<bool>("warning"); |
| 156 | |
| 157 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("Without warning") <<cxx . . $ `operator<<`(61fb880f51a53ddf). false; |
| 158 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("With warning") <<cxx . . $ `operator<<`(61fb880f51a53ddf). true; |
| 159 | } |
| 160 | void test_invalid_propertycxx . . $ tst_ServiceProperties#test_invalid_property(49f6e7a06ebc5aa8).() |
| 161 | { |
| 162 | if (!errorcxx . . $ tst_ServiceProperties#error..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 163 | QSKIPcxx . . $ `<external>/8602788698586413231/qtestcase.h:193:9`!(qPrintablecxx . . $ `<external>/15045578679651060896/qglobal.h:831:11`!(error)); |
| 164 | } |
| 165 | QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(bool, warning); |
| 166 | qputenvcxx . . $ qputenv(d42e8231112a1b5b).("SHOW_SERVICEPROPERTIES_WARNINGS", warningcxx . . $ QByteArray#QByteArray(34d26762b42c433a). ? "1" : "0"); |
| 167 | if (warning) { |
| 168 | // \u201C is a "Left Double Quotation Mark", and \u201D is "Right Double Quotation Mark" |
| 169 | QRegularExpressioncxx . . $ QRegularExpression# warningRecxx . . $ QRegularExpression#QRegularExpression(4279d2539df7cd4a).(QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!(u" QML ServiceProperties: No such property ['\u201C]ThisIsAnInvalidPropertyToWatch['\u201D]$")); |
| 170 | QTestcxx . . $ QTest/::ignoreMessagecxx . . $ QTest/ignoreMessage(f69cfd74466c3965).(QtWarningMsgcxx . . $ QtWarningMsg., warningRe); |
| 171 | } |
| 172 | QScopedPointercxx . . $ QScopedPointer#<LomiriTestCasecxx . . $ LomiriTestCase#> testcxx . . $ QScopedPointer#QScopedPointer(6f97683fca3ece44).(new LomiriTestCasecxx . . $ LomiriTestCase#("InvalidPropertyWatcher.qml"cxx . . $ QString#QString(85c52e162fed56f9).)); |
| 173 | UCServicePropertiescxx . . $ UCServiceProperties# *watcher = static_cast<UCServicePropertiescxx . . $ UCServiceProperties#*>(test->cxx . . $ QScopedPointer#`operator->`(34d6acfd341ba7ab).rootObjectcxx . . $ QQuickView#rootObject(e7eee0192cff5fb0).()->propertycxx . . $ QObject#property(950ff6813be46b58).("service").valuecxx . . $ QVariant#value(8f5363d873dd4781).<QObjectcxx . . $ QObject#*>()); |
| 174 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(watcher); |
| 175 | // error should contain the warning |
| 176 | // \u201C is a "Left Double Quotation Mark", and \u201D is "Right Double Quotation Mark" |
| 177 | // And sometimes they appear as '?' for some reason. However, that's beside the point of the test. |
| 178 | QRegularExpressioncxx . . $ QRegularExpression# errorRecxx . . $ QRegularExpression#QRegularExpression(4279d2539df7cd4a).(QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!(u"^No such property ['\u201C?]ThisIsAnInvalidPropertyToWatch['\u201D?]$")); |
| 179 | QTRY_VERIFY2cxx . . $ `<external>/8602788698586413231/qtestcase.h:176:9`!(errorRe.match(watcher->property("error").toString()).hasMatch(), |
| 180 | qPrintablecxx . . $ `<external>/15045578679651060896/qglobal.h:831:11`!(QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("The content of the \"error\" property is \"%1\"") |
| 181 | .arg(watcher->property("error").toString()))); |
| 182 | } |
| 183 | |
| 184 | void test_one_valid_one_invalid_property_datacxx . . $ tst_ServiceProperties#test_one_valid_one_invalid_property_data(49f6e7a06ebc5aa8).() |
| 185 | { |
| 186 | QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<bool>("warning"); |
| 187 | |
| 188 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("Without warning") <<cxx . . $ `operator<<`(61fb880f51a53ddf). false; |
| 189 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("With warning") <<cxx . . $ `operator<<`(61fb880f51a53ddf). true; |
| 190 | } |
| 191 | void test_one_valid_one_invalid_propertycxx . . $ tst_ServiceProperties#test_one_valid_one_invalid_property(49f6e7a06ebc5aa8).() |
| 192 | { |
| 193 | if (!errorcxx . . $ tst_ServiceProperties#error..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 194 | QSKIPcxx . . $ `<external>/8602788698586413231/qtestcase.h:193:9`!(qPrintablecxx . . $ `<external>/15045578679651060896/qglobal.h:831:11`!(error)); |
| 195 | } |
| 196 | QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(bool, warning); |
| 197 | qputenvcxx . . $ qputenv(d42e8231112a1b5b).("SHOW_SERVICEPROPERTIES_WARNINGS", warningcxx . . $ QByteArray#QByteArray(34d26762b42c433a). ? "1" : "0"); |
| 198 | if (warning) { |
| 199 | // \u201C is a "Left Double Quotation Mark", and \u201D is "Right Double Quotation Mark" |
| 200 | QRegularExpressioncxx . . $ QRegularExpression# warningRecxx . . $ QRegularExpression#QRegularExpression(4279d2539df7cd4a).(QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!(u" QML ServiceProperties: No such property ['\u201C]ThisIsAnInvalidPropertyToWatch['\u201D]$")); |
| 201 | QTestcxx . . $ QTest/::ignoreMessagecxx . . $ QTest/ignoreMessage(f69cfd74466c3965).(QtWarningMsgcxx . . $ QtWarningMsg., warningRe); |
| 202 | |
| 203 | } |
| 204 | QScopedPointercxx . . $ QScopedPointer#<LomiriTestCasecxx . . $ LomiriTestCase#> testcxx . . $ QScopedPointer#QScopedPointer(6f97683fca3ece44).(new LomiriTestCasecxx . . $ LomiriTestCase#("InvalidPropertyWatcher2.qml"cxx . . $ QString#QString(85c52e162fed56f9).)); |
| 205 | UCServicePropertiescxx . . $ UCServiceProperties# *watcher = static_cast<UCServicePropertiescxx . . $ UCServiceProperties#*>(test->cxx . . $ QScopedPointer#`operator->`(34d6acfd341ba7ab).rootObjectcxx . . $ QQuickView#rootObject(e7eee0192cff5fb0).()->propertycxx . . $ QObject#property(950ff6813be46b58).("service").valuecxx . . $ QVariant#value(8f5363d873dd4781).<QObjectcxx . . $ QObject#*>()); |
| 206 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(watcher); |
| 207 | // error should contain the wearning |
| 208 | // \u201C is a "Left Double Quotation Mark", and \u201D is "Right Double Quotation Mark" |
| 209 | // And sometimes they appear as '?' for some reason. However, that's beside the point of the test. |
| 210 | QRegularExpressioncxx . . $ QRegularExpression# errorRecxx . . $ QRegularExpression#QRegularExpression(4279d2539df7cd4a).(QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!(u"^No such property ['\u201C?]ThisIsAnInvalidPropertyToWatch['\u201D?]$")); |
| 211 | QTRY_VERIFY2cxx . . $ `<external>/8602788698586413231/qtestcase.h:176:9`!(errorRe.match(watcher->property("error").toString()).hasMatch(), |
| 212 | qPrintablecxx . . $ `<external>/15045578679651060896/qglobal.h:831:11`!(QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("The content of \"error\" property is \"%1\"") |
| 213 | .arg(watcher->property("error").toString()))); |
| 214 | } |
| 215 | |
| 216 | void test_change_connection_props_datacxx . . $ tst_ServiceProperties#test_change_connection_props_data(49f6e7a06ebc5aa8).() |
| 217 | { |
| 218 | QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("property"); |
| 219 | QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<QStringcxx . . $ QString#>("value"); |
| 220 | QTestcxx . . $ QTest/::addColumncxx . . $ QTest/addColumn(cfe4d590606f2f46).<bool>("warning"); |
| 221 | |
| 222 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("Changing servcie, no warning") <<cxx . . $ `operator<<`(1c43a92f59c6a770). "service" <<cxx . . $ `operator<<`(1c43a92f59c6a770). "anything.else" <<cxx . . $ `operator<<`(61fb880f51a53ddf). false; |
| 223 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("Changing servcie, with warning") <<cxx . . $ `operator<<`(1c43a92f59c6a770). "service" <<cxx . . $ `operator<<`(1c43a92f59c6a770). "anything.else" <<cxx . . $ `operator<<`(61fb880f51a53ddf). true; |
| 224 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("Changing interface, no warning") <<cxx . . $ `operator<<`(1c43a92f59c6a770). "serviceInterface" <<cxx . . $ `operator<<`(1c43a92f59c6a770). "anything.else" <<cxx . . $ `operator<<`(61fb880f51a53ddf). false; |
| 225 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("Changing interface, with warning") <<cxx . . $ `operator<<`(1c43a92f59c6a770). "serviceInterface" <<cxx . . $ `operator<<`(1c43a92f59c6a770). "anything.else" <<cxx . . $ `operator<<`(61fb880f51a53ddf). true; |
| 226 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("Changing adaptor, no warning") <<cxx . . $ `operator<<`(1c43a92f59c6a770). "adaptorInterface" <<cxx . . $ `operator<<`(1c43a92f59c6a770). "anything.else" <<cxx . . $ `operator<<`(61fb880f51a53ddf). false; |
| 227 | QTestcxx . . $ QTest/::newRowcxx . . $ QTest/newRow(71534bb7a360de38).("Changing adaptor, with warning") <<cxx . . $ `operator<<`(1c43a92f59c6a770). "adaptorInterface" <<cxx . . $ `operator<<`(1c43a92f59c6a770). "anything.else" <<cxx . . $ `operator<<`(61fb880f51a53ddf). true; |
| 228 | } |
| 229 | void test_change_connection_propscxx . . $ tst_ServiceProperties#test_change_connection_props(49f6e7a06ebc5aa8).() |
| 230 | { |
| 231 | QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, property); |
| 232 | QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(QString, value); |
| 233 | |
| 234 | if (!errorcxx . . $ tst_ServiceProperties#error..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 235 | QSKIPcxx . . $ `<external>/8602788698586413231/qtestcase.h:193:9`!(qPrintablecxx . . $ `<external>/15045578679651060896/qglobal.h:831:11`!(error)); |
| 236 | } |
| 237 | QFETCHcxx . . $ `<external>/8602788698586413231/qtestcase.h:201:9`!(bool, warning); |
| 238 | qputenvcxx . . $ qputenv(d42e8231112a1b5b).("SHOW_SERVICEPROPERTIES_WARNINGS", warningcxx . . $ QByteArray#QByteArray(34d26762b42c433a). ? "1" : "0"); |
| 239 | if (warning) { |
| 240 | ignoreWarningcxx . . $ tst_ServiceProperties#ignoreWarning(b4044705ef85da45).("IncomingCallVibrateWatcher.qml"cxx . . $ QString#QString(85c52e162fed56f9)., 22, 5, "QML ServiceProperties: Changing connection parameters forbidden."cxx . . $ QString#QString(85c52e162fed56f9).); |
| 241 | } |
| 242 | QScopedPointercxx . . $ QScopedPointer#<LomiriTestCasecxx . . $ LomiriTestCase#> testcxx . . $ QScopedPointer#QScopedPointer(6f97683fca3ece44).(new LomiriTestCasecxx . . $ LomiriTestCase#("IncomingCallVibrateWatcher.qml"cxx . . $ QString#QString(85c52e162fed56f9).)); |
| 243 | UCServicePropertiescxx . . $ UCServiceProperties# *watcher = static_cast<UCServicePropertiescxx . . $ UCServiceProperties#*>(test->cxx . . $ QScopedPointer#`operator->`(34d6acfd341ba7ab).rootObjectcxx . . $ QQuickView#rootObject(e7eee0192cff5fb0).()->propertycxx . . $ QObject#property(950ff6813be46b58).("service").valuecxx . . $ QVariant#value(8f5363d873dd4781).<QObjectcxx . . $ QObject#*>()); |
| 244 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(watcher); |
| 245 | |
| 246 | // try to change the property |
| 247 | watcher->setPropertycxx . . $ QObject#setProperty(395943cdf6cf5058).(property.toLocal8Bitcxx . . $ QString#toLocal8Bit(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), valuecxx . . $ QVariant#QVariant(3520e46b33348bf6).); |
| 248 | // error shoudl also have the warning |
| 249 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(watcher->property("error").toString(), QString("Changing connection parameters forbidden.")); |
| 250 | } |
| 251 | |
| 252 | }; |
| 253 | |
| 254 | QTEST_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:508:9`!(tst_ServiceProperties) |
| 255 | |
| 256 | #include "tst_serviceproperties.moc"cxx . . $ `<file>/tests/unit/serviceproperties11/.moc/tst_serviceproperties.moc`/ |