[monotouch-test] Check a few more permissions that sometimes make the app crash due to a TCC violation on Mac Catalyst. (#12134)
* [monotouch-test] Check a few more permissions that sometimes make the app crash due to a TCC violation on Mac Catalyst. * [monotouch-test] Adjust CaptureDeviceTest to only verify camera permission for Audio+Video, any other value is not supported by the OS. Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
This commit is contained in:
Родитель
7dd7960f57
Коммит
60fa8c90fe
|
@ -987,6 +987,12 @@ partial class TestRuntime
|
|||
#if !MONOMAC && !__TVOS__ && !__WATCHOS__
|
||||
public static void RequestCameraPermission (NSString mediaTypeToken, bool assert_granted = false)
|
||||
{
|
||||
#if __MACCATALYST__
|
||||
// Microphone requires a hardened runtime entitlement for Mac Catalyst: com.apple.security.device.microphonee,
|
||||
// so just ignore these tests for now.
|
||||
NUnit.Framework.Assert.Ignore ("Requires a hardened runtime entitlement: com.apple.security.device.microphone");
|
||||
#endif // __MACCATALYST__
|
||||
|
||||
if (AVCaptureDevice.GetAuthorizationStatus (mediaTypeToken) == AVAuthorizationStatus.NotDetermined) {
|
||||
if (IgnoreTestThatRequiresSystemPermissions ())
|
||||
NUnit.Framework.Assert.Ignore ("This test would show a dialog to ask for permission to access the camera.");
|
||||
|
@ -1077,6 +1083,10 @@ partial class TestRuntime
|
|||
// tvOS doesn't have a (developer-accessible) microphone, but it seems to have API that requires developers
|
||||
// to request microphone access on other platforms (which means that it makes sense to both run those tests
|
||||
// on tvOS (because the API's there) and to request microphone access (because that's required on other platforms).
|
||||
#elif __MACCATALYST__
|
||||
// Microphone requires a hardened runtime entitlement for Mac Catalyst: com.apple.security.device.microphonee,
|
||||
// so just ignore these tests for now.
|
||||
NUnit.Framework.Assert.Ignore ("Requires a hardened runtime entitlement: com.apple.security.device.microphone");
|
||||
#else
|
||||
if (!CheckXcodeVersion (6, 0))
|
||||
return; // The API to check/request permission isn't available in earlier versions, the dialog will just pop up.
|
||||
|
|
|
@ -21,6 +21,9 @@ namespace MonoTouchFixtures.AVFoundation {
|
|||
[Test]
|
||||
public void CompareConstantEnum ()
|
||||
{
|
||||
TestRuntime.RequestCameraPermission (AVMediaType.Audio, true);
|
||||
TestRuntime.RequestCameraPermission (AVMediaType.Video, true);
|
||||
|
||||
Compare (AVMediaType.Audio, AVMediaTypes.Audio);
|
||||
Compare (AVMediaType.ClosedCaption, AVMediaTypes.ClosedCaption);
|
||||
Compare (AVMediaType.Metadata, AVMediaTypes.Metadata);
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace MonoTouchFixtures.AudioToolbox {
|
|||
|
||||
public AudioSessionTest ()
|
||||
{
|
||||
TestRuntime.RequestMicrophonePermission ();
|
||||
AudioSession.Initialize ();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче