/* SPDX-FileCopyrightText: 2012-2013 Jan Grulich SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "gsmsettingtest.h" #include "settings/gsmsetting.h" #include #include void GsmSettingTest::testSetting_data() { QTest::addColumn("number"); QTest::addColumn("username"); QTest::addColumn("password"); QTest::addColumn("passwordFlags"); QTest::addColumn("apn"); QTest::addColumn("networkId"); QTest::addColumn("networkType"); QTest::addColumn("pin"); QTest::addColumn("pinFlags"); QTest::addColumn("allowedBand"); QTest::addColumn("homeOnly"); QTest::addColumn("deviceId"); QTest::addColumn("simId"); QTest::addColumn("simOperatorId"); QTest::newRow("setting1") << QString("0123456789") // number << QString("foo") // username << QString("bar") // password << (qint32)2 // passwordFlags << QString("test") // apn << QString("MCC-MNC") // networkId << (qint32)1 // networkType << QString("1010") // pin << (qint32)4 // pinFlags << (quint32)0 // allowedBand << true // homeOnly << QString("someDeviceId") // deviceId << QString("someSimId") // simId << QString("someSimOperatorId"); // simOperatorId } void GsmSettingTest::testSetting() { QFETCH(QString, number); QFETCH(QString, username); QFETCH(QString, password); QFETCH(qint32, passwordFlags); QFETCH(QString, apn); QFETCH(QString, networkId); QFETCH(qint32, networkType); QFETCH(QString, pin); QFETCH(qint32, pinFlags); QFETCH(quint32, allowedBand); QFETCH(bool, homeOnly); QFETCH(QString, deviceId); QFETCH(QString, simId); QFETCH(QString, simOperatorId); QVariantMap map; map.insert(QLatin1String(NM_SETTING_GSM_NUMBER), number); map.insert(QLatin1String(NM_SETTING_GSM_USERNAME), username); map.insert(QLatin1String(NM_SETTING_GSM_PASSWORD), password); map.insert(QLatin1String(NM_SETTING_GSM_PASSWORD_FLAGS), passwordFlags); map.insert(QLatin1String(NM_SETTING_GSM_APN), apn); map.insert(QLatin1String(NM_SETTING_GSM_NETWORK_ID), networkId); map.insert(QLatin1String("network-type"), networkType); map.insert(QLatin1String("allowed-bands"), allowedBand); map.insert(QLatin1String(NM_SETTING_GSM_PIN), pin); map.insert(QLatin1String(NM_SETTING_GSM_PIN_FLAGS), pinFlags); map.insert(QLatin1String(NM_SETTING_GSM_HOME_ONLY), homeOnly); map.insert(QLatin1String(NM_SETTING_GSM_DEVICE_ID), deviceId); map.insert(QLatin1String(NM_SETTING_GSM_SIM_ID), simId); map.insert(QLatin1String(NM_SETTING_GSM_SIM_OPERATOR_ID), simOperatorId); NetworkManager::GsmSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(GsmSettingTest) #include "moc_gsmsettingtest.cpp"