我有一个AVPlayer,我想检查allowExternalPlayBack是否设置为false。所以在我的代码中我有类似
的东西NSURL *url = [NSURL URLWithString:@"https://www.apple.com"];
AVPlayerItem *item = [[AVPlayerItem alloc] initWithURL:url];
AVPlayer *player = [AVPlayer playerWithPlayerItem:item];
player.allowsExternalPlayback = NO;
当我尝试在单元测试中测试它时,即使在下面的代码中,这也不起作用。
NSURL *url = [NSURL URLWithString:@"https://www.apple.com"];
AVPlayerItem *item = [[AVPlayerItem alloc] initWithURL:url];
AVPlayer *player = [AVPlayer playerWithPlayerItem:item];
player.allowsExternalPlayback = NO;
XCTAssertFalse(player.allowsExternalPlayback);
结果:allowsExternalPlayback仍为YES 预期结果:allowsExternalPlayback为NO(在断言点)