diff --git a/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample.xcodeproj/project.pbxproj b/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample.xcodeproj/project.pbxproj index e99bd8c4..49dbdc38 100644 --- a/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample.xcodeproj/project.pbxproj +++ b/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample.xcodeproj/project.pbxproj @@ -53,6 +53,7 @@ 193228D72ACF6AC900966FE1 /* MuxPlayerSwiftExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MuxPlayerSwiftExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 193228DB2ACF6AC900966FE1 /* MuxPlayerSwiftExampleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MuxPlayerSwiftExampleUITests.swift; sourceTree = ""; }; 193228DD2ACF6AC900966FE1 /* MuxPlayerSwiftExampleUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MuxPlayerSwiftExampleUITestsLaunchTests.swift; sourceTree = ""; }; + 193D52E82CAC78C0004F20AA /* MuxPlayerSwiftExample.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = MuxPlayerSwiftExample.xctestplan; sourceTree = ""; }; 1966C52F2BEB4740005486D5 /* ProcessInfo+EnvironmentVariables.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProcessInfo+EnvironmentVariables.swift"; sourceTree = ""; }; 19DD16AE2BEC010400F4DF4F /* SinglePlayerExampleController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SinglePlayerExampleController.swift; sourceTree = ""; }; 19DD16B02BEC028C00F4DF4F /* SmartCacheExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SmartCacheExampleViewController.swift; sourceTree = ""; }; @@ -89,6 +90,7 @@ 193228AE2ACF6AC700966FE1 = { isa = PBXGroup; children = ( + 193D52E82CAC78C0004F20AA /* MuxPlayerSwiftExample.xctestplan */, 193228B92ACF6AC700966FE1 /* MuxPlayerSwiftExample */, 193228D02ACF6AC900966FE1 /* MuxPlayerSwiftExampleTests */, 193228DA2ACF6AC900966FE1 /* MuxPlayerSwiftExampleUITests */, diff --git a/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample.xcodeproj/xcshareddata/xcschemes/MuxPlayerSwiftExample.xcscheme b/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample.xcodeproj/xcshareddata/xcschemes/MuxPlayerSwiftExample.xcscheme index 22a8ff6c..2262ec05 100644 --- a/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample.xcodeproj/xcshareddata/xcschemes/MuxPlayerSwiftExample.xcscheme +++ b/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample.xcodeproj/xcshareddata/xcschemes/MuxPlayerSwiftExample.xcscheme @@ -26,8 +26,13 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES" - shouldAutocreateTestPlan = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES"> + + + + - + - + @@ -43,6 +43,7 @@ + @@ -97,6 +98,7 @@ + diff --git a/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample/SinglePlayerExampleController.swift b/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample/SinglePlayerExampleController.swift index 5d60a4cf..f6346696 100644 --- a/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample/SinglePlayerExampleController.swift +++ b/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample/SinglePlayerExampleController.swift @@ -100,6 +100,8 @@ class SinglePlayerExampleController: UIViewController { super.viewDidLoad() view.backgroundColor = .black + view.accessibilityLabel = "A single player example that uses AVPlayerViewController" + view.accessibilityIdentifier = "SinglePlayerView" let maximumResolutionsMenu = UIMenu( title: "Set Maximum Resolution", diff --git a/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample/SinglePlayerLayerExampleViewController.swift b/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample/SinglePlayerLayerExampleViewController.swift index 47c83d35..560481b8 100644 --- a/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample/SinglePlayerLayerExampleViewController.swift +++ b/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample/SinglePlayerLayerExampleViewController.swift @@ -106,6 +106,8 @@ class SinglePlayerLayerExampleViewController: UIViewController { super.viewDidLoad() playerView.backgroundColor = .black + view.accessibilityLabel = "A single player example that uses AVPlayerLayer" + view.accessibilityIdentifier = "SinglePlayerLayerView" playerView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(playerView) diff --git a/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExampleTests/MuxPlayerSwiftExampleTests.swift b/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExampleTests/MuxPlayerSwiftExampleTests.swift index 3c4dac28..aea3cbc0 100644 --- a/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExampleTests/MuxPlayerSwiftExampleTests.swift +++ b/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExampleTests/MuxPlayerSwiftExampleTests.swift @@ -15,20 +15,4 @@ final class MuxPlayerSwiftExampleTests: XCTestCase { override func tearDownWithError() throws { // Put teardown code here. This method is called after the invocation of each test method in the class. } - - func testExample() throws { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. - // Any test you write for XCTest can be annotated as throws and async. - // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. - // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. - } - - func testPerformanceExample() throws { - // This is an example of a performance test case. - self.measure { - // Put the code you want to measure the time of here. - } - } - } diff --git a/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExampleUITests/MuxPlayerSwiftExampleUITests.swift b/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExampleUITests/MuxPlayerSwiftExampleUITests.swift index 8c2134c6..8f1fcbca 100644 --- a/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExampleUITests/MuxPlayerSwiftExampleUITests.swift +++ b/Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExampleUITests/MuxPlayerSwiftExampleUITests.swift @@ -20,20 +20,96 @@ final class MuxPlayerSwiftExampleUITests: XCTestCase { // Put teardown code here. This method is called after the invocation of each test method in the class. } - func testExample() throws { - // UI tests must launch the application that they test. - let app = XCUIApplication() - app.launch() + func launchAndWaitUntilInForeground( + application: XCUIApplication + ) throws { + application.launchEnvironment = [ + "ENV_KEY": "qr9665qr78dac0hqld9bjofps", + "PLAYBACK_ID": "qxb01i6T202018GFS02vp9RIe01icTcDCjVzQpmaB00CUisJ4" + ] + application.launch() - // Use XCTAssert and related functions to verify your tests produce the correct results. + let isRunningInForeground = application.wait( + for: .runningForeground, + timeout: 5.0 + ) + + guard isRunningInForeground else { + XCTFail("Failed to launch application") + return + } } - func testLaunchPerformance() throws { - if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { - // This measures how long it takes to launch your application. - measure(metrics: [XCTApplicationLaunchMetric()]) { - XCUIApplication().launch() - } + func tapCell( + cellIdentifier: String, + waitFor viewIdentifier: String, + application: XCUIApplication + ) throws { + let cellElement = application.cells.element( + matching: .cell, + identifier: cellIdentifier + ) + + guard cellElement.exists else { + XCTFail("Failed to find cell element: \(cellIdentifier)") + return + } + + cellElement.tap() + + let viewElement = application.descendants( + matching: .any + ).element( + matching: .any, + identifier: viewIdentifier + ) + + let isViewElementOnScreen = viewElement.waitForExistence( + timeout: 150.0 + ) + + guard isViewElementOnScreen else { + XCTFail("Failed to navigate to view element: \(viewIdentifier)") + return + } + + let isUnknown = application.wait( + for: .unknown, + timeout: 25.0 + ) + + guard !isUnknown else { + XCTFail("Application interrupted while playing video") + return } } + + + func testVideoOnDemandPlayerViewController() throws { + let application = XCUIApplication() + + try launchAndWaitUntilInForeground( + application: application + ) + + try tapCell( + cellIdentifier: "SinglePlayerExample", + waitFor: "SinglePlayerView", + application: application + ) + } + + func testVideoOnDemandPlayerLayer() throws { + let application = XCUIApplication() + + try launchAndWaitUntilInForeground( + application: application + ) + + try tapCell( + cellIdentifier: "SinglePlayerLayerExample", + waitFor: "SinglePlayerLayerView", + application: application + ) + } }