test/src/engine_tests/SyncTests.cc
author Volker Birk <vb@pep.foundation>
Thu, 16 Aug 2018 15:28:36 +0200
branchsync
changeset 2852 135a3e49e48d
child 2853 f5f2abf9adcf
permissions -rw-r--r--
basic test code
vb@2852
     1
// This file is under GNU General Public License 3.0
vb@2852
     2
// see LICENSE.txt
vb@2852
     3
vb@2852
     4
#include <stdlib.h>
vb@2852
     5
#include <string>
vb@2852
     6
vb@2852
     7
#include "pEpEngine.h"
vb@2852
     8
#include "sync_api.h"
vb@2852
     9
#include "Sync_event.h"
vb@2852
    10
vb@2852
    11
#include "EngineTestSessionSuite.h"
vb@2852
    12
#include "SyncTests.h"
vb@2852
    13
vb@2852
    14
#include "locked_queue.hh"
vb@2852
    15
vb@2852
    16
using namespace std;
vb@2852
    17
vb@2852
    18
class Sync_Adapter {
vb@2852
    19
public:
vb@2852
    20
    utility::locked_queue< Sync_event_t * > q;
vb@2852
    21
vb@2852
    22
    static PEP_STATUS notifyHandshake(
vb@2852
    23
        void *obj,
vb@2852
    24
        pEp_identity *me,
vb@2852
    25
        pEp_identity *partner,
vb@2852
    26
        sync_handshake_signal signal
vb@2852
    27
    )
vb@2852
    28
    {
vb@2852
    29
        return PEP_STATUS_OK;
vb@2852
    30
    }
vb@2852
    31
vb@2852
    32
    static int inject_sync_event(SYNC_EVENT ev, void *management)
vb@2852
    33
    {
vb@2852
    34
        return 0;
vb@2852
    35
    }
vb@2852
    36
    static Sync_event_t *retrieve_next_sync_event(void *management)
vb@2852
    37
    {
vb@2852
    38
        return NULL;
vb@2852
    39
    }
vb@2852
    40
};
vb@2852
    41
vb@2852
    42
SyncTests::SyncTests(string suitename, string test_home_dir) :
vb@2852
    43
    EngineTestSessionSuite::EngineTestSessionSuite(suitename, test_home_dir) {
vb@2852
    44
    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("SyncTests::check_sync"),
vb@2852
    45
                                                                      static_cast<Func>(&SyncTests::check_sync)));
vb@2852
    46
}
vb@2852
    47
vb@2852
    48
void SyncTests::check_sync() {
vb@2852
    49
    Sync_Adapter adapter;
vb@2852
    50
vb@2852
    51
    PEP_STATUS status = register_sync_callbacks(
vb@2852
    52
            session,
vb@2852
    53
            &adapter.q,
vb@2852
    54
            Sync_Adapter::notifyHandshake,
vb@2852
    55
            Sync_Adapter::inject_sync_event,
vb@2852
    56
            Sync_Adapter::retrieve_next_sync_event
vb@2852
    57
        );
vb@2852
    58
vb@2852
    59
    TEST_ASSERT(status == PEP_STATUS_OK);
vb@2852
    60
    unregister_sync_callbacks(session);
vb@2852
    61
}
vb@2852
    62