1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the QtPim module of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
46
ContactsSavingTestCase {
48
name: "ContactsExportImportE2ETests"
52
manager: getManagerUnderTest()
64
contexts: ContactDetail.ContextOther
69
// Base for vcard file names.
70
property string vcardFileNameBase: 'tst_contacts_export_import_e2e_'
72
function test_contactExportImportWithTinyContactExportSignaling() {
74
var signalSpy = initTestForTargetListeningToSignal(model, "exportCompleted");
76
// Save and fetch test contact.
77
model.saveContact(testContact);
78
waitForContactsChanged();
80
// Export contacts to vcard file.
81
var vcardFilePath = Qt.resolvedUrl(vcardFileNameBase + "1.vcard");
82
model.exportContacts(vcardFilePath, ["Sync"]);
83
waitForTargetSignal(signalSpy);
85
// Empty all contacts and import just created vcard file.
87
listenToContactsChanged();
88
model.importContacts(vcardFilePath, ["Sync"]);
89
waitForContactsChanged();
90
compare (model.error, "NoError", "importError");
92
// Check that imported contact has correct data.
93
compare (model.contacts.length, 1, "import count");
94
var importedContact = model.contacts[0];
95
compare(importedContact.name.firstName,"First", "imported contact first name");
96
compare(importedContact.name.lastName,"Last", "imported contact last name");
99
function test_exportListOfDeclarativeContacts() {
100
var signalSpy = initTestForTargetListeningToSignal(model, "exportCompleted");
102
// Export contacts to vcard file.
103
var vcardFilePath = Qt.resolvedUrl(vcardFileNameBase + "contactsList.vcard");
104
var temp = new Array(1);
105
temp[0] = testContact;
106
model.exportContacts(vcardFilePath, ["Sync"], temp);
107
waitForTargetSignal(signalSpy);
109
// Empty all contacts and import just created vcard file.
110
emptyContacts(model);
111
listenToContactsChanged();
112
model.importContacts(vcardFilePath, ["Sync"]);
113
waitForContactsChanged();
114
compare (model.error, "NoError", "importError");
116
// Check that imported contact has correct data.
117
compare (model.contacts.length, 1, "import count");
118
var importedContact = model.contacts[0];
119
compare(importedContact.name.firstName,"First", "imported contact first name");
120
compare(importedContact.name.lastName,"Last", "imported contact last name");
125
function initTestCase() {
126
initTestForModel(model);
127
waitForContactsChanged();
129
// The wait is needed so the model is populated
130
// (e.g. with garbage left from previous test runs)
131
// before cleanup() is called.
132
emptyContacts(model);
136
initTestForModel(model);
140
emptyContacts(model);
143
function cleanupTestCase() {
144
emptyContacts(model);
145
finishTestForModel(model);