~ci-train-bot/online-accounts-api/online-accounts-api-ubuntu-xenial-landing-033

« back to all changes in this revision

Viewing changes to tests/lib/OnlineAccounts/functional_tests/functional_tests.cpp

  • Committer: CI Train Bot
  • Author(s): Alberto Mardegan
  • Date: 2015-09-23 12:41:36 UTC
  • mfrom: (8.4.11 update)
  • Revision ID: ci-train-bot@canonical.com-20150923124136-43tthyu1l6lkqq3l
Docs, fixes, library install

- Docs
- Couple of bugfixes
- Package the daemon as a library

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "OnlineAccounts/OAuth2Data"
25
25
#include "OnlineAccounts/PasswordData"
26
26
#include "OnlineAccounts/account_info.h"
27
 
#include "daemon/dbus_constants.h"
 
27
#include "OnlineAccountsDaemon/dbus_constants.h"
28
28
#include <QDBusConnection>
29
29
#include <QObject>
30
30
#include <QSignalSpy>
31
31
#include <QTest>
32
32
#include <libqtdbusmock/DBusMock.h>
33
33
 
 
34
namespace QTest {
 
35
template<>
 
36
char *toString(const QVariantMap &map)
 
37
{
 
38
    QJsonDocument doc(QJsonObject::fromVariantMap(map));
 
39
    return qstrdup(doc.toJson(QJsonDocument::Compact).data());
 
40
}
 
41
} // QTest namespace
 
42
 
34
43
class FunctionalTests: public QObject
35
44
{
36
45
    Q_OBJECT
316
325
    QCOMPARE(account->serviceId(), serviceId);
317
326
    QCOMPARE(int(account->authenticationMethod()), authenticationMethod);
318
327
 
319
 
    Q_FOREACH(const QString &key, settings.keys()) {
320
 
        QCOMPARE(account->setting(key), settings.value(key));
 
328
    QVariantMap accountSettings;
 
329
    Q_FOREACH(const QString &key, account->keys()) {
 
330
        accountSettings.insert(key, account->setting(key));
321
331
    }
 
332
    QCOMPARE(accountSettings, settings);
322
333
 
323
334
    delete account;
324
335
}
481
492
    QCOMPARE(oauth1reply.token(), QByteArray("a token"));
482
493
    QCOMPARE(oauth1reply.tokenSecret(), QByteArray("a token secret"));
483
494
    QCOMPARE(oauth1reply.signatureMethod(), QByteArray("PLAIN"));
 
495
    /* Compare the whole data dictionary */
 
496
    QVariantMap expectedData;
 
497
    expectedData.insert(ONLINE_ACCOUNTS_AUTH_KEY_CONSUMER_KEY, "a key");
 
498
    expectedData.insert(ONLINE_ACCOUNTS_AUTH_KEY_CONSUMER_SECRET, "a secret");
 
499
    expectedData.insert(ONLINE_ACCOUNTS_AUTH_KEY_TOKEN, "a token");
 
500
    expectedData.insert(ONLINE_ACCOUNTS_AUTH_KEY_TOKEN_SECRET, "a token secret");
 
501
    expectedData.insert(ONLINE_ACCOUNTS_AUTH_KEY_SIGNATURE_METHOD, "PLAIN");
 
502
    QCOMPARE(oauth1reply.data(), expectedData);
484
503
 
485
504
    /* Test OAuth 2.0 */
486
505
    account = manager.account(2);