mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
MockMediaProvider → MediaProviderMock.
This commit is contained in:
@@ -16,6 +16,7 @@ enum MediaProviderError: Error {
|
||||
case cancelled
|
||||
}
|
||||
|
||||
// sourcery: AutoMockable
|
||||
protocol MediaProviderProtocol {
|
||||
func imageFromSource(_ source: MediaSourceProxy?, size: CGSize?) -> UIImage?
|
||||
func loadImageFromSource(_ source: MediaSourceProxy, size: CGSize?) async -> Result<UIImage, MediaProviderError>
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
//
|
||||
// Copyright 2022-2024 New Vector Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Please see LICENSE in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
struct MockMediaProvider: MediaProviderProtocol {
|
||||
func loadThumbnailForSource(source: MediaSourceProxy, size: CGSize) async -> Result<Data, MediaProviderError> {
|
||||
fatalError("Not implemented")
|
||||
}
|
||||
|
||||
func imageFromSource(_ source: MediaSourceProxy?, size: CGSize?) -> UIImage? {
|
||||
guard source != nil else {
|
||||
return nil
|
||||
}
|
||||
|
||||
if source?.url == .picturesDirectory {
|
||||
return Asset.Images.appLogo.image
|
||||
}
|
||||
|
||||
return UIImage(systemName: "photo")
|
||||
}
|
||||
|
||||
func loadImageFromSource(_ source: MediaSourceProxy, size: CGSize?) async -> Result<UIImage, MediaProviderError> {
|
||||
guard let image = UIImage(systemName: "photo") else {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
return .success(image)
|
||||
}
|
||||
|
||||
func loadImageDataFromSource(_ source: MediaSourceProxy) async -> Result<Data, MediaProviderError> {
|
||||
guard let image = UIImage(systemName: "photo"),
|
||||
let data = image.pngData() else {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
return .success(data)
|
||||
}
|
||||
|
||||
var loadFileFromSourceReturnValue: MediaFileHandleProxy?
|
||||
func loadFileFromSource(_ source: MediaSourceProxy, body: String?) async -> Result<MediaFileHandleProxy, MediaProviderError> {
|
||||
if let loadFileFromSourceReturnValue {
|
||||
return .success(loadFileFromSourceReturnValue)
|
||||
}
|
||||
return .failure(.failedRetrievingFile)
|
||||
}
|
||||
|
||||
func loadImageRetryingOnReconnection(_ source: MediaSourceProxy, size: CGSize?) -> Task<UIImage, any Error> {
|
||||
Task {
|
||||
guard let image = UIImage(systemName: "photo") else {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
return image
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user