diff --git a/src/Samples.UITest/BookLibrary.Test/BookLibrary.Test.csproj b/src/Samples.UITest/BookLibrary.Test/BookLibrary.Test.csproj index 5d12c5e3..e46fb508 100644 --- a/src/Samples.UITest/BookLibrary.Test/BookLibrary.Test.csproj +++ b/src/Samples.UITest/BookLibrary.Test/BookLibrary.Test.csproj @@ -9,10 +9,11 @@ - + + - + diff --git a/src/Samples.UITest/BookLibrary.Test/Tests/BookLibraryTest.cs b/src/Samples.UITest/BookLibrary.Test/Tests/BookLibraryTest.cs new file mode 100644 index 00000000..c4ea9a49 --- /dev/null +++ b/src/Samples.UITest/BookLibrary.Test/Tests/BookLibraryTest.cs @@ -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); + } +} diff --git a/src/Samples.UITest/BookLibrary.Test/UITest.cs b/src/Samples.UITest/BookLibrary.Test/UITest.cs new file mode 100644 index 00000000..2ef904d4 --- /dev/null +++ b/src/Samples.UITest/BookLibrary.Test/UITest.cs @@ -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(); +} + +public record LaunchArguments(string? AdditionalArguments = null) : LaunchArgumentsBase +{ + public override string ToArguments() + { + string?[] args = [CreateArg(AdditionalArguments)]; + return string.Join(" ", args.Where(x => !string.IsNullOrEmpty(x))); + } +} \ No newline at end of file diff --git a/src/Samples.UITest/BookLibrary.Test/Views/ShellWindow.cs b/src/Samples.UITest/BookLibrary.Test/Views/ShellWindow.cs new file mode 100644 index 00000000..ecd1880b --- /dev/null +++ b/src/Samples.UITest/BookLibrary.Test/Views/ShellWindow.cs @@ -0,0 +1,8 @@ +using FlaUI.Core; +using FlaUI.Core.AutomationElements; + +namespace UITest.BookLibrary.Views; + +public class ShellWindow(FrameworkAutomationElementBase element) : Window(element) +{ +} diff --git a/src/Samples.UITest/UITest.Core/UITest.Core.csproj b/src/Samples.UITest/UITest.Core/UITest.Core.csproj index cc2f9108..69ec98c9 100644 --- a/src/Samples.UITest/UITest.Core/UITest.Core.csproj +++ b/src/Samples.UITest/UITest.Core/UITest.Core.csproj @@ -9,6 +9,6 @@ - + diff --git a/src/Samples.UITest/Writer.Test/UITest.cs b/src/Samples.UITest/Writer.Test/UITest.cs index 6e4c5cfc..0a07404e 100644 --- a/src/Samples.UITest/Writer.Test/UITest.cs +++ b/src/Samples.UITest/Writer.Test/UITest.cs @@ -8,7 +8,7 @@ namespace UITest.Writer; -public class UITest(ITestOutputHelper log) : UITestBase(log, "Writer/Release/net8.0-windows/writer.exe", "Samples.UITest/Writer/") +public class UITest(ITestOutputHelper log) : UITestBase(log, "Writer/Release/net8.0-windows/Writer.exe", "Samples.UITest/Writer/") { public Application Launch(LaunchArguments? arguments = null) { diff --git a/src/Samples.UITest/Writer.Test/Writer.Test.csproj b/src/Samples.UITest/Writer.Test/Writer.Test.csproj index 9ecffd83..8c0708d6 100644 --- a/src/Samples.UITest/Writer.Test/Writer.Test.csproj +++ b/src/Samples.UITest/Writer.Test/Writer.Test.csproj @@ -9,10 +9,11 @@ - + + - +