IOSAD-103 testBasicSendMessage IOSAD-103
authorDirk Zimmermann <dirk@pep-project.org>
Wed, 31 Oct 2018 16:38:25 +0100
branchIOSAD-103
changeset 749fb20f6ea54ea
parent 748 eb3b7b15414d
child 750 c29db2e0851e
IOSAD-103 testBasicSendMessage
pEpObjCTests/PEPSessionTest.m
pEpObjCTests/TestUtils/PEPSessionTestSendMessageDelegate.m
     1.1 --- a/pEpObjCTests/PEPSessionTest.m	Wed Oct 31 16:38:25 2018 +0100
     1.2 +++ b/pEpObjCTests/PEPSessionTest.m	Wed Oct 31 16:38:25 2018 +0100
     1.3 @@ -1197,6 +1197,39 @@
     1.4      XCTAssertEqualObjects(decryptedAttachment.filename, attachment.filename);
     1.5  }
     1.6  
     1.7 +#pragma mark - Send Message
     1.8 +
     1.9 +/**
    1.10 + Prove that mySelf triggers a message to be sent.
    1.11 + */
    1.12 +- (void)testBasicSendMessage
    1.13 +{
    1.14 +    PEPSession *session = [PEPSession new];
    1.15 +
    1.16 +    XCTAssertEqual(self.sendMessageDelegate.messages.count, 0);
    1.17 +
    1.18 +    NSLog(@"*** waiting for message on %lu", (unsigned long) self.sendMessageDelegate);
    1.19 +
    1.20 +    XCTKVOExpectation *expHaveMessage = [[XCTKVOExpectation alloc]
    1.21 +                                         initWithKeyPath:@"lastMessage"
    1.22 +                                         object:self.sendMessageDelegate];
    1.23 +
    1.24 +    PEPIdentity *identMe = [[PEPIdentity alloc]
    1.25 +                            initWithAddress:@"me-myself-and-i@pep-project.org"
    1.26 +                            userID:@"me-myself-and-i"
    1.27 +                            userName:@"pEp Me"
    1.28 +                            isOwn:YES];
    1.29 +    NSError *error = nil;
    1.30 +    XCTAssertTrue([session mySelf:identMe error:&error]);
    1.31 +    XCTAssertNil(error);
    1.32 +
    1.33 +    XCTAssertNotNil(identMe.fingerPrint);
    1.34 +
    1.35 +    [self waitForExpectations:@[expHaveMessage] timeout:1000];
    1.36 +
    1.37 +    XCTAssertEqual(self.sendMessageDelegate.messages.count, 1);
    1.38 +}
    1.39 +
    1.40  #pragma mark - Key Reset
    1.41  
    1.42  - (void)testBasicKeyResetTrust
     2.1 --- a/pEpObjCTests/TestUtils/PEPSessionTestSendMessageDelegate.m	Wed Oct 31 16:38:25 2018 +0100
     2.2 +++ b/pEpObjCTests/TestUtils/PEPSessionTestSendMessageDelegate.m	Wed Oct 31 16:38:25 2018 +0100
     2.3 @@ -22,6 +22,7 @@
     2.4  }
     2.5  
     2.6  - (PEP_STATUS)sendMessage:(PEPMessage * _Nonnull)message {
     2.7 +    NSLog(@"*** received message on %lu", (unsigned long) self);
     2.8      [self.messages addObject:message];
     2.9      self.lastMessage = message;
    2.10      return PEP_STATUS_OK;