-
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.
UITest: add first BookLibrary test; improve UITest infrastructure
- Loading branch information
Showing
7 changed files
with
59 additions
and
6 deletions.
There are no files selected for viewing
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
15 changes: 15 additions & 0 deletions
15
src/Samples.UITest/BookLibrary.Test/Tests/BookLibraryTest.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,15 @@ | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace UITest.BookLibrary.Tests; | ||
|
||
public class BookLibraryTest(ITestOutputHelper log) : UITest(log) | ||
{ | ||
[Fact] | ||
public void AboutTest() | ||
{ | ||
Launch(); | ||
var window = GetShellWindow(); | ||
Thread.Sleep(3000); | ||
} | ||
} |
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,28 @@ | ||
using FlaUI.Core; | ||
using FlaUI.Core.AutomationElements; | ||
using UITest.BookLibrary.Views; | ||
using Xunit.Abstractions; | ||
|
||
namespace UITest.BookLibrary; | ||
|
||
public class UITest(ITestOutputHelper log) : UITestBase(log, "BookLibrary/Release/net8.0-windows/BookLibrary.exe", "Samples.UITest/BookLibrary/") | ||
{ | ||
public Application Launch(LaunchArguments? arguments = null) | ||
{ | ||
var args = (arguments ?? new LaunchArguments()).ToArguments(); | ||
Log.WriteLine($"Launch: {args}"); | ||
Environment.CurrentDirectory = Path.GetDirectoryName(Executable)!; // TODO: Bug in App that CurrentDir must be Exe dir | ||
return App = Application.Launch(Executable, args); | ||
} | ||
|
||
public ShellWindow GetShellWindow() => App!.GetMainWindow(Automation).As<ShellWindow>(); | ||
} | ||
|
||
public record LaunchArguments(string? AdditionalArguments = null) : LaunchArgumentsBase | ||
{ | ||
public override string ToArguments() | ||
{ | ||
string?[] args = [CreateArg(AdditionalArguments)]; | ||
return string.Join(" ", args.Where(x => !string.IsNullOrEmpty(x))); | ||
} | ||
} |
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,8 @@ | ||
using FlaUI.Core; | ||
using FlaUI.Core.AutomationElements; | ||
|
||
namespace UITest.BookLibrary.Views; | ||
|
||
public class ShellWindow(FrameworkAutomationElementBase element) : Window(element) | ||
{ | ||
} |
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