~phablet-team/telephony-service/trunk

« back to all changes in this revision

Viewing changes to TelephonyApp/tests/ConversationFeedItemTest.cpp

  • Committer: Tarmac
  • Author(s): Tiago Salem Herrmann, Gustavo Pichorim Boiko
  • Date: 2012-11-13 20:42:49 UTC
  • mfrom: (434.5.73 marumbi-aggregate)
  • Revision ID: tarmac-20121113204249-n8drkv6gs554khon
Group the SMS messages and the call log into the new Communication view.

Approved by Tiago Salem Herrmann.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU 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
 
 
17
#include <QtCore/QObject>
 
18
#include <QtTest/QtTest>
 
19
#include "conversationfeeditem.h"
 
20
 
 
21
class ConversationFeedItemTest : public QObject
 
22
{
 
23
    Q_OBJECT
 
24
 
 
25
private Q_SLOTS:
 
26
    void initTestCase();
 
27
    void cleanupTestCase();
 
28
    void testContactId();
 
29
    void testContactAlias();
 
30
    void testContactAvatar();
 
31
    void testIncoming();
 
32
    void testTimestamp();
 
33
 
 
34
private:
 
35
    ConversationFeedItem *item;
 
36
};
 
37
 
 
38
void ConversationFeedItemTest::initTestCase()
 
39
{
 
40
    item = new ConversationFeedItem(this);
 
41
}
 
42
 
 
43
void ConversationFeedItemTest::cleanupTestCase()
 
44
{
 
45
    delete item;
 
46
}
 
47
 
 
48
void ConversationFeedItemTest::testContactId()
 
49
{
 
50
    QSignalSpy signalSpy(item, SIGNAL(contactIdChanged()));
 
51
    QString id("OneContactId");
 
52
    item->setContactId(id);
 
53
 
 
54
    QCOMPARE(item->contactId(), id);
 
55
    QCOMPARE(signalSpy.count(), 1);
 
56
}
 
57
 
 
58
void ConversationFeedItemTest::testContactAlias()
 
59
{
 
60
    QSignalSpy signalSpy(item, SIGNAL(contactAliasChanged()));
 
61
    QString alias("OneContactAlias");
 
62
    item->setContactAlias(alias);
 
63
 
 
64
    QCOMPARE(item->contactAlias(), alias);
 
65
    QCOMPARE(signalSpy.count(), 1);
 
66
}
 
67
 
 
68
void ConversationFeedItemTest::testContactAvatar()
 
69
{
 
70
    QSignalSpy signalSpy(item, SIGNAL(contactAvatarChanged()));
 
71
    QUrl avatar("/a/file/somewhere");
 
72
    item->setContactAvatar(avatar);
 
73
 
 
74
    QCOMPARE(item->contactAvatar(), avatar);
 
75
    QCOMPARE(signalSpy.count(), 1);
 
76
}
 
77
 
 
78
void ConversationFeedItemTest::testIncoming()
 
79
{
 
80
    QSignalSpy signalSpy(item, SIGNAL(incomingChanged()));
 
81
    bool incoming = false;
 
82
    item->setIncoming(incoming);
 
83
 
 
84
    QCOMPARE(item->incoming(), incoming);
 
85
    QCOMPARE(signalSpy.count(), 1);
 
86
}
 
87
 
 
88
void ConversationFeedItemTest::testTimestamp()
 
89
{
 
90
    QSignalSpy signalSpy(item, SIGNAL(timestampChanged()));
 
91
    QDateTime timestamp = QDateTime::currentDateTime();
 
92
    item->setTimestamp(timestamp);
 
93
 
 
94
    QCOMPARE(item->timestamp(), timestamp);
 
95
    QCOMPARE(signalSpy.count(), 1);
 
96
}
 
97
 
 
98
QTEST_MAIN(ConversationFeedItemTest)
 
99
#include "ConversationFeedItemTest.moc"