File indexing completed on 2024-10-06 03:43:33
0001 /* 0002 SPDX-FileCopyrightText: 2018 Billy Laws <blaws05@gmai.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "vxlansettingtest.h" 0008 0009 #include "settings/vxlansetting.h" 0010 0011 #include <libnm/NetworkManager.h> 0012 0013 #include <QTest> 0014 0015 void VxlanSettingTest::testSetting_data() 0016 { 0017 QTest::addColumn<quint32>("ageing"); 0018 QTest::addColumn<quint32>("destinationPort"); 0019 QTest::addColumn<quint32>("id"); 0020 QTest::addColumn<bool>("l2Miss"); 0021 QTest::addColumn<bool>("l3Miss"); 0022 QTest::addColumn<bool>("learning"); 0023 QTest::addColumn<quint32>("limit"); 0024 QTest::addColumn<QString>("local"); 0025 QTest::addColumn<QString>("parent"); 0026 QTest::addColumn<bool>("proxy"); 0027 QTest::addColumn<QString>("remote"); 0028 QTest::addColumn<bool>("rsc"); 0029 QTest::addColumn<quint32>("sourcePortMax"); 0030 QTest::addColumn<quint32>("sourcePortMin"); 0031 QTest::addColumn<quint32>("tos"); 0032 QTest::addColumn<quint32>("ttl"); 0033 0034 QTest::newRow("setting1") << (quint32)2 // ageing 0035 << (quint32)334 // destinationPort 0036 << (quint32)2 // id 0037 << (bool)true // l2Miss 0038 << (bool)true // l3Miss 0039 << (bool)false // learning 0040 << (quint32)2 // limit 0041 << QString("foo") // local 0042 << QString("bar") // parent 0043 << (bool)true // proxy 0044 << QString("foo") // remote 0045 << (bool)true // rsc 0046 << (quint32)2 // sourcePortMax 0047 << (quint32)2 // sourcePortMin 0048 << (quint32)2 // tos 0049 << (quint32)2; // ttl 0050 } 0051 0052 void VxlanSettingTest::testSetting() 0053 { 0054 QFETCH(quint32, ageing); 0055 QFETCH(quint32, destinationPort); 0056 QFETCH(quint32, id); 0057 QFETCH(bool, l2Miss); 0058 QFETCH(bool, l3Miss); 0059 QFETCH(bool, learning); 0060 QFETCH(quint32, limit); 0061 QFETCH(QString, local); 0062 QFETCH(QString, parent); 0063 QFETCH(bool, proxy); 0064 QFETCH(QString, remote); 0065 QFETCH(bool, rsc); 0066 QFETCH(quint32, sourcePortMax); 0067 QFETCH(quint32, sourcePortMin); 0068 QFETCH(quint32, tos); 0069 QFETCH(quint32, ttl); 0070 0071 QVariantMap map; 0072 0073 map.insert(QLatin1String(NM_SETTING_VXLAN_AGEING), ageing); 0074 map.insert(QLatin1String(NM_SETTING_VXLAN_DESTINATION_PORT), destinationPort); 0075 map.insert(QLatin1String(NM_SETTING_VXLAN_ID), id); 0076 map.insert(QLatin1String(NM_SETTING_VXLAN_L2_MISS), l2Miss); 0077 map.insert(QLatin1String(NM_SETTING_VXLAN_L3_MISS), l3Miss); 0078 map.insert(QLatin1String(NM_SETTING_VXLAN_LEARNING), learning); 0079 map.insert(QLatin1String(NM_SETTING_VXLAN_LIMIT), limit); 0080 map.insert(QLatin1String(NM_SETTING_VXLAN_LOCAL), local); 0081 map.insert(QLatin1String(NM_SETTING_VXLAN_PARENT), parent); 0082 map.insert(QLatin1String(NM_SETTING_VXLAN_PROXY), proxy); 0083 map.insert(QLatin1String(NM_SETTING_VXLAN_REMOTE), remote); 0084 map.insert(QLatin1String(NM_SETTING_VXLAN_RSC), rsc); 0085 map.insert(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MAX), sourcePortMax); 0086 map.insert(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MIN), sourcePortMin); 0087 map.insert(QLatin1String(NM_SETTING_VXLAN_TOS), tos); 0088 map.insert(QLatin1String(NM_SETTING_VXLAN_TTL), ttl); 0089 0090 NetworkManager::VxlanSetting setting; 0091 setting.fromMap(map); 0092 0093 QVariantMap map1 = setting.toMap(); 0094 QVariantMap::const_iterator it = map.constBegin(); 0095 while (it != map.constEnd()) { 0096 QCOMPARE(it.value(), map1.value(it.key())); 0097 ++it; 0098 } 0099 } 0100 0101 QTEST_MAIN(VxlanSettingTest) 0102 0103 #include "moc_vxlansettingtest.cpp"