2020-02-01 17:53:28 +08:00
|
|
|
import XCTest
|
|
|
|
import SwiftUI
|
2020-02-04 11:04:55 +08:00
|
|
|
import ViewInspector
|
|
|
|
@testable import SDWebImageSwiftUI
|
|
|
|
|
2020-03-24 18:47:35 +08:00
|
|
|
extension PlatformViewRepresentable where Self: Inspectable {
|
2020-02-04 11:04:55 +08:00
|
|
|
|
|
|
|
func platformView() throws -> PlatformViewType {
|
|
|
|
#if os(macOS)
|
|
|
|
return try nsView()
|
|
|
|
#else
|
|
|
|
return try uiView()
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2020-02-01 17:53:28 +08:00
|
|
|
|
|
|
|
class TestUtils {
|
|
|
|
static var testBundle = Bundle(for: TestUtils.self)
|
|
|
|
|
|
|
|
class func testImageBundle() -> Bundle {
|
|
|
|
let imagePath = (testBundle.resourcePath! as NSString).appendingPathComponent("Images.bundle")
|
|
|
|
return Bundle(path: imagePath)!
|
|
|
|
}
|
|
|
|
|
|
|
|
class func testImageData(name: String) -> Data? {
|
|
|
|
guard let url = testImageBundle().url(forResource: name, withExtension: nil) else {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return try? Data(contentsOf: url)
|
|
|
|
}
|
|
|
|
}
|