diff --git a/test/Makefile b/test/Makefile index eebdd3b..7f8f4d2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -4,17 +4,20 @@ LDFLAGS=-L../ $(ENGINE_LIB) LDLIBS=-lstdc++ -lpEpEngine -lpEpAdapter CXXFLAGS+=-I../ -.PHONY=all, test_adapter, test_library +.PHONY=all, test_adapter, test_adapter_cxx, test_library -all: test_adapter test_library +all: test_adapter test_adapter_cxx test_library test_adapter: test_adapter.cc ../libpEpAdapter.a +test_adapter_cxx: test_adapter_cxx.cc ../libpEpAdapter.a + test_library: test_library.cc ../libpEpAdapter.a -clean: +clean: rm -vf test_adapter rm -rvf test_adapter.dSYM + rm -vf test_adapter_cxx + rm -rvf test_adapter_cxx.dSYM rm -vf test_library rm -rvf test_library.dSYM - diff --git a/test/test_adapter.cc b/test/test_adapter.cc index 7bd1986..75e78c0 100644 --- a/test/test_adapter.cc +++ b/test/test_adapter.cc @@ -24,6 +24,7 @@ PEP_STATUS notifyHandshake(pEp_identity *me, pEp_identity *partner, sync_handsha int main() { + // Create new identity pEpLog("updating or creating identity for me"); pEp_identity *me = new_identity("alice@peptest.ch", NULL, "23", "Who the F* is Alice"); assert(me); @@ -31,10 +32,18 @@ int main() free_identity(me); pEp::throw_status(status); - pEpLog("starting the adapter including sync"); - startup(messageToSend, notifyHandshake); - sleep(3); - shutdown(); - + // start and stop sync repeatedly + useconds_t sleepuSec = 1000 * 100; + unsigned long long int nrIters = 1000 * 1000 * 1000; + for (int i = 0; i < nrIters; i++) { + pEpLog("RUN NR: "); + pEpLog(i); + pEpLog("SYNC START"); + pEpLog("starting the adapter including sync"); + startup(messageToSend, notifyHandshake); + pEpLog("SYNC STOP"); + usleep(sleepuSec); + shutdown(); + } return 0; } diff --git a/test/test_adapter_cxx.cc b/test/test_adapter_cxx.cc new file mode 100644 index 0000000..e44a2ed --- /dev/null +++ b/test/test_adapter_cxx.cc @@ -0,0 +1,56 @@ +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + +#include "Adapter.hh" +#include +#include +#include +#include + +using namespace pEp::Adapter; + +PEP_STATUS messageToSend(struct _message *msg) { + pEpLog("called"); + return PEP_STATUS_OK; +} + +PEP_STATUS notifyHandshake(pEp_identity *me, pEp_identity *partner, sync_handshake_signal signal) { + pEpLog("called"); + return PEP_STATUS_OK; +} + +class JNISync { +public: + void onSyncStartup() { + pEpLog("called"); + } + + void onSyncShutdown() { + pEpLog("called"); + } +} o; + +int main() { + // Create new identity + pEpLog("updating or creating identity for me"); + pEp_identity *me = new_identity("alice@peptest.ch", NULL, "23", "Who the F* is Alice"); + assert(me); + PEP_STATUS status = myself(session(), me); + free_identity(me); + pEp::throw_status(status); + + // start and stop sync repeatedly + useconds_t sleepuSec = 1000 * 100; + unsigned long long int nrIters = 1000 * 1000 * 1000; + for (int i = 0; i < nrIters; i++) { + pEpLog("RUN NR: "); + pEpLog(i); + pEpLog("SYNC START"); + pEpLog("starting the adapter including sync"); + startup(messageToSend, notifyHandshake, &o, &JNISync::onSyncStartup, &JNISync::onSyncShutdown); + pEpLog("SYNC STOP"); + usleep(sleepuSec); + shutdown(); + } + return 0; +}