ObjC单元测试允许外部播放

时间:2015-11-25 13:28:34

标签: objective-c unit-testing

我有一个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(在断言点)

0 个答案:

没有答案