File indexing completed on 2024-04-21 03:59:54

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 "ovsinterfacesettingtest.h"
0008 
0009 #include "settings/ovsinterfacesetting.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_INTERFACE_TYPE "type"
0017 #endif
0018 
0019 void OvsInterfaceSettingTest::testSetting_data()
0020 {
0021     QTest::addColumn<QString>("type");
0022 
0023     QTest::newRow("setting1") << QString("internal"); // type
0024 }
0025 
0026 void OvsInterfaceSettingTest::testSetting()
0027 {
0028     QFETCH(QString, type);
0029 
0030     QVariantMap map;
0031 
0032     map.insert(QLatin1String(NM_SETTING_OVS_INTERFACE_TYPE), type);
0033 
0034     NetworkManager::OvsInterfaceSetting 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(OvsInterfaceSettingTest)
0048 
0049 #include "moc_ovsinterfacesettingtest.cpp"