mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Add test for TextField cursor position * Add comment and one more assert * Fix cursor position at the end * Remove unused local field --------- Co-authored-by: BDisp <bd.bdisp@gmail.com>
This commit is contained in:
@@ -24,5 +24,10 @@ internal class FakeOutput : IConsoleOutput
|
||||
public void SetCursorVisibility (CursorVisibility visibility) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void SetCursorPosition (int col, int row) { }
|
||||
public void SetCursorPosition (int col, int row) { CursorPosition = new Point (col, row); }
|
||||
|
||||
/// <summary>
|
||||
/// The last value set by calling <see cref="SetCursorPosition"/>
|
||||
/// </summary>
|
||||
public Point CursorPosition { get; private set; }
|
||||
}
|
||||
|
||||
@@ -706,10 +706,14 @@ public class GuiTestContext : IDisposable
|
||||
/// is found (of Type T) or all views are looped through (back to the beginning)
|
||||
/// in which case triggers hard stop and Exception
|
||||
/// </summary>
|
||||
/// <param name="evaluator">Delegate that returns true if the passed View is the one
|
||||
/// you are trying to focus. Leave <see langword="null"/> to focus the first view of type
|
||||
/// <typeparamref name="T"/></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public GuiTestContext Focus<T> (Func<T, bool> evaluator) where T : View
|
||||
public GuiTestContext Focus<T> (Func<T, bool>? evaluator = null) where T : View
|
||||
{
|
||||
evaluator ??= _ => true;
|
||||
Toplevel? t = Application.Top;
|
||||
|
||||
HashSet<View> seen = new ();
|
||||
@@ -816,4 +820,13 @@ public class GuiTestContext : IDisposable
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the last set position of the cursor.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Point GetCursorPosition ()
|
||||
{
|
||||
return _output.CursorPosition;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user