File indexing completed on 2024-12-01 12:40: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 "proxysettingtest.h" 0008 0009 #include "settings/proxysetting.h" 0010 0011 #include <libnm/NetworkManager.h> 0012 0013 #include <QTest> 0014 0015 #if !NM_CHECK_VERSION(1, 6, 0) 0016 #define NM_SETTING_PROXY_BROWSER_ONLY "browser-only" 0017 #define NM_SETTING_PROXY_METHOD "method" 0018 #define NM_SETTING_PROXY_PAC_SCRIPT "pac-script" 0019 #define NM_SETTING_PROXY_PAC_URL "pac-url" 0020 #endif 0021 0022 void ProxySettingTest::testSetting_data() 0023 { 0024 QTest::addColumn<bool>("browserOnly"); 0025 QTest::addColumn<quint32>("method"); 0026 QTest::addColumn<QString>("pacScript"); 0027 QTest::addColumn<QString>("pacUrl"); 0028 0029 QTest::newRow("setting1") << false // browserOnly 0030 << (quint32)1 // method 0031 << QString("script") // pacScript 0032 << QString("url"); // pacUrl 0033 } 0034 0035 void ProxySettingTest::testSetting() 0036 { 0037 QFETCH(bool, browserOnly); 0038 QFETCH(quint32, method); 0039 QFETCH(QString, pacScript); 0040 QFETCH(QString, pacUrl); 0041 0042 QVariantMap map; 0043 0044 map.insert(QLatin1String(NM_SETTING_PROXY_BROWSER_ONLY), browserOnly); 0045 map.insert(QLatin1String(NM_SETTING_PROXY_METHOD), method); 0046 map.insert(QLatin1String(NM_SETTING_PROXY_PAC_SCRIPT), pacScript); 0047 map.insert(QLatin1String(NM_SETTING_PROXY_PAC_URL), pacUrl); 0048 0049 NetworkManager::ProxySetting setting; 0050 setting.fromMap(map); 0051 0052 QVariantMap map1 = setting.toMap(); 0053 0054 // Will fail if set some default values, because they are skipped in toMap() method 0055 QVariantMap::const_iterator it = map.constBegin(); 0056 while (it != map.constEnd()) { 0057 QCOMPARE(it.value(), map1.value(it.key())); 0058 ++it; 0059 } 0060 } 0061 0062 QTEST_MAIN(ProxySettingTest) 0063 0064 #include "moc_proxysettingtest.cpp"