Merge lp:~renatofilho/address-book-app/fix-1400468-rtm into lp:address-book-app/rtm-14.09

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Bill Filler
Approved revision: 292
Merged at revision: 289
Proposed branch: lp:~renatofilho/address-book-app/fix-1400468-rtm
Merge into: lp:address-book-app/rtm-14.09
Diff against target: 246 lines (+166/-20)
6 files modified
debian/control (+1/-0)
debian/rules (+3/-0)
src/imports/Ubuntu/Contacts/ContactListModel.qml (+24/-20)
tests/data/tst_ContactListModel_data.vcf (+30/-0)
tests/qml/CMakeLists.txt (+2/-0)
tests/qml/tst_ContactListModel.qml (+106/-0)
To merge this branch: bzr merge lp:~renatofilho/address-book-app/fix-1400468-rtm
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+244852@code.launchpad.net

Commit message

Fix phone number search to find the search term in any position of the field value.

To post a comment you must log in.
291. By Renato Araujo Oliveira Filho

Added dbus as build dep.

292. By Renato Araujo Oliveira Filho

Enable unit test debug if it fails.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2014-12-04 13:18:23 +0000
3+++ debian/control 2014-12-16 19:35:55 +0000
4@@ -3,6 +3,7 @@
5 Priority: optional
6 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
7 Build-Depends: cmake,
8+ dbus,
9 debhelper (>= 9),
10 dh-translations,
11 libgl1-mesa-dev | libgl-dev,
12
13=== modified file 'debian/rules'
14--- debian/rules 2014-07-02 20:29:48 +0000
15+++ debian/rules 2014-12-16 19:35:55 +0000
16@@ -14,6 +14,9 @@
17 # (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=601774).
18 $(MAKE) -C obj-$(DEB_HOST_GNU_TYPE) address-book-app.pot
19
20+override_dh_auto_test:
21+ CTEST_OUTPUT_ON_FAILURE=1 dh_auto_test
22+
23 .PHONY: override_dh_strip
24 override_dh_strip:
25 dh_strip --dbg-package=address-book-app-dbg
26
27=== modified file 'src/imports/Ubuntu/Contacts/ContactListModel.qml'
28--- src/imports/Ubuntu/Contacts/ContactListModel.qml 2014-08-18 18:05:38 +0000
29+++ src/imports/Ubuntu/Contacts/ContactListModel.qml 2014-12-16 19:35:55 +0000
30@@ -66,26 +66,30 @@
31 id: contactTermFilter
32
33 property string value: ""
34-
35- DetailFilter {
36- detail: ContactDetail.DisplayLabel
37- field: DisplayLabel.Label
38- value: contactTermFilter.value
39- matchFlags: DetailFilter.MatchContains
40- }
41-
42- DetailFilter {
43- detail: ContactDetail.PhoneNumber
44- field: PhoneNumber.Number
45- value: contactTermFilter.value
46- matchFlags: DetailFilter.MatchPhoneNumber
47- }
48-
49- DetailFilter {
50- detail: ContactDetail.PhoneNumber
51- field: PhoneNumber.Number
52- value: contactTermFilter.value
53- matchFlags: DetailFilter.MatchContains
54+ property var phoneNumberFilter: DetailFilter {
55+ detail: ContactDetail.PhoneNumber
56+ field: PhoneNumber.Number
57+ value: contactTermFilter.value
58+ matchFlags: (DetailFilter.MatchPhoneNumber | DetailFilter.MatchContains)
59+ }
60+
61+ filters: [
62+ DetailFilter {
63+ detail: ContactDetail.DisplayLabel
64+ field: DisplayLabel.Label
65+ value: contactTermFilter.value
66+ matchFlags: DetailFilter.MatchContains
67+ }
68+ ]
69+
70+ onValueChanged: {
71+ var containsLetter = /^[a-zA-Z]/.test(value)
72+
73+ if (containsLetter && (filters.length > 1)) {
74+ filters = [filters[0]]
75+ } else if (!containsLetter) {
76+ filters = [filters[0], phoneNumberFilter]
77+ }
78 }
79 },
80 IntersectionFilter {
81
82=== added file 'tests/data/tst_ContactListModel_data.vcf'
83--- tests/data/tst_ContactListModel_data.vcf 1970-01-01 00:00:00 +0000
84+++ tests/data/tst_ContactListModel_data.vcf 2014-12-16 19:35:55 +0000
85@@ -0,0 +1,30 @@
86+BEGIN:VCARD
87+VERSION:3.0
88+UID:47bbbfcab7c9b8ef0e7375074d22ff54905174bd
89+X-QTPROJECT-EXTENDED-DETAIL:CLIENTPIDMAP;[\n "1"\n]\n
90+N:First;Last;;;
91+FN:First Last
92+X-QTPROJECT-FAVORITE:false;0
93+TEL:123456
94+CATEGORIES:F
95+END:VCARD
96+BEGIN:VCARD
97+VERSION:3.0
98+UID:e5bb57fc852541dfc9ad29d583a36f1c353b65ed
99+X-QTPROJECT-EXTENDED-DETAIL:CLIENTPIDMAP;[\n "1"\n]\n
100+N:Fulano;de;tal6;;
101+FN:Fulano de Tal6
102+X-QTPROJECT-FAVORITE:false;0
103+TEL:123678
104+CATEGORIES:F
105+END:VCARD
106+BEGIN:VCARD
107+VERSION:3.0
108+UID:0d753ce1005dde92f69e4ddb62222240691693a0
109+X-QTPROJECT-EXTENDED-DETAIL:CLIENTPIDMAP;[\n "1"\n]\n
110+N:Fulano;da;Silva1;;;
111+FN:Fulano da Silva1
112+X-QTPROJECT-FAVORITE:false;0
113+TEL:555666
114+CATEGORIES:F
115+END:VCARD
116
117=== modified file 'tests/qml/CMakeLists.txt'
118--- tests/qml/CMakeLists.txt 2014-12-04 13:18:23 +0000
119+++ tests/qml/CMakeLists.txt 2014-12-16 19:35:55 +0000
120@@ -22,6 +22,7 @@
121
122 if(QMLTESTRUNNER_BIN AND XVFB_RUN_BIN)
123 declare_qml_test("contact_list" tst_ContactList.qml)
124+ declare_qml_test("Contact_list_model" tst_ContactListModel.qml)
125 declare_qml_test("contact_editor" tst_ContactEditor.qml)
126 declare_qml_test("contact_avatar" tst_ContactAvatar.qml)
127 declare_qml_test("list_with_actions" tst_ListWithActions.qml)
128@@ -40,6 +41,7 @@
129 tst_ContactEditor.qml
130 tst_ContactAvatar.qml
131 tst_ContactList.qml
132+ tst_ContactListModel.qml
133 tst_ListWithActions.qml
134 tst_ContactPreviewPage.qml
135 tst_VCardParser.qml
136
137=== added file 'tests/qml/tst_ContactListModel.qml'
138--- tests/qml/tst_ContactListModel.qml 1970-01-01 00:00:00 +0000
139+++ tests/qml/tst_ContactListModel.qml 2014-12-16 19:35:55 +0000
140@@ -0,0 +1,106 @@
141+/*
142+ * Copyright (C) 2014 Canonical, Ltd.
143+ *
144+ * This program is free software; you can redistribute it and/or modify
145+ * it under the terms of the GNU General Public License as published by
146+ * the Free Software Foundation; version 3.
147+ *
148+ * This program is distributed in the hope that it will be useful,
149+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
150+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
151+ * GNU General Public License for more details.
152+ *
153+ * You should have received a copy of the GNU General Public License
154+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
155+ */
156+
157+import QtQuick 2.2
158+import QtTest 1.0
159+import Ubuntu.Components 1.1
160+import Ubuntu.Test 0.1
161+import Ubuntu.Contacts 0.1
162+
163+Item {
164+ id: root
165+
166+ property var application
167+ property var contactListModelObj
168+
169+ width: units.gu(40)
170+ height: units.gu(80)
171+
172+ Component {
173+ id: contactListModelCmp
174+
175+ ContactListModel {
176+ id: contactListModel
177+
178+ property int contactCount: contacts ? contacts.length : 0
179+
180+ manager: "memory"
181+ Component.onCompleted: importContacts(Qt.resolvedUrl("../data/tst_ContactListModel_data.vcf"))
182+ }
183+ }
184+
185+ UbuntuTestCase {
186+ id: contactListModelTestCase
187+ name: 'contactListModelTestCase'
188+
189+ when: windowShown
190+
191+ function init()
192+ {
193+ root.contactListModelObj = contactListModelCmp.createObject(root)
194+ //waitForRendering(root.contactListModelObj)
195+ }
196+
197+ function cleanup()
198+ {
199+ root.contactListModelObj.destroy()
200+ }
201+
202+ function test_contactImport()
203+ {
204+ tryCompare(root.contactListModelObj, "contactCount", 3)
205+ }
206+
207+ function test_searchByPhoneNumber()
208+ {
209+ root.contactListModelObj.filterTerm = "555"
210+ tryCompare(root.contactListModelObj, "contactCount", 1)
211+
212+ root.contactListModelObj.filterTerm = "5"
213+ tryCompare(root.contactListModelObj, "contactCount", 2)
214+
215+ root.contactListModelObj.filterTerm = "6"
216+ tryCompare(root.contactListModelObj, "contactCount", 3)
217+ }
218+
219+ function test_searchByContactName()
220+ {
221+ root.contactListModelObj.filterTerm = "First"
222+ tryCompare(root.contactListModelObj, "contactCount", 1)
223+
224+ root.contactListModelObj.filterTerm = "Fulano"
225+ tryCompare(root.contactListModelObj, "contactCount", 2)
226+
227+ root.contactListModelObj.filterTerm = "F"
228+ tryCompare(root.contactListModelObj, "contactCount", 3)
229+
230+ root.contactListModelObj.filterTerm = "tal6"
231+ tryCompare(root.contactListModelObj, "contactCount", 1)
232+ }
233+
234+ function test_searchByNameAndNumber()
235+ {
236+ root.contactListModelObj.filterTerm = "First"
237+ tryCompare(root.contactListModelObj, "contactCount", 1)
238+
239+ root.contactListModelObj.filterTerm = "555"
240+ tryCompare(root.contactListModelObj, "contactCount", 1)
241+
242+ root.contactListModelObj.filterTerm = "1"
243+ tryCompare(root.contactListModelObj, "contactCount", 3)
244+ }
245+ }
246+}

Subscribers

People subscribed via source and target branches