diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/App.xaml b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/App.xaml new file mode 100644 index 0000000000..36c657ee60 --- /dev/null +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/App.xaml.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/App.xaml.cs new file mode 100644 index 0000000000..a03d5e34fd --- /dev/null +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/App.xaml.cs @@ -0,0 +1,12 @@ +namespace Microsoft.ML.OnnxRuntime.Tests.MAUI +{ + public partial class App : Application + { + public App() + { + InitializeComponent(); + + MainPage = new AppShell(); + } + } +} diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/AppiumHelper.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/AppiumHelper.cs index f0908f0499..eac7ac5f52 100644 --- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/AppiumHelper.cs +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/AppiumHelper.cs @@ -18,27 +18,23 @@ internal partial class AppiumHelper : IDisposable public AppiumDriver App => driver ?? throw new NullReferenceException("AppiumDriver is null"); - public void Start() + public AppiumHelper() { - if (driver is not null) - { - throw new InvalidOperationException("AppiumDriver is already started."); - } - server = new AppiumLocalServer(DefaultHostAddress, DefaultHostPort); driver = CreateDriver(); // this function is implemented in the platform specific code } public void Stop() { + + // this seems to kill the app if everything works correctly but isn't as consistent if it fails due to a + // zombie process. trying using autoterminate in MauiProgram.cs for a more graceful way, but not sure if + // BrowserStack will require Quit to be explicitly called. this needs more debugging + driver?.Quit(); + driver = null; + server?.Dispose(); server = null; - - // this seems to kills the app if everything works correctly but isn't as consistent if it fails due to a - // zombie process. trying using autoterminate in MauiProgram.cs for a more graceful way, but not sure if - // BrowserStack will require Quit to be explicitly called. - // driver?.Quit(); - // driver = null; } protected virtual void Dispose(bool disposing) diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/MauiProgram.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/MauiProgram.cs index 17a66739f3..bb9c3dfdfd 100644 --- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/MauiProgram.cs +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/MauiProgram.cs @@ -45,11 +45,7 @@ public class XunitTestRunnerWithAppium : ITestRunner { using (var appiumHelper = new AppiumHelper()) { - appiumHelper.Start(); await runTests(); - // this seems to close the app. not sure if there's a higher up place we could/should do that or not. - // the IResultChannel is still open, so we could potentially do it there. - appiumHelper.Stop(); } } catch (Exception ex) diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj index 36fa7e9085..43975386ad 100644 --- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj @@ -85,15 +85,9 @@ - - - + + + @@ -108,6 +102,14 @@ + @@ -117,9 +119,7 @@ - <_VisualStudioTestRunnerFiles - Include="@(PackagingOutputs)" - Condition="$([System.String]::Copy('%(PackagingOutputs.FullPath)').Contains('xunit.runner.visualstudio'))" /> + <_VisualStudioTestRunnerFiles Include="@(PackagingOutputs)" Condition="$([System.String]::Copy('%(PackagingOutputs.FullPath)').Contains('xunit.runner.visualstudio'))" />