diff --git a/test/test_adapter.cc b/test/test_adapter.cc index dacc996..3fee1e5 100644 --- a/test/test_adapter.cc +++ b/test/test_adapter.cc @@ -9,6 +9,7 @@ #include #include #include "../src/Adapter.hh" +#include "../src/utils.hh" using namespace std; using namespace pEp; @@ -28,7 +29,9 @@ PEP_STATUS notifyHandshake(::pEp_identity *me, ::pEp_identity *partner, ::sync_h int main(int argc, char **argv) { Test::setup(argc, argv); + Adapter::pEpLog::set_enabled(true); + Adapter::session.initialize(Adapter::SyncModes::Async, false, messageToSend, notifyHandshake); // Create new identity TESTLOG("updating or creating identity for me"); ::pEp_identity *me = new_identity("alice@peptest.ch", NULL, "23", "Who the F* is Alice"); @@ -45,10 +48,10 @@ int main(int argc, char **argv) TESTLOG(i); TESTLOG("SYNC START"); TESTLOG("starting the adapter including sync"); - Adapter::startup(messageToSend, notifyHandshake); + Adapter::startup(); TESTLOG("SYNC STOP"); usleep(sleepuSec); - Adapter::shutdown(); + Adapter::stop_sync(); } return 0; } diff --git a/test/test_ensure_passphrase.cc b/test/test_ensure_passphrase.cc index f9d2fc8..06f32d4 100644 --- a/test/test_ensure_passphrase.cc +++ b/test/test_ensure_passphrase.cc @@ -16,7 +16,7 @@ using namespace std; int main(int argc, char** argv) { Test::setup(argc, argv); - + Adapter::session.initialize(); passphrase_cache.add("erwin"); passphrase_cache.add("cathy"); passphrase_cache.add("bob"); diff --git a/test/test_group.cc b/test/test_group.cc index 4277753..b7072a6 100644 --- a/test/test_group.cc +++ b/test/test_group.cc @@ -72,7 +72,6 @@ GroupQueryInterface* gq = nullptr; void test_create_alice_me() { - // Adapter::session(pEp::Adapter::release); logH2("test_create_alice_me"); alice = ::new_identity("alice@peptest.ch", NULL, "23", "Alice"); assert(alice); @@ -115,7 +114,7 @@ void test_create_carol_partner() void test_setup_and_start_sync() { logH2("test_setup_and_start_sync"); - Adapter::sync_initialize(Adapter::SyncModes::Async, &test_messageToSend, &test_notifyHandshake, false); + Adapter::start_sync(); } void test_group_create() @@ -220,7 +219,7 @@ int main(int argc, char** argv) // gu = &gdr; // gq = &gdr; - + Adapter::session.initialize(); // Setup Test Context test_create_alice_me(); @@ -250,6 +249,6 @@ int main(int argc, char** argv) test_group_dissolve(); - Adapter::shutdown(); + Adapter::stop_sync(); return 0; } diff --git a/test/test_leave_device_group.cc b/test/test_leave_device_group.cc index b5ca810..532fbcd 100644 --- a/test/test_leave_device_group.cc +++ b/test/test_leave_device_group.cc @@ -9,6 +9,7 @@ #include #include "../src/callback_dispatcher.hh" +#include "../src/Adapter.hh" #include "../src/passphrase_cache.hh" using namespace std; @@ -54,7 +55,7 @@ vector<::sync_handshake_signal> expected_notification = { SYNC_NOTIFY_IN_GROUP, int main(int argc, char** argv) { Test::setup(argc, argv); - Adapter::session(); + Adapter::session.initialize(pEp::Adapter::SyncModes::Async, false); // set up two own identites for sync @@ -95,7 +96,7 @@ int main(int argc, char** argv) // register at callback_dispatcher and start sync callback_dispatcher.add(test_messageToSend, test_notifyHandshake); - CallbackDispatcher::start_sync(); + Adapter::start_sync(); // leave device group @@ -109,14 +110,14 @@ int main(int argc, char** argv) // switch off and on again - CallbackDispatcher::start_sync(); + Adapter::start_sync(); sleep(2); assert(Adapter::is_sync_running()); - CallbackDispatcher::stop_sync(); + Adapter::stop_sync(); Test::join_sync_thread(); assert(!Adapter::is_sync_running()); - Adapter::session(Adapter::release); + Adapter::session.release(); return 0; } diff --git a/test/test_message_cache.cc b/test/test_message_cache.cc index a344f24..b236dfe 100644 --- a/test/test_message_cache.cc +++ b/test/test_message_cache.cc @@ -17,6 +17,7 @@ using namespace pEp; int main(int argc, char **argv) { Test::setup(argc, argv); + Adapter::session.initialize(); ::pEp_identity *alice = ::new_identity("alice@mail.com", nullptr, PEP_OWN_USERID, "Alice"); ::myself(Adapter::session(), alice); @@ -118,6 +119,6 @@ int main(int argc, char **argv) ::free_identity(bob); ::free_identity(alice); - Adapter::session(Adapter::release); + Adapter::session.release(); return 0; } diff --git a/test/test_passphrase_cache.cc b/test/test_passphrase_cache.cc index 305df36..ace0fed 100644 --- a/test/test_passphrase_cache.cc +++ b/test/test_passphrase_cache.cc @@ -30,7 +30,7 @@ extern "C" { int main(int argc, char **argv) { Test::setup(argc, argv); - + Adapter::session.initialize(); const char *str = "23"; char *bytes = NULL; int n = 42; @@ -96,6 +96,6 @@ int main(int argc, char **argv) status = cache.api(api_test2, Adapter::session(), 23, str, bytes, sl); assert(status == PEP_STATUS_OK); - Adapter::session(Adapter::release); + Adapter::session.release(); return 0; } diff --git a/test/test_group_swarm.cc b/test/test_swarm_group.cc similarity index 94% rename from test/test_group_swarm.cc rename to test/test_swarm_group.cc index 8e7629e..6c231d1 100644 --- a/test/test_group_swarm.cc +++ b/test/test_swarm_group.cc @@ -158,6 +158,11 @@ int test_pEp_init(TestUnitSwarm &pity, TextContext *ctx) pity.log("HOME : " + std::string(getenv("HOME"))); pity.log("PUD : " + std::string(::per_user_directory())); pity.log("PMD : " + std::string(::per_machine_directory())); + pEp::Adapter::session.initialize( + pEp::Adapter::SyncModes::Async, + false, + test_messageToSend, + test_notifyHandshake); return 0; } @@ -167,19 +172,15 @@ int test_create_myself(TestUnitSwarm &pity, TextContext *ctx) pity.log("updating or creating identity for me"); ctx->own_ident = createOwnIdent(ctx->own_name); ::PEP_STATUS status = ::myself(Adapter::session(), ctx->own_ident.get()); - // Create cpt - // PITYASSERT(ctx->cpt != nullptr, ""); - // ctx->cpt->ident = createCptIdent(ctx->getCpt().addr); pEp::throw_status(status); return 0; } int test_start_sync(TestUnitSwarm &pity, TextContext *ctx) { - Adapter::sync_initialize(SyncModes::Off, test_messageToSend, test_notifyHandshake, false); + Adapter::session + .initialize(Adapter::SyncModes::Async, false, test_messageToSend, test_notifyHandshake); processsAllMessages(); - - ::adapter_group_init(); return 0; } @@ -487,14 +488,5 @@ int main(int argc, char *argv[]) swarm.addTestUnit(i, TestUnitSwarm("test_receive_all", test_receive_all)); } - // ------------------------------------------------------------------------------------ - // swarm.addTestUnit(2, TestUnitSwarm("test_pEp_init", test_pEp_init)); - // swarm.addTestUnit(2, TestUnitSwarm("test_create_myself", test_create_myself)); - // swarm.addTestUnit(2, TestUnitSwarm("test_tofu_react", test_tofu_react)); - // swarm.addTestUnit(2, TestUnitSwarm("test_start_sync", test_start_sync)); - // swarm.addTestUnit(2, TestUnitSwarm("test_group_join", test_group_join)); - // swarm.addTestUnit(2, TestUnitSwarm("test_receive_groupmessage", test_receive_groupmessage)); - // ------------------------------------------------------------------------------------ - suite.run(); } diff --git a/test/test_tofu_one2many.cc b/test/test_swarm_tofu.cc similarity index 97% rename from test/test_tofu_one2many.cc rename to test/test_swarm_tofu.cc index 9168ddb..cad3a19 100644 --- a/test/test_tofu_one2many.cc +++ b/test/test_swarm_tofu.cc @@ -82,13 +82,11 @@ void tofu_receiveAndReply(TestUnitSwarm &pity, TextContext *ctx) int test_create_myself(TestUnitSwarm &pity, TextContext *ctx) { + Adapter::session.initialize(); // Create new identity pity.log("updating or creating identity for me"); ctx->own_ident = createOwnIdent(ctx->own_name); ::PEP_STATUS status = ::myself(Adapter::session(), ctx->own_ident.get()); - // Create cpt - // PITYASSERT(ctx->cpt != nullptr, ""); - // ctx->cpt->ident = createCptIdent(ctx->getCpt().addr); pEp::throw_status(status); return 0; } diff --git a/test/test_sync_init.cc b/test/test_sync_init.cc index 9d91374..acbc50b 100644 --- a/test/test_sync_init.cc +++ b/test/test_sync_init.cc @@ -28,7 +28,7 @@ PEP_STATUS notifyHandshake(pEp_identity *me, pEp_identity *partner, ::sync_hands int main(int argc, char **argv) { pEp::Test::setup(argc, argv); - + Adapter::session.initialize(Adapter::SyncModes::Async, false); // Create new identity TESTLOG("updating or creating identity for me"); ::pEp_identity *me = ::new_identity("alice@peptest.ch", NULL, "23", "Who the F* is Alice"); @@ -44,11 +44,10 @@ int main(int argc, char **argv) TESTLOG(i); TESTLOG("SYNC START"); TESTLOG("starting the adapter including sync"); - - Adapter::sync_initialize(Adapter::SyncModes::Off, messageToSend, notifyHandshake, false); + Adapter::start_sync(); TESTLOG("SYNC STOP"); Utils::sleep_millis(500); - Adapter::shutdown(); + Adapter::stop_sync(); } return 0; } diff --git a/test/test_tofu.cc b/test/test_tofu.cc index f2462cd..e67daff 100644 --- a/test/test_tofu.cc +++ b/test/test_tofu.cc @@ -101,7 +101,7 @@ int tofu(PityUnit &pity, PityPerspective *ctx, bool init) pity.log("partner: " + ctx->getCpt().addr); pity.log("HOME : " + std::string(getenv("HOME"))); pity.log("PUD : " + std::string(::per_user_directory())); - + Adapter::session.initialize(); // Create new identity pity.log("updating or creating identity for me");