File indexing completed on 2024-11-03 12:44:09
0001 /* 0002 SPDX-FileCopyrightText: 2018 Pranav Gade <pranavgade20@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "ovspatchsettingtest.h" 0008 0009 #include "settings/ovspatchsetting.h" 0010 0011 #include <libnm/NetworkManager.h> 0012 0013 #include <QTest> 0014 0015 #if !NM_CHECK_VERSION(1, 10, 0) 0016 #define NM_SETTING_OVS_PATCH_PEER "peer" 0017 #endif 0018 0019 void OvsPatchSettingTest::testSetting_data() 0020 { 0021 QTest::addColumn<QString>("peer"); 0022 0023 QTest::newRow("setting1") << QString("abc"); // peer 0024 } 0025 0026 void OvsPatchSettingTest::testSetting() 0027 { 0028 QFETCH(QString, peer); 0029 0030 QVariantMap map; 0031 0032 map.insert(QLatin1String(NM_SETTING_OVS_PATCH_PEER), peer); 0033 0034 NetworkManager::OvsPatchSetting setting; 0035 setting.fromMap(map); 0036 0037 QVariantMap map1 = setting.toMap(); 0038 0039 // Will fail if set some default values, because they are skipped in toMap() method 0040 QVariantMap::const_iterator it = map.constBegin(); 0041 while (it != map.constEnd()) { 0042 QCOMPARE(it.value(), map1.value(it.key())); 0043 ++it; 0044 } 0045 } 0046 0047 QTEST_MAIN(OvsPatchSettingTest) 0048 0049 #include "moc_ovspatchsettingtest.cpp"