Screenshot.swift 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*****************************************************************************
  2. * Screenshot.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 Screenshot: XCTestCase {
  15. let app = XCUIApplication()
  16. var helper: TestHelper!
  17. override func setUp() {
  18. super.setUp()
  19. XCUIDevice.shared.orientation = .portrait
  20. SDStatusBarManager.sharedInstance().enableOverrides()
  21. setupSnapshot(app)
  22. helper = TestHelper(app)
  23. app.launch()
  24. }
  25. override func tearDown() {
  26. SDStatusBarManager.sharedInstance().disableOverrides()
  27. }
  28. func testCaptureVideoPlayback() {
  29. download(name: "http://jell.yfish.us/media/jellyfish-10-mbps-hd-h264.mkv")
  30. helper.tap(.Video)
  31. app.collectionViews.cells.element(boundBy: 0).tap()
  32. XCUIDevice.shared.orientation = .landscapeLeft
  33. snapshot("playback")
  34. }
  35. func testCaptureAudioTab() {
  36. helper.tap(.Audio)
  37. snapshot("audio_tab")
  38. }
  39. func testCaptureNetworkTab() {
  40. helper.tap(.Server)
  41. snapshot("network_tab")
  42. }
  43. func testCaptureVideoTab() {
  44. helper.tap(.Video)
  45. snapshot("video_tab")
  46. }
  47. func download(name fileName: String) {
  48. helper.tap(.Downloads)
  49. let downloadTextfield = app.textFields["http://myserver.com/file.mkv"]
  50. downloadTextfield.clearAndEnter(text: fileName)
  51. app.buttons["Download"].tap()
  52. let cancelDownloadButton = app.buttons["flatDeleteButton"]
  53. let predicate = NSPredicate(format: "exists == 0")
  54. expectation(for: predicate, evaluatedWith: cancelDownloadButton, handler: nil)
  55. waitForExpectations(timeout: 20.0) { err in
  56. XCTAssertNil(err)
  57. downloadTextfield.typeText("\n")
  58. }
  59. }
  60. }