VLCTestVideoCodecs.swift 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*****************************************************************************
  2. * VLCTestVideoCodecs.swift
  3. * VLC for iOSUITests
  4. *****************************************************************************
  5. * Copyright (c) 2018 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Mike JS. Choi <mkchoi212 # icloud.com>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. import Foundation
  13. import XCTest
  14. class VLCTestVideoCodecs: XCTestCase {
  15. let app = XCUIApplication()
  16. var helper: TestHelper!
  17. override func setUp() {
  18. super.setUp()
  19. XCUIDevice.shared.orientation = .portrait
  20. setupSnapshot(app)
  21. helper = TestHelper(app)
  22. setupSnapshot(app)
  23. app.launch()
  24. }
  25. func testMovCodec() {
  26. stream(named: "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov")
  27. }
  28. func testHEVCCodec10b() {
  29. stream(named: "http://jell.yfish.us/media/jellyfish-90-mbps-hd-hevc-10bit.mkv")
  30. }
  31. func testHEVCCodec() {
  32. stream(named: "http://jell.yfish.us/media/jellyfish-25-mbps-hd-hevc.mkv")
  33. }
  34. func testH264Codec() {
  35. stream(named: "http://jell.yfish.us/media/jellyfish-25-mbps-hd-h264.mkv")
  36. }
  37. func stream(named fileName: String) {
  38. helper.tapTabBarItem(VLCAccessibilityIdentifier.localNetwork)
  39. app.cells[VLCAccessibilityIdentifier.stream].tap()
  40. let addressTextField = app.textFields["http://myserver.com/file.mkv"].firstMatch
  41. addressTextField.clearAndEnter(text: fileName)
  42. app.buttons["Open Network Stream"].tap()
  43. XCTContext.runActivity(named: "Wait for video to load") { _ in
  44. let displayTime = app.navigationBars["VLCMovieView"].buttons["--:--"]
  45. let zeroPredicate = NSPredicate(format: "exists == 0")
  46. let videoOpened = expectation(for: zeroPredicate, evaluatedWith: displayTime, handler: nil)
  47. wait(for: [videoOpened], timeout: 20.0)
  48. }
  49. XCTContext.runActivity(named: "Check if video is playing") { _ in
  50. let playPause = app.buttons[VLCAccessibilityIdentifier.playPause]
  51. let onePredicate = NSPredicate(format: "exists == 1")
  52. let videoPlaying = expectation(for: onePredicate, evaluatedWith: playPause, handler: nil)
  53. if !(app.navigationBars["VLCMovieView"].buttons["Done"].exists) {
  54. app.otherElements["Video Player Title"].tap()
  55. }
  56. wait(for: [videoPlaying], timeout: 20)
  57. }
  58. }
  59. }