Merge lp:~boiko/history-service/fix_telepathy_init_on_qml into lp:history-service

Proposed by Gustavo Pichorim Boiko
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 227
Merged at revision: 226
Proposed branch: lp:~boiko/history-service/fix_telepathy_init_on_qml
Merge into: lp:history-service
Diff against target: 207 lines (+112/-10)
6 files modified
daemon/main.cpp (+0/-5)
src/telepathyhelper.cpp (+6/-0)
tests/Ubuntu.History/CMakeLists.txt (+8/-0)
tests/Ubuntu.History/HistoryEventModelTest.cpp (+95/-0)
tests/common/telepathytest.cpp (+2/-4)
tests/common/telepathytest.h (+1/-1)
To merge this branch: bzr merge lp:~boiko/history-service/fix_telepathy_init_on_qml
Reviewer Review Type Date Requested Status
Tiago Salem Herrmann (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+292843@code.launchpad.net

Commit message

Make sure Telepathy types are always initialized.

Description of the change

Make sure Telepathy types are always initialized.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

looks good. thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'daemon/main.cpp'
--- daemon/main.cpp 2013-09-17 14:41:07 +0000
+++ daemon/main.cpp 2016-04-25 17:57:17 +0000
@@ -20,8 +20,6 @@
20 */20 */
2121
22#include "historydaemon.h"22#include "historydaemon.h"
23#include <TelepathyQt/Types>
24#include <TelepathyQt/Debug>
2523
26bool checkApplicationRunning()24bool checkApplicationRunning()
27{25{
@@ -35,9 +33,6 @@
35}33}
36int main(int argc, char **argv)34int main(int argc, char **argv)
37{35{
38 Tp::registerTypes();
39 Tp::enableWarnings(true);
40
41 QCoreApplication app(argc, argv);36 QCoreApplication app(argc, argv);
4237
43 if (checkApplicationRunning()) {38 if (checkApplicationRunning()) {
4439
=== modified file 'src/telepathyhelper.cpp'
--- src/telepathyhelper.cpp 2015-10-06 12:50:14 +0000
+++ src/telepathyhelper.cpp 2016-04-25 17:57:17 +0000
@@ -23,6 +23,8 @@
23#include "telepathyhelper_p.h"23#include "telepathyhelper_p.h"
2424
25#include <TelepathyQt/ClientRegistrar>25#include <TelepathyQt/ClientRegistrar>
26#include <TelepathyQt/Types>
27#include <TelepathyQt/Debug>
2628
27namespace History29namespace History
28{30{
@@ -32,6 +34,10 @@
32 mChannelObserver(0),34 mChannelObserver(0),
33 mReady(false)35 mReady(false)
34{36{
37 // initialize telepathy
38 Tp::registerTypes();
39 Tp::enableWarnings(true);
40
35 mAccountFeatures << Tp::Account::FeatureCore41 mAccountFeatures << Tp::Account::FeatureCore
36 << Tp::Account::FeatureProtocolInfo;42 << Tp::Account::FeatureProtocolInfo;
37 mContactFeatures << Tp::Contact::FeatureAlias43 mContactFeatures << Tp::Contact::FeatureAlias
3844
=== modified file 'tests/Ubuntu.History/CMakeLists.txt'
--- tests/Ubuntu.History/CMakeLists.txt 2015-05-19 11:55:20 +0000
+++ tests/Ubuntu.History/CMakeLists.txt 2016-04-25 17:57:17 +0000
@@ -2,6 +2,8 @@
2 ${CMAKE_CURRENT_BINARY_DIR}2 ${CMAKE_CURRENT_BINARY_DIR}
3 ${CMAKE_SOURCE_DIR}/Ubuntu/History3 ${CMAKE_SOURCE_DIR}/Ubuntu/History
4 ${CMAKE_SOURCE_DIR}/src4 ${CMAKE_SOURCE_DIR}/src
5 ${CMAKE_SOURCE_DIR}/tests/common
6 ${TP_QT5_INCLUDE_DIRS}
5 )7 )
68
7set(SOURCE_DIR ${CMAKE_SOURCE_DIR}/Ubuntu/History)9set(SOURCE_DIR ${CMAKE_SOURCE_DIR}/Ubuntu/History)
@@ -12,3 +14,9 @@
12 USE_XVFB14 USE_XVFB
13 TASKS --task ${CMAKE_BINARY_DIR}/daemon/history-daemon --ignore-return --task-name history-daemon15 TASKS --task ${CMAKE_BINARY_DIR}/daemon/history-daemon --ignore-return --task-name history-daemon
14 WAIT_FOR com.canonical.HistoryService)16 WAIT_FOR com.canonical.HistoryService)
17generate_telepathy_test(HistoryEventModelTest
18 SOURCES HistoryEventModelTest.cpp
19 LIBRARIES ${TP_QT5_LIBRARIES} mockcontroller telepathytest history-qml
20 USE_XVFB
21 TASKS --task ${CMAKE_BINARY_DIR}/daemon/history-daemon --ignore-return --task-name history-daemon
22 WAIT_FOR com.canonical.HistoryService)
1523
=== added file 'tests/Ubuntu.History/HistoryEventModelTest.cpp'
--- tests/Ubuntu.History/HistoryEventModelTest.cpp 1970-01-01 00:00:00 +0000
+++ tests/Ubuntu.History/HistoryEventModelTest.cpp 2016-04-25 17:57:17 +0000
@@ -0,0 +1,95 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This file is part of history-service.
5 *
6 * telephony-service is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * telephony-service is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <QtTest/QtTest>
20#include "telepathytest.h"
21#include "manager.h"
22#include "textevent.h"
23#include "historyeventmodel.h"
24
25class HistoryEventModelTest : public TelepathyTest
26{
27 Q_OBJECT
28
29private Q_SLOTS:
30 void initTestCase();
31 void testTelepathyInitializedCorrectly();
32
33private:
34 History::Manager *mManager;
35};
36
37void HistoryEventModelTest::initTestCase()
38{
39 initialize(0);
40
41 mManager = History::Manager::instance();
42}
43
44void HistoryEventModelTest::testTelepathyInitializedCorrectly()
45{
46 Tp::AccountPtr account = addAccount("mock", "ofono", "My Account");
47 QVERIFY(!account.isNull());
48
49 // we don't actually test anything on the model other than it having the event
50 // but if telepathy is not properly initialized, this will crash.
51 HistoryEventModel model;
52 QString participant("textParticipant");
53
54 // create a temporary thread to populate the model
55 History::Thread textThread = mManager->threadForParticipants(account->uniqueIdentifier(),
56 History::EventTypeText,
57 QStringList() << participant,
58 History::MatchCaseSensitive, true);
59
60 History::TextEvent event(textThread.accountId(),
61 textThread.threadId(),
62 "theEventId",
63 participant,
64 QDateTime::currentDateTime(),
65 true,
66 "Hi there",
67 History::MessageTypeText,
68 History::MessageStatusRead,
69 QDateTime::currentDateTime(),
70 "The subject",
71 History::TextEventAttachments(),
72 textThread.participants());
73 QVERIFY(mManager->writeEvents(History::Events() << event));
74
75 HistoryQmlFilter *filter = new HistoryQmlFilter(this);
76 filter->setFilterProperty(History::FieldThreadId);
77 filter->setFilterValue(textThread.threadId());
78 model.setFilter(filter);
79
80 HistoryQmlSort *sort = new HistoryQmlSort(this);
81 sort->setSortOrder(HistoryQmlSort::DescendingOrder);
82 sort->setSortField("timestamp");
83 model.setSort(sort);
84
85 QTRY_COMPARE(model.rowCount(), 1);
86
87 // this will trigger the crash if tp-qt is not properly initialized
88 qDebug() << model.index(0).data(HistoryEventModel::SenderRole);
89
90 mManager->removeThreads(History::Threads() << textThread);
91 QTRY_COMPARE(model.rowCount(), 0);
92}
93
94QTEST_MAIN(HistoryEventModelTest)
95#include "HistoryEventModelTest.moc"
096
=== modified file 'tests/common/telepathytest.cpp'
--- tests/common/telepathytest.cpp 2015-10-06 12:50:14 +0000
+++ tests/common/telepathytest.cpp 2016-04-25 17:57:17 +0000
@@ -24,10 +24,8 @@
24#include "telepathytest.h"24#include "telepathytest.h"
25#include "telepathyhelper_p.h"25#include "telepathyhelper_p.h"
2626
27void TelepathyTest::initialize()27void TelepathyTest::initialize(int waitTime)
28{28{
29 Tp::registerTypes();
30
31 QSignalSpy spy(History::TelepathyHelper::instance(), SIGNAL(setupReady()));29 QSignalSpy spy(History::TelepathyHelper::instance(), SIGNAL(setupReady()));
32 QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, DEFAULT_TIMEOUT);30 QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, DEFAULT_TIMEOUT);
3331
@@ -70,7 +68,7 @@
70 QTRY_VERIFY(mReady);68 QTRY_VERIFY(mReady);
7169
72 // give some time for telepathy stuff to settle70 // give some time for telepathy stuff to settle
73 QTest::qWait(1000);71 QTest::qWait(waitTime);
74}72}
7573
76void TelepathyTest::doCleanup()74void TelepathyTest::doCleanup()
7775
=== modified file 'tests/common/telepathytest.h'
--- tests/common/telepathytest.h 2015-04-07 14:40:58 +0000
+++ tests/common/telepathytest.h 2016-04-25 17:57:17 +0000
@@ -30,7 +30,7 @@
30 Q_OBJECT30 Q_OBJECT
3131
32protected:32protected:
33 void initialize();33 void initialize(int waitTime = 1000);
34 void doCleanup();34 void doCleanup();
3535
36 // helper slots36 // helper slots

Subscribers

People subscribed via source and target branches