File indexing completed on 2024-10-06 03:43:33
0001 /* 0002 SPDX-FileCopyrightText: 2016 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 "tunsettingtest.h" 0008 0009 #include "settings/tunsetting.h" 0010 0011 #include <libnm/NetworkManager.h> 0012 0013 #include <QTest> 0014 0015 void TunSettingTest::testSetting_data() 0016 { 0017 QTest::addColumn<QString>("group"); 0018 QTest::addColumn<quint32>("mode"); 0019 QTest::addColumn<bool>("multiQueue"); 0020 QTest::addColumn<QString>("owner"); 0021 QTest::addColumn<bool>("pi"); 0022 QTest::addColumn<bool>("vnetHdr"); 0023 0024 QTest::newRow("setting1") << QString("randomGroup") // group 0025 << (quint32)2 // mode 0026 << true // multi-queue 0027 << QString("randomOwner") // owner 0028 << true // pi 0029 << true; // vnet-hdr 0030 } 0031 0032 void TunSettingTest::testSetting() 0033 { 0034 QFETCH(QString, group); 0035 QFETCH(quint32, mode); 0036 QFETCH(bool, multiQueue); 0037 QFETCH(QString, owner); 0038 QFETCH(bool, pi); 0039 QFETCH(bool, vnetHdr); 0040 0041 QVariantMap map; 0042 0043 map.insert(QLatin1String(NM_SETTING_TUN_GROUP), group); 0044 map.insert(QLatin1String(NM_SETTING_TUN_MODE), mode); 0045 map.insert(QLatin1String(NM_SETTING_TUN_MULTI_QUEUE), multiQueue); 0046 map.insert(QLatin1String(NM_SETTING_TUN_OWNER), owner); 0047 map.insert(QLatin1String(NM_SETTING_TUN_PI), pi); 0048 map.insert(QLatin1String(NM_SETTING_TUN_VNET_HDR), vnetHdr); 0049 0050 NetworkManager::TunSetting setting; 0051 setting.fromMap(map); 0052 0053 QVariantMap map1 = setting.toMap(); 0054 0055 // Will fail if set some default values, because they are skipped in toMap() method 0056 QVariantMap::const_iterator it = map.constBegin(); 0057 while (it != map.constEnd()) { 0058 QCOMPARE(it.value(), map1.value(it.key())); 0059 ++it; 0060 } 0061 } 0062 0063 QTEST_MAIN(TunSettingTest) 0064 0065 #include "moc_tunsettingtest.cpp"