From f513048c92687a367379476e26ceb0e64461104b Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Tue, 7 Nov 2023 10:24:19 +0000 Subject: [PATCH] [Tests] Fix Designer Tests to use ` AndroidSdkResolver.GetMaxInstalledPlatform ()` Our designer tests were not using ` AndroidSdkResolver.GetMaxInstalledPlatform ()`. As a result if the `android-27` platform was NOT installed the unit tests would fail. Lets update the system to use the helper method to find the latest installed platform and use that. --- .../Tasks/ManagedResourceParserTests.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ManagedResourceParserTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ManagedResourceParserTests.cs index ec969f4dfd8..67485ff7f8d 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ManagedResourceParserTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ManagedResourceParserTests.cs @@ -398,7 +398,8 @@ GenerateResourceDesigner CreateTask (string path) }; task.CaseMapFile = Path.Combine (Root, path, "case_map.txt"); task.IsApplication = true; - task.JavaPlatformJarPath = Path.Combine (AndroidSdkDirectory, "platforms", "android-27", "android.jar"); + int platform = AndroidSdkResolver.GetMaxInstalledPlatform (); + task.JavaPlatformJarPath = Path.Combine (AndroidSdkDirectory, "platforms", $"android-{platform}", "android.jar"); return task; } @@ -496,7 +497,8 @@ public void UpdateLayoutIdIsIncludedInDesigner ([Values(true, false)] bool useRt task.CaseMapFile = Path.Combine (Root, path, "case_map.txt"); File.WriteAllText (task.ResourceFlagFile, string.Empty); task.IsApplication = true; - task.JavaPlatformJarPath = Path.Combine (AndroidSdkDirectory, "platforms", "android-27", "android.jar"); + int platform = AndroidSdkResolver.GetMaxInstalledPlatform (); + task.JavaPlatformJarPath = Path.Combine (AndroidSdkDirectory, "platforms", $"android-{platform}", "android.jar"); Assert.IsTrue (task.Execute (), "Task should have executed successfully."); Assert.IsTrue (File.Exists (task.NetResgenOutputFile), $"{task.NetResgenOutputFile} should have been created."); var expected = Path.Combine (ExpectedOutputDir, "GenerateDesignerFileExpected.cs"); @@ -811,7 +813,8 @@ int styleable ElevenAttributes_attr09 9 task.ResourceDirectory = Path.Combine (Root, path, "res"); task.Resources = new TaskItem [] {}; task.IsApplication = true; - task.JavaPlatformJarPath = Path.Combine (AndroidSdkDirectory, "platforms", "android-27", "android.jar"); + int platform = AndroidSdkResolver.GetMaxInstalledPlatform (); + task.JavaPlatformJarPath = Path.Combine (AndroidSdkDirectory, "platforms", $"android-{platform}", "android.jar"); Assert.IsTrue (task.Execute (), "Task should have executed successfully."); Assert.IsTrue (File.Exists (task.NetResgenOutputFile), $"{task.NetResgenOutputFile} should have been created."); var expected = Path.Combine (ExpectedOutputDir, "GenerateDesignerFileWithElevenStyleableAttributesExpected.cs");