Skip to content

Commit ec78c1f

Browse files
committed
Test the debug typemaps
1 parent b81132f commit ec78c1f

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,18 @@ public void SingleProject_ApplicationId ([Values (false, true)] bool testOnly)
565565
}
566566

567567
[Test]
568-
public void AppWithStyleableUsageRuns ([Values (true, false)] bool isRelease, [Values (true, false)] bool linkResources)
568+
public void AppWithStyleableUsageRuns ([Values (true, false)] bool useCLR, [Values (true, false)] bool isRelease,
569+
[Values (true, false)] bool linkResources, [Values (true, false)] bool useStringTypeMaps)
569570
{
571+
// Not all combinations are valid, ignore those that aren't
572+
if (!useCLR && useStringTypeMaps) {
573+
Assert.Ignore ("String-based typemaps mode is used only in CoreCLR apps");
574+
}
575+
576+
if (useCLR && isRelease && useStringTypeMaps) {
577+
Assert.Ignore ("String-based typemaps mode is available only in Debug CoreCLR builds");
578+
}
579+
570580
var rootPath = Path.Combine (Root, "temp", TestName);
571581
var lib = new XamarinAndroidLibraryProject () {
572582
ProjectName = "Styleable.Library"
@@ -615,6 +625,7 @@ public MyLibraryLayout (Android.Content.Context context, Android.Util.IAttribute
615625
proj = new XamarinAndroidApplicationProject () {
616626
IsRelease = isRelease,
617627
};
628+
proj.SetProperty ("UseMonoRuntime", useCLR ? "false" : "true");
618629
proj.AddReference (lib);
619630

620631
proj.AndroidResources.Add (new AndroidItem.AndroidResource ("Resources\\values\\styleables.xml") {
@@ -652,15 +663,27 @@ public MyLayout (Android.Content.Context context, Android.Util.IAttributeSet att
652663
}
653664
");
654665

655-
var abis = new string [] { "armeabi-v7a", "arm64-v8a", "x86", "x86_64" };
666+
string[] abis = useCLR switch {
667+
true => new string [] { "arm64-v8a", "x86_64" },
668+
false => new string [] { "armeabi-v7a", "arm64-v8a", "x86", "x86_64" },
669+
};
670+
656671
proj.SetAndroidSupportedAbis (abis);
657672
var libBuilder = CreateDllBuilder (Path.Combine (rootPath, lib.ProjectName));
658673
Assert.IsTrue (libBuilder.Build (lib), "Library should have built succeeded.");
659674
builder = CreateApkBuilder (Path.Combine (rootPath, proj.ProjectName));
660675

661-
662676
Assert.IsTrue (builder.Install (proj), "Install should have succeeded.");
663-
RunProjectAndAssert (proj, builder);
677+
678+
Dictionary<string, string>? environmentVariables = null;
679+
if (useCLR && !isRelease && useStringTypeMaps) {
680+
// The variable must have content to enable string-based typemaps
681+
environmentVariables = new (StringComparer.Ordinal) {
682+
{"CI_TYPEMAP_DEBUG_USE_STRINGS", "yes"}
683+
};
684+
}
685+
686+
RunProjectAndAssert (proj, builder, environmentVariables: environmentVariables);
664687

665688
var didStart = WaitForActivityToStart (proj.PackageName, "MainActivity",
666689
Path.Combine (Root, builder.ProjectDirectory, "startup-logcat.log"));

0 commit comments

Comments
 (0)