Skip to content

Commit

Permalink
[tests] Add check for bluetooth permission
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentDondain committed Aug 19, 2019
1 parent d24f87b commit aa799d5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/common/TestRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#if !__WATCHOS__
using MediaPlayer;
#endif
using CoreBluetooth;
using UIKit;
#endif
using ObjCRuntime;
Expand Down Expand Up @@ -646,6 +647,24 @@ public static bool IgnoreTestThatRequiresSystemPermissions ()
return !string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("DISABLE_SYSTEM_PERMISSION_TESTS"));
}

#if !MONOMAC
public static void CheckBluetoothPermission (bool assert_granted = false)
{
var centralManager = new CBCentralManager ();
switch (centralManager.Authorization) {
case CBManagerAuthorization.NotDetermined:
if (IgnoreTestThatRequiresSystemPermissions ())
NUnit.Framework.Assert.Ignore ("This test would show a dialog to ask for permission to use bluetooth.");
break;
case CBManagerAuthorization.Denied:
case CBManagerAuthorization.Restricted:
if (assert_granted)
NUnit.Framework.Assert.Fail ("This test requires permission to use bluetooth.");
break;
}
}
#endif // !!MONOMAC

#if !MONOMAC && !__TVOS__ && !__WATCHOS__
public static void RequestCameraPermission (NSString mediaTypeToken, bool assert_granted = false)
{
Expand Down
3 changes: 3 additions & 0 deletions tests/monotouch-test/CoreBluetooth/CentralManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public override void DisconnectedPeripheral (CBCentralManager central, CBPeriphe
[SetUp]
public void SetUp ()
{
// iOS 13 and friends require bluetooth permission
if (TestRuntime.CheckXcodeVersion (11, 0))
TestRuntime.CheckBluetoothPermission ();
// Required API is available in macOS 10.8, but it doesn't work (hangs in 10.8-10.9, randomly crashes in 10.10) on the bots.
TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 10, 11, throwIfOtherPlatform: false);
var e = new AutoResetEvent (false);
Expand Down

3 comments on commit aa799d5

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Device tests completed (Failed) on iOS-Beta on Azure DevOps(iOS-Beta): Html Report 🔥

Test results

10 tests failed, 67 tests passed.

Failed tests

  • monotouch-test/iOS Unified 64-bits - device/Debug: Failed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Failed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Failed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Failed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Failed
  • monotouch-test/iOS Unified 64-bits - device/Release: Failed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Failed
  • monotouch-test/iOS Unified 64-bits - device/Release (all optimizations): Failed
  • monotouch-test/iOS Unified 64-bits - device/Debug (all optimizations): Failed
  • monotouch-test/iOS Unified 64-bits - device/Debug: SGenConc: Failed

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Device tests completed (Failed) on TvOS-Beta on Azure DevOps(TvOS-Beta): Html Report 🔥

Test results

10 tests failed, 67 tests passed.

Failed tests

  • mono-native-compat/tvOS - device/Debug: Failed
  • mono-native-unified/tvOS - device/Debug: Failed
  • mono-native-compat/tvOS - device/AssemblyBuildTarget: SDK framework (debug): Failed
  • mono-native-compat/tvOS - device/AssemblyBuildTarget: SDK framework (debug, profiling): Failed
  • mono-native-compat/tvOS - device/Release: Failed
  • mono-native-compat/tvOS - device/AssemblyBuildTarget: SDK framework (release): Failed
  • mono-native-unified/tvOS - device/AssemblyBuildTarget: SDK framework (debug): Failed
  • mono-native-unified/tvOS - device/AssemblyBuildTarget: SDK framework (debug, profiling): Failed
  • mono-native-unified/tvOS - device/Release: Failed
  • mono-native-unified/tvOS - device/AssemblyBuildTarget: SDK framework (release): Failed

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build was (probably) aborted

🔥 Jenkins job (on internal Jenkins) failed in stage(s) 'Package XM tests, Test run, Test run' 🔥

Build succeeded
✅ Packages: xamarin.ios-12.99.2.91.pkg xamarin.mac-5.99.2.91.pkg
API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Test run failed 🔥

Test results

5 tests failed, 229 tests passed.

Failed tests

  • xammac tests/Mac Modern/Debug: BuildFailure
  • xammac tests/Mac Modern/Debug: BuildFailure
  • xammac tests/Mac Modern/Release: BuildFailure
  • xammac tests/Mac Modern/Release: BuildFailure
  • monotouch-test/watchOS 32-bits - simulator/Debug: Crashed

Please sign in to comment.