File indexing completed on 2024-12-01 03:44:46

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 "bridgesettingtest.h"
0008 
0009 #include "settings/bridgesetting.h"
0010 
0011 #include <libnm/NetworkManager.h>
0012 
0013 #include <QTest>
0014 
0015 void BridgeSettingTest::testSetting_data()
0016 {
0017     QTest::addColumn<QString>("interfaceName");
0018     QTest::addColumn<bool>("stp");
0019     QTest::addColumn<quint16>("priority");
0020     QTest::addColumn<quint16>("forwardDelay");
0021     QTest::addColumn<quint16>("helloTime");
0022     QTest::addColumn<quint16>("maxAge");
0023     QTest::addColumn<quint32>("ageintTime");
0024     QTest::addColumn<bool>("multicastSnooping");
0025     QTest::addColumn<QByteArray>("macAddress");
0026 
0027     QTest::newRow("setting1") << QString("eth0") // interfaceName
0028                               << false // stp
0029                               << (quint16)10 // priority
0030                               << (quint16)5 // forwardDelay
0031                               << (quint16)5 // helloTime
0032                               << (quint16)10 // maxAge
0033                               << (quint32)10000 // ageintTime
0034                               << false // multicastSnooping
0035                               << QByteArray("54:EE:75:53:E9:E4"); // macAddress
0036 }
0037 
0038 void BridgeSettingTest::testSetting()
0039 {
0040     QFETCH(QString, interfaceName);
0041     QFETCH(bool, stp);
0042     QFETCH(quint16, priority);
0043     QFETCH(quint16, forwardDelay);
0044     QFETCH(quint16, helloTime);
0045     QFETCH(quint16, maxAge);
0046     QFETCH(quint32, ageintTime);
0047     QFETCH(bool, multicastSnooping);
0048     QFETCH(QByteArray, macAddress);
0049 
0050     QVariantMap map;
0051 
0052     map.insert(QLatin1String("interface-name"), interfaceName);
0053     map.insert(QLatin1String(NM_SETTING_BRIDGE_STP), stp);
0054     map.insert(QLatin1String(NM_SETTING_BRIDGE_PRIORITY), priority);
0055     map.insert(QLatin1String(NM_SETTING_BRIDGE_FORWARD_DELAY), forwardDelay);
0056     map.insert(QLatin1String(NM_SETTING_BRIDGE_HELLO_TIME), helloTime);
0057     map.insert(QLatin1String(NM_SETTING_BRIDGE_MAX_AGE), maxAge);
0058     map.insert(QLatin1String(NM_SETTING_BRIDGE_AGEING_TIME), ageintTime);
0059     map.insert(QLatin1String(NM_SETTING_BRIDGE_MULTICAST_SNOOPING), multicastSnooping);
0060     map.insert(QLatin1String(NM_SETTING_BRIDGE_MAC_ADDRESS), macAddress);
0061 
0062     NetworkManager::BridgeSetting setting;
0063     setting.fromMap(map);
0064 
0065     QVariantMap map1 = setting.toMap();
0066     QVariantMap::const_iterator it = map.constBegin();
0067     while (it != map.constEnd()) {
0068         QCOMPARE(it.value(), map1.value(it.key()));
0069         ++it;
0070     }
0071 }
0072 
0073 QTEST_MAIN(BridgeSettingTest)
0074 
0075 #include "moc_bridgesettingtest.cpp"