2
* Copyright (C) 2010 Intel Corporation
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) version 3.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
#ifndef INCL_SYNC_BUTEOTEST
20
#define INCL_SYNC_BUTEOTEST
22
#include <syncevo/util.h>
23
#include <syncevo/declarations.h>
27
#include <QDomDocument>
28
#include "ClientTest.h"
30
using namespace SyncEvo;
33
* ButeoTest is used to invoke buteo to do client test with the help
34
* of client test framework. The basic idea is to implement doSync and
35
* replace with invocation of buteo's dbus server - 'msyncd'.
37
* 1) pre-run: This may include set up sync options for local client
38
* and target server, prepare local databases
39
* 2) run: run sync by sending dbus calls to 'msyncd' and wait until
41
* 3) post-run: collect sync result and statistics
43
class ButeoTest : public QObject {
46
ButeoTest(ClientTest &client,
48
const string &logbase,
49
const SyncEvo::SyncOptions &options);
51
// prepare sync sources
52
void prepareSources(const int *sources, const vector<string> &source2Config);
55
SyncEvo::SyncMLStatus doSync(SyncEvo::SyncReport *report);
58
void syncStatus(QString, int, QString, int);
59
void resultsAvailable(QString, QString);
60
void serviceUnregistered(QString);
69
* 1. set deviceid, max-message-size options to /etc/sync/meego-sync-conf.xml
70
* 2. set wbxml option, sync mode, enabled selected sources and disable other sources
80
// do actually running
83
// get sync results from buteo and set them to sync report
84
void genSyncResults(const QString &text, SyncEvo::SyncReport *report);
86
// whether configured sources include contacts
89
// truncate file and write content to file
90
static void writeToFile(const QString &filePath, const QString &content );
92
//replace the element value with a new value
93
static void replaceElement(QString &xml, const QString &elem, const QString &value);
95
// build a dom tree from file
96
static void buildDomFromFile(QDomDocument &doc, const QString &filePath);
101
SyncEvo::SyncOptions m_options;
102
std::set<string> m_configedSources;
103
QString m_syncResults;
106
static QString m_deviceIds[2];
107
//mappings for syncevolution source and buteo storage
108
static map<string, string> m_source2storage;
109
//flag for initialization
110
static bool m_inited;
115
* Qtcontacts use tracker to store data. However, it can't specify
116
* the place where to store them. Since we have to separate client A
117
* and B's data, restore and backup their databases
119
class QtContactsSwitcher {
121
/** do preparation */
122
static void prepare(ClientTest &client);
124
static string getId(ClientTest &client);
128
* 1. terminate tracker
129
* 2. copy tracker databases from backup to its default place
133
static void restoreStorage(ClientTest &client);
137
* 1. terminate tracker
138
* 2. copy tracker databases from default place to backup
141
static void backupStorage(ClientTest &client);
143
static void setDatabases(const string databases[]);
145
// get the file path of databases
146
static std::string getDatabasePath(int index = 0);
148
//terminate tracker daemons
149
static void terminate();
151
//start tracker daemons
154
//copy databases between default place and backup place
155
static void copyDatabases(ClientTest &client, bool fromDefault = true);
157
//databases used by tracker
158
static std::string m_databases[5];
159
static std::string m_dirs[2];