Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit cb5c320

Browse files
committed
print out base 64 string instead of attach the image
1 parent 52a27f4 commit cb5c320

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

packages/video_player/video_player_avfoundation/example/ios/RunnerUITests/VideoPlayerUITests.m

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
@import os.log;
66
@import XCTest;
7+
@import CoreGraphics;
78

89
@interface VideoPlayerUITests : XCTestCase
910
@property(nonatomic, strong) XCUIApplication *app;
@@ -78,20 +79,29 @@ - (void)testEncryptedVideoStream {
7879
XCTAssertTrue(selectedTab.isSelected);
7980

8081
// Wait until the video is loaded.
81-
[NSThread sleepForTimeInterval:60];
82+
[NSThread sleepForTimeInterval:5];
8283

8384
NSMutableSet *frames = [NSMutableSet set];
84-
int numberOfFrames = 60;
85+
int numberOfFrames = 5;
8586
for (int i = 0; i < numberOfFrames; i++) {
86-
XCUIScreenshot *screenshot = self.app.screenshot;
87+
UIImage *image = self.app.screenshot.image;
8788

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];
92104

93-
UIImage *image = screenshot.image;
94-
[frames addObject:UIImagePNGRepresentation(image)];
95105
// The sample interval must NOT be the same as video length.
96106
// Otherwise it would always result in the same frame.
97107
[NSThread sleepForTimeInterval:1];

0 commit comments

Comments
 (0)