Browse Source

Test: API changes update all tests

* call session.initialize() before using a session
* use session.release() instead of session.(release)
* Adapter::startup() arguments moved to session.initialize()
* Adapter::shutdown() renamed to stop_sync()
LIB-11
heck 4 months ago
parent
commit
64c652652c
10 changed files with 31 additions and 38 deletions
  1. +5
    -2
      test/test_adapter.cc
  2. +1
    -1
      test/test_ensure_passphrase.cc
  3. +3
    -4
      test/test_group.cc
  4. +6
    -5
      test/test_leave_device_group.cc
  5. +2
    -1
      test/test_message_cache.cc
  6. +2
    -2
      test/test_passphrase_cache.cc
  7. +7
    -15
      test/test_swarm_group.cc
  8. +1
    -3
      test/test_swarm_tofu.cc
  9. +3
    -4
      test/test_sync_init.cc
  10. +1
    -1
      test/test_tofu.cc

+ 5
- 2
test/test_adapter.cc View File

@ -9,6 +9,7 @@
#include <pEp/sync_api.h>
#include <pEp/keymanagement.h>
#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;
}

+ 1
- 1
test/test_ensure_passphrase.cc View File

@ -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");


+ 3
- 4
test/test_group.cc View File

@ -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;
}

+ 6
- 5
test/test_leave_device_group.cc View File

@ -9,6 +9,7 @@
#include <pEp/sync_api.h>
#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;
}

+ 2
- 1
test/test_message_cache.cc View File

@ -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;
}

+ 2
- 2
test/test_passphrase_cache.cc View File

@ -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;
}

test/test_group_swarm.cc → test/test_swarm_group.cc View File


test/test_tofu_one2many.cc → test/test_swarm_tofu.cc View File


+ 3
- 4
test/test_sync_init.cc View File

@ -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;
}

+ 1
- 1
test/test_tofu.cc View File

@ -101,7 +101,7 @@ int tofu(PityUnit<PityPerspective> &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");


Loading…
Cancel
Save