VLCiOSTestVideoCodecs.swift 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*****************************************************************************
  2. * VLCiOSTestVideoCodecs.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 VLCiOSTestVideoCodecs: XCTestCase {
  15. let app = XCUIApplication()
  16. let helper = LocaleHelper(lang: deviceLanguage, target: VLCiOSTestVideoCodecs.self)
  17. let moreTab = XCUIApplication().tabBars.buttons.element(boundBy: 4)
  18. override func setUp() {
  19. super.setUp()
  20. XCUIDevice.shared.orientation = .portrait
  21. setupSnapshot(app)
  22. app.launch()
  23. }
  24. func testDownload() {
  25. download(name: "http://jell.yfish.us/media/jellyfish-10-mbps-hd-h264.mkv")
  26. app.tabBars.buttons["Video"].tap()
  27. app.collectionViews.cells.element(boundBy: 0).tap()
  28. app.navigationBars["VLCMovieView"].buttons[helper.localized(key: "VIDEO_ASPECT_RATIO_BUTTON")].tap()
  29. snapshot("playback")
  30. }
  31. func testMovCodec() {
  32. stream(named: "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov")
  33. }
  34. func testHEVCCodec10b() {
  35. stream(named: "http://jell.yfish.us/media/jellyfish-90-mbps-hd-hevc-10bit.mkv")
  36. }
  37. func testHEVCCodec() {
  38. stream(named: "http://jell.yfish.us/media/jellyfish-25-mbps-hd-hevc.mkv")
  39. }
  40. func testH264Codec() {
  41. stream(named: "http://jell.yfish.us/media/jellyfish-25-mbps-hd-h264.mkv")
  42. }
  43. func download(name fileName: String) {
  44. moreTab.tap()
  45. app.staticTexts[helper.localized(key: "DOWNLOAD_FROM_HTTP")].tap()
  46. let downloadTextfield = app.textFields["http://myserver.com/file.mkv"]
  47. downloadTextfield.clearAndEnter(text: fileName)
  48. app.buttons[helper.localized(key: "BUTTON_DOWNLOAD")].tap()
  49. let cancelDownloadButton = app.buttons["flatDeleteButton"]
  50. let predicate = NSPredicate(format: "exists == 0")
  51. expectation(for: predicate, evaluatedWith: cancelDownloadButton, handler: nil)
  52. waitForExpectations(timeout: 20.0) { err in
  53. XCTAssertNil(err)
  54. downloadTextfield.typeText("\n")
  55. }
  56. }
  57. func stream(named fileName: String) {
  58. moreTab.tap()
  59. app.staticTexts[helper.localized(key: "OPEN_NETWORK")].tap()
  60. let addressTextField = app.textFields["http://myserver.com/file.mkv"]
  61. addressTextField.clearAndEnter(text: fileName)
  62. app.buttons[helper.localized(key: "OPEN_NETWORK")].tap()
  63. let displayTime = app.navigationBars["VLCMovieView"].buttons["--:--"]
  64. let zeroPredicate = NSPredicate(format: "exists == 0")
  65. expectation(for: zeroPredicate, evaluatedWith: displayTime, handler: nil)
  66. waitForExpectations(timeout: 20.0) { err in
  67. XCTAssertNil(err)
  68. if !(self.app.buttons[self.helper.localized(key: "BUTTON_DONE")].exists) {
  69. self.app.otherElements[self.helper.localized(key: "VO_VIDEOPLAYER_TITLE")].tap()
  70. }
  71. let playPause = self.app.buttons[self.helper.localized(key: "PLAY_PAUSE_BUTTON")]
  72. let onePredicate = NSPredicate(format: "exists == 1")
  73. self.expectation(for: onePredicate, evaluatedWith: playPause, handler: nil)
  74. self.waitForExpectations(timeout: 20.0, handler: nil)
  75. }
  76. }
  77. }