pEpObjCTests/PEPSyncTest.m
changeset 391 3a63cf867f1f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/pEpObjCTests/PEPSyncTest.m	Thu Jan 18 15:41:10 2018 +0100
     1.3 @@ -0,0 +1,107 @@
     1.4 +//
     1.5 +//  PEPSyncTest.m
     1.6 +//  pEpObjCAdapterTests
     1.7 +//
     1.8 +//  Created by Andreas Buff on 17.01.18.
     1.9 +//  Copyright © 2018 p≡p. All rights reserved.
    1.10 +//
    1.11 +
    1.12 +#import <XCTest/XCTest.h>
    1.13 +
    1.14 +#import "PEPIdentity.h"
    1.15 +#import "PEPObjCAdapter.h"
    1.16 +
    1.17 +// Commented. See testSyncSession
    1.18 +// MARK: - PEPSyncDelegate
    1.19 +
    1.20 +@interface SomeSyncDelegate : NSObject<PEPSyncDelegate>
    1.21 +
    1.22 +- (BOOL)waitUntilSent:(time_t)maxSec;
    1.23 +
    1.24 +@property (nonatomic) bool sendWasCalled;
    1.25 +@property (nonatomic, strong) NSCondition *cond;
    1.26 +
    1.27 +@end
    1.28 +
    1.29 +@implementation SomeSyncDelegate
    1.30 +
    1.31 +//- (id)init
    1.32 +//{
    1.33 +//    if (self = [super init])  {
    1.34 +//        self.sendWasCalled = false;
    1.35 +//        self.cond = [[NSCondition alloc] init];
    1.36 +//    }
    1.37 +//    return self;
    1.38 +//}
    1.39 +//
    1.40 +//- (PEP_STATUS)notifyHandshakeWithSignal:(sync_handshake_signal)signal me:(id)me
    1.41 +//                                partner:(id)partner
    1.42 +//{
    1.43 +//    return PEP_STATUS_OK;
    1.44 +//}
    1.45 +//
    1.46 +//- (PEP_STATUS)sendMessage:(id)msg //never used afaics. Delete?
    1.47 +//{
    1.48 +//    [_cond lock];
    1.49 +//
    1.50 +//    self.sendWasCalled = true;
    1.51 +//    [_cond signal];
    1.52 +//    [_cond unlock];
    1.53 +//
    1.54 +//    return PEP_STATUS_OK;
    1.55 +//}
    1.56 +//
    1.57 +//- (PEP_STATUS)fastPolling:(bool)isfast
    1.58 +//{
    1.59 +//    return PEP_STATUS_OK;
    1.60 +//}
    1.61 +//
    1.62 +//- (BOOL)waitUntilSent:(time_t)maxSec
    1.63 +//{
    1.64 +//    bool res;
    1.65 +//    [_cond lock];
    1.66 +//    [_cond waitUntilDate:[NSDate dateWithTimeIntervalSinceNow:maxSec]];
    1.67 +//    res = _sendWasCalled;
    1.68 +//    [_cond unlock];
    1.69 +//    return res;
    1.70 +//}
    1.71 +//
    1.72 +//@end
    1.73 +//
    1.74 +//@interface PEPSyncTest : XCTestCase
    1.75 +//
    1.76 +//@end
    1.77 +//
    1.78 +//@implementation PEPSyncTest
    1.79 +//
    1.80 +////BUFF: ?? commented due to: Can't currently work, engine doesn't contain sync.
    1.81 +//- (void)testSyncSession
    1.82 +//{
    1.83 +//    PEPSession *session = [PEPSession new];
    1.84 +//    SomeSyncDelegate *syncDelegate = [[SomeSyncDelegate alloc] init];
    1.85 +//    [self pEpSetUp];
    1.86 +//
    1.87 +//    // This should attach session just created
    1.88 +//    [PEPObjCAdapter startSync:syncDelegate];
    1.89 +//
    1.90 +//    PEPIdentity *identMe = [[PEPIdentity alloc]
    1.91 +//                            initWithAddress:@"pep.test.iosgenkey@pep-project.org"
    1.92 +//                            userID:@"Me"
    1.93 +//                            userName:@"pEp Test iOS GenKey"
    1.94 +//                            isOwn:YES];
    1.95 +//
    1.96 +//    [session mySelf:identMe];
    1.97 +//
    1.98 +//    bool res = [syncDelegate waitUntilSent:1];
    1.99 +//
   1.100 +//    // Can't currently work, engine doesn't contain sync.
   1.101 +//    XCTAssertFalse(res);
   1.102 +//
   1.103 +//    // This should detach session just created
   1.104 +//    [PEPObjCAdapter stopSync];
   1.105 +//
   1.106 +//    [self pEpCleanUp];
   1.107 +//}
   1.108 +//}
   1.109 +
   1.110 +@end