File indexing completed on 2024-12-01 12:40:54
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 "pppsettingtest.h" 0008 0009 #include "settings/pppsetting.h" 0010 0011 #include <libnm/NetworkManager.h> 0012 0013 #include <QTest> 0014 0015 void PppSettingTest::testSetting_data() 0016 { 0017 QTest::addColumn<bool>("noAuth"); 0018 QTest::addColumn<bool>("refuseEap"); 0019 QTest::addColumn<bool>("refusePap"); 0020 QTest::addColumn<bool>("refuseChap"); 0021 QTest::addColumn<bool>("refuseMschap"); 0022 QTest::addColumn<bool>("refuseMschapv2"); 0023 QTest::addColumn<bool>("noBsdComp"); 0024 QTest::addColumn<bool>("noDeflate"); 0025 QTest::addColumn<bool>("noVjCompare"); 0026 QTest::addColumn<bool>("requireMppe"); 0027 QTest::addColumn<bool>("requireMppe128"); 0028 QTest::addColumn<bool>("mppeStateful"); 0029 QTest::addColumn<bool>("cRtsCts"); 0030 QTest::addColumn<quint32>("baud"); 0031 QTest::addColumn<quint32>("mru"); 0032 QTest::addColumn<quint32>("mtu"); 0033 QTest::addColumn<quint32>("lcpEchoFailure"); 0034 QTest::addColumn<quint32>("lcpEchoInterval"); 0035 0036 QTest::newRow("setting1") << false // noAuth 0037 << true // refuseEap 0038 << true // refusePap 0039 << true // refuseChap 0040 << true // refuseMschap 0041 << true // refuseMschapv2 0042 << true // noBsdComp 0043 << true // noDeflate 0044 << true // noVjCompare 0045 << true // requireMppe 0046 << true // requireMppe128 0047 << true // mppeStateful 0048 << true // cRtsCts 0049 << (quint32)1000 // baud 0050 << (quint32)128 // mru 0051 << (quint32)500 // mtu 0052 << (quint32)2 // lcpEchoFailure 0053 << (quint32)3; // lcpEchoInterval 0054 } 0055 0056 void PppSettingTest::testSetting() 0057 { 0058 QFETCH(bool, noAuth); 0059 QFETCH(bool, refuseEap); 0060 QFETCH(bool, refusePap); 0061 QFETCH(bool, refuseChap); 0062 QFETCH(bool, refuseMschap); 0063 QFETCH(bool, refuseMschapv2); 0064 QFETCH(bool, noBsdComp); 0065 QFETCH(bool, noDeflate); 0066 QFETCH(bool, noVjCompare); 0067 QFETCH(bool, requireMppe); 0068 QFETCH(bool, requireMppe128); 0069 QFETCH(bool, mppeStateful); 0070 QFETCH(bool, cRtsCts); 0071 QFETCH(quint32, baud); 0072 QFETCH(quint32, mru); 0073 QFETCH(quint32, mtu); 0074 QFETCH(quint32, lcpEchoFailure); 0075 QFETCH(quint32, lcpEchoInterval); 0076 0077 QVariantMap map; 0078 0079 map.insert(QLatin1String(NM_SETTING_PPP_NOAUTH), noAuth); 0080 map.insert(QLatin1String(NM_SETTING_PPP_REFUSE_EAP), refuseEap); 0081 map.insert(QLatin1String(NM_SETTING_PPP_REFUSE_PAP), refusePap); 0082 map.insert(QLatin1String(NM_SETTING_PPP_REFUSE_CHAP), refuseChap); 0083 map.insert(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAP), refuseMschap); 0084 map.insert(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAPV2), refuseMschapv2); 0085 map.insert(QLatin1String(NM_SETTING_PPP_NOBSDCOMP), noBsdComp); 0086 map.insert(QLatin1String(NM_SETTING_PPP_NODEFLATE), noDeflate); 0087 map.insert(QLatin1String(NM_SETTING_PPP_NO_VJ_COMP), noVjCompare); 0088 map.insert(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE), requireMppe); 0089 map.insert(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE_128), requireMppe128); 0090 map.insert(QLatin1String(NM_SETTING_PPP_MPPE_STATEFUL), mppeStateful); 0091 map.insert(QLatin1String(NM_SETTING_PPP_CRTSCTS), cRtsCts); 0092 map.insert(QLatin1String(NM_SETTING_PPP_BAUD), baud); 0093 map.insert(QLatin1String(NM_SETTING_PPP_MRU), mru); 0094 map.insert(QLatin1String(NM_SETTING_PPP_MTU), mtu); 0095 map.insert(QLatin1String(NM_SETTING_PPP_LCP_ECHO_FAILURE), lcpEchoFailure); 0096 map.insert(QLatin1String(NM_SETTING_PPP_LCP_ECHO_INTERVAL), lcpEchoInterval); 0097 0098 NetworkManager::PppSetting setting; 0099 setting.fromMap(map); 0100 0101 QVariantMap map1 = setting.toMap(); 0102 QVariantMap::const_iterator it = map.constBegin(); 0103 while (it != map.constEnd()) { 0104 QCOMPARE(it.value(), map1.value(it.key())); 0105 ++it; 0106 } 0107 } 0108 0109 QTEST_MAIN(PppSettingTest) 0110 0111 #include "moc_pppsettingtest.cpp"