|
|
@ -13,21 +13,7 @@ import XCTest
|
|
|
|
@testable import SignalServiceKit
|
|
|
|
@testable import SignalServiceKit
|
|
|
|
|
|
|
|
|
|
|
|
class TestJobRecord: SSKJobRecord {
|
|
|
|
class TestJobRecord: SSKJobRecord {
|
|
|
|
// override init(label: String) {
|
|
|
|
|
|
|
|
// super.init(label: label)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// override init(uniqueId: String?) {
|
|
|
|
|
|
|
|
// super.init(uniqueId: uniqueId)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// required init?(coder: NSCoder) {
|
|
|
|
|
|
|
|
// super.init(coder: coder)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// required init(dictionary dictionaryValue: [AnyHashable: Any]!) throws {
|
|
|
|
|
|
|
|
// try! super.init(dictionary: dictionaryValue)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let kJobRecordLabel = "TestJobRecord"
|
|
|
|
let kJobRecordLabel = "TestJobRecord"
|
|
|
@ -38,6 +24,8 @@ class TestJobQueue: JobQueue {
|
|
|
|
typealias DurableOperationType = TestDurableOperation
|
|
|
|
typealias DurableOperationType = TestDurableOperation
|
|
|
|
var jobRecordLabel: String = kJobRecordLabel
|
|
|
|
var jobRecordLabel: String = kJobRecordLabel
|
|
|
|
static var maxRetries: UInt = 1
|
|
|
|
static var maxRetries: UInt = 1
|
|
|
|
|
|
|
|
var runningOperations: [TestDurableOperation] = []
|
|
|
|
|
|
|
|
var requiresInternet: Bool = false
|
|
|
|
|
|
|
|
|
|
|
|
func setup() {
|
|
|
|
func setup() {
|
|
|
|
defaultSetup()
|
|
|
|
defaultSetup()
|
|
|
@ -65,18 +53,16 @@ class TestJobQueue: JobQueue {
|
|
|
|
init() { }
|
|
|
|
init() { }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class TestDurableOperation: DurableOperation {
|
|
|
|
class TestDurableOperation: OWSOperation, DurableOperation {
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: DurableOperation
|
|
|
|
// MARK: DurableOperation
|
|
|
|
|
|
|
|
|
|
|
|
var jobRecord: TestJobRecord
|
|
|
|
var jobRecord: TestJobRecord
|
|
|
|
|
|
|
|
|
|
|
|
var remainingRetries: UInt = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
weak var durableOperationDelegate: TestJobQueue?
|
|
|
|
weak var durableOperationDelegate: TestJobQueue?
|
|
|
|
|
|
|
|
|
|
|
|
var operation: Operation {
|
|
|
|
var operation: OWSOperation {
|
|
|
|
return BlockOperation { self.jobBlock(self.jobRecord) }
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MARK:
|
|
|
|
// MARK:
|
|
|
@ -87,6 +73,11 @@ class TestDurableOperation: DurableOperation {
|
|
|
|
self.jobRecord = jobRecord
|
|
|
|
self.jobRecord = jobRecord
|
|
|
|
self.jobBlock = jobBlock
|
|
|
|
self.jobBlock = jobBlock
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override func run() {
|
|
|
|
|
|
|
|
jobBlock(jobRecord)
|
|
|
|
|
|
|
|
self.reportSuccess()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class JobQueueTest: SSKBaseTestSwift {
|
|
|
|
class JobQueueTest: SSKBaseTestSwift {
|
|
|
|