summaryrefslogtreecommitdiff
path: root/qt4/tests/dbus/conn-capabilities.cpp
blob: edc8568edc20fb817fb38d347b20067d4a0cda63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <tests/lib/test.h>

#include <tests/lib/glib-helpers/test-conn-helper.h>

#include <tests/lib/glib/echo2/conn.h>

#include <TelepathyQt4/Connection>
#include <TelepathyQt4/ConnectionCapabilities>

#include <telepathy-glib/debug.h>

using namespace Tp;

class TestConnCapabilities : public Test
{
    Q_OBJECT

public:
    TestConnCapabilities(QObject *parent = 0)
        : Test(parent), conn(0)
    { }

private Q_SLOTS:
    void initTestCase();
    void init();

    void testCapabilities();

    void cleanup();
    void cleanupTestCase();

private:
    TestConnHelper *conn;
};

void TestConnCapabilities::initTestCase()
{
    initTestCaseImpl();

    g_type_init();
    g_set_prgname("conn-capabilities");
    tp_debug_set_flags("all");
    dbus_g_bus_get(DBUS_BUS_STARTER, 0);
}

void TestConnCapabilities::init()
{
    initImpl();
}

void TestConnCapabilities::testCapabilities()
{
    TestConnHelper *conn = new TestConnHelper(this,
            EXAMPLE_TYPE_ECHO_2_CONNECTION,
            "account", "me@example.com",
            "protocol", "contacts",
            NULL);
    QCOMPARE(conn->isReady(), false);

    // Before the connection is Ready, it doesn't guarantee support for anything but doesn't crash
    // either if we ask it for something
    QCOMPARE(conn->client()->capabilities().textChats(), false);
    QCOMPARE(conn->client()->capabilities().textChatrooms(), false);
    QCOMPARE(conn->client()->capabilities().streamedMediaCalls(), false);
    QCOMPARE(conn->client()->capabilities().streamedMediaAudioCalls(), false);
    QCOMPARE(conn->client()->capabilities().streamedMediaVideoCalls(), false);
    QCOMPARE(conn->client()->capabilities().streamedMediaVideoCallsWithAudio(), false);
    QCOMPARE(conn->client()->capabilities().upgradingStreamedMediaCalls(), false);

    QCOMPARE(conn->connect(), true);

    // Now we should have the real information on what the connection supports
    QCOMPARE(conn->client()->capabilities().textChats(), true);
    QCOMPARE(conn->client()->capabilities().textChatrooms(), false);
    QCOMPARE(conn->client()->capabilities().streamedMediaCalls(), false);
    QCOMPARE(conn->client()->capabilities().streamedMediaAudioCalls(), false);
    QCOMPARE(conn->client()->capabilities().streamedMediaVideoCalls(), false);
    QCOMPARE(conn->client()->capabilities().streamedMediaVideoCallsWithAudio(), false);
    QCOMPARE(conn->client()->capabilities().upgradingStreamedMediaCalls(), false);

    // Now, invalidate the connection by disconnecting it
    QCOMPARE(conn->disconnect(), true);

    // Check that no support for anything is again reported
    QCOMPARE(conn->client()->capabilities().textChats(), false);
    QCOMPARE(conn->client()->capabilities().textChatrooms(), false);
    QCOMPARE(conn->client()->capabilities().streamedMediaCalls(), false);
    QCOMPARE(conn->client()->capabilities().streamedMediaAudioCalls(), false);
    QCOMPARE(conn->client()->capabilities().streamedMediaVideoCalls(), false);
    QCOMPARE(conn->client()->capabilities().streamedMediaVideoCallsWithAudio(), false);
    QCOMPARE(conn->client()->capabilities().upgradingStreamedMediaCalls(), false);

    delete conn;
}

void TestConnCapabilities::cleanup()
{
    cleanupImpl();
}

void TestConnCapabilities::cleanupTestCase()
{
    cleanupTestCaseImpl();
}

QTEST_MAIN(TestConnCapabilities)
#include "_gen/conn-capabilities.cpp.moc.hpp"