Skip to content

Commit

Permalink
[tests] Add check for bluetooth permission (#6796)
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentDondain authored Aug 21, 2019
1 parent dd39447 commit 37e7023
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/common/TestRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#if XAMCORE_2_0
using AVFoundation;
using CoreBluetooth;
using Foundation;
#if !__TVOS__
using Contacts;
Expand Down Expand Up @@ -654,6 +655,23 @@ public static bool IgnoreTestThatRequiresSystemPermissions ()
return !string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("DISABLE_SYSTEM_PERMISSION_TESTS"));
}

public static void CheckBluetoothPermission (bool assert_granted = false)
{
// New in Xcode11
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;
}
}

#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

6 comments on commit 37e7023

@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) 'Running XM tests on '10.15', Running XM tests on '10.15'' 🔥

Build succeeded
✅ Packages: xamarin.ios-12.99.3.6.pkg xamarin.mac-5.99.3.6.pkg
API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Xamarin.Mac tests on 10.15 failed: Xamarin.Mac tests on macOS 10.15 failed (introspection) 🔥
🔥 Test run failed 🔥

Test results

2 tests failed, 232 tests passed.

Failed tests

  • monotouch-test/watchOS 32-bits - simulator/Debug: Crashed
  • MTouch tests/NUnit: Failed (Execution failed with exit code 1)

@VincentDondain
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting state to success where context is VSTS: device tests (TvOS-Beta).

Known issue: https://github.com/xamarin/maccore/issues/1809

@VincentDondain
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting state to success where context is continuous-integration/jenkins/branch.

Failing MTouch test already fixed in #6821 and known HE0038 https://github.com/xamarin/maccore/issues/581

@VincentDondain
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting state to success where context is VSTS: device tests (iOS-Beta).

Test failures already fixed in #6823

Please sign in to comment.