QuickLook media. (#447)

* Use QL previews for video and present full screen.
* Use URL(staticString:) in more places.
* Fix DesignKit issues.
This commit is contained in:
Doug
2023-01-12 17:37:33 +00:00
committed by GitHub
parent 3153c0f0d9
commit c383029203
20 changed files with 135 additions and 349 deletions
@@ -168,7 +168,7 @@ final class MediaProviderTests: XCTestCase {
}
func test_whenFileFromSourceWithSource_correctValuesAreReturned() throws {
let expectedURL = try XCTUnwrap(URL(string: "some_url"))
let expectedURL = URL(filePath: "/some/file/path")
fileCache.fileURLToReturn = expectedURL
let url = mediaProvider.fileFromSource(MediaSourceProxy(urlString: "test/test1"), fileExtension: "png")
XCTAssertEqual(fileCache.fileKey, "test1")
@@ -177,7 +177,7 @@ final class MediaProviderTests: XCTestCase {
}
func test_whenLoadFileFromSourceAndFileFromSourceExists_urlIsReturned() async throws {
let expectedURL = try XCTUnwrap(URL(string: "some_url"))
let expectedURL = URL(filePath: "/some/file/path")
let expectedResult: Result<URL, MediaProviderError> = .success(expectedURL)
fileCache.fileURLToReturn = expectedURL
let result = await mediaProvider.loadFileFromSource(MediaSourceProxy(urlString: "test/test1"), fileExtension: "png")
@@ -185,7 +185,7 @@ final class MediaProviderTests: XCTestCase {
}
func test_whenLoadFileFromSourceAndNoFileFromSourceExists_mediaLoadedFromSource() async throws {
let expectedURL = try XCTUnwrap(URL(string: "some_url"))
let expectedURL = URL(filePath: "/some/file/path")
let expectedResult: Result<URL, MediaProviderError> = .success(expectedURL)
mediaProxy.mediaContentData = try loadTestImage().pngData()
fileCache.storeURLToReturn = expectedURL
@@ -217,14 +217,14 @@ final class MediaProviderTests: XCTestCase {
}
func test_whenFileFromURLString_correctURLIsReturned() throws {
let expectedURL = try XCTUnwrap(URL(string: "some_url"))
let expectedURL = URL(filePath: "/some/file/path")
fileCache.fileURLToReturn = expectedURL
let url = mediaProvider.fileFromURLString("test/test1", fileExtension: "png")
XCTAssertEqual(url?.absoluteString, expectedURL.absoluteString)
}
func test_whenLoadFileFromURLString_correctURLIsReturned() async throws {
let expectedURL = try XCTUnwrap(URL(string: "some_url"))
let expectedURL = URL(filePath: "/some/file/path")
let expectedResult: Result<URL, MediaProviderError> = .success(expectedURL)
fileCache.fileURLToReturn = expectedURL
let result = await mediaProvider.loadFileFromURLString("test/test1", fileExtension: "png")
@@ -1,44 +0,0 @@
//
// Copyright 2022 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import XCTest
@testable import ElementX
@MainActor
class VideoPlayerScreenViewModelTests: XCTestCase {
var viewModel: VideoPlayerViewModelProtocol!
var context: VideoPlayerViewModelType.Context!
@MainActor override func setUpWithError() throws {
viewModel = VideoPlayerViewModel(videoURL: URL(staticString: "https://storage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"), autoplay: true)
context = viewModel.context
}
@MainActor func testCancel() async throws {
var correctResult = false
viewModel.callback = { result in
switch result {
case .cancel:
correctResult = true
}
}
context.send(viewAction: .cancel)
await Task.yield()
XCTAssert(correctResult)
}
}