|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "ut_cntdefaultinfoprovider.h" |
|
19 #include "cntdefaultinfoprovider.h" |
|
20 |
|
21 void TestCntDefaultInfoProvider::initTestCase() |
|
22 { |
|
23 mCntDefaultInfoProvider = NULL; |
|
24 } |
|
25 |
|
26 void TestCntDefaultInfoProvider::create() |
|
27 { |
|
28 mCntDefaultInfoProvider = new CntDefaultInfoProvider(); |
|
29 } |
|
30 |
|
31 void TestCntDefaultInfoProvider::testSupportedFields() |
|
32 { |
|
33 QVERIFY(mCntDefaultInfoProvider->supportedFields() == ContactInfoIcon1Field | ContactInfoTextField); |
|
34 } |
|
35 |
|
36 void TestCntDefaultInfoProvider::testRequestInfo() |
|
37 { |
|
38 QSignalSpy spy(mCntDefaultInfoProvider, SIGNAL(infoFieldReady(CntInfoProvider*, int, ContactInfoField, const QString&))); |
|
39 |
|
40 QContact c; |
|
41 QContactName name; |
|
42 name.setFirstName("firstname"); |
|
43 name.setLastName("lastname"); |
|
44 c.saveDetail(&name); |
|
45 |
|
46 ContactInfoFields fields; |
|
47 fields = ContactInfoIcon2Field; |
|
48 |
|
49 mCntDefaultInfoProvider->requestInfo(c, fields); |
|
50 QCOMPARE(spy.count(), 0); |
|
51 |
|
52 fields = ContactInfoIcon1Field | ContactInfoTextField; |
|
53 |
|
54 mCntDefaultInfoProvider->requestInfo(c, fields); |
|
55 QCOMPARE(spy.count(), 0); |
|
56 |
|
57 QContactPhoneNumber number; |
|
58 number.setNumber("1234567"); |
|
59 number.setContexts(QContactDetail::ContextHome); |
|
60 number.setSubTypes(QContactPhoneNumber::SubTypeMobile); |
|
61 c.saveDetail(&number); |
|
62 |
|
63 mCntDefaultInfoProvider->requestInfo(c, fields); |
|
64 QCOMPARE(spy.count(), 1); |
|
65 spy.clear(); |
|
66 |
|
67 c.setPreferredDetail("call", number); |
|
68 |
|
69 mCntDefaultInfoProvider->requestInfo(c, fields); |
|
70 QCOMPARE(spy.count(), 1); |
|
71 spy.clear(); |
|
72 |
|
73 QContactAvatar avatar; |
|
74 c.saveDetail(&avatar); |
|
75 |
|
76 mCntDefaultInfoProvider->requestInfo(c, fields); |
|
77 QCOMPARE(spy.count(), 1); |
|
78 spy.clear(); |
|
79 |
|
80 avatar.setImageUrl(QUrl("dummyavatar")); |
|
81 c.saveDetail(&avatar); |
|
82 |
|
83 mCntDefaultInfoProvider->requestInfo(c, fields); |
|
84 QCOMPARE(spy.count(), 2); |
|
85 } |
|
86 |
|
87 void TestCntDefaultInfoProvider::cleanupTestCase() |
|
88 { |
|
89 delete mCntDefaultInfoProvider; |
|
90 mCntDefaultInfoProvider = NULL; |
|
91 } |
|
92 |