Merge lp:~renatofilho/address-book-service/fix-duplicated-fields into lp:address-book-service

Proposed by Renato Araujo Oliveira Filho
Status: Needs review
Proposed branch: lp:~renatofilho/address-book-service/fix-duplicated-fields
Merge into: lp:address-book-service
Prerequisite: lp:~renatofilho/address-book-service/fix-1269561
Diff against target: 181 lines (+139/-9)
3 files modified
lib/gee-utils.h (+8/-8)
tests/unittest/CMakeLists.txt (+1/-1)
tests/unittest/contact-edit-test.cpp (+130/-0)
To merge this branch: bzr merge lp:~renatofilho/address-book-service/fix-duplicated-fields
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Needs Fixing
Bill Filler (community) Needs Fixing
PS Jenkins bot continuous-integration Approve
Review via email: mp+208040@code.launchpad.net

Commit message

Added support to store contacts with duplicate details values.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

tested, doesn't work. same problem as before

review: Needs Fixing
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

120. By Renato Araujo Oliveira Filho

Added support to store contacts with duplicate details values.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/gee-utils.h'
--- lib/gee-utils.h 2013-10-30 19:07:49 +0000
+++ lib/gee-utils.h 2014-02-24 23:23:25 +0000
@@ -43,10 +43,10 @@
43#define SET_AFD_NEW() \43#define SET_AFD_NEW() \
44 GEE_SET(gee_hash_set_new(FOLKS_TYPE_ABSTRACT_FIELD_DETAILS, \44 GEE_SET(gee_hash_set_new(FOLKS_TYPE_ABSTRACT_FIELD_DETAILS, \
45 (GBoxedCopyFunc) g_object_ref, g_object_unref, \45 (GBoxedCopyFunc) g_object_ref, g_object_unref, \
46 _folks_abstract_field_details_hash_data_func, \46 NULL, \
47 NULL, \47 NULL, \
48 NULL, \48 NULL, \
49 _folks_abstract_field_details_equal_data_func, \49 NULL, \
50 NULL, \50 NULL, \
51 NULL))51 NULL))
5252
@@ -71,10 +71,10 @@
71 NULL, \71 NULL, \
72 NULL, \72 NULL, \
73 NULL, \73 NULL, \
74 _folks_abstract_field_details_hash_data_func, \74 NULL, \
75 NULL, \75 NULL, \
76 NULL, \76 NULL, \
77 _folks_abstract_field_details_equal_data_func, \77 NULL, \
78 NULL, \78 NULL, \
79 NULL))79 NULL))
8080
8181
=== modified file 'tests/unittest/CMakeLists.txt'
--- tests/unittest/CMakeLists.txt 2014-02-24 23:23:25 +0000
+++ tests/unittest/CMakeLists.txt 2014-02-24 23:23:25 +0000
@@ -71,7 +71,7 @@
71 declare_test(addressbook-test True ${BASE_CLIENT_TEST_SRC})71 declare_test(addressbook-test True ${BASE_CLIENT_TEST_SRC})
72 declare_test(service-life-cycle-test True ${BASE_CLIENT_TEST_SRC})72 declare_test(service-life-cycle-test True ${BASE_CLIENT_TEST_SRC})
73 declare_test(contact-link-test True ${BASE_CLIENT_TEST_SRC})73 declare_test(contact-link-test True ${BASE_CLIENT_TEST_SRC})
7474 declare_test(contact-edit-test True ${BASE_CLIENT_TEST_SRC})
75elseif()75elseif()
76 message(STATUS "DBus test runner not found. Some tests will be disabled")76 message(STATUS "DBus test runner not found. Some tests will be disabled")
77endif()77endif()
7878
=== added file 'tests/unittest/contact-edit-test.cpp'
--- tests/unittest/contact-edit-test.cpp 1970-01-01 00:00:00 +0000
+++ tests/unittest/contact-edit-test.cpp 2014-02-24 23:23:25 +0000
@@ -0,0 +1,130 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This file is part of contact-service-app.
5 *
6 * contact-service-app 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 * contact-service-app 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 "base-client-test.h"
20#include "lib/source.h"
21#include "common/dbus-service-defs.h"
22#include "common/vcard-parser.h"
23
24#include <QObject>
25#include <QtDBus>
26#include <QtTest>
27#include <QDebug>
28#include <QtVersit>
29
30class ContactEditTest : public BaseClientTest
31{
32 Q_OBJECT
33private:
34 QString m_basicVcard;
35
36private Q_SLOTS:
37 void initTestCase()
38 {
39 BaseClientTest::initTestCase();
40 m_basicVcard = QStringLiteral("BEGIN:VCARD\n"
41 "VERSION:3.0\n"
42 "N:Tal;Fulano_;de;;\n"
43 "EMAIL:fulano_@ubuntu.com\n"
44 "EMAIL:fulano_@ubuntu.com\n"
45 "TEL;TYPE=CELL:8888888\n"
46 "TEL;TYPE=ISDN:8888888\n"
47 "END:VCARD");
48 }
49
50 void testSaveDuplicatedEmail()
51 {
52 // call create contact
53 QDBusReply<QString> reply = m_serverIface->call("createContact", m_basicVcard, "dummy-store");
54
55 // check if the returned id is valid
56 QString newContactId = reply.value();
57 QVERIFY(!newContactId.isEmpty());
58
59 // query created contact
60 QDBusReply<QStringList> reply2 = m_dummyIface->call("listContacts");
61 QCOMPARE(reply2.value().count(), 1);
62 QList<QtContacts::QContact> contactsCreated = galera::VCardParser::vcardToContact(reply2.value());
63 QCOMPARE(contactsCreated.count(), 1);
64
65 // check if the contact has the 2 emails
66 QList<QtContacts::QContactEmailAddress> emails = contactsCreated[0].details<QtContacts::QContactEmailAddress>();
67 QCOMPARE(emails.size(), 2);
68 QCOMPARE(emails[0].emailAddress(), QStringLiteral("fulano_@ubuntu.com"));
69 QCOMPARE(emails[1].emailAddress(), QStringLiteral("fulano_@ubuntu.com"));
70
71 // check if the contact has the 2 phones
72 QList<QtContacts::QContactPhoneNumber> phones = contactsCreated[0].details<QtContacts::QContactPhoneNumber>();
73 QCOMPARE(phones.size(), 2);
74 QCOMPARE(phones[0].number(), QStringLiteral("8888888"));
75 QCOMPARE(phones[1].number(), QStringLiteral("8888888"));
76 }
77
78 void testAddANewEmailWithTheSameAddress()
79 {
80 // call create contact
81 QDBusReply<QString> replyString = m_serverIface->call("createContact", m_basicVcard, "dummy-store");
82
83 // check if the returned id is valid
84 QString newContactId = replyString.value();
85 QVERIFY(!newContactId.isEmpty());
86
87 // query created contact
88 QDBusReply<QStringList> replyStringList = m_dummyIface->call("listContacts");
89 QCOMPARE(replyStringList.value().count(), 1);
90 QList<QtContacts::QContact> contacts = galera::VCardParser::vcardToContact(replyStringList.value());
91 QCOMPARE(contacts.count(), 1);
92
93 // add a email with the same address but different context
94 QtContacts::QContact contact = contacts[0];
95 QtContacts::QContactEmailAddress email;
96 email.setEmailAddress("fulano_@ubuntu.com");
97 QList<int> contexts;
98 contexts << QtContacts::QContactDetail::ContextWork;
99 email.setContexts(contexts);
100 contact.saveDetail(&email);
101
102 // save the changes
103 QStringList vcards = galera::VCardParser::contactToVcard(QList<QtContacts::QContact>() << contact);
104 replyStringList = m_serverIface->call("updateContacts", vcards);
105
106 // query updated contacts
107 replyStringList = m_dummyIface->call("listContacts");
108 QCOMPARE(replyStringList.value().count(), 1);
109 contacts = galera::VCardParser::vcardToContact(replyStringList.value());
110 QCOMPARE(contacts.count(), 1);
111
112 // check if the contact has the 3 emails
113 QList<QtContacts::QContactEmailAddress> emails = contacts[0].details<QtContacts::QContactEmailAddress>();
114 QCOMPARE(emails.size(), 3);
115 bool hasWorkEmail = false;
116 Q_FOREACH(QtContacts::QContactEmailAddress email, emails) {
117 QCOMPARE(email.emailAddress(), QStringLiteral("fulano_@ubuntu.com"));
118 if (email.contexts() == contexts) {
119 // we only have one work e-mail
120 QCOMPARE(hasWorkEmail, false);
121 hasWorkEmail = true;
122 }
123 }
124 QCOMPARE(hasWorkEmail, true);
125 }
126};
127
128QTEST_MAIN(ContactEditTest)
129
130#include "contact-edit-test.moc"

Subscribers

People subscribed via source and target branches