2 #include "../contactfields.h"
8 class ContactFieldsTest
: public QObject
13 void testFieldCount();
17 KContacts::Addressee mContact
;
20 QTEST_MAIN(ContactFieldsTest
)
22 static const QString
s_formattedName(QStringLiteral("User, Joe"));
23 static const QString
s_prefix(QStringLiteral("Mr."));
24 static const QString
s_givenName(QStringLiteral("Joe"));
25 static const QString
s_additionalName(QStringLiteral("Doe"));
26 static const QString
s_familyName(QStringLiteral("User"));
27 static const QString
s_suffix(QStringLiteral("Jr."));
28 static const QString
s_nickName(QStringLiteral("joe"));
29 static const QString
s_birthday(QStringLiteral("1966-12-03"));
30 static const QString
s_anniversary(QStringLiteral("1980-10-02"));
31 static const QString
s_homeAddressStreet(QStringLiteral("My Home Street"));
32 static const QString
s_homeAddressPostOfficeBox(QStringLiteral("My Home POB"));
33 static const QString
s_homeAddressLocality(QStringLiteral("My Home Locality"));
34 static const QString
s_homeAddressRegion(QStringLiteral("My Home Address"));
35 static const QString
s_homeAddressPostalCode(QStringLiteral("My Home Postal Code"));
36 static const QString
s_homeAddressCountry(QStringLiteral("My Home Country"));
37 static const QString
s_homeAddressLabel(QStringLiteral("My Home Label"));
38 static const QString
s_businessAddressStreet(QStringLiteral("My Business Street"));
39 static const QString
s_businessAddressPostOfficeBox(QStringLiteral("My Business POB"));
40 static const QString
s_businessAddressLocality(QStringLiteral("My Business Locality"));
41 static const QString
s_businessAddressRegion(QStringLiteral("My Business Region"));
42 static const QString
s_businessAddressPostalCode(QStringLiteral("My Business Postal Code"));
43 static const QString
s_businessAddressCountry(QStringLiteral("My Business Country"));
44 static const QString
s_businessAddressLabel(QStringLiteral("My Business Label"));
45 static const QString
s_homePhone(QStringLiteral("000111222"));
46 static const QString
s_businessPhone(QStringLiteral("333444555"));
47 static const QString
s_mobilePhone(QStringLiteral("666777888"));
48 static const QString
s_homeFax(QStringLiteral("999000111"));
49 static const QString
s_businessFax(QStringLiteral("222333444"));
50 static const QString
s_carPhone(QStringLiteral("555666777"));
51 static const QString
s_isdn(QStringLiteral("888999000"));
52 static const QString
s_pager(QStringLiteral("111222333"));
53 static const QString
s_preferredEmail(QStringLiteral("me@somewhere.org"));
54 static const QString
s_email2(QStringLiteral("you@somewhere.org"));
55 static const QString
s_email3(QStringLiteral("she@somewhere.org"));
56 static const QString
s_email4(QStringLiteral("it@somewhere.org"));
57 static const QString
s_mailer(QStringLiteral("kmail2"));
58 static const QString
s_title(QStringLiteral("Chief"));
59 static const QString
s_role(QStringLiteral("Developer"));
60 static const QString
s_organization(QStringLiteral("KDE"));
61 static const QString
s_note(QStringLiteral("That's a small note"));
62 static const QString
s_homepage(QStringLiteral("http://www.kde.de"));
63 static const QString
s_blogFeed(QStringLiteral("http://planetkde.org"));
64 static const QString
s_profession(QStringLiteral("Developer"));
65 static const QString
s_office(QStringLiteral("Room 2443"));
66 static const QString
s_manager(QStringLiteral("Hans"));
67 static const QString
s_assistant(QStringLiteral("Hins"));
68 static const QString
s_spouse(QStringLiteral("My Darling"));
70 void ContactFieldsTest::testFieldCount()
72 QCOMPARE(ContactFields::allFields().count(), 48);
75 void ContactFieldsTest::testSetGet()
77 KContacts::Addressee contact
;
79 ContactFields::setValue(ContactFields::FormattedName
, s_formattedName
, contact
);
80 ContactFields::setValue(ContactFields::Prefix
, s_prefix
, contact
);
81 ContactFields::setValue(ContactFields::GivenName
, s_givenName
, contact
);
82 ContactFields::setValue(ContactFields::AdditionalName
, s_additionalName
, contact
);
83 ContactFields::setValue(ContactFields::FamilyName
, s_familyName
, contact
);
84 ContactFields::setValue(ContactFields::Suffix
, s_suffix
, contact
);
85 ContactFields::setValue(ContactFields::NickName
, s_nickName
, contact
);
86 ContactFields::setValue(ContactFields::Birthday
, s_birthday
, contact
);
87 ContactFields::setValue(ContactFields::Anniversary
, s_anniversary
, contact
);
88 ContactFields::setValue(ContactFields::HomeAddressStreet
, s_homeAddressStreet
, contact
);
89 ContactFields::setValue(ContactFields::HomeAddressPostOfficeBox
, s_homeAddressPostOfficeBox
, contact
);
90 ContactFields::setValue(ContactFields::HomeAddressLocality
, s_homeAddressLocality
, contact
);
91 ContactFields::setValue(ContactFields::HomeAddressRegion
, s_homeAddressRegion
, contact
);
92 ContactFields::setValue(ContactFields::HomeAddressPostalCode
, s_homeAddressPostalCode
, contact
);
93 ContactFields::setValue(ContactFields::HomeAddressCountry
, s_homeAddressCountry
, contact
);
94 ContactFields::setValue(ContactFields::HomeAddressLabel
, s_homeAddressLabel
, contact
);
95 ContactFields::setValue(ContactFields::BusinessAddressStreet
, s_businessAddressStreet
, contact
);
96 ContactFields::setValue(ContactFields::BusinessAddressPostOfficeBox
, s_businessAddressPostOfficeBox
, contact
);
97 ContactFields::setValue(ContactFields::BusinessAddressLocality
, s_businessAddressLocality
, contact
);
98 ContactFields::setValue(ContactFields::BusinessAddressRegion
, s_businessAddressRegion
, contact
);
99 ContactFields::setValue(ContactFields::BusinessAddressPostalCode
, s_businessAddressPostalCode
, contact
);
100 ContactFields::setValue(ContactFields::BusinessAddressCountry
, s_businessAddressCountry
, contact
);
101 ContactFields::setValue(ContactFields::BusinessAddressLabel
, s_businessAddressLabel
, contact
);
102 ContactFields::setValue(ContactFields::HomePhone
, s_homePhone
, contact
);
103 ContactFields::setValue(ContactFields::BusinessPhone
, s_businessPhone
, contact
);
104 ContactFields::setValue(ContactFields::MobilePhone
, s_mobilePhone
, contact
);
105 ContactFields::setValue(ContactFields::HomeFax
, s_homeFax
, contact
);
106 ContactFields::setValue(ContactFields::BusinessFax
, s_businessFax
, contact
);
107 ContactFields::setValue(ContactFields::CarPhone
, s_carPhone
, contact
);
108 ContactFields::setValue(ContactFields::Isdn
, s_isdn
, contact
);
109 ContactFields::setValue(ContactFields::Pager
, s_pager
, contact
);
110 ContactFields::setValue(ContactFields::PreferredEmail
, s_preferredEmail
, contact
);
111 ContactFields::setValue(ContactFields::Email2
, s_email2
, contact
);
112 ContactFields::setValue(ContactFields::Email3
, s_email3
, contact
);
113 ContactFields::setValue(ContactFields::Email4
, s_email4
, contact
);
114 ContactFields::setValue(ContactFields::Mailer
, s_mailer
, contact
);
115 ContactFields::setValue(ContactFields::Title
, s_title
, contact
);
116 ContactFields::setValue(ContactFields::Role
, s_role
, contact
);
117 ContactFields::setValue(ContactFields::Organization
, s_organization
, contact
);
118 ContactFields::setValue(ContactFields::Note
, s_note
, contact
);
119 ContactFields::setValue(ContactFields::Homepage
, s_homepage
, contact
);
120 ContactFields::setValue(ContactFields::BlogFeed
, s_blogFeed
, contact
);
121 ContactFields::setValue(ContactFields::Profession
, s_profession
, contact
);
122 ContactFields::setValue(ContactFields::Office
, s_office
, contact
);
123 ContactFields::setValue(ContactFields::Manager
, s_manager
, contact
);
124 ContactFields::setValue(ContactFields::Assistant
, s_assistant
, contact
);
125 ContactFields::setValue(ContactFields::Anniversary
, s_anniversary
, contact
);
126 ContactFields::setValue(ContactFields::Spouse
, s_spouse
, contact
);
128 const KContacts::Addressee contactCopy
= contact
;
130 QCOMPARE(ContactFields::value(ContactFields::FormattedName
, contactCopy
), s_formattedName
);
131 QCOMPARE(ContactFields::value(ContactFields::Prefix
, contactCopy
), s_prefix
);
132 QCOMPARE(ContactFields::value(ContactFields::GivenName
, contactCopy
), s_givenName
);
133 QCOMPARE(ContactFields::value(ContactFields::AdditionalName
, contactCopy
), s_additionalName
);
134 QCOMPARE(ContactFields::value(ContactFields::FamilyName
, contactCopy
), s_familyName
);
135 QCOMPARE(ContactFields::value(ContactFields::Suffix
, contactCopy
), s_suffix
);
136 QCOMPARE(ContactFields::value(ContactFields::NickName
, contactCopy
), s_nickName
);
137 QCOMPARE(ContactFields::value(ContactFields::Birthday
, contactCopy
), s_birthday
);
138 QCOMPARE(ContactFields::value(ContactFields::Anniversary
, contactCopy
), s_anniversary
);
139 QCOMPARE(ContactFields::value(ContactFields::HomeAddressStreet
, contactCopy
), s_homeAddressStreet
);
140 QCOMPARE(ContactFields::value(ContactFields::HomeAddressPostOfficeBox
, contactCopy
), s_homeAddressPostOfficeBox
);
141 QCOMPARE(ContactFields::value(ContactFields::HomeAddressLocality
, contactCopy
), s_homeAddressLocality
);
142 QCOMPARE(ContactFields::value(ContactFields::HomeAddressRegion
, contactCopy
), s_homeAddressRegion
);
143 QCOMPARE(ContactFields::value(ContactFields::HomeAddressPostalCode
, contactCopy
), s_homeAddressPostalCode
);
144 QCOMPARE(ContactFields::value(ContactFields::HomeAddressCountry
, contactCopy
), s_homeAddressCountry
);
145 QCOMPARE(ContactFields::value(ContactFields::HomeAddressLabel
, contactCopy
), s_homeAddressLabel
);
146 QCOMPARE(ContactFields::value(ContactFields::BusinessAddressStreet
, contactCopy
), s_businessAddressStreet
);
147 QCOMPARE(ContactFields::value(ContactFields::BusinessAddressPostOfficeBox
, contactCopy
), s_businessAddressPostOfficeBox
);
148 QCOMPARE(ContactFields::value(ContactFields::BusinessAddressLocality
, contactCopy
), s_businessAddressLocality
);
149 QCOMPARE(ContactFields::value(ContactFields::BusinessAddressRegion
, contactCopy
), s_businessAddressRegion
);
150 QCOMPARE(ContactFields::value(ContactFields::BusinessAddressPostalCode
, contactCopy
), s_businessAddressPostalCode
);
151 QCOMPARE(ContactFields::value(ContactFields::BusinessAddressCountry
, contactCopy
), s_businessAddressCountry
);
152 QCOMPARE(ContactFields::value(ContactFields::BusinessAddressLabel
, contactCopy
), s_businessAddressLabel
);
153 QCOMPARE(ContactFields::value(ContactFields::HomePhone
, contactCopy
), s_homePhone
);
154 QCOMPARE(ContactFields::value(ContactFields::BusinessPhone
, contactCopy
), s_businessPhone
);
155 QCOMPARE(ContactFields::value(ContactFields::MobilePhone
, contactCopy
), s_mobilePhone
);
156 QCOMPARE(ContactFields::value(ContactFields::HomeFax
, contactCopy
), s_homeFax
);
157 QCOMPARE(ContactFields::value(ContactFields::BusinessFax
, contactCopy
), s_businessFax
);
158 QCOMPARE(ContactFields::value(ContactFields::CarPhone
, contactCopy
), s_carPhone
);
159 QCOMPARE(ContactFields::value(ContactFields::Isdn
, contactCopy
), s_isdn
);
160 QCOMPARE(ContactFields::value(ContactFields::Pager
, contactCopy
), s_pager
);
161 QCOMPARE(ContactFields::value(ContactFields::PreferredEmail
, contactCopy
), s_preferredEmail
);
162 QCOMPARE(ContactFields::value(ContactFields::Email2
, contactCopy
), s_email2
);
163 QCOMPARE(ContactFields::value(ContactFields::Email3
, contactCopy
), s_email3
);
164 QCOMPARE(ContactFields::value(ContactFields::Email4
, contactCopy
), s_email4
);
165 QCOMPARE(ContactFields::value(ContactFields::Mailer
, contactCopy
), s_mailer
);
166 QCOMPARE(ContactFields::value(ContactFields::Title
, contactCopy
), s_title
);
167 QCOMPARE(ContactFields::value(ContactFields::Role
, contactCopy
), s_role
);
168 QCOMPARE(ContactFields::value(ContactFields::Organization
, contactCopy
), s_organization
);
169 QCOMPARE(ContactFields::value(ContactFields::Note
, contactCopy
), s_note
);
170 QCOMPARE(ContactFields::value(ContactFields::Homepage
, contactCopy
), s_homepage
);
171 QCOMPARE(ContactFields::value(ContactFields::BlogFeed
, contactCopy
), s_blogFeed
);
172 QCOMPARE(ContactFields::value(ContactFields::Profession
, contactCopy
), s_profession
);
173 QCOMPARE(ContactFields::value(ContactFields::Office
, contactCopy
), s_office
);
174 QCOMPARE(ContactFields::value(ContactFields::Manager
, contactCopy
), s_manager
);
175 QCOMPARE(ContactFields::value(ContactFields::Assistant
, contactCopy
), s_assistant
);
176 QCOMPARE(ContactFields::value(ContactFields::Anniversary
, contactCopy
), s_anniversary
);
177 QCOMPARE(ContactFields::value(ContactFields::Spouse
, contactCopy
), s_spouse
);
180 #include "contactfieldstest.moc"