[AVFoundaation] Fix bug 44322 - AVAssetDownloadUrlSession.CreateSession throws a System.InvalidCastException: Specified cast is not valid.
https://bugzilla.xamarin.com/show_bug.cgi?id=44322 AVAssetDownloadUrlSession.CreateSession according to headers it should return an AVAssetDownloadUrlSession but it is returning an apple internal type NSURLBackgroundSession so with our current bindings it throws an InvalidCastException, adding ForcedTypeAttribute will create the managed type wihout the actual typecheck. Added test verifing that the API no longer throws.
This commit is contained in:
Родитель
bcbe813ab1
Коммит
7845caa577
|
@ -10453,6 +10453,7 @@ namespace XamCore.AVFoundation {
|
||||||
[BaseType (typeof (NSUrlSession), Name = "AVAssetDownloadURLSession")]
|
[BaseType (typeof (NSUrlSession), Name = "AVAssetDownloadURLSession")]
|
||||||
interface AVAssetDownloadUrlSession {
|
interface AVAssetDownloadUrlSession {
|
||||||
[Static]
|
[Static]
|
||||||
|
[ForcedType]
|
||||||
[Export ("sessionWithConfiguration:assetDownloadDelegate:delegateQueue:")]
|
[Export ("sessionWithConfiguration:assetDownloadDelegate:delegateQueue:")]
|
||||||
AVAssetDownloadUrlSession CreateSession (NSUrlSessionConfiguration configuration, [NullAllowed] IAVAssetDownloadDelegate @delegate, [NullAllowed] NSOperationQueue delegateQueue);
|
AVAssetDownloadUrlSession CreateSession (NSUrlSessionConfiguration configuration, [NullAllowed] IAVAssetDownloadDelegate @delegate, [NullAllowed] NSOperationQueue delegateQueue);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#if !__WATCHOS__ && !__TVOS__
|
#if !__WATCHOS__ && !__TVOS__
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using ObjCRuntime;
|
||||||
|
|
||||||
#if XAMCORE_2_0
|
#if XAMCORE_2_0
|
||||||
using Foundation;
|
using Foundation;
|
||||||
|
@ -38,6 +39,20 @@ namespace monotouchtest {
|
||||||
Assert.Throws <NotSupportedException> (() => AVAssetDownloadUrlSession.FromWeakConfiguration (NSUrlSessionConfiguration.DefaultSessionConfiguration, new NSObject (), null), "FromWeakConfiguration should throw NotSupportedException");
|
Assert.Throws <NotSupportedException> (() => AVAssetDownloadUrlSession.FromWeakConfiguration (NSUrlSessionConfiguration.DefaultSessionConfiguration, new NSObject (), null), "FromWeakConfiguration should throw NotSupportedException");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CreateSessionTest ()
|
||||||
|
{
|
||||||
|
if (!TestRuntime.CheckXcodeVersion (7, 0))
|
||||||
|
Assert.Ignore ("Ignoring AVAssetDownloadUrlSession tests: Requires iOS9+");
|
||||||
|
|
||||||
|
if (Runtime.Arch == Arch.DEVICE)
|
||||||
|
Assert.Ignore ("Ignoring CreateSessionTest tests: Requires com.apple.developer.media-asset-download entitlement");
|
||||||
|
|
||||||
|
using (var backgroundConfiguration = NSUrlSessionConfiguration.CreateBackgroundSessionConfiguration ("HLS-Identifier")) {
|
||||||
|
Assert.DoesNotThrow (() => AVAssetDownloadUrlSession.CreateSession (backgroundConfiguration, null, NSOperationQueue.MainQueue), "Should not throw InvalidCastException");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: Disabling this test from now, will reenable once apple releases docs on what is ecpected to have this entitlement key
|
// FIXME: Disabling this test from now, will reenable once apple releases docs on what is ecpected to have this entitlement key
|
||||||
// Reason: Creating an AVAssetDownloadURLSession requires the com.apple.developer.media-asset-download entitlement
|
// Reason: Creating an AVAssetDownloadURLSession requires the com.apple.developer.media-asset-download entitlement
|
||||||
// [Test]
|
// [Test]
|
||||||
|
|
Загрузка…
Ссылка в новой задаче