pEpObjCTests/PEPSyncTest.m
author Dirk Zimmermann <dirk@pep-project.org>
Tue, 24 Apr 2018 13:29:19 +0200
branchIOSAD-92
changeset 594 a9cae3a6f78d
parent 391 3a63cf867f1f
permissions -rw-r--r--
IOSAD-92 PEPIdentity using hashBasedOnKeys etc.
andreas@391
     1
//
andreas@391
     2
//  PEPSyncTest.m
andreas@391
     3
//  pEpObjCAdapterTests
andreas@391
     4
//
andreas@391
     5
//  Created by Andreas Buff on 17.01.18.
andreas@391
     6
//  Copyright © 2018 p≡p. All rights reserved.
andreas@391
     7
//
andreas@391
     8
andreas@391
     9
#import <XCTest/XCTest.h>
andreas@391
    10
andreas@391
    11
#import "PEPIdentity.h"
andreas@391
    12
#import "PEPObjCAdapter.h"
andreas@391
    13
andreas@391
    14
// Commented. See testSyncSession
andreas@391
    15
// MARK: - PEPSyncDelegate
andreas@391
    16
andreas@391
    17
@interface SomeSyncDelegate : NSObject<PEPSyncDelegate>
andreas@391
    18
andreas@391
    19
- (BOOL)waitUntilSent:(time_t)maxSec;
andreas@391
    20
andreas@391
    21
@property (nonatomic) bool sendWasCalled;
andreas@391
    22
@property (nonatomic, strong) NSCondition *cond;
andreas@391
    23
andreas@391
    24
@end
andreas@391
    25
andreas@391
    26
@implementation SomeSyncDelegate
andreas@391
    27
andreas@391
    28
//- (id)init
andreas@391
    29
//{
andreas@391
    30
//    if (self = [super init])  {
andreas@391
    31
//        self.sendWasCalled = false;
andreas@391
    32
//        self.cond = [[NSCondition alloc] init];
andreas@391
    33
//    }
andreas@391
    34
//    return self;
andreas@391
    35
//}
andreas@391
    36
//
andreas@391
    37
//- (PEP_STATUS)notifyHandshakeWithSignal:(sync_handshake_signal)signal me:(id)me
andreas@391
    38
//                                partner:(id)partner
andreas@391
    39
//{
andreas@391
    40
//    return PEP_STATUS_OK;
andreas@391
    41
//}
andreas@391
    42
//
andreas@391
    43
//- (PEP_STATUS)sendMessage:(id)msg //never used afaics. Delete?
andreas@391
    44
//{
andreas@391
    45
//    [_cond lock];
andreas@391
    46
//
andreas@391
    47
//    self.sendWasCalled = true;
andreas@391
    48
//    [_cond signal];
andreas@391
    49
//    [_cond unlock];
andreas@391
    50
//
andreas@391
    51
//    return PEP_STATUS_OK;
andreas@391
    52
//}
andreas@391
    53
//
andreas@391
    54
//- (PEP_STATUS)fastPolling:(bool)isfast
andreas@391
    55
//{
andreas@391
    56
//    return PEP_STATUS_OK;
andreas@391
    57
//}
andreas@391
    58
//
andreas@391
    59
//- (BOOL)waitUntilSent:(time_t)maxSec
andreas@391
    60
//{
andreas@391
    61
//    bool res;
andreas@391
    62
//    [_cond lock];
andreas@391
    63
//    [_cond waitUntilDate:[NSDate dateWithTimeIntervalSinceNow:maxSec]];
andreas@391
    64
//    res = _sendWasCalled;
andreas@391
    65
//    [_cond unlock];
andreas@391
    66
//    return res;
andreas@391
    67
//}
andreas@391
    68
//
andreas@391
    69
//@end
andreas@391
    70
//
andreas@391
    71
//@interface PEPSyncTest : XCTestCase
andreas@391
    72
//
andreas@391
    73
//@end
andreas@391
    74
//
andreas@391
    75
//@implementation PEPSyncTest
andreas@391
    76
//
andreas@391
    77
////BUFF: ?? commented due to: Can't currently work, engine doesn't contain sync.
andreas@391
    78
//- (void)testSyncSession
andreas@391
    79
//{
andreas@391
    80
//    PEPSession *session = [PEPSession new];
andreas@391
    81
//    SomeSyncDelegate *syncDelegate = [[SomeSyncDelegate alloc] init];
andreas@391
    82
//    [self pEpSetUp];
andreas@391
    83
//
andreas@391
    84
//    // This should attach session just created
andreas@391
    85
//    [PEPObjCAdapter startSync:syncDelegate];
andreas@391
    86
//
andreas@391
    87
//    PEPIdentity *identMe = [[PEPIdentity alloc]
andreas@391
    88
//                            initWithAddress:@"pep.test.iosgenkey@pep-project.org"
andreas@391
    89
//                            userID:@"Me"
andreas@391
    90
//                            userName:@"pEp Test iOS GenKey"
andreas@391
    91
//                            isOwn:YES];
andreas@391
    92
//
andreas@391
    93
//    [session mySelf:identMe];
andreas@391
    94
//
andreas@391
    95
//    bool res = [syncDelegate waitUntilSent:1];
andreas@391
    96
//
andreas@391
    97
//    // Can't currently work, engine doesn't contain sync.
andreas@391
    98
//    XCTAssertFalse(res);
andreas@391
    99
//
andreas@391
   100
//    // This should detach session just created
andreas@391
   101
//    [PEPObjCAdapter stopSync];
andreas@391
   102
//
andreas@391
   103
//    [self pEpCleanUp];
andreas@391
   104
//}
andreas@391
   105
//}
andreas@391
   106
andreas@391
   107
@end