File indexing completed on 2024-10-06 09:44:08
0001 /* 0002 SPDX-FileCopyrightText: 2012-2013 Jan Grulich <jgrulich@redhat.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "adslsettingtest.h" 0008 0009 #include "settings/adslsetting.h" 0010 0011 #include <libnm/NetworkManager.h> 0012 0013 #include <QTest> 0014 0015 void AdslSettingTest::testSetting_data() 0016 { 0017 QTest::addColumn<QString>("username"); 0018 QTest::addColumn<QString>("password"); 0019 QTest::addColumn<quint32>("passwordFlags"); 0020 QTest::addColumn<QString>("protocol"); 0021 QTest::addColumn<QString>("encapsulation"); 0022 QTest::addColumn<quint32>("vpi"); 0023 QTest::addColumn<quint32>("vci"); 0024 0025 QTest::newRow("setting1") << QString("username") // username 0026 << QString("password") // options 0027 << (quint32)2 // passwordFlags 0028 << "pppoa" // protocol 0029 << "llc" // encapsulation 0030 << (quint32)8 // vpi 0031 << (quint32)35; // vci 0032 } 0033 0034 void AdslSettingTest::testSetting() 0035 { 0036 QFETCH(QString, username); 0037 QFETCH(QString, password); 0038 QFETCH(quint32, passwordFlags); 0039 QFETCH(QString, protocol); 0040 QFETCH(QString, encapsulation); 0041 QFETCH(quint32, vpi); 0042 QFETCH(quint32, vci); 0043 0044 QVariantMap map; 0045 0046 map.insert(QLatin1String(NM_SETTING_ADSL_USERNAME), username); 0047 map.insert(QLatin1String(NM_SETTING_ADSL_PASSWORD), password); 0048 map.insert(QLatin1String(NM_SETTING_ADSL_PASSWORD_FLAGS), passwordFlags); 0049 map.insert(QLatin1String(NM_SETTING_ADSL_PROTOCOL), protocol); 0050 map.insert(QLatin1String(NM_SETTING_ADSL_ENCAPSULATION), encapsulation); 0051 map.insert(QLatin1String(NM_SETTING_ADSL_VPI), vpi); 0052 map.insert(QLatin1String(NM_SETTING_ADSL_VCI), vci); 0053 0054 NetworkManager::AdslSetting setting; 0055 setting.fromMap(map); 0056 0057 QVariantMap map1 = setting.toMap(); 0058 QVariantMap::const_iterator it = map.constBegin(); 0059 while (it != map.constEnd()) { 0060 QCOMPARE(it.value(), map1.value(it.key())); 0061 ++it; 0062 } 0063 } 0064 0065 QTEST_MAIN(AdslSettingTest) 0066 0067 #include "moc_adslsettingtest.cpp"