File indexing completed on 2024-11-10 03:42:53

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 "pppoesettingtest.h"
0008 
0009 #include "settings/pppoesetting.h"
0010 
0011 #include <libnm/NetworkManager.h>
0012 
0013 #include <QTest>
0014 
0015 void PppoeSettingTest::testSetting_data()
0016 {
0017     QTest::addColumn<QString>("service");
0018     QTest::addColumn<QString>("username");
0019     QTest::addColumn<QString>("password");
0020     QTest::addColumn<quint32>("passwordFlags");
0021 
0022     QTest::newRow("setting1") << QString("service") // service
0023                               << QString("username") // username
0024                               << QString("password") // password
0025                               << (quint32)3; // passwordFlags
0026 }
0027 
0028 void PppoeSettingTest::testSetting()
0029 {
0030     QFETCH(QString, service);
0031     QFETCH(QString, username);
0032     QFETCH(QString, password);
0033     QFETCH(quint32, passwordFlags);
0034 
0035     QVariantMap map;
0036 
0037     map.insert(QLatin1String(NM_SETTING_PPPOE_SERVICE), service);
0038     map.insert(QLatin1String(NM_SETTING_PPPOE_USERNAME), username);
0039     map.insert(QLatin1String(NM_SETTING_PPPOE_PASSWORD), password);
0040     map.insert(QLatin1String(NM_SETTING_PPPOE_PASSWORD_FLAGS), passwordFlags);
0041 
0042     NetworkManager::PppoeSetting setting;
0043     setting.fromMap(map);
0044 
0045     QVariantMap map1 = setting.toMap();
0046     QVariantMap::const_iterator it = map.constBegin();
0047     while (it != map.constEnd()) {
0048         QCOMPARE(it.value(), map1.value(it.key()));
0049         ++it;
0050     }
0051 }
0052 
0053 QTEST_MAIN(PppoeSettingTest)
0054 
0055 #include "moc_pppoesettingtest.cpp"