From 1d1aefa7484205810b8add88a32540a41b1ac1a8 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Fri, 29 Jan 2021 07:59:17 -0600 Subject: [PATCH] [tests] add test for Fast Deployment & satellite assemblies (#5546) Context: https://github.com/xamarin/monodroid/pull/1156 This adds a class library project to `LocalizedAssemblies_ShouldBeFastDeployed` that contains satellite assemblies. The test now verifies that `es/Localization.resources.dll` is deployed. --- .../Tests/InstallTests.cs | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs index d33300a2081..7deaa229b29 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs @@ -440,7 +440,20 @@ public void LocalizedAssemblies_ShouldBeFastDeployed () AssertCommercialBuild (); AssertHasDevices (); - var proj = new XamarinAndroidApplicationProject { + var path = Path.Combine ("temp", TestName); + var lib = new XamarinAndroidLibraryProject { + ProjectName = "Localization", + OtherBuildItems = { + new BuildItem ("EmbeddedResource", "Bar.resx") { + TextContent = () => InlineData.ResxWithContents ("Cancel") + }, + new BuildItem ("EmbeddedResource", "Bar.es.resx") { + TextContent = () => InlineData.ResxWithContents ("Cancelar") + } + } + }; + + var app = new XamarinAndroidApplicationProject { EmbedAssembliesIntoApk = false, OtherBuildItems = { new BuildItem ("EmbeddedResource", "Foo.resx") { @@ -451,24 +464,26 @@ public void LocalizedAssemblies_ShouldBeFastDeployed () } } }; + app.References.Add (new BuildItem.ProjectReference ($"..\\{lib.ProjectName}\\{lib.ProjectName}.csproj", lib.ProjectName, lib.ProjectGuid)); - using (var builder = CreateApkBuilder ()) { - Assert.IsTrue (builder.Install (proj), "Install should have succeeded."); - var projectOutputPath = Path.Combine (Root, builder.ProjectDirectory, proj.OutputPath); + using (var libBuilder = CreateDllBuilder (Path.Combine (path, lib.ProjectName))) + using (var appBuilder = CreateApkBuilder (Path.Combine (path, app.ProjectName))) { + Assert.IsTrue (libBuilder.Build (lib), "Library Build should have succeeded."); + Assert.IsTrue (appBuilder.Install (app), "App Install should have succeeded."); + var projectOutputPath = Path.Combine (Root, appBuilder.ProjectDirectory, app.OutputPath); var resourceFilesFromDisk = Directory.EnumerateFiles (projectOutputPath, "*.resources.dll", SearchOption.AllDirectories) .Select (r => r = r.Replace (projectOutputPath, string.Empty).Replace ("\\", "/")); var overrideContents = string.Empty; - foreach (var dir in GetOverrideDirectoryPaths (proj.PackageName)) { - overrideContents += RunAdbCommand ($"shell run-as {proj.PackageName} find {dir}"); + foreach (var dir in GetOverrideDirectoryPaths (app.PackageName)) { + overrideContents += RunAdbCommand ($"shell run-as {app.PackageName} find {dir}"); } - builder.BuildLogFile = "uninstall.log"; - builder.Uninstall (proj); Assert.IsTrue (resourceFilesFromDisk.Any (), $"Unable to find any localized assemblies in {resourceFilesFromDisk}"); foreach (var res in resourceFilesFromDisk) { StringAssert.Contains (res, overrideContents, $"{res} did not exist in the .__override__ directory.\nFound:{overrideContents}"); } - + appBuilder.BuildLogFile = "uninstall.log"; + appBuilder.Uninstall (app); } }