File indexing completed on 2024-12-08 03:44:11
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 "matchsettingtest.h" 0008 0009 #include "settings/matchsetting.h" 0010 0011 #include <libnm/NetworkManager.h> 0012 0013 #include <QTest> 0014 0015 #if !NM_CHECK_VERSION(1, 14, 0) 0016 #define NM_SETTING_MATCH_INTERFACE_NAME "interface-name" 0017 #endif 0018 0019 void MatchSettingTest::testSetting_data() 0020 { 0021 QTest::addColumn<QStringList>("interfaceName"); 0022 0023 QTest::newRow("setting1") << QStringList{QString("name1"), QString("name2")}; // interfaceName 0024 } 0025 0026 void MatchSettingTest::testSetting() 0027 { 0028 QFETCH(QStringList, interfaceName); 0029 0030 QVariantMap map; 0031 0032 map.insert(QLatin1String(NM_SETTING_MATCH_INTERFACE_NAME), interfaceName); 0033 0034 NetworkManager::MatchSetting 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(MatchSettingTest) 0048 0049 #include "moc_matchsettingtest.cpp"