-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
114 additions
and
7 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/Samples.UITest/InformationManager.Test/InformationManager.Test.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0-windows</TargetFramework> | ||
<RootNamespace>UITest.InformationManager</RootNamespace> | ||
|
||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0" /> | ||
<PackageReference Include="xunit" Version="2.8.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="../UITest.Core/UITest.Core.csproj" /> | ||
</ItemGroup> | ||
</Project> |
27 changes: 27 additions & 0 deletions
27
src/Samples.UITest/InformationManager.Test/Tests/GeneralTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using FlaUI.Core.AutomationElements; | ||
using FlaUI.Core.Capturing; | ||
using UITest.SystemViews; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace UITest.InformationManager.Tests; | ||
|
||
public class GeneralTest(ITestOutputHelper log) : UITest(log) | ||
{ | ||
[Fact] | ||
public void AboutTest() => Run(() => | ||
{ | ||
Launch(); | ||
var window = GetShellWindow(); | ||
window.AboutButton.Click(); | ||
|
||
var messageBox = window.FirstModalWindow().As<MessageBox>(); | ||
Assert.Equal("Waf Information Manager", messageBox.Title); | ||
Log.WriteLine(messageBox.Message); | ||
Assert.StartsWith("Waf Information Manager ", messageBox.Message); | ||
Capture.Screen().ToFile(GetScreenshotFile("About")); | ||
messageBox.Buttons[0].Click(); | ||
|
||
window.ExitButton.Click(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using FlaUI.Core; | ||
using FlaUI.Core.AutomationElements; | ||
using System.Diagnostics; | ||
using UITest.InformationManager.Views; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
[assembly: CollectionBehavior(DisableTestParallelization = true)] | ||
|
||
namespace UITest.InformationManager; | ||
|
||
public abstract class UITest(ITestOutputHelper log) : UITestBase(log, "InformationManager.exe", | ||
Environment.GetEnvironmentVariable("UITestExePath") ?? "out/InformationManager/Release/net8.0-windows/", | ||
Environment.GetEnvironmentVariable("UITestOutputPath") ?? "out/Samples.UITest/InformationManager/") | ||
{ | ||
public Application Launch(LaunchArguments? arguments = null, bool resetSettings = true) | ||
{ | ||
Log.WriteLine(""); | ||
if (resetSettings) | ||
{ | ||
var productName = FileVersionInfo.GetVersionInfo(Executable).ProductName ?? throw new InvalidOperationException("Could not read the ProductName from the exe."); | ||
var settingsFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), productName, "Settings", "Settings.xml"); | ||
if (File.Exists(settingsFile)) File.Delete(settingsFile); | ||
Log.WriteLine($"Delete settings: {settingsFile}"); | ||
} | ||
var args = (arguments ?? new LaunchArguments()).ToArguments(); | ||
Log.WriteLine($"Launch: {args}"); | ||
return App = Application.Launch(Executable, args); | ||
} | ||
|
||
public ShellWindow GetShellWindow() => App!.GetMainWindow(Automation).As<ShellWindow>(); | ||
} | ||
|
||
public record LaunchArguments(string? UICulture = "en-US", string? Culture = "en-US", string? AdditionalArguments = null) : LaunchArgumentsBase | ||
{ | ||
public override string ToArguments() | ||
{ | ||
string?[] args = [CreateArg(UICulture), CreateArg(Culture), AdditionalArguments]; | ||
return string.Join(" ", args.Where(x => !string.IsNullOrEmpty(x))); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/Samples.UITest/InformationManager.Test/Views/ShellWindow.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using FlaUI.Core; | ||
using FlaUI.Core.AutomationElements; | ||
|
||
namespace UITest.InformationManager.Views; | ||
|
||
public class ShellWindow(FrameworkAutomationElementBase element) : Window(element) | ||
{ | ||
public Button AboutButton => this.Find("AboutButton").AsButton(); | ||
|
||
public Button ExitButton => this.Find("ExitButton").AsButton(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters