Fixes #4009 - fix tree ordering (#4015)

This commit is contained in:
Thomas Nind
2025-04-05 13:47:39 +01:00
committed by Tig
parent 47833bfc80
commit 4d87d5f249
11 changed files with 356 additions and 110 deletions

View File

@@ -243,7 +243,18 @@ public class GuiTestContext : IDisposable
/// <returns></returns>
public GuiTestContext Then (Action doAction)
{
doAction ();
try
{
doAction ();
}
catch(Exception)
{
Stop ();
_hardStop.Cancel();
throw;
}
return this;
}
@@ -360,6 +371,7 @@ public class GuiTestContext : IDisposable
{
SendNetKey (k);
}
WaitIteration ();
break;
default:
throw new ArgumentOutOfRangeException ();
@@ -550,4 +562,25 @@ public class GuiTestContext : IDisposable
WaitIteration ();
}
/// <summary>
/// Sets the input focus to the given <see cref="View"/>.
/// Throws <see cref="ArgumentException"/> if focus did not change due to system
/// constraints e.g. <paramref name="toFocus"/>
/// <see cref="View.CanFocus"/> is <see langword="false"/>
/// </summary>
/// <param name="toFocus"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public GuiTestContext Focus (View toFocus)
{
toFocus.FocusDeepest (NavigationDirection.Forward, TabBehavior.TabStop);
if (!toFocus.HasFocus)
{
throw new ArgumentException ("Failed to set focus, FocusDeepest did not result in HasFocus becoming true. Ensure view is added and focusable");
}
return WaitIteration ();
}
}