VLC_for_iOSTestVideoCodecs.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // VLC_for_iOSTestVideoCodecs.m
  3. // VLC for iOSUITests
  4. //
  5. // Created by Carola Nitz on 9/25/17.
  6. // Copyright © 2017 VideoLAN. All rights reserved.
  7. //
  8. #import <XCTest/XCTest.h>
  9. @interface XCUIElement(Test)
  10. - (void)clearAndEnterText:(NSString *)text;
  11. @end
  12. @implementation XCUIElement(Test)
  13. - (void)clearAndEnterText:(NSString *)text {
  14. if( ![[self value] isKindOfClass:[NSString class]]) {
  15. XCTFail("Tried to clear and enter text into a non string value");
  16. return;
  17. }
  18. [self tap];
  19. NSString *deleteString = @"";
  20. for (int i = 0; i < [(NSString *)[self value] length]; i++){
  21. deleteString = [deleteString stringByAppendingString:XCUIKeyboardKeyDelete];
  22. }
  23. [self typeText:deleteString];
  24. [self typeText:text];
  25. }
  26. @end
  27. @interface VLC_for_iOSTestVideoCodecs : XCTestCase
  28. @end
  29. @implementation VLC_for_iOSTestVideoCodecs
  30. - (void)setUp {
  31. [super setUp];
  32. self.continueAfterFailure = YES;
  33. [[[XCUIApplication alloc] init] launch];
  34. [[XCUIDevice sharedDevice] setOrientation:UIDeviceOrientationFaceUp];
  35. }
  36. - (void)tearDown {
  37. // Put teardown code here. This method is called after the invocation of each test method in the class.
  38. [super tearDown];
  39. }
  40. - (void)testMovCodec
  41. {
  42. [self playWithFilename:@"rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov"];
  43. }
  44. - (void)testHEVCCodec10b
  45. {
  46. [self playWithFilename:@"http://jell.yfish.us/media/jellyfish-90-mbps-hd-hevc-10bit.mkv"];
  47. }
  48. - (void)testHEVCCodec
  49. {
  50. [self playWithFilename:@"http://jell.yfish.us/media/jellyfish-25-mbps-hd-hevc.mkv"];
  51. }
  52. - (void)testH264Codec
  53. {
  54. [self playWithFilename:@"http://jell.yfish.us/media/jellyfish-25-mbps-hd-h264.mkv"];
  55. }
  56. - (void)playWithFilename:(NSString *)filename
  57. {
  58. XCUIApplication *app = [[XCUIApplication alloc] init];
  59. [app.navigationBars[@"All Files"].buttons[@"Open VLC sidebar menu"] tap];
  60. [app.cells.staticTexts[@"Network Stream"] tap];
  61. XCUIElement *httpMyserverComFileMkvTextField = app.textFields.allElementsBoundByIndex.firstObject;
  62. [httpMyserverComFileMkvTextField clearAndEnterText:filename];
  63. [[[XCUIApplication alloc] init].buttons[@"Open Network Stream"] tap];
  64. XCUIElement *displayTime = app.buttons[@"--:--"];
  65. __block NSPredicate *predicate = [NSPredicate predicateWithFormat:@"exists == 0"];
  66. [self expectationForPredicate:predicate evaluatedWithObject:displayTime handler:nil];
  67. //we wait for the displaytime to change
  68. [self waitForExpectationsWithTimeout:20.0 handler:^(NSError * _Nullable error) {
  69. //once it changes we tap the videoplayer to bring up the playelements
  70. [app.otherElements[@"Video Player"] doubleTap];
  71. XCUIElement *playpause = app.buttons[@"Play or Pause current playback"];
  72. predicate = [NSPredicate predicateWithFormat:@"exists == 1"];
  73. [self expectationForPredicate:predicate evaluatedWithObject:playpause handler:nil];
  74. [self waitForExpectationsWithTimeout:20.0 handler:nil];
  75. }];
  76. }
  77. @end