diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/KnownPackages.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/KnownPackages.cs index 5caf109940b..baac0375292 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/KnownPackages.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/KnownPackages.cs @@ -592,6 +592,10 @@ public static class KnownPackages Id = "SkiaSharp.Views", Version = "2.88.3", }; + public static Package Microsoft_Intune_Maui_Essentials_android = new Package { + Id = "Microsoft.Intune.Maui.Essentials.android", + Version = "10.0.0-beta", + }; } } diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs index 084db3dfc4c..ea9f5da4c7c 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs @@ -1130,5 +1130,39 @@ public void FixLegacyResourceDesignerStep ([Values (true, false)] bool isRelease Assert.IsTrue (didLaunch, "Activity should have started."); } } + + [Test] + public void MicrosoftIntune ([Values (false, true)] bool isRelease) + { + proj = new XamarinAndroidApplicationProject { + IsRelease = isRelease, + PackageReferences = { + KnownPackages.AndroidXAppCompat, + KnownPackages.Microsoft_Intune_Maui_Essentials_android, + }, + }; + proj.MainActivity = proj.DefaultMainActivity + .Replace ("Icon = \"@drawable/icon\")]", "Icon = \"@drawable/icon\", Theme = \"@style/Theme.AppCompat.Light.DarkActionBar\")]") + .Replace ("public class MainActivity : Activity", "public class MainActivity : AndroidX.AppCompat.App.AppCompatActivity"); + var abis = new string [] { "armeabi-v7a", "arm64-v8a", "x86", "x86_64" }; + proj.SetAndroidSupportedAbis (abis); + builder = CreateApkBuilder (); + builder.BuildLogFile = "install.log"; + Assert.IsTrue (builder.Install (proj), "Install should have succeeded."); + + var intermediate = Path.Combine (Root, builder.ProjectDirectory, proj.IntermediateOutputPath); + var dexFile = Path.Combine (intermediate, "android", "bin", "classes.dex"); + FileAssert.Exists (dexFile); + var className = "Lcom/xamarin/microsoftintune/MainActivity;"; + var methodName = "onMAMCreate"; + Assert.IsTrue (DexUtils.ContainsClassWithMethod (className, methodName, "(Landroid/os/Bundle;)V", dexFile, AndroidSdkPath), $"`{dexFile}` should include `{className}` and `{methodName}!"); + + RunProjectAndAssert (proj, builder); + + WaitForPermissionActivity (Path.Combine (Root, builder.ProjectDirectory, "permission-logcat.log")); + bool didLaunch = WaitForActivityToStart (proj.PackageName, "MainActivity", + Path.Combine (Root, builder.ProjectDirectory, "logcat.log"), 30); + Assert.IsTrue (didLaunch, "Activity should have started."); + } } }