pEpForiOSTests/NetworkBackgroundServiceTests.swift
author Xavier Algarra <xavier@pep-project.org>
Tue, 06 Jun 2017 07:49:23 +0200
changeset 2248 75013a586bfd
parent 805 9ae921d9be1d
child 827 344c63bfde93
permissions -rw-r--r--
IOS-137 add multiple accounts option with the new login
     1 //
     2 //  NetworkBackgroundServiceTests.swift
     3 //  pEpForiOS
     4 //
     5 //  Created by hernani on 07/10/16.
     6 //  Copyright © 2016 p≡p Security S.A. All rights reserved.
     7 //
     8 
     9 import Foundation
    10 import XCTest
    11 
    12 import pEpForiOS
    13 
    14 class NetworkBackgroundServiceTests: XCTestCase {
    15     let comp = "NetworkBackgroundServiceTests"
    16     var networkBackgroundService: NetworkBackgroundService!
    17 
    18     override func setUp() {
    19         super.setUp()
    20         networkBackgroundService = NetworkBackgroundService()
    21     }
    22     
    23     override func tearDown() {
    24         // Put teardown code here. This method is called after the invocation of each test method in the class.
    25         super.tearDown()
    26     }
    27 
    28     // Test service existence.
    29     func testExistenceNetworkBackgroundService() {
    30         XCTAssertNotNil(networkBackgroundService)
    31     }
    32    
    33     // Test GCD queue existence.
    34     func testExistenceBackgroundQueue() {
    35         XCTAssertTrue(networkBackgroundService.isBackgroundQueueExistent())
    36     }
    37     
    38     // Test basic ImapSync in background on start & cancel.
    39     func testImapConnection() {
    40         let connectInfo = TestData.connectInfo
    41         let imapBlock = DispatchWorkItem {
    42             let _ = ImapSync(connectInfo: connectInfo)
    43         }
    44         networkBackgroundService.doWork(workItem: imapBlock)
    45         XCTAssertFalse(imapBlock.isCancelled)
    46         imapBlock.cancel()
    47         XCTAssertTrue(imapBlock.isCancelled)
    48     }
    49     
    50     // XXX: Test reception of a crafted message through the CoreData layer.
    51     func testCoreDataMessageReception() {
    52         XCTAssertTrue(false)
    53     }
    54     
    55     // XXX: Test sending out a plain text message in CoreData format.
    56     func testSendCoreDataMessageUnencrypted() {
    57         XCTAssertTrue(false)
    58     }
    59     
    60     // XXX: Test sending
    61     func testSendCoreDataMessageEncrypted() {
    62         XCTAssertTrue(false)
    63     }
    64     
    65     
    66 
    67     /*
    68      * Not used currently.
    69     func testPerformanceExample() {
    70         // This is an example of a performance test case.
    71         self.measure {
    72             // Put the code you want to measure the time of here.
    73         }
    74     }
    75     */
    76 
    77 }