[tests] add test for Microsoft.Intune (#7926)
Context: https://www.nuget.org/packages/Microsoft.Intune.Maui.Essentials.android/9.5.2-beta The `Microsoft.Intune.Maui.Essentials.android` makes use of specific MSBuild targets and "remapping" features. We should add a test verifying that it stays working over time. Assert `MainActivity.onMAMCreate` exists in `classes.dex`, to verify this package actually "does something". Otherwise, the test would just pass if we removed the Intune package.
This commit is contained in:
Родитель
9ace5da646
Коммит
93b3d00ac5
|
@ -592,6 +592,10 @@ namespace Xamarin.ProjectTools
|
|||
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",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1170,5 +1170,39 @@ namespace UnnamedProject
|
|||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче