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