Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
}
}

36 changes: 36 additions & 0 deletions tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1130,5 +1130,41 @@ public void FixLegacyResourceDesignerStep ([Values (true, false)] bool isRelease
Assert.IsTrue (didLaunch, "Activity should have started.");
}
}

[Test]
public void MicrosoftIntune ([Values (false, true)] bool isRelease)
{
if (!Builder.UseDotNet)
Assert.Ignore ("Test is only valid in .NET 8+");
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.");
}
}
}