File indexing completed on 2024-12-08 03:44:11

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 "serialsettingtest.h"
0008 
0009 #include "settings/serialsetting.h"
0010 
0011 #include <libnm/NetworkManager.h>
0012 
0013 #include <QTest>
0014 
0015 void SerialSettingTest::testSetting_data()
0016 {
0017     QTest::addColumn<quint32>("baud");
0018     QTest::addColumn<quint32>("bits");
0019     QTest::addColumn<QChar>("parity");
0020     QTest::addColumn<quint32>("stopbits");
0021     QTest::addColumn<quint64>("sendDelay");
0022 
0023     QTest::newRow("setting1") << (quint32)56000 // baud
0024                               << (quint32)16 // bits
0025                               << QChar('E') // parity
0026                               << (quint32)2 // stopbits
0027                               << (quint64)1000; // senddelay
0028 }
0029 
0030 void SerialSettingTest::testSetting()
0031 {
0032     QFETCH(quint32, baud);
0033     QFETCH(quint32, bits);
0034     QFETCH(QChar, parity);
0035     QFETCH(quint32, stopbits);
0036     QFETCH(quint64, sendDelay);
0037 
0038     QVariantMap map;
0039 
0040     map.insert(QLatin1String(NM_SETTING_SERIAL_BAUD), baud);
0041     map.insert(QLatin1String(NM_SETTING_SERIAL_BITS), bits);
0042     map.insert(QLatin1String(NM_SETTING_SERIAL_PARITY), parity);
0043     map.insert(QLatin1String(NM_SETTING_SERIAL_STOPBITS), stopbits);
0044     map.insert(QLatin1String(NM_SETTING_SERIAL_SEND_DELAY), sendDelay);
0045 
0046     NetworkManager::SerialSetting setting;
0047     setting.fromMap(map);
0048 
0049     QVariantMap map1 = setting.toMap();
0050     QVariantMap::const_iterator it = map.constBegin();
0051     while (it != map.constEnd()) {
0052         QCOMPARE(it.value(), map1.value(it.key()));
0053         ++it;
0054     }
0055 }
0056 
0057 QTEST_MAIN(SerialSettingTest)
0058 
0059 #include "moc_serialsettingtest.cpp"