mercredi 25 novembre 2015

ObjC Unit test allowsExternalPlayback

I have an AVPlayer where I want to check if allowsExternalPlayBack is set to false. So in my code I have something like

NSURL *url = [NSURL URLWithString:@"https://www.apple.com"];
AVPlayerItem *item = [[AVPlayerItem alloc] initWithURL:url];
AVPlayer *player = [AVPlayer playerWithPlayerItem:item];
player.allowsExternalPlayback = NO;

When I try to test this in a unit test, even in following code, This does not work.

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);

Result: allowsExternalPlayback is still YES Expected result: allowsExternalPlayback is NO (at the point of assertion)

Aucun commentaire:

Enregistrer un commentaire