Debian Codegraph @

tests/online-accounts/OnlineAccounts/tst_authentication_data/tst_authentication_data.cpp

raw symbols SCIP
1 /*
2 * This file is part of libOnlineAccounts
3 *
4 * Copyright (C) 2015 Canonical Ltd.
5 *
6 * Contact: Alberto Mardegan <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License version 3, as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include <QObject>
22 #include <QTest>
23 #include <LomiriOnlineAccounts/authentication_data.h>
24
25 using namespace OnlineAccounts;
26
27 class AuthenticationDataTest : public QObject
28 {
29 Q_OBJECT
30
31 private Q_SLOTS:
32 void testData();
33 };
34
35 void AuthenticationDataTest::testData()
36 {
37 OAuth2Data oauth2;
38
39 oauth2.setClientId("client");
40 QCOMPARE(oauth2.clientId(), QByteArray("client"));
41
42 oauth2.setInteractive(false);
43 QCOMPARE(oauth2.interactive(), false);
44
45 OAuth2Data copy = oauth2;
46 QCOMPARE(copy.clientId(), QByteArray("client"));
47 QCOMPARE(copy.interactive(), false);
48
49 oauth2.setClientId("client-changed");
50 QCOMPARE(oauth2.clientId(), QByteArray("client-changed"));
51 QCOMPARE(copy.clientId(), QByteArray("client"));
52
53 /* As dictionary */
54 QVariantMap expectedParameters;
55 expectedParameters.insert("ClientId", QByteArray("client-changed"));
56 QCOMPARE(oauth2.parameters(), expectedParameters);
57
58 QVariantMap parameters;
59 parameters.insert("UnknownKey", "some value");
60 parameters.insert("Hello", "World");
61 oauth2.setParameters(parameters);
62 QCOMPARE(oauth2.parameters(), parameters);
63 }
64
65 QTEST_MAIN(AuthenticationDataTest)
66 #include "tst_authentication_data.moc"