summaryrefslogtreecommitdiff
path: root/tests/rccspec.cpp
blob: 089e6839dd3a3365a8cc2ce327e1786ba00c4b48 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include <QtTest/QtTest>

#include <TelepathyQt/RequestableChannelClassSpec>

using namespace Tp;

class TestRCCSpec : public QObject
{
    Q_OBJECT

private Q_SLOTS:
    void testRCCSpec();
};

void TestRCCSpec::testRCCSpec()
{
    RequestableChannelClassSpec spec;

    spec = RequestableChannelClassSpec::textChat();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_TEXT);
    QCOMPARE(spec.targetHandleType(), HandleTypeContact);
    QCOMPARE(spec.fixedProperties().size(), 2);
    QCOMPARE(spec.allowedProperties().isEmpty(), true);

    spec = RequestableChannelClassSpec::textChatroom();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_TEXT);
    QCOMPARE(spec.targetHandleType(), HandleTypeRoom);
    QCOMPARE(spec.fixedProperties().size(), 2);
    QCOMPARE(spec.allowedProperties().isEmpty(), true);

    spec = RequestableChannelClassSpec::streamedMediaCall();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA);
    QCOMPARE(spec.targetHandleType(), HandleTypeContact);
    QCOMPARE(spec.fixedProperties().size(), 2);
    QCOMPARE(spec.allowedProperties().isEmpty(), true);

    spec = RequestableChannelClassSpec::streamedMediaAudioCall();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA);
    QCOMPARE(spec.targetHandleType(), HandleTypeContact);
    QCOMPARE(spec.fixedProperties().size(), 2);
    QCOMPARE(spec.allowedProperties().size(), 1);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA + QLatin1String(".InitialAudio")), true);

    spec = RequestableChannelClassSpec::streamedMediaVideoCall();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA);
    QCOMPARE(spec.targetHandleType(), HandleTypeContact);
    QCOMPARE(spec.fixedProperties().size(), 2);
    QCOMPARE(spec.allowedProperties().size(), 1);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA + QLatin1String(".InitialVideo")), true);

    spec = RequestableChannelClassSpec::streamedMediaVideoCallWithAudio();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA);
    QCOMPARE(spec.targetHandleType(), HandleTypeContact);
    QCOMPARE(spec.fixedProperties().size(), 2);
    QCOMPARE(spec.allowedProperties().size(), 2);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA + QLatin1String(".InitialAudio")), true);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA + QLatin1String(".InitialVideo")), true);

    spec = RequestableChannelClassSpec::conferenceTextChat();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_TEXT);
    QVERIFY(!spec.hasTargetHandleType());
    QCOMPARE(spec.allowedProperties().size(), 1);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialChannels")), true);

    spec = RequestableChannelClassSpec::conferenceTextChatWithInvitees();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_TEXT);
    QVERIFY(!spec.hasTargetHandleType());
    QCOMPARE(spec.allowedProperties().size(), 2);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialChannels")), true);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles")), true);

    spec = RequestableChannelClassSpec::conferenceTextChatroom();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_TEXT);
    QCOMPARE(spec.targetHandleType(), HandleTypeRoom);
    QCOMPARE(spec.allowedProperties().size(), 1);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialChannels")), true);

    spec = RequestableChannelClassSpec::conferenceTextChatroomWithInvitees();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_TEXT);
    QCOMPARE(spec.targetHandleType(), HandleTypeRoom);
    QCOMPARE(spec.allowedProperties().size(), 2);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialChannels")), true);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles")), true);

    spec = RequestableChannelClassSpec::conferenceStreamedMediaCall();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA);
    QVERIFY(!spec.hasTargetHandleType());
    QCOMPARE(spec.allowedProperties().size(), 1);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialChannels")), true);

    spec = RequestableChannelClassSpec::conferenceStreamedMediaCallWithInvitees();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA);
    QVERIFY(!spec.hasTargetHandleType());
    QCOMPARE(spec.allowedProperties().size(), 2);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialChannels")), true);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles")), true);

    spec = RequestableChannelClassSpec::contactSearch();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_CONTACT_SEARCH);
    QCOMPARE(spec.fixedProperties().size(), 1);
    QCOMPARE(spec.allowedProperties().isEmpty(), true);

    spec = RequestableChannelClassSpec::contactSearchWithSpecificServer();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_CONTACT_SEARCH);
    QCOMPARE(spec.fixedProperties().size(), 1);
    QCOMPARE(spec.allowedProperties().size(), 1);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_TYPE_CONTACT_SEARCH + QLatin1String(".Server")), true);

    spec = RequestableChannelClassSpec::contactSearchWithLimit();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_CONTACT_SEARCH);
    QCOMPARE(spec.fixedProperties().size(), 1);
    QCOMPARE(spec.allowedProperties().size(), 1);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_TYPE_CONTACT_SEARCH + QLatin1String(".Limit")), true);

    spec = RequestableChannelClassSpec::contactSearchWithSpecificServerAndLimit();
    QCOMPARE(spec.channelType(), TP_QT_IFACE_CHANNEL_TYPE_CONTACT_SEARCH);
    QCOMPARE(spec.fixedProperties().size(), 1);
    QCOMPARE(spec.allowedProperties().size(), 2);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_TYPE_CONTACT_SEARCH + QLatin1String(".Server")), true);
    QCOMPARE(spec.allowsProperty(TP_QT_IFACE_CHANNEL_TYPE_CONTACT_SEARCH + QLatin1String(".Limit")), true);

    QCOMPARE(RequestableChannelClassSpec::streamedMediaVideoCallWithAudio().supports(
                RequestableChannelClassSpec::streamedMediaVideoCall()), true);
    QCOMPARE(RequestableChannelClassSpec::streamedMediaVideoCallWithAudio().supports(
                RequestableChannelClassSpec::streamedMediaAudioCall()), true);
    QCOMPARE(RequestableChannelClassSpec::streamedMediaVideoCallWithAudio().supports(
                RequestableChannelClassSpec::streamedMediaCall()), true);

    QCOMPARE(RequestableChannelClassSpec::textChat() == RequestableChannelClassSpec::textChatroom(), false);

    RequestableChannelClass rcc;
    rcc.fixedProperties.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"),
            TP_QT_IFACE_CHANNEL_TYPE_TEXT);
    rcc.fixedProperties.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType"),
            (uint) HandleTypeContact);
    spec = RequestableChannelClassSpec(rcc);
    QCOMPARE(RequestableChannelClassSpec::textChat() == spec, true);
}

QTEST_MAIN(TestRCCSpec)
#include "_gen/rccspec.cpp.moc.hpp"