ActiveSync: fixed testImport test

The testImport test must write all existing items into a file for
comparison. Normally this is done with the backup backend operation,
which does not exist with the ActiveSync backend.

This commit adds a version specifically for that backend. DumpItems()
assumes that item meta data was updated correctly and then reads their
data via ActiveSync[Calendar]Source::readItem() = eas_sync_handler_fetch_item().

Note that this is unnecessarily complex for ActiveSyncCalendarSource:
it reads single VEVENTs, parsed by ActiveSyncCalendarSource, instead
of writing the VCALENDAR produced by activesyncd directly as for ActiveSyncSource.
Will be fixed in the next commit.

activesyncd commit ID:
c788aa464dd866fcb5eaac27533bd53ff1aa5c84
This commit is contained in:
Patrick Ohly 2011-07-28 16:26:40 +02:00
parent 8e36af6a9b
commit ee0d351843
2 changed files with 31 additions and 1 deletions

View File

@ -146,7 +146,6 @@ class ActiveSyncSource :
/** sync config used by this instance, never NULL */
SyncConfig &getSyncConfig() { return *m_context; }
protected:
/* partial implementation of SyncSource */
virtual void enableServerMode();
virtual bool serverModeEnabled() const;

View File

@ -30,6 +30,8 @@
# include <cppunit/extensions/HelperMacros.h>
#endif
#include <fstream>
#include <syncevo/declarations.h>
SE_BEGIN_CXX
@ -130,6 +132,31 @@ namespace {
}
#endif
/**
* Takes all existing items in the source and writes them into the file,
* separated by a blank line. beginSync() with the previous sync key was
* already called.
*
* Used for testing and thus should better not rely on cached information,
* but ActiveSync doesn't offer an independent "list and/or retrieve all items"
* operation. Using the cached information implies that we won't find bugs in
* the handling of that information.
*/
static int DumpItems(ClientTest &client, TestingSyncSource &source, const char *file)
{
ActiveSyncSource &eassource = static_cast<ActiveSyncSource &>(source);
ofstream out(file);
BOOST_FOREACH (const std::string &easid, eassource.getAllItems()) {
std::string item;
eassource.readItem(easid, item);
out << item << '\n';
if (!boost::ends_with(item, "\n")) {
out << '\n';
}
}
return 0;
}
static TestingSyncSource *createEASSource(const ClientTestConfig::createsource_t &create,
ClientTest &client, int source, bool isSourceA)
{
@ -179,6 +206,7 @@ public:
config.createSourceB = boost::bind(createEASSource, config.createSourceB,
_1, _2, _3);
config.dump = DumpItems;
}
} ActiveSyncContactTest;
@ -195,6 +223,7 @@ public:
_1, _2, _3);
config.createSourceB = boost::bind(createEASSource, config.createSourceB,
_1, _2, _3);
config.dump = DumpItems;
}
} ActiveSyncEventTest;
@ -211,6 +240,7 @@ public:
_1, _2, _3);
config.createSourceB = boost::bind(createEASSource, config.createSourceB,
_1, _2, _3);
config.dump = DumpItems;
}
} ActiveSyncTodoTest;
@ -227,6 +257,7 @@ public:
_1, _2, _3);
config.createSourceB = boost::bind(createEASSource, config.createSourceB,
_1, _2, _3);
config.dump = DumpItems;
}
} ActiveSyncMemoTest;