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 "bondsettingtest.h"
0008 
0009 #include "settings/bondsetting.h"
0010 
0011 #include <libnm/NetworkManager.h>
0012 
0013 #include <QTest>
0014 
0015 void BondSettingTest::testSetting_data()
0016 {
0017     QTest::addColumn<QString>("interfaceName");
0018     QTest::addColumn<NMStringMap>("options");
0019 
0020     NMStringMap options;
0021     options.insert("mode", "802.3ad");
0022 
0023     QTest::newRow("setting1") << QString("eth0") // interfaceName
0024                               << options; // options
0025 }
0026 
0027 void BondSettingTest::testSetting()
0028 {
0029     QFETCH(QString, interfaceName);
0030     QFETCH(NMStringMap, options);
0031 
0032     QVariantMap map;
0033 
0034     map.insert(QLatin1String("interface-name"), interfaceName);
0035     map.insert(QLatin1String(NM_SETTING_BOND_OPTIONS), QVariant::fromValue<NMStringMap>(options));
0036 
0037     NetworkManager::BondSetting setting;
0038     setting.fromMap(map);
0039 
0040     QVariantMap map1 = setting.toMap();
0041 
0042     QCOMPARE(map.value(QLatin1String("interface-name")), map1.value(QLatin1String("interface-name")));
0043     NMStringMap stringMap1 = map.value(QLatin1String(NM_SETTING_BOND_OPTIONS)).value<NMStringMap>();
0044     NMStringMap stringMap2 = map1.value(QLatin1String(NM_SETTING_BOND_OPTIONS)).value<NMStringMap>();
0045 
0046     NMStringMap::const_iterator it = stringMap1.constBegin();
0047     while (it != stringMap1.constEnd()) {
0048         QCOMPARE(it.value(), stringMap2.value(it.key()));
0049         ++it;
0050     }
0051 }
0052 
0053 QTEST_MAIN(BondSettingTest)
0054 
0055 #include "moc_bondsettingtest.cpp"