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