IOS-1545 rename NetworkServiceObserver to ReplicationServiceObserver IOS-1545
authorAlejandro Gelos <agp@pep.security>
Thu, 18 Apr 2019 15:46:08 +0200
branchIOS-1545
changeset 83174dcaa1c257df
parent 8315 0438a54b5094
child 8318 3310c93a7409
IOS-1545 rename NetworkServiceObserver to ReplicationServiceObserver
pEpForiOS.xcodeproj/project.pbxproj
pEpForiOSTests/ReplicationServiceTests.swift
pEpForiOSTests/TestUtils/NetworkServiceObserver.swift
pEpForiOSTests/TestUtils/ReplicationServiceObserver.swift
pEpForiOSTests/TestUtils/TestUtil.swift
     1.1 --- a/pEpForiOS.xcodeproj/project.pbxproj	Thu Apr 18 11:56:49 2019 +0200
     1.2 +++ b/pEpForiOS.xcodeproj/project.pbxproj	Thu Apr 18 15:46:08 2019 +0200
     1.3 @@ -56,7 +56,7 @@
     1.4  		151DE7E11FC5D3FA00CDC273 /* Handshake.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 151DE7E31FC5D3FA00CDC273 /* Handshake.storyboard */; };
     1.5  		151DE7E41FC5D41600CDC273 /* FolderViews.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 151DE7E61FC5D41600CDC273 /* FolderViews.storyboard */; };
     1.6  		151F71F7202A06760057C74D /* TestDataBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 151F71EC202A06750057C74D /* TestDataBase.swift */; };
     1.7 -		151F71F9202A06760057C74D /* NetworkServiceObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 151F71EE202A06750057C74D /* NetworkServiceObserver.swift */; };
     1.8 +		151F71F9202A06760057C74D /* ReplicationServiceObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 151F71EE202A06750057C74D /* ReplicationServiceObserver.swift */; };
     1.9  		151F71FA202A06760057C74D /* DecryptionAttemptCounterDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 151F71EF202A06750057C74D /* DecryptionAttemptCounterDelegate.swift */; };
    1.10  		151F71FB202A06760057C74D /* MockBackgrounder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 151F71F0202A06750057C74D /* MockBackgrounder.swift */; };
    1.11  		151F71FC202A06760057C74D /* CoreDataDrivenTestBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 151F71F1202A06750057C74D /* CoreDataDrivenTestBase.swift */; };
    1.12 @@ -537,7 +537,7 @@
    1.13  		151DE7E21FC5D3FA00CDC273 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Handshake.storyboard; sourceTree = "<group>"; };
    1.14  		151DE7E51FC5D41600CDC273 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/FolderViews.storyboard; sourceTree = "<group>"; };
    1.15  		151F71EC202A06750057C74D /* TestDataBase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestDataBase.swift; sourceTree = "<group>"; };
    1.16 -		151F71EE202A06750057C74D /* NetworkServiceObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkServiceObserver.swift; sourceTree = "<group>"; };
    1.17 +		151F71EE202A06750057C74D /* ReplicationServiceObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReplicationServiceObserver.swift; sourceTree = "<group>"; };
    1.18  		151F71EF202A06750057C74D /* DecryptionAttemptCounterDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DecryptionAttemptCounterDelegate.swift; sourceTree = "<group>"; };
    1.19  		151F71F0202A06750057C74D /* MockBackgrounder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MockBackgrounder.swift; sourceTree = "<group>"; };
    1.20  		151F71F1202A06750057C74D /* CoreDataDrivenTestBase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreDataDrivenTestBase.swift; sourceTree = "<group>"; };
    1.21 @@ -1078,7 +1078,7 @@
    1.22  				151F71F4202A06750057C74D /* Message+TestUtils.swift */,
    1.23  				003C0FA620B5581A0093A987 /* SecretTestData.swift */,
    1.24  				151F71F0202A06750057C74D /* MockBackgrounder.swift */,
    1.25 -				151F71EE202A06750057C74D /* NetworkServiceObserver.swift */,
    1.26 +				151F71EE202A06750057C74D /* ReplicationServiceObserver.swift */,
    1.27  				151F71EC202A06750057C74D /* TestDataBase.swift */,
    1.28  				151F71F5202A06750057C74D /* TestUtil.swift */,
    1.29  				495F689921E6600500A10C63 /* ScreenshotTestUtil.swift */,
    1.30 @@ -3076,7 +3076,7 @@
    1.31  				151F71FB202A06760057C74D /* MockBackgrounder.swift in Sources */,
    1.32  				43D51E891DD5D902008B77A8 /* SimpleOperationsTest.swift in Sources */,
    1.33  				151F71FE202A06760057C74D /* CdMessage+TestUtils.swift in Sources */,
    1.34 -				151F71F9202A06760057C74D /* NetworkServiceObserver.swift in Sources */,
    1.35 +				151F71F9202A06760057C74D /* ReplicationServiceObserver.swift in Sources */,
    1.36  				150E18C0219D8C6C009E9048 /* ComposeViewModelSectionTest.swift in Sources */,
    1.37  				43F7F07A1F6AD44600BDF151 /* HandshakeTests.swift in Sources */,
    1.38  				1569AEA520E14DC3002102A0 /* ReUploadTest.swift in Sources */,
     2.1 --- a/pEpForiOSTests/ReplicationServiceTests.swift	Thu Apr 18 11:56:49 2019 +0200
     2.2 +++ b/pEpForiOSTests/ReplicationServiceTests.swift	Thu Apr 18 15:46:08 2019 +0200
     2.3 @@ -42,7 +42,7 @@
     2.4  
     2.5          let replicationService = ReplicationService(parentName: #function)
     2.6  
     2.7 -        let del = NetworkServiceObserver(
     2.8 +        let del = ReplicationServiceObserver(
     2.9              expAccountsSynced: expectation(description: "expSingleAccountSynced"))
    2.10          replicationService.unitTestDelegate = del
    2.11          replicationService.delegate = del
     3.1 --- a/pEpForiOSTests/TestUtils/NetworkServiceObserver.swift	Thu Apr 18 11:56:49 2019 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,66 +0,0 @@
     3.4 -//
     3.5 -//  NetworkServiceObserver.swift
     3.6 -//  pEpForiOS
     3.7 -//
     3.8 -//  Created by Andreas Buff on 29.08.17.
     3.9 -//  Copyright © 2017 p≡p Security S.A. All rights reserved.
    3.10 -//
    3.11 -
    3.12 -import XCTest
    3.13 -import CoreData
    3.14 -
    3.15 -@testable import MessageModel
    3.16 -@testable import pEpForiOS
    3.17 -
    3.18 -class NetworkServiceObserver: CustomDebugStringConvertible {
    3.19 -    let expAllSynced: XCTestExpectation?
    3.20 -    var expCanceled: XCTestExpectation?
    3.21 -    var accountInfo: AccountConnectInfo?
    3.22 -    let numAccountsToBeSynced: Int
    3.23 -    var accountIDsSynced = Set<NSManagedObjectID>()
    3.24 -
    3.25 -    var debugDescription: String {
    3.26 -        return expAllSynced?.debugDescription ?? "unknown"
    3.27 -    }
    3.28 -
    3.29 -    let failOnError: Bool
    3.30 -
    3.31 -    init(numAccountsToSync: Int = 1,
    3.32 -         expAccountsSynced: XCTestExpectation? = nil,
    3.33 -         expCanceled: XCTestExpectation? = nil,
    3.34 -         failOnError: Bool = false) {
    3.35 -        self.numAccountsToBeSynced = numAccountsToSync
    3.36 -        self.expAllSynced = expAccountsSynced
    3.37 -        self.expCanceled = expCanceled
    3.38 -        self.failOnError = failOnError
    3.39 -    }
    3.40 -}
    3.41 -
    3.42 -// MARK: - ReplicationServiceUnitTestDelegate
    3.43 -
    3.44 -extension NetworkServiceObserver: ReplicationServiceUnitTestDelegate {
    3.45 -    func replicationServiceDidSync(service: ReplicationService, accountInfo: AccountConnectInfo,
    3.46 -                 errorProtocol: ServiceErrorProtocol) {
    3.47 -        if errorProtocol.hasErrors() && failOnError {
    3.48 -            XCTFail()
    3.49 -        }
    3.50 -        if self.accountInfo == nil {
    3.51 -            self.accountInfo = accountInfo
    3.52 -        }
    3.53 -        accountIDsSynced.insert(accountInfo.accountID)
    3.54 -        if accountIDsSynced.count == numAccountsToBeSynced {
    3.55 -            expAllSynced?.fulfill()
    3.56 -        }
    3.57 -    }
    3.58 -}
    3.59 -
    3.60 -// MARK: - ReplicationServiceDelegate
    3.61 -extension NetworkServiceObserver: ReplicationServiceDelegate {
    3.62 -    func replicationServiceDidFinishLastSyncLoop(service: ReplicationService) {
    3.63 -        // ignore
    3.64 -    }
    3.65 -
    3.66 -    func replicationServiceDidCancel(service: ReplicationService) {
    3.67 -        expCanceled?.fulfill()
    3.68 -    }
    3.69 -}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/pEpForiOSTests/TestUtils/ReplicationServiceObserver.swift	Thu Apr 18 15:46:08 2019 +0200
     4.3 @@ -0,0 +1,66 @@
     4.4 +//
     4.5 +//  ReplicationServiceObserver.swift
     4.6 +//  pEpForiOS
     4.7 +//
     4.8 +//  Created by Andreas Buff on 29.08.17.
     4.9 +//  Copyright © 2017 p≡p Security S.A. All rights reserved.
    4.10 +//
    4.11 +
    4.12 +import XCTest
    4.13 +import CoreData
    4.14 +
    4.15 +@testable import MessageModel
    4.16 +@testable import pEpForiOS
    4.17 +
    4.18 +class ReplicationServiceObserver: CustomDebugStringConvertible {
    4.19 +    let expAllSynced: XCTestExpectation?
    4.20 +    var expCanceled: XCTestExpectation?
    4.21 +    var accountInfo: AccountConnectInfo?
    4.22 +    let numAccountsToBeSynced: Int
    4.23 +    var accountIDsSynced = Set<NSManagedObjectID>()
    4.24 +
    4.25 +    var debugDescription: String {
    4.26 +        return expAllSynced?.debugDescription ?? "unknown"
    4.27 +    }
    4.28 +
    4.29 +    let failOnError: Bool
    4.30 +
    4.31 +    init(numAccountsToSync: Int = 1,
    4.32 +         expAccountsSynced: XCTestExpectation? = nil,
    4.33 +         expCanceled: XCTestExpectation? = nil,
    4.34 +         failOnError: Bool = false) {
    4.35 +        self.numAccountsToBeSynced = numAccountsToSync
    4.36 +        self.expAllSynced = expAccountsSynced
    4.37 +        self.expCanceled = expCanceled
    4.38 +        self.failOnError = failOnError
    4.39 +    }
    4.40 +}
    4.41 +
    4.42 +// MARK: - ReplicationServiceUnitTestDelegate
    4.43 +
    4.44 +extension ReplicationServiceObserver: ReplicationServiceUnitTestDelegate {
    4.45 +    func replicationServiceDidSync(service: ReplicationService, accountInfo: AccountConnectInfo,
    4.46 +                 errorProtocol: ServiceErrorProtocol) {
    4.47 +        if errorProtocol.hasErrors() && failOnError {
    4.48 +            XCTFail()
    4.49 +        }
    4.50 +        if self.accountInfo == nil {
    4.51 +            self.accountInfo = accountInfo
    4.52 +        }
    4.53 +        accountIDsSynced.insert(accountInfo.accountID)
    4.54 +        if accountIDsSynced.count == numAccountsToBeSynced {
    4.55 +            expAllSynced?.fulfill()
    4.56 +        }
    4.57 +    }
    4.58 +}
    4.59 +
    4.60 +// MARK: - ReplicationServiceDelegate
    4.61 +extension ReplicationServiceObserver: ReplicationServiceDelegate {
    4.62 +    func replicationServiceDidFinishLastSyncLoop(service: ReplicationService) {
    4.63 +        // ignore
    4.64 +    }
    4.65 +
    4.66 +    func replicationServiceDidCancel(service: ReplicationService) {
    4.67 +        expCanceled?.fulfill()
    4.68 +    }
    4.69 +}
     5.1 --- a/pEpForiOSTests/TestUtils/TestUtil.swift	Thu Apr 18 11:56:49 2019 +0200
     5.2 +++ b/pEpForiOSTests/TestUtils/TestUtil.swift	Thu Apr 18 15:46:08 2019 +0200
     5.3 @@ -234,7 +234,7 @@
     5.4  
     5.5          let expAccountsSynced = testCase.expectation(description: "allAccountsSynced")
     5.6          // A temp variable is necassary, since the replicationServiceUnitTestDelegate is weak
     5.7 -        let del = NetworkServiceObserver(numAccountsToSync: numAccountsToSync,
     5.8 +        let del = ReplicationServiceObserver(numAccountsToSync: numAccountsToSync,
     5.9                                           expAccountsSynced: expAccountsSynced,
    5.10                                           failOnError: true)
    5.11  
    5.12 @@ -252,7 +252,7 @@
    5.13  
    5.14      // MARK: - ReplicationService
    5.15      static public func cancelReplicationServiceAndWait(replicationService: ReplicationService, testCase: XCTestCase) {
    5.16 -        let del = NetworkServiceObserver(
    5.17 +        let del = ReplicationServiceObserver(
    5.18              expCanceled: testCase.expectation(description: "expCanceled"))
    5.19          replicationService.unitTestDelegate = del
    5.20          replicationService.delegate = del