~tiagosh/telepathy-qt/group-chat2

« back to all changes in this revision

Viewing changes to tests/lib/glib-helpers/test-conn-helper.h

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo
  • Date: 2013-06-06 04:56:14 UTC
  • Revision ID: package-import@ubuntu.com-20130606045614-inpxexo6765rnmp1
Tags: upstream-0.9.3
ImportĀ upstreamĀ versionĀ 0.9.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _TelepathyQt_tests_lib_glib_helpers_test_conn_helper_h_HEADER_GUARD_
 
2
#define _TelepathyQt_tests_lib_glib_helpers_test_conn_helper_h_HEADER_GUARD_
 
3
 
 
4
#include <tests/lib/test.h>
 
5
 
 
6
#include <TelepathyQt/Constants>
 
7
#include <TelepathyQt/Features>
 
8
#include <TelepathyQt/Types>
 
9
 
 
10
#include <glib-object.h>
 
11
 
 
12
#include <telepathy-glib/telepathy-glib.h>
 
13
 
 
14
namespace Tp
 
15
{
 
16
class PendingContacts;
 
17
}
 
18
 
 
19
class TestConnHelper : public QObject
 
20
{
 
21
    Q_OBJECT
 
22
 
 
23
public:
 
24
    TestConnHelper(Test *parent,
 
25
            GType gType, const QString &account, const QString &protocol);
 
26
    TestConnHelper(Test *parent,
 
27
            GType gType, const char *firstPropertyName, ...);
 
28
    TestConnHelper(Test *parent,
 
29
            const Tp::ChannelFactoryConstPtr &channelFactory,
 
30
            const Tp::ContactFactoryConstPtr &contactFactory,
 
31
            GType gType, const QString &account, const QString &protocol);
 
32
    TestConnHelper(Test *parent,
 
33
            const Tp::ChannelFactoryConstPtr &channelFactory,
 
34
            const Tp::ContactFactoryConstPtr &contactFactory,
 
35
            GType gType, const char *firstPropertyName, ...);
 
36
 
 
37
    virtual ~TestConnHelper();
 
38
 
 
39
    GObject *service() const { return mService; }
 
40
    Tp::ConnectionPtr client() const { return mClient; }
 
41
    QString objectPath() const;
 
42
 
 
43
    bool isValid() const;
 
44
    bool isReady(const Tp::Features &features = Tp::Features()) const;
 
45
    bool enableFeatures(const Tp::Features &features);
 
46
    bool connect(const Tp::Features &features = Tp::Features());
 
47
    bool disconnect();
 
48
 
 
49
    QList<Tp::ContactPtr> contacts(const QStringList &ids,
 
50
            const Tp::Features &features = Tp::Features());
 
51
    QList<Tp::ContactPtr> contacts(const Tp::UIntList &handles,
 
52
            const Tp::Features &features = Tp::Features());
 
53
    QList<Tp::ContactPtr> upgradeContacts(const QList<Tp::ContactPtr> &contacts,
 
54
            const Tp::Features &features = Tp::Features());
 
55
 
 
56
    Tp::ChannelPtr createChannel(const QVariantMap &request);
 
57
    Tp::ChannelPtr createChannel(const QString &channelType, const Tp::ContactPtr &target);
 
58
    Tp::ChannelPtr createChannel(const QString &channelType,
 
59
            Tp::HandleType targetHandleType, uint targetHandle);
 
60
    Tp::ChannelPtr createChannel(const QString &channelType,
 
61
            Tp::HandleType targetHandleType, const QString &targetID);
 
62
    Tp::ChannelPtr ensureChannel(const QVariantMap &request);
 
63
    Tp::ChannelPtr ensureChannel(const QString &channelType, const Tp::ContactPtr &target);
 
64
    Tp::ChannelPtr ensureChannel(const QString &channelType,
 
65
            Tp::HandleType targetHandleType, uint targetHandle);
 
66
    Tp::ChannelPtr ensureChannel(const QString &channelType,
 
67
            Tp::HandleType targetHandleType, const QString &targetID);
 
68
 
 
69
private Q_SLOTS:
 
70
    void expectConnInvalidated();
 
71
    void expectContactsForIdentifiersFinished(Tp::PendingOperation *op);
 
72
    void expectContactsForHandlesFinished(Tp::PendingOperation *op);
 
73
    void expectUpgradeContactsFinished(Tp::PendingOperation *op);
 
74
    void expectCreateChannelFinished(Tp::PendingOperation *op);
 
75
    void expectEnsureChannelFinished(Tp::PendingOperation *op);
 
76
 
 
77
private:
 
78
    void init(Test *parent,
 
79
            const Tp::ChannelFactoryConstPtr &channelFactory,
 
80
            const Tp::ContactFactoryConstPtr &contactFactory,
 
81
            GType gType, const char *firstPropertyName, ...);
 
82
    void init(Test *parent,
 
83
            const Tp::ChannelFactoryConstPtr &channelFactory,
 
84
            const Tp::ContactFactoryConstPtr &contactFactory,
 
85
            GType gType, const char *firstPropertyName, va_list varArgs);
 
86
 
 
87
    void expectPendingContactsFinished(Tp::PendingContacts *pc);
 
88
 
 
89
    Test *mParent;
 
90
    QEventLoop *mLoop;
 
91
    GObject *mService;
 
92
    Tp::ConnectionPtr mClient;
 
93
 
 
94
    // The property retrieved by expectPendingContactsFinished()
 
95
    QList<Tp::ContactPtr> mContacts;
 
96
    // Property used by expectPendingContactsFinished()
 
97
    Tp::Features mContactFeatures;
 
98
    // The property retrieved by expectCreate/EnsureChannelFinished()
 
99
    Tp::ChannelPtr mChannel;
 
100
};
 
101
 
 
102
#endif // _TelepathyQt_tests_lib_glib_helpers_test_conn_helper_h_HEADER_GUARD_