Screenshot.swift 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.tapTabBarItem(.Video)
  31. app.collectionViews.cells.element(boundBy: 0).tap()
  32. XCUIDevice.shared.orientation = .landscapeLeft
  33. snapshot("playback")
  34. }
  35. func testCaptureAudioTab() {
  36. helper.tapTabBarItem(.Audio)
  37. snapshot("audio_tab")
  38. }
  39. func testCaptureNetworkTab() {
  40. helper.tapTabBarItem(.LocalNetwork)
  41. snapshot("network_tab")
  42. }
  43. func testCaptureVideoTab() {
  44. helper.tapTabBarItem(.Video)
  45. snapshot("video_tab")
  46. }
  47. func download(name fileName: String) {
  48. helper.tapTabBarItem(.LocalNetwork)
  49. app.cells["Downloads"].tap()
  50. let downloadTextfield = app.textFields["http://myserver.com/file.mkv"]
  51. downloadTextfield.clearAndEnter(text: fileName)
  52. app.buttons["Download"].tap()
  53. let cancelDownloadButton = app.buttons["flatDeleteButton"]
  54. let predicate = NSPredicate(format: "exists == 0")
  55. expectation(for: predicate, evaluatedWith: cancelDownloadButton, handler: nil)
  56. waitForExpectations(timeout: 20.0) { err in
  57. XCTAssertNil(err)
  58. downloadTextfield.typeText("\n")
  59. }
  60. }
  61. }