~ubuntu-branches/ubuntu/trusty/telephony-service/trusty

« back to all changes in this revision

Viewing changes to handler/tests/mock/connection.h

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Gustavo Pichorim Boiko, Timo Jyrinki, Tiago Salem Herrmann
  • Date: 2014-01-30 17:08:38 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20140130170838-42iekm3rlprvz8nq
Tags: 0.1+14.04.20140130-0ubuntu1
[ Gustavo Pichorim Boiko ]
* Add the infrastructure to write tests for the handler, and write
  tests for the most important bits of it.
* Make the dbus-based tests more robust. (LP: #1270778)
* Improve the support for handling multiple calls by: Using a
  different approach to detect background calls in the QML plugin.
  Make it possible to hangup the active call to answer an incoming
  one. Show notifications when calls are put on hold, when they are
  rejected and when they end. .

[ Timo Jyrinki ]
* Use QT_QPA_PLATFORM=minimal to fix test failures (LP: #1270770).
  (LP: #1270770)

[ Tiago Salem Herrmann ]
* Fix default action for missed calls. Add voicemail entries to the
  messaging menu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Copyright (C) 2013 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it under
 
5
 * the terms of the GNU General Public License version 3, as published by
 
6
 * the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
 
9
 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
 
10
 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
 * General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
 
17
 *          Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
 
18
 */
 
19
 
 
20
#ifndef MOCKCONNECTION_H
 
21
#define MOCKCONNECTION_H
 
22
 
 
23
// qt
 
24
#include <QTimer>
 
25
 
 
26
// telepathy-qt
 
27
#include <TelepathyQt/BaseConnection>
 
28
#include <TelepathyQt/BaseChannel>
 
29
#include <TelepathyQt/BaseCall>
 
30
#include <TelepathyQt/AbstractAdaptor>
 
31
#include <TelepathyQt/DBusError>
 
32
 
 
33
// mock-cm
 
34
#include "textchannel.h"
 
35
#include "callchannel.h"
 
36
#include "dbustypes.h"
 
37
 
 
38
class MockTextChannel;
 
39
class MockCallChannel;
 
40
class MockConnectionDBus;
 
41
 
 
42
class MockConnection : public Tp::BaseConnection
 
43
{
 
44
    Q_OBJECT
 
45
    Q_DISABLE_COPY(MockConnection)
 
46
public:
 
47
    MockConnection(const QDBusConnection &dbusConnection,
 
48
                    const QString &cmName,
 
49
                    const QString &protocolName,
 
50
                    const QVariantMap &parameters);
 
51
 
 
52
    QStringList inspectHandles(uint handleType, const Tp::UIntList& handles, Tp::DBusError *error);
 
53
    Tp::UIntList requestHandles(uint handleType, const QStringList& identifiers, Tp::DBusError* error);
 
54
    Tp::BaseChannelPtr createChannel(const QString& channelType, uint targetHandleType,
 
55
                                     uint targetHandle, Tp::DBusError *error);
 
56
    Tp::ContactAttributesMap getContactAttributes(const Tp::UIntList &handles, const QStringList &ifaces, Tp::DBusError *error);
 
57
    uint setPresence(const QString& status, const QString& statusMessage, Tp::DBusError *error);
 
58
    void connect(Tp::DBusError *error);
 
59
    void setOnline(bool online);
 
60
 
 
61
    Tp::BaseConnectionRequestsInterfacePtr requestsIface;
 
62
    Tp::BaseConnectionSimplePresenceInterfacePtr simplePresenceIface;
 
63
    Tp::BaseConnectionContactsInterfacePtr contactsIface;
 
64
    uint newHandle(const QString &identifier);
 
65
 
 
66
    uint ensureHandle(const QString &id);
 
67
    Tp::BaseChannelPtr createTextChannel(uint targetHandleType,
 
68
                                         uint targetHandle, Tp::DBusError *error);
 
69
    Tp::BaseChannelPtr createCallChannel(uint targetHandleType,
 
70
                                         uint targetHandle, Tp::DBusError *error);
 
71
 
 
72
    ~MockConnection();
 
73
 
 
74
    QString placeCall(const QVariantMap &properties);
 
75
Q_SIGNALS:
 
76
    void messageSent(const QString &message, const QVariantMap &info);
 
77
    void callReceived(const QString &callerId);
 
78
    void callEnded(const QString &callerId);
 
79
    void callStateChanged(const QString &callerId, const QString &objectPath, const QString &state);
 
80
 
 
81
public Q_SLOTS:
 
82
    void placeIncomingMessage(const QString &message, const QVariantMap &info);
 
83
    void hangupCall(const QString &callerId);
 
84
    void setCallState(const QString &phoneNumber, const QString &state);
 
85
    void onTextChannelClosed();
 
86
    void onCallChannelClosed();
 
87
    void onCallStateChanged(MockCallChannel *channel, const QString &state);
 
88
    void onMessageRead(const QString &id);
 
89
 
 
90
private:
 
91
    void addMMSToService(const QString &path, const QVariantMap &properties, const QString &servicePath);
 
92
    QMap<uint, QString> mHandles;
 
93
 
 
94
    QMap<QString, MockTextChannel*> mTextChannels;
 
95
    QMap<QString, MockCallChannel*> mCallChannels;
 
96
    QMap<QString, QString> mInitialCallStatus;
 
97
 
 
98
    QStringList mModems;
 
99
    uint mHandleCount;
 
100
    Tp::SimplePresence mSelfPresence;
 
101
    Tp::SimplePresence mRequestedSelfPresence;
 
102
 
 
103
    MockConnectionDBus *mDBus;
 
104
    QStringList mIncomingCalls;
 
105
};
 
106
 
 
107
#endif