54 lines
1.2 KiB
Swift
54 lines
1.2 KiB
Swift
//
|
|
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
import XCTest
|
|
@testable import SignalServiceKit
|
|
import CocoaLumberjack
|
|
|
|
@objc
|
|
public class SSKBaseTestSwift: XCTestCase {
|
|
|
|
@objc
|
|
public override func setUp() {
|
|
super.setUp()
|
|
|
|
DDLog.add(DDTTYLogger.sharedInstance!)
|
|
|
|
ClearCurrentAppContextForTests()
|
|
SetCurrentAppContext(TestAppContext())
|
|
|
|
MockSSKEnvironment.activate()
|
|
|
|
GroupManager.forceV1Groups()
|
|
}
|
|
|
|
@objc
|
|
public override func tearDown() {
|
|
AssertIsOnMainThread()
|
|
|
|
// Spin the main run loop to flush any remaining async work.
|
|
var done = false
|
|
DispatchQueue.main.async { done = true }
|
|
while !done {
|
|
CFRunLoopRunInMode(.defaultMode, 0.0, true)
|
|
}
|
|
|
|
super.tearDown()
|
|
}
|
|
|
|
@objc
|
|
public func read(_ block: @escaping (SDSAnyReadTransaction) -> Void) {
|
|
return databaseStorage.read(block: block)
|
|
}
|
|
|
|
public func write<T>(_ block: @escaping (SDSAnyWriteTransaction) -> T) -> T {
|
|
return databaseStorage.write(block: block)
|
|
}
|
|
|
|
@objc
|
|
public func asyncWrite(_ block: @escaping (SDSAnyWriteTransaction) -> Void) {
|
|
return databaseStorage.asyncWrite(block: block)
|
|
}
|
|
}
|