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 test suite 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
****************************************************************************/
42
// This module implements no userdata storage location related test data for
43
// a set of tests shared with other similar modules for cases of no system
44
// storage and no storages at all.
46
#include "tst_missingstorage.h"
48
Q_DECLARE_METATYPE(QContactAbstractRequest::StorageLocations)
49
Q_DECLARE_METATYPE(QContactManager::Error)
51
tst_StoragesLocationsMissing::tst_StoragesLocationsMissing()
53
QString partitions_json = QFINDTESTDATA("partitions.json");
54
QVERIFY2(!partitions_json.isEmpty(), "partitions.json file is missing");
55
QVERIFY2(m_jsondbProcess.start(partitions_json), "Failed to start JsonDb process");
58
tst_StoragesLocationsMissing::~tst_StoragesLocationsMissing()
60
m_jsondbProcess.terminate();
63
void tst_StoragesLocationsMissing::init()
65
// Make sure all tests in this test case start with an empty system storage.
66
QContactIdFetchRequest idFetchRequest;
67
idFetchRequest.setManager(m_contactManager);
68
idFetchRequest.setStorageLocations(QContactAbstractRequest::SystemStorage);
69
idFetchRequest.start();
70
idFetchRequest.waitForFinished();
71
if (!idFetchRequest.ids().isEmpty()) {
72
QContactRemoveRequest removeRequest;
73
removeRequest.setManager(m_contactManager);
74
removeRequest.setContactIds(idFetchRequest.ids());
75
removeRequest.start();
76
removeRequest.waitForFinished();
80
void tst_StoragesLocationsMissing::fetchData()
82
QTest::addColumn<int>("storageLocations");
83
QTest::addColumn<QContactManager::Error>("expectedError");
85
QTest::newRow("from user") << int(QContactAbstractRequest::UserDataStorage)
86
<< QContactManager::InvalidStorageLocationError;
88
QTest::newRow("from system") << int(QContactAbstractRequest::SystemStorage)
89
<< QContactManager::DoesNotExistError;
91
QTest::newRow("from both") << int(QContactAbstractRequest::SystemStorage | QContactAbstractRequest::UserDataStorage)
92
<< QContactManager::InvalidStorageLocationError;
94
QTest::newRow("from invalid") << (0x8)
95
<< QContactManager::InvalidStorageLocationError;
97
QTest::newRow("from invalid with user") << int(0x8 | QContactAbstractRequest::UserDataStorage)
98
<< QContactManager::InvalidStorageLocationError;
100
QTest::newRow("from invalid with system") << int(0x8 | QContactAbstractRequest::SystemStorage)
101
<< QContactManager::InvalidStorageLocationError;
104
void tst_StoragesLocationsMissing::idData()
106
QTest::addColumn<QString>("jsonId");
107
QTest::addColumn<int>("storageLocation");
108
QTest::addColumn<QContactManager::Error>("expectedError");
110
QTest::newRow("from user") << QString("a096c227-fc6f-46ad-89b8-1883fb490a38")
111
<< int(QContactAbstractRequest::UserDataStorage)
112
<< QContactManager::InvalidStorageLocationError;
114
QTest::newRow("from system") << QString("a096c227-fc6f-46ad-89b8-1883fb490a38")
115
<< int(QContactAbstractRequest::SystemStorage)
116
<< QContactManager::DoesNotExistError;
118
QTest::newRow("from invalid") << QString("a096c227-fc6f-46ad-89b8-1883fb490a38")
120
<< QContactManager::InvalidStorageLocationError;
122
QTest::newRow("with empty id") << QString()
124
<< QContactManager::InvalidStorageLocationError;
127
void tst_StoragesLocationsMissing::idsData()
129
QTest::addColumn<QString>("jsonId");
130
QTest::addColumn<int>("firstStorageLocation");
131
QTest::addColumn<int>("secondStorageLocation");
132
QTest::addColumn<QContactManager::Error>("expectedError");
134
QTest::newRow("from user") << QString("a096c227-fc6f-46ad-89b8-1883fb490a38")
135
<< int(QContactAbstractRequest::UserDataStorage)
136
<< int(QContactAbstractRequest::UserDataStorage)
137
<< QContactManager::InvalidStorageLocationError;
140
QTest::newRow("from system") << QString("a096c227-fc6f-46ad-89b8-1883fb490a38")
141
<< int(QContactAbstractRequest::SystemStorage)
142
<< int(QContactAbstractRequest::SystemStorage)
143
<< QContactManager::DoesNotExistError;
145
QTest::newRow("from user and system") << QString("a096c227-fc6f-46ad-89b8-1883fb490a38")
146
<< int(QContactAbstractRequest::UserDataStorage)
147
<< int(QContactAbstractRequest::SystemStorage)
148
<< QContactManager::InvalidStorageLocationError;
150
QTest::newRow("from invalid with user") << QString("a096c227-fc6f-46ad-89b8-1883fb490a38")
152
<< int(QContactAbstractRequest::UserDataStorage)
153
<< QContactManager::InvalidStorageLocationError;
155
QTest::newRow("from invalid with system") << QString("a096c227-fc6f-46ad-89b8-1883fb490a38")
157
<< int(QContactAbstractRequest::SystemStorage)
158
<< QContactManager::InvalidStorageLocationError;
160
QTest::newRow("from user and system with an empty id") << QString()
161
<< int(QContactAbstractRequest::UserDataStorage)
162
<< int(QContactAbstractRequest::SystemStorage)
163
<< QContactManager::InvalidStorageLocationError;
166
void tst_StoragesLocationsMissing::saveData()
168
QTest::addColumn<int>("storageLocation");
169
QTest::addColumn<QContactManager::Error>("expectedError");
171
QTest::newRow("to user") << int(QContactAbstractRequest::UserDataStorage)
172
<< QContactManager::InvalidStorageLocationError;
174
QTest::newRow("to system") << int(QContactAbstractRequest::SystemStorage)
175
<< QContactManager::NoError;
177
QTest::newRow("to invalid") << (0x8)
178
<< QContactManager::InvalidStorageLocationError;