Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] add test for monodroid#1156 #5546

Merged
merged 1 commit into from
Jan 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions tests/MSBuildDeviceIntegration/Tests/InstallTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ("<data name=\"CancelButton\"><value>Cancel</value></data>")
},
new BuildItem ("EmbeddedResource", "Bar.es.resx") {
TextContent = () => InlineData.ResxWithContents ("<data name=\"CancelButton\"><value>Cancelar</value></data>")
}
}
};

var app = new XamarinAndroidApplicationProject {
EmbedAssembliesIntoApk = false,
OtherBuildItems = {
new BuildItem ("EmbeddedResource", "Foo.resx") {
Expand All @@ -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);
}
}

Expand Down