|
4 | 4 |
|
5 | 5 | @import os.log;
|
6 | 6 | @import XCTest;
|
| 7 | +@import CoreGraphics; |
7 | 8 |
|
8 | 9 | @interface VideoPlayerUITests : XCTestCase
|
9 | 10 | @property(nonatomic, strong) XCUIApplication *app;
|
@@ -78,20 +79,29 @@ - (void)testEncryptedVideoStream {
|
78 | 79 | XCTAssertTrue(selectedTab.isSelected);
|
79 | 80 |
|
80 | 81 | // Wait until the video is loaded.
|
81 |
| - [NSThread sleepForTimeInterval:60]; |
| 82 | + [NSThread sleepForTimeInterval:5]; |
82 | 83 |
|
83 | 84 | NSMutableSet *frames = [NSMutableSet set];
|
84 |
| - int numberOfFrames = 60; |
| 85 | + int numberOfFrames = 5; |
85 | 86 | for (int i = 0; i < numberOfFrames; i++) {
|
86 |
| - XCUIScreenshot *screenshot = self.app.screenshot; |
| 87 | + UIImage *image = self.app.screenshot.image; |
87 | 88 |
|
88 |
| - // Attach the screenshots for debugging if the test fails. |
89 |
| - XCTAttachment *attachment = [XCTAttachment attachmentWithScreenshot:screenshot]; |
90 |
| - attachment.lifetime = XCTAttachmentLifetimeKeepAlways; |
91 |
| - [self addAttachment:attachment]; |
| 89 | + // Plugin CI does not support attaching screenshot. |
| 90 | + // Convert the image to base64 encoded string, and print it out for debugging purpose. |
| 91 | + // NSLog truncates long strings, so need to scale downn image. |
| 92 | + CGSize smallerSize = CGSizeMake(100, 200); |
| 93 | + UIGraphicsBeginImageContextWithOptions(smallerSize, NO, 0.0); |
| 94 | + [image drawInRect:CGRectMake(0, 0, smallerSize.width, smallerSize.height)]; |
| 95 | + UIImage *smallerImage = UIGraphicsGetImageFromCurrentImageContext(); |
| 96 | + UIGraphicsEndImageContext(); |
| 97 | + |
| 98 | + // 0.5 compression is good enough for debugging purpose. |
| 99 | + NSData *imageData = UIImageJPEGRepresentation(smallerImage, 0.5); |
| 100 | + NSString *imageString = [imageData base64EncodedStringWithOptions:0]; |
| 101 | + NSLog(@"frame %d image data:\n%@", i, imageString); |
| 102 | + |
| 103 | + [frames addObject:imageString]; |
92 | 104 |
|
93 |
| - UIImage *image = screenshot.image; |
94 |
| - [frames addObject:UIImagePNGRepresentation(image)]; |
95 | 105 | // The sample interval must NOT be the same as video length.
|
96 | 106 | // Otherwise it would always result in the same frame.
|
97 | 107 | [NSThread sleepForTimeInterval:1];
|
|
0 commit comments