classclienttest.tex

来自「This SDK allows to integrate a syncml st」· TEX 代码 · 共 137 行

TEX
137
字号
\section{ClientTest Class Reference}\label{classClientTest}\index{ClientTest@{ClientTest}}This is the interface expected by the testing framework for sync clients.  {\tt \#include $<$ClientTest.h$>$}Inheritance diagram for ClientTest:\nopagebreak\begin{figure}[H]\begin{center}\leavevmode\includegraphics[width=64pt]{classClientTest__inherit__graph}\end{center}\end{figure}\subsection*{Public Member Functions}\begin{CompactItemize}\item \textbf{ClientTest} (int serverSleepSec=0, const std::string \&serverLog=\char`\"{}\char`\"{})\label{group__ClientTest_gf569060e4a730e4f48c44076a32a496a}\item virtual void {\bf registerTests} ()\begin{CompactList}\small\item\em This is the only function provided by \doxyref{ClientTest}{p.}{classClientTest} itself: it registers tests using this instance of \doxyref{ClientTest}{p.}{classClientTest} for later use during a test run. \item\end{CompactList}\item virtual int {\bf getNumSources} ()=0\begin{CompactList}\small\item\em Data sources are enumbered from 0 to n-1 for the purpose of testing. \item\end{CompactList}\item virtual void {\bf getSourceConfig} (int source, {\bf Config} \&config)=0\begin{CompactList}\small\item\em Called to fill the given test source config with information about a sync source identified by its index. \item\end{CompactList}\item virtual {\bf ClientTest} $\ast$ {\bf getClientB} ()=0\begin{CompactList}\small\item\em The instance to use as second client. \item\end{CompactList}\item virtual bool {\bf isB64Enabled} ()=0\label{classClientTest_4b04191d3b5eb3e6967479096a4d83f2}\begin{CompactList}\small\item\em Returning true enables tests which only work if the server is a Funambol server which supports the \char`\"{}b64\char`\"{} encoding of items on the transport level. \item\end{CompactList}\item virtual int {\bf sync} (const int $\ast$activeSources, SyncMode syncMode, const {\bf CheckSyncReport} \&checkReport, long maxMsgSize=0, long maxObjSize=0, bool loSupport=false, const char $\ast$encoding=\char`\"{}\char`\"{})=0\begin{CompactList}\small\item\em Execute a synchronization with the selected sync sources and the selected synchronization options. \item\end{CompactList}\item virtual void {\bf postSync} (int res, const std::string \&logname)\begin{CompactList}\small\item\em This is called after successful \doxyref{sync()}{p.}{classClientTest_5e5a95277a8c953307c6c4c9415fe627} calls (res == 0) as well as after unsuccessful ones (res != 1). \item\end{CompactList}\end{CompactItemize}\subsection*{Static Public Member Functions}\begin{CompactItemize}\item static int {\bf dump} ({\bf ClientTest} \&client, {\bf SyncSource} \&source, const char $\ast$file)\label{group__ClientTest_g21f82c79cc49a242a9ddb28ccc4ae4cf}\begin{CompactList}\small\item\em utility function for dumping items which are C strings with blank lines as separator \item\end{CompactList}\item static int {\bf import} ({\bf ClientTest} \&client, {\bf SyncSource} \&source, const char $\ast$file)\label{group__ClientTest_g6f8c5e62da7b5da62d4bf5e5f9f8938e}\begin{CompactList}\small\item\em utility function for importing items with blank lines as separator \item\end{CompactList}\item static bool {\bf compare} ({\bf ClientTest} \&client, const char $\ast$fileA, const char $\ast$fileB)\label{group__ClientTest_g489f26d3ca7ec7dec96b14bc81b89dc0}\begin{CompactList}\small\item\em utility function for comparing vCard and iCal files with the external synccompare.pl Perl script \item\end{CompactList}\item static void {\bf getTestData} (const char $\ast$type, {\bf Config} \&config)\begin{CompactList}\small\item\em A derived class can use this call to get default test cases, but still has to add callbacks which create sources and execute a sync session. \item\end{CompactList}\end{CompactItemize}\subsection*{Protected Attributes}\begin{CompactItemize}\item int {\bf serverSleepSeconds}\label{classClientTest_1a7a18a21c887f14a874a9595bbaf916}\begin{CompactList}\small\item\em time to sleep in \doxyref{postSync()}{p.}{group__ClientTest_g6793f73554f9f225ddc059d1aa95c09b} \item\end{CompactList}\item std::string {\bf serverLogFileName}\label{classClientTest_742fde2670c30a58ba0cc4b4f2a43e5b}\begin{CompactList}\small\item\em server log file which is copied by \doxyref{postSync()}{p.}{group__ClientTest_g6793f73554f9f225ddc059d1aa95c09b} and then truncated (Unix only, Windows does not allow such access to an open file) \item\end{CompactList}\end{CompactItemize}\subsection*{Classes}\begin{CompactItemize}\item struct {\bf Config}\begin{CompactList}\small\item\em Information about a data source. \item\end{CompactList}\end{CompactItemize}\subsection{Detailed Description}This is the interface expected by the testing framework for sync clients. It defines several methods that a derived class must implement if it wants to use that framework. Note that this class itself is not derived from \doxyref{SyncClient}{p.}{classSyncClient}. This gives a user of this framework the freedom to implement it in two different ways:\begin{itemize}\item implement a class derived from both \doxyref{SyncClient}{p.}{classSyncClient} and \doxyref{ClientTest}{p.}{classClientTest}\item add testing of an existing subclass of \doxyref{SyncClient}{p.}{classSyncClient} by implementing a \doxyref{ClientTest}{p.}{classClientTest} which uses that subclass\end{itemize}The client is expected to support change tracking for multiple servers. Although the framework always always tests against the same server, for most tests it is necessary to access the database without affecting the next synchronization with the server. This is done by asking the client for two different sync sources via \doxyref{Config::createSourceA}{p.}{structClientTest_1_1Config_4b88084e4d9abe94aa4e5ab37c4d0b13} and \doxyref{Config::createSourceB}{p.}{structClientTest_1_1Config_9d8b5a3de6b9ddd500e44aaff9d59b7e} which have to create them in a suitable way - pretty much as if the client was synchronized against different server. A third, different change tracking is needed for real synchronizations of the data.Furthermore the client is expected to support multiple data sources of the same kind, f.i. two different address books. This is used to test full client A $<$-$>$ server $<$-$>$ client B synchronizations in some tests or to check server modifications done by client A with a synchronization against client B. In those tests client A is mapped to the first data source and client B to the second one.Finally the \doxyref{SyncSource}{p.}{classSyncSource} API is used in slightly different ways which go beyond what is normally expected from a \doxyref{SyncSource}{p.}{classSyncSource} implementation:\begin{itemize}\item beginSync() may be called without setting a sync mode: when \doxyref{SyncSource::getSyncMode()}{p.}{classSyncSource_ce8ef908b97565021a4038595051b672} returns SYNC\_\-NONE the source is expected to make itself ready to iterate over all, new, updated and deleted items\item items may be added via \doxyref{SyncSource::addItem()}{p.}{classSyncSource_a840375b776d5f73c4e0f2b64c875844} with a type of \char`\"{}raw\char`\"{}: this implies that the type is the one used for items in the \doxyref{ClientTest::Config}{p.}{structClientTest_1_1Config} below\end{itemize}Handling configuration and creating classes is entirely done by the subclass of \doxyref{ClientTest}{p.}{classClientTest}, the frameworks makes no assumptions about how this is done. Instead it queries the \doxyref{ClientTest}{p.}{classClientTest} for properties (like available sync sources) and then creates several tests. \subsection{Member Function Documentation}\index{ClientTest@{ClientTest}!getNumSources@{getNumSources}}\index{getNumSources@{getNumSources}!ClientTest@{ClientTest}}\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual int ClientTest::getNumSources ()\hspace{0.3cm}{\tt  [pure virtual]}}\label{classClientTest_d7b3592d2623c8076ffc43c4600a2f16}Data sources are enumbered from 0 to n-1 for the purpose of testing. This call returns n. Implemented in {\bf TestFileSource} \doxyref{}{p.}{classTestFileSource_902fb0eb77c02d4a55f46d36f611bafa}.\index{ClientTest@{ClientTest}!getSourceConfig@{getSourceConfig}}\index{getSourceConfig@{getSourceConfig}!ClientTest@{ClientTest}}\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual void ClientTest::getSourceConfig (int {\em source}, {\bf Config} \& {\em config})\hspace{0.3cm}{\tt  [pure virtual]}}\label{classClientTest_c2dde793eb4770cba8486c0b3e7849fb}Called to fill the given test source config with information about a sync source identified by its index. It's okay to only fill in the available pieces of information and set everything else to zero. \index{ClientTest@{ClientTest}!getClientB@{getClientB}}\index{getClientB@{getClientB}!ClientTest@{ClientTest}}\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual {\bf ClientTest}$\ast$ ClientTest::getClientB ()\hspace{0.3cm}{\tt  [pure virtual]}}\label{classClientTest_44aff5e4f5e3a92cd4bacadca6f52716}The instance to use as second client. Returning NULL disables all checks which require a second client. The returned pointer must remain valid throughout the life time of the tests.The second client must be configured to access the same server and have data sources which match the ones from the primary client. Implemented in {\bf TestFileSource} \doxyref{}{p.}{classTestFileSource_9330cd09cfbe9b0d81e50bdc71432a03}.\index{ClientTest@{ClientTest}!sync@{sync}}\index{sync@{sync}!ClientTest@{ClientTest}}\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual int ClientTest::sync (const int $\ast$ {\em activeSources}, SyncMode {\em syncMode}, const {\bf CheckSyncReport} \& {\em checkReport}, long {\em maxMsgSize} = {\tt 0}, long {\em maxObjSize} = {\tt 0}, bool {\em loSupport} = {\tt false}, const char $\ast$ {\em encoding} = {\tt \char`\"{}\char`\"{}})\hspace{0.3cm}{\tt  [pure virtual]}}\label{classClientTest_5e5a95277a8c953307c6c4c9415fe627}Execute a synchronization with the selected sync sources and the selected synchronization options. The log file in LOG has been set up already for the synchronization run and should not be changed by the client.\begin{Desc}\item[Parameters:]\begin{description}\item[{\em activeSources}]a -1 terminated array of sync source indices \item[{\em syncMode}]the synchronization mode to be used \item[{\em checkReport}]has to be called after a successful or unsuccessful sync, will dump the report and (optionally) check the result; beware, the later may throw exceptions inside CPPUNIT macros \item[{\em maxMsgSize}]$>$0: enable the maximum message size, else disable it \item[{\em maxObjSize}]same as maxMsgSize for maximum object size \item[{\em loSupport}]if TRUE, then the sync is expected to enable Large Object support \item[{\em encoding}]if non-empty, then let client library transform all items into this format (guaranteed to be not NULL)\end{description}\end{Desc}\begin{Desc}\item[Returns:]return code of SyncClient::sync() \end{Desc}Implemented in {\bf TestFileSource} \doxyref{}{p.}{classTestFileSource_755fa61dbfe32288a7c68e37e21e21ea}.The documentation for this class was generated from the following files:\begin{CompactItemize}\item test/ClientTest.h\item test/ClientTest.cpp\end{CompactItemize}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?