File indexing completed on 2024-10-06 03:43:32

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 "cdmasettingtest.h"
0008 
0009 #include "settings/cdmasetting.h"
0010 
0011 #include <libnm/NetworkManager.h>
0012 
0013 #include <QTest>
0014 
0015 void CdmaSettingTest::testSetting_data()
0016 {
0017     QTest::addColumn<QString>("number");
0018     QTest::addColumn<QString>("username");
0019     QTest::addColumn<QString>("password");
0020     QTest::addColumn<quint32>("passwordFlags");
0021 
0022     QTest::newRow("setting1") << QString("#123456789") // number
0023                               << QString("username") // username
0024                               << QString("password") // password
0025                               << (quint32)2; // passwordFlags
0026 }
0027 
0028 void CdmaSettingTest::testSetting()
0029 {
0030     QFETCH(QString, number);
0031     QFETCH(QString, username);
0032     QFETCH(QString, password);
0033     QFETCH(quint32, passwordFlags);
0034 
0035     QVariantMap map;
0036 
0037     map.insert(QLatin1String(NM_SETTING_CDMA_NUMBER), number);
0038     map.insert(QLatin1String(NM_SETTING_CDMA_USERNAME), username);
0039     map.insert(QLatin1String(NM_SETTING_CDMA_PASSWORD), password);
0040     map.insert(QLatin1String(NM_SETTING_CDMA_PASSWORD_FLAGS), passwordFlags);
0041 
0042     NetworkManager::CdmaSetting 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(CdmaSettingTest)
0054 
0055 #include "moc_cdmasettingtest.cpp"