summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2010-03-18 18:32:49 +0100
committerPatrick Ohly <patrick.ohly@intel.com>2010-03-18 18:37:39 +0100
commitea43ed062509b1f99395886669d575ec32e30e15 (patch)
treeb81dcd29ca68bd72912a4e4350e66897ad0d6238
parentcc5cffd9bbbf11e6de644138adf5c416977b0732 (diff)
client-test: check that suspend tests really suspendserver
The suspend tests would have passed even if the client never really executed the suspend request. Now the tests verify whether the next session really resumes. It does that except for some corner cases (first message, last message), which is acceptable. When multiple sources are involved, first and last message of each source cannot be identified reliably, so in that case suspend is not checked. The SyncReport must be available for this checking. The check() method was made virtual to implement such checks in a derived class, but that is neither convenient nor does it currently work because SyncOptions copies the CheckSyncReport instance.
-rw-r--r--test/ClientTest.cpp21
-rw-r--r--test/ClientTest.h10
2 files changed, 29 insertions, 2 deletions
diff --git a/test/ClientTest.cpp b/test/ClientTest.cpp
index 6f39268d..4553f575 100644
--- a/test/ClientTest.cpp
+++ b/test/ClientTest.cpp
@@ -2971,7 +2971,22 @@ void SyncTests::doInterruptResume(int changes,
// no need for resend tests, unless they were interrupted at the first message
if (!resend || interruptAtMessage == 0) {
- accessClientB->doSync("retryB", SyncOptions(SYNC_TWO_WAY));
+ SyncReport report;
+ accessClientB->doSync("retryB",
+ SyncOptions(SYNC_TWO_WAY,
+ CheckSyncReport().setMode(SYNC_TWO_WAY).setReport(&report)));
+ // Suspending at first and last message doesn't need a
+ // resume, everything else does. When multiple sources
+ // are involved, some may suspend, some may not, so we
+ // cannot check.
+ if (suspend &&
+ interruptAtMessage != 0 &&
+ interruptAtMessage + 1 != maxMsgNum &&
+ report.size() == 1) {
+ BOOST_FOREACH(const SyncReport::SourceReport_t &sourceReport, report) {
+ CPPUNIT_ASSERT(sourceReport.second.isResumeSync());
+ }
+ }
}
}
@@ -4052,6 +4067,10 @@ void ClientTest::getTestData(const char *type, Config &config)
void CheckSyncReport::check(SyncMLStatus status, SyncReport &report) const
{
+ if (m_report) {
+ *m_report = report;
+ }
+
stringstream str;
str << report;
diff --git a/test/ClientTest.h b/test/ClientTest.h
index d4ee4a64..0329c924 100644
--- a/test/ClientTest.h
+++ b/test/ClientTest.h
@@ -70,7 +70,8 @@ class CheckSyncReport {
serverUpdated(srUpdated),
serverDeleted(srDeleted),
mustSucceed(mstSucceed),
- syncMode(mode)
+ syncMode(mode),
+ m_report(NULL)
{}
virtual ~CheckSyncReport() {}
@@ -80,6 +81,13 @@ class CheckSyncReport {
bool mustSucceed;
SyncMode syncMode;
+ // if set, then the report is copied here
+ SyncReport *m_report;
+
+ CheckSyncReport &setMode(SyncMode mode) { syncMode = mode; return *this; }
+ CheckSyncReport &setReport(SyncReport *report) { m_report = report; return *this; }
+
+
/**
* checks that the sync completed as expected and throws
* CPPUnit exceptions if something is wrong