test/src/engine_tests/SyncTests.cc
branchsync
changeset 2852 135a3e49e48d
child 2853 f5f2abf9adcf
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/src/engine_tests/SyncTests.cc	Thu Aug 16 15:28:36 2018 +0200
     1.3 @@ -0,0 +1,62 @@
     1.4 +// This file is under GNU General Public License 3.0
     1.5 +// see LICENSE.txt
     1.6 +
     1.7 +#include <stdlib.h>
     1.8 +#include <string>
     1.9 +
    1.10 +#include "pEpEngine.h"
    1.11 +#include "sync_api.h"
    1.12 +#include "Sync_event.h"
    1.13 +
    1.14 +#include "EngineTestSessionSuite.h"
    1.15 +#include "SyncTests.h"
    1.16 +
    1.17 +#include "locked_queue.hh"
    1.18 +
    1.19 +using namespace std;
    1.20 +
    1.21 +class Sync_Adapter {
    1.22 +public:
    1.23 +    utility::locked_queue< Sync_event_t * > q;
    1.24 +
    1.25 +    static PEP_STATUS notifyHandshake(
    1.26 +        void *obj,
    1.27 +        pEp_identity *me,
    1.28 +        pEp_identity *partner,
    1.29 +        sync_handshake_signal signal
    1.30 +    )
    1.31 +    {
    1.32 +        return PEP_STATUS_OK;
    1.33 +    }
    1.34 +
    1.35 +    static int inject_sync_event(SYNC_EVENT ev, void *management)
    1.36 +    {
    1.37 +        return 0;
    1.38 +    }
    1.39 +    static Sync_event_t *retrieve_next_sync_event(void *management)
    1.40 +    {
    1.41 +        return NULL;
    1.42 +    }
    1.43 +};
    1.44 +
    1.45 +SyncTests::SyncTests(string suitename, string test_home_dir) :
    1.46 +    EngineTestSessionSuite::EngineTestSessionSuite(suitename, test_home_dir) {
    1.47 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("SyncTests::check_sync"),
    1.48 +                                                                      static_cast<Func>(&SyncTests::check_sync)));
    1.49 +}
    1.50 +
    1.51 +void SyncTests::check_sync() {
    1.52 +    Sync_Adapter adapter;
    1.53 +
    1.54 +    PEP_STATUS status = register_sync_callbacks(
    1.55 +            session,
    1.56 +            &adapter.q,
    1.57 +            Sync_Adapter::notifyHandshake,
    1.58 +            Sync_Adapter::inject_sync_event,
    1.59 +            Sync_Adapter::retrieve_next_sync_event
    1.60 +        );
    1.61 +
    1.62 +    TEST_ASSERT(status == PEP_STATUS_OK);
    1.63 +    unregister_sync_callbacks(session);
    1.64 +}
    1.65 +