diff options
author | Mateo Torres-Ruiz <mateoatr@users.noreply.github.com> | 2021-08-10 03:11:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-10 03:11:56 +0300 |
commit | 604abc216ada9b8ebf39c38d725a08c04f87c563 (patch) | |
tree | 90b510775aa13805aba083ac8531aa9a5330818c /src/installer | |
parent | 1dfe32adcb30c18a617bb8870589cae225d522f0 (diff) |
Improve GUI error dialog when no runtime is installed (#57089)
* Add architecture and runtime version to error dialog
* PR feedback
Diffstat (limited to 'src/installer')
-rw-r--r-- | src/installer/tests/HostActivation.Tests/PortableAppActivation.cs | 69 |
1 files changed, 43 insertions, 26 deletions
diff --git a/src/installer/tests/HostActivation.Tests/PortableAppActivation.cs b/src/installer/tests/HostActivation.Tests/PortableAppActivation.cs index 1abb3ad75b9..73d808145f7 100644 --- a/src/installer/tests/HostActivation.Tests/PortableAppActivation.cs +++ b/src/installer/tests/HostActivation.Tests/PortableAppActivation.cs @@ -494,11 +494,9 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation } } - [Theory] + [Fact] [PlatformSpecific(TestPlatforms.Windows)] // GUI app host is only supported on Windows. - [InlineData(true)] - [InlineData(false)] - public void AppHost_GUI_FrameworkDependent_MissingRuntimeFramework_ErrorReportedInDialog(bool missingHostfxr) + public void AppHost_GUI_FrameworkDependent_MissingRuntimeFramework_ErrorReportedInDialog() { var fixture = sharedTestState.PortableAppFixture_Built .Copy(); @@ -515,22 +513,12 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation string expectedErrorCode; string expectedUrlQuery; - string expectedUrlParameter = null; - if (missingHostfxr) - { - expectedErrorCode = Constants.ErrorCode.CoreHostLibMissingFailure.ToString("x"); - expectedUrlQuery = "missing_runtime=true&"; - expectedUrlParameter = $"&apphost_version={sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}"; - } - else - { - invalidDotNet = new DotNetBuilder(invalidDotNet, sharedTestState.RepoDirectories.BuiltDotnet, "missingFramework") - .Build() - .BinPath; - expectedErrorCode = Constants.ErrorCode.FrameworkMissingFailure.ToString("x"); - expectedUrlQuery = $"framework={Constants.MicrosoftNETCoreApp}&framework_version={sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}"; - } + invalidDotNet = new DotNetBuilder(invalidDotNet, sharedTestState.RepoDirectories.BuiltDotnet, "missingFramework") + .Build() + .BinPath; + expectedErrorCode = Constants.ErrorCode.FrameworkMissingFailure.ToString("x"); + expectedUrlQuery = $"framework={Constants.MicrosoftNETCoreApp}&framework_version={sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}"; Command command = Command.Create(appExe) .EnableTracingAndCaptureOutputs() .DotNetRoot(invalidDotNet) @@ -541,16 +529,45 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation command.Process.Kill(); var result = command.WaitForExit(true) - .Should().Fail(); - - result.And.HaveStdErrContaining($"Showing error dialog for application: '{Path.GetFileName(appExe)}' - error code: 0x{expectedErrorCode}") + .Should().Fail() + .And.HaveStdErrContaining($"Showing error dialog for application: '{Path.GetFileName(appExe)}' - error code: 0x{expectedErrorCode}") .And.HaveStdErrContaining($"url: 'https://aka.ms/dotnet-core-applaunch?{expectedUrlQuery}") .And.HaveStdErrContaining("&gui=true"); + } + } - if (expectedUrlParameter != null) - { - result.And.HaveStdErrContaining(expectedUrlParameter); - } + [Fact] + [PlatformSpecific(TestPlatforms.Windows)] + public void AppHost_GUI_MissingRuntime_ErrorReportedInDialog() + { + var fixture = sharedTestState.PortableAppFixture_Built + .Copy(); + + string appExe = fixture.TestProject.AppExe; + File.Copy(sharedTestState.BuiltAppHost, appExe, overwrite: true); + AppHostExtensions.BindAppHost(appExe); + AppHostExtensions.SetWindowsGraphicalUserInterfaceBit(appExe); + + string invalidDotNet = SharedFramework.CalculateUniqueTestDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "guiErrors")); + using (new TestArtifact(invalidDotNet)) + { + Directory.CreateDirectory(invalidDotNet); + var command = Command.Create(appExe) + .EnableTracingAndCaptureOutputs() + .DotNetRoot(invalidDotNet) + .MultilevelLookup(false) + .Start(); + + WaitForPopupFromProcess(command.Process); + command.Process.Kill(); + + var expectedErrorCode = Constants.ErrorCode.CoreHostLibMissingFailure.ToString("x"); + var result = command.WaitForExit(true) + .Should().Fail() + .And.HaveStdErrContaining($"Showing error dialog for application: '{Path.GetFileName(appExe)}' - error code: 0x{expectedErrorCode}") + .And.HaveStdErrContaining($"url: 'https://aka.ms/dotnet-core-applaunch?missing_runtime=true") + .And.HaveStdErrContaining("gui=true") + .And.HaveStdErrContaining($"&apphost_version={sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}"); } } |