File indexing completed on 2024-12-22 04:45:41
0001 /* 0002 SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "oauthsettingswidgettest.h" 0008 #include "administratorsettingsdialog/oauth/oauthsettingswidget.h" 0009 #include "settingswidgetshelper.h" 0010 #include <QCheckBox> 0011 #include <QLineEdit> 0012 QTEST_MAIN(OauthSettingsWidgetTest) 0013 OauthSettingsWidgetTest::OauthSettingsWidgetTest(QObject *parent) 0014 : QObject{parent} 0015 { 0016 } 0017 0018 void OauthSettingsWidgetTest::shouldHaveDefaultValues() 0019 { 0020 OauthSettingsWidget w(nullptr); 0021 auto mSignWithApple = w.findChild<QCheckBox *>(QStringLiteral("mSignWithApple")); 0022 QVERIFY(mSignWithApple); 0023 QVERIFY(!mSignWithApple->isChecked()); 0024 QVERIFY(!mSignWithApple->text().isEmpty()); 0025 QVERIFY(!mSignWithApple->toolTip().isEmpty()); 0026 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mSignWithApple), QStringLiteral("Accounts_OAuth_Apple")); 0027 0028 auto mAccountsOAuthAppleId = w.findChild<QLineEdit *>(QStringLiteral("mAccountsOAuthAppleId")); 0029 QVERIFY(mAccountsOAuthAppleId); 0030 QVERIFY(mAccountsOAuthAppleId->text().isEmpty()); 0031 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mAccountsOAuthAppleId), QStringLiteral("Accounts_OAuth_Apple_id")); 0032 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Apple_id")); 0033 0034 auto mAccountsOAuthAppleIss = w.findChild<QLineEdit *>(QStringLiteral("mAccountsOAuthAppleIss")); 0035 QVERIFY(mAccountsOAuthAppleIss); 0036 QVERIFY(mAccountsOAuthAppleIss->text().isEmpty()); 0037 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mAccountsOAuthAppleIss), QStringLiteral("Accounts_OAuth_Apple_iss")); 0038 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Apple_iss")); 0039 0040 auto AccountsOAuthAppleKid = w.findChild<QLineEdit *>(QStringLiteral("AccountsOAuthAppleKid")); 0041 QVERIFY(AccountsOAuthAppleKid); 0042 QVERIFY(AccountsOAuthAppleKid->text().isEmpty()); 0043 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(AccountsOAuthAppleKid), QStringLiteral("Accounts_OAuth_Apple_kid")); 0044 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Apple_kid")); 0045 0046 auto mTwitterLogin = w.findChild<QCheckBox *>(QStringLiteral("mTwitterLogin")); 0047 QVERIFY(mTwitterLogin); 0048 QVERIFY(!mTwitterLogin->isChecked()); 0049 QVERIFY(!mTwitterLogin->text().isEmpty()); 0050 QVERIFY(mTwitterLogin->toolTip().isEmpty()); 0051 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mTwitterLogin), QStringLiteral("Accounts_OAuth_Twitter")); 0052 0053 auto mTwitterId = w.findChild<QLineEdit *>(QStringLiteral("mTwitterId")); 0054 QVERIFY(mTwitterId); 0055 QVERIFY(mTwitterId->text().isEmpty()); 0056 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mTwitterId), QStringLiteral("Accounts_OAuth_Twitter_id")); 0057 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Twitter_id")); 0058 0059 auto mTwitterSecret = w.findChild<QLineEdit *>(QStringLiteral("mTwitterSecret")); 0060 QVERIFY(mTwitterSecret); 0061 QVERIFY(mTwitterSecret->text().isEmpty()); 0062 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mTwitterSecret), QStringLiteral("Accounts_OAuth_Twitter_secret")); 0063 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Twitter_secret")); 0064 0065 auto mTwitterCallbackURL = w.findChild<QLineEdit *>(QStringLiteral("mTwitterCallbackURL")); 0066 QVERIFY(mTwitterCallbackURL); 0067 QVERIFY(mTwitterCallbackURL->text().isEmpty()); 0068 QVERIFY(mTwitterCallbackURL->isReadOnly()); 0069 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mTwitterCallbackURL), QStringLiteral("Accounts_OAuth_Twitter_callback_url")); 0070 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Twitter_callback_url")); 0071 0072 auto mLinkedInLogin = w.findChild<QCheckBox *>(QStringLiteral("mLinkedInLogin")); 0073 QVERIFY(mLinkedInLogin); 0074 QVERIFY(!mLinkedInLogin->isChecked()); 0075 QVERIFY(!mLinkedInLogin->text().isEmpty()); 0076 QVERIFY(mLinkedInLogin->toolTip().isEmpty()); 0077 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mLinkedInLogin), QStringLiteral("Accounts_OAuth_Linkedin")); 0078 0079 auto mLinkedInId = w.findChild<QLineEdit *>(QStringLiteral("mLinkedInId")); 0080 QVERIFY(mLinkedInId); 0081 QVERIFY(mLinkedInId->text().isEmpty()); 0082 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mLinkedInId), QStringLiteral("Accounts_OAuth_Linkedin_id")); 0083 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Linkedin_id")); 0084 0085 auto mLinkedInSecret = w.findChild<QLineEdit *>(QStringLiteral("mLinkedInSecret")); 0086 QVERIFY(mLinkedInSecret); 0087 QVERIFY(mLinkedInSecret->text().isEmpty()); 0088 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mLinkedInSecret), QStringLiteral("Accounts_OAuth_Linkedin_secret")); 0089 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Linkedin_secret")); 0090 0091 auto mLinkedInCallbackURL = w.findChild<QLineEdit *>(QStringLiteral("mLinkedInCallbackURL")); 0092 QVERIFY(mLinkedInCallbackURL); 0093 QVERIFY(mLinkedInCallbackURL->text().isEmpty()); 0094 QVERIFY(mLinkedInCallbackURL->isReadOnly()); 0095 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mLinkedInCallbackURL), QStringLiteral("Accounts_OAuth_Linkedin_callback_url")); 0096 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Linkedin_callback_url")); 0097 0098 auto mProxyHost = w.findChild<QLineEdit *>(QStringLiteral("mProxyHost")); 0099 QVERIFY(mProxyHost); 0100 QVERIFY(mProxyHost->text().isEmpty()); 0101 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mProxyHost), QStringLiteral("Accounts_OAuth_Proxy_host")); 0102 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Proxy_host")); 0103 0104 auto mProxyServices = w.findChild<QLineEdit *>(QStringLiteral("mProxyServices")); 0105 QVERIFY(mProxyServices); 0106 QVERIFY(mProxyServices->text().isEmpty()); 0107 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mProxyServices), QStringLiteral("Accounts_OAuth_Proxy_services")); 0108 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Proxy_services")); 0109 0110 auto mMeteorLogin = w.findChild<QCheckBox *>(QStringLiteral("mMeteorLogin")); 0111 QVERIFY(mMeteorLogin); 0112 QVERIFY(!mMeteorLogin->isChecked()); 0113 QVERIFY(!mMeteorLogin->text().isEmpty()); 0114 QVERIFY(mMeteorLogin->toolTip().isEmpty()); 0115 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mMeteorLogin), QStringLiteral("Accounts_OAuth_Meteor")); 0116 0117 auto mMeteorId = w.findChild<QLineEdit *>(QStringLiteral("mMeteorId")); 0118 QVERIFY(mMeteorId); 0119 QVERIFY(mMeteorId->text().isEmpty()); 0120 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mMeteorId), QStringLiteral("Accounts_OAuth_Meteor_id")); 0121 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Meteor_id")); 0122 0123 auto mMeteorSecret = w.findChild<QLineEdit *>(QStringLiteral("mMeteorSecret")); 0124 QVERIFY(mMeteorSecret); 0125 QVERIFY(mMeteorSecret->text().isEmpty()); 0126 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mMeteorSecret), QStringLiteral("Accounts_OAuth_Meteor_secret")); 0127 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Meteor_secret")); 0128 0129 auto mMeteorCallbackURL = w.findChild<QLineEdit *>(QStringLiteral("mMeteorCallbackURL")); 0130 QVERIFY(mMeteorCallbackURL); 0131 QVERIFY(mMeteorCallbackURL->text().isEmpty()); 0132 QVERIFY(mMeteorCallbackURL->isReadOnly()); 0133 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mMeteorCallbackURL), QStringLiteral("Accounts_OAuth_Meteor_callback_url")); 0134 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Meteor_callback_url")); 0135 0136 auto mFacebookLogin = w.findChild<QCheckBox *>(QStringLiteral("mFacebookLogin")); 0137 QVERIFY(mFacebookLogin); 0138 QVERIFY(!mFacebookLogin->isChecked()); 0139 QVERIFY(!mFacebookLogin->text().isEmpty()); 0140 QVERIFY(mFacebookLogin->toolTip().isEmpty()); 0141 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mFacebookLogin), QStringLiteral("Accounts_OAuth_Facebook")); 0142 0143 auto mFacebookId = w.findChild<QLineEdit *>(QStringLiteral("mFacebookId")); 0144 QVERIFY(mFacebookId); 0145 QVERIFY(mFacebookId->text().isEmpty()); 0146 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mFacebookId), QStringLiteral("Accounts_OAuth_Facebook_id")); 0147 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Facebook_id")); 0148 0149 auto mFacebookSecret = w.findChild<QLineEdit *>(QStringLiteral("mFacebookSecret")); 0150 QVERIFY(mFacebookSecret); 0151 QVERIFY(mFacebookSecret->text().isEmpty()); 0152 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mFacebookSecret), QStringLiteral("Accounts_OAuth_Facebook_secret")); 0153 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Facebook_secret")); 0154 0155 auto mFacebookCallbackURL = w.findChild<QLineEdit *>(QStringLiteral("mFacebookCallbackURL")); 0156 QVERIFY(mFacebookCallbackURL); 0157 QVERIFY(mFacebookCallbackURL->text().isEmpty()); 0158 QVERIFY(mFacebookCallbackURL->isReadOnly()); 0159 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mFacebookCallbackURL), QStringLiteral("Accounts_OAuth_Facebook_callback_url")); 0160 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Facebook_callback_url")); 0161 0162 auto mGithubLogin = w.findChild<QCheckBox *>(QStringLiteral("mGithubLogin")); 0163 QVERIFY(mGithubLogin); 0164 QVERIFY(!mGithubLogin->isChecked()); 0165 QVERIFY(!mGithubLogin->text().isEmpty()); 0166 QVERIFY(mGithubLogin->toolTip().isEmpty()); 0167 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mGithubLogin), QStringLiteral("Accounts_OAuth_Github")); 0168 0169 auto mGithubId = w.findChild<QLineEdit *>(QStringLiteral("mGithubId")); 0170 QVERIFY(mGithubId); 0171 QVERIFY(mGithubId->text().isEmpty()); 0172 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mGithubId), QStringLiteral("Accounts_OAuth_Github_id")); 0173 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Github_id")); 0174 0175 auto mGithubSecret = w.findChild<QLineEdit *>(QStringLiteral("mGithubSecret")); 0176 QVERIFY(mGithubSecret); 0177 QVERIFY(mGithubSecret->text().isEmpty()); 0178 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mGithubSecret), QStringLiteral("Accounts_OAuth_Github_secret")); 0179 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Github_secret")); 0180 0181 auto mGithubCallbackURL = w.findChild<QLineEdit *>(QStringLiteral("mGithubCallbackURL")); 0182 QVERIFY(mGithubCallbackURL); 0183 QVERIFY(mGithubCallbackURL->text().isEmpty()); 0184 QVERIFY(mGithubCallbackURL->isReadOnly()); 0185 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mGithubCallbackURL), QStringLiteral("Accounts_OAuth_Github_callback_url")); 0186 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Github_callback_url")); 0187 0188 auto mTokenpassLogin = w.findChild<QCheckBox *>(QStringLiteral("mTokenpassLogin")); 0189 QVERIFY(mTokenpassLogin); 0190 QVERIFY(!mTokenpassLogin->isChecked()); 0191 QVERIFY(!mTokenpassLogin->text().isEmpty()); 0192 QVERIFY(mTokenpassLogin->toolTip().isEmpty()); 0193 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mTokenpassLogin), QStringLiteral("Accounts_OAuth_Tokenpass")); 0194 0195 auto mTokenpassId = w.findChild<QLineEdit *>(QStringLiteral("mTokenpassId")); 0196 QVERIFY(mTokenpassId); 0197 QVERIFY(mTokenpassId->text().isEmpty()); 0198 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mTokenpassId), QStringLiteral("Accounts_OAuth_Tokenpass_id")); 0199 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Tokenpass_id")); 0200 0201 auto mTokenpassSecret = w.findChild<QLineEdit *>(QStringLiteral("mTokenpassSecret")); 0202 QVERIFY(mTokenpassSecret); 0203 QVERIFY(mTokenpassSecret->text().isEmpty()); 0204 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mTokenpassSecret), QStringLiteral("Accounts_OAuth_Tokenpass_secret")); 0205 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Tokenpass_secret")); 0206 0207 auto mTokenpassCallbackURL = w.findChild<QLineEdit *>(QStringLiteral("mTokenpassCallbackURL")); 0208 QVERIFY(mTokenpassCallbackURL); 0209 QVERIFY(mTokenpassCallbackURL->text().isEmpty()); 0210 QVERIFY(mTokenpassCallbackURL->isReadOnly()); 0211 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mTokenpassCallbackURL), QStringLiteral("Accounts_OAuth_Tokenpass_callback_url")); 0212 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Tokenpass_callback_url")); 0213 0214 auto mTokenpassServerURL = w.findChild<QLineEdit *>(QStringLiteral("mTokenpassServerURL")); 0215 QVERIFY(mTokenpassServerURL); 0216 QVERIFY(mTokenpassServerURL->text().isEmpty()); 0217 QVERIFY(!mTokenpassServerURL->toolTip().isEmpty()); 0218 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mTokenpassServerURL), QStringLiteral("API_Tokenpass_URL")); 0219 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("API_Tokenpass_URL")); 0220 0221 auto mGoogleLogin = w.findChild<QCheckBox *>(QStringLiteral("mGoogleLogin")); 0222 QVERIFY(mGoogleLogin); 0223 QVERIFY(!mGoogleLogin->isChecked()); 0224 QVERIFY(!mGoogleLogin->text().isEmpty()); 0225 QVERIFY(mGoogleLogin->toolTip().isEmpty()); 0226 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mGoogleLogin), QStringLiteral("Accounts_OAuth_Google")); 0227 0228 auto mGoogleId = w.findChild<QLineEdit *>(QStringLiteral("mGoogleId")); 0229 QVERIFY(mGoogleId); 0230 QVERIFY(mGoogleId->text().isEmpty()); 0231 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mGoogleId), QStringLiteral("Accounts_OAuth_Google_id")); 0232 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Google_id")); 0233 0234 auto mGoogleSecret = w.findChild<QLineEdit *>(QStringLiteral("mGoogleSecret")); 0235 QVERIFY(mGoogleSecret); 0236 QVERIFY(mGoogleSecret->text().isEmpty()); 0237 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mGoogleSecret), QStringLiteral("Accounts_OAuth_Google_secret")); 0238 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Google_secret")); 0239 0240 auto mGoogleCallbackURL = w.findChild<QLineEdit *>(QStringLiteral("mGoogleCallbackURL")); 0241 QVERIFY(mGoogleCallbackURL); 0242 QVERIFY(mGoogleCallbackURL->text().isEmpty()); 0243 QVERIFY(mGoogleCallbackURL->isReadOnly()); 0244 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mGoogleCallbackURL), QStringLiteral("Accounts_OAuth_Google_callback_url")); 0245 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Google_callback_url")); 0246 0247 auto mDolphinUrl = w.findChild<QLineEdit *>(QStringLiteral("mDolphinUrl")); 0248 QVERIFY(mDolphinUrl); 0249 QVERIFY(mDolphinUrl->text().isEmpty()); 0250 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mDolphinUrl), QStringLiteral("Accounts_OAuth_Dolphin_URL")); 0251 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Dolphin_URL")); 0252 0253 auto mDolphinEnable = w.findChild<QCheckBox *>(QStringLiteral("mDolphinEnable")); 0254 QVERIFY(mDolphinEnable); 0255 QVERIFY(!mDolphinEnable->isChecked()); 0256 QVERIFY(!mDolphinEnable->text().isEmpty()); 0257 QVERIFY(mDolphinEnable->toolTip().isEmpty()); 0258 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mDolphinEnable), QStringLiteral("Accounts_OAuth_Dolphin")); 0259 0260 auto mDolphinId = w.findChild<QLineEdit *>(QStringLiteral("mDolphinId")); 0261 QVERIFY(mDolphinId); 0262 QVERIFY(mDolphinId->text().isEmpty()); 0263 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mDolphinId), QStringLiteral("Accounts_OAuth_Dolphin_id")); 0264 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Dolphin_id")); 0265 0266 auto mDolphinSecret = w.findChild<QLineEdit *>(QStringLiteral("mDolphinSecret")); 0267 QVERIFY(mDolphinSecret); 0268 QVERIFY(mDolphinSecret->text().isEmpty()); 0269 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mDolphinSecret), QStringLiteral("Accounts_OAuth_Dolphin_secret")); 0270 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("Accounts_OAuth_Dolphin_secret")); 0271 } 0272 0273 #include "moc_oauthsettingswidgettest.cpp"