有没有办法评估MPMoviePlayerViewController是否正在使用XCTest的UI测试框架播放或暂停?
我可以通过录音机吐出的这段漂亮的代码来管理视频元素
[[[[[[[[app.otherElements[@"VideoPlayer_ViewController"] childrenMatchingType:XCUIElementTypeOther] elementBoundByIndex:0]
childrenMatchingType:XCUIElementTypeOther].element
childrenMatchingType:XCUIElementTypeOther].element
childrenMatchingType:XCUIElementTypeOther] matchingIdentifier:@"Video"]
但我没有在XCUIElement接口或XCUIElementAttributes协议中看到任何可以帮助我断言播放器正在播放或暂停的内容。有什么建议吗?
答案 0 :(得分:0)
结束设置accessibilityValue
视图控制器视图的MPMoviePlayerViewController
,如此
- (void)moviePlayerPlaybackStateDidChange:(NSNotification *)notification
{
if (self.player.playbackState == MPMoviePlaybackStatePlaying) {
self.view.accessibilityValue = @"MPMoviePlaybackStatePlaying";
}
if (self.player.playbackState == MPMoviePlaybackStatePaused) {
self.view.accessibilityValue = @"MPMoviePlaybackStatePaused";
}
}
然后我可以像这样访问
// Playing
[[[XCUIApplication alloc] init].otherElements[@"VideoPlayer_ViewController"].value isEqualToString:@"MPMoviePlaybackStatePlaying"];
// Paused
[[[XCUIApplication alloc] init].otherElements[@"VideoPlayer_ViewController"].value isEqualToString:@"MPMoviePlaybackStatePaused"];