Skip to content

Commit 4850b10

Browse files
committed
Merge branch 'main' into dev/grendel/blobs-in-lib
* main: [tests] add test for Microsoft.Intune (#7926)
2 parents daf3ed3 + 0808d18 commit 4850b10

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/KnownPackages.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,10 @@ public static class KnownPackages
592592
Id = "SkiaSharp.Views",
593593
Version = "2.88.3",
594594
};
595+
public static Package Microsoft_Intune_Maui_Essentials_android = new Package {
596+
Id = "Microsoft.Intune.Maui.Essentials.android",
597+
Version = "10.0.0-beta",
598+
};
595599
}
596600
}
597601

tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,5 +1130,39 @@ public void FixLegacyResourceDesignerStep ([Values (true, false)] bool isRelease
11301130
Assert.IsTrue (didLaunch, "Activity should have started.");
11311131
}
11321132
}
1133+
1134+
[Test]
1135+
public void MicrosoftIntune ([Values (false, true)] bool isRelease)
1136+
{
1137+
proj = new XamarinAndroidApplicationProject {
1138+
IsRelease = isRelease,
1139+
PackageReferences = {
1140+
KnownPackages.AndroidXAppCompat,
1141+
KnownPackages.Microsoft_Intune_Maui_Essentials_android,
1142+
},
1143+
};
1144+
proj.MainActivity = proj.DefaultMainActivity
1145+
.Replace ("Icon = \"@drawable/icon\")]", "Icon = \"@drawable/icon\", Theme = \"@style/Theme.AppCompat.Light.DarkActionBar\")]")
1146+
.Replace ("public class MainActivity : Activity", "public class MainActivity : AndroidX.AppCompat.App.AppCompatActivity");
1147+
var abis = new string [] { "armeabi-v7a", "arm64-v8a", "x86", "x86_64" };
1148+
proj.SetAndroidSupportedAbis (abis);
1149+
builder = CreateApkBuilder ();
1150+
builder.BuildLogFile = "install.log";
1151+
Assert.IsTrue (builder.Install (proj), "Install should have succeeded.");
1152+
1153+
var intermediate = Path.Combine (Root, builder.ProjectDirectory, proj.IntermediateOutputPath);
1154+
var dexFile = Path.Combine (intermediate, "android", "bin", "classes.dex");
1155+
FileAssert.Exists (dexFile);
1156+
var className = "Lcom/xamarin/microsoftintune/MainActivity;";
1157+
var methodName = "onMAMCreate";
1158+
Assert.IsTrue (DexUtils.ContainsClassWithMethod (className, methodName, "(Landroid/os/Bundle;)V", dexFile, AndroidSdkPath), $"`{dexFile}` should include `{className}` and `{methodName}!");
1159+
1160+
RunProjectAndAssert (proj, builder);
1161+
1162+
WaitForPermissionActivity (Path.Combine (Root, builder.ProjectDirectory, "permission-logcat.log"));
1163+
bool didLaunch = WaitForActivityToStart (proj.PackageName, "MainActivity",
1164+
Path.Combine (Root, builder.ProjectDirectory, "logcat.log"), 30);
1165+
Assert.IsTrue (didLaunch, "Activity should have started.");
1166+
}
11331167
}
11341168
}

0 commit comments

Comments
 (0)