Fixes #4080. TabGroup not always navigate correctly across groups (#4085)

* Fixes #4080. TabGroup not always navigate correctly across groups

* Remove duplicated code

* Improves code by removing duplicate code

* Made requested changes

* Change to Theory unit test

* Cleanup to run git actions again

* Trying fix racing fail unit tests

---------

Co-authored-by: Tig <tig@users.noreply.github.com>
This commit is contained in:
BDisp
2025-06-04 19:41:03 +01:00
committed by GitHub
parent 8fef16d35f
commit 4f707c453d
6 changed files with 173 additions and 36 deletions

View File

@@ -12,7 +12,6 @@ public class BasicFluentAssertionTests
_out = new TestOutputWriter (outputHelper);
}
[Theory]
[ClassData (typeof (V2TestDrivers))]
public void GuiTestContext_NewInstance_Runs (V2TestDriver d)
@@ -24,7 +23,6 @@ public class BasicFluentAssertionTests
context.Stop ();
}
[Theory]
[ClassData (typeof (V2TestDrivers))]
public void GuiTestContext_QuitKey_Stops (V2TestDriver d)
@@ -153,4 +151,76 @@ public class BasicFluentAssertionTests
.WriteOutLogs (_out);
Assert.True (clicked);
}
[Theory]
[ClassData (typeof (V2TestDrivers))]
public void Toplevel_TabGroup_Forward_Backward (V2TestDriver d)
{
var v1 = new View { Id = "v1", CanFocus = true };
var v2 = new View { Id = "v2", CanFocus = true };
var v3 = new View { Id = "v3", CanFocus = true };
var v4 = new View { Id = "v4", CanFocus = true };
var v5 = new View { Id = "v5", CanFocus = true };
var v6 = new View { Id = "v6", CanFocus = true };
using GuiTestContext c = With.A<Window> (50, 20, d)
.Then (
() =>
{
var w1 = new Window { Id = "w1" };
w1.Add (v1, v2);
var w2 = new Window { Id = "w2" };
w2.Add (v3, v4);
var w3 = new Window { Id = "w3" };
w3.Add (v5, v6);
Toplevel top = Application.Top!;
Application.Top!.Add (w1, w2, w3);
})
.WaitIteration ()
.Then (() => Assert.True (v5.HasFocus))
.RaiseKeyDownEvent (Key.F6)
.Then (() => Assert.True (v1.HasFocus))
.RaiseKeyDownEvent (Key.F6)
.Then (() => Assert.True (v3.HasFocus))
.RaiseKeyDownEvent (Key.F6.WithShift)
.Then (() => Assert.True (v1.HasFocus))
.RaiseKeyDownEvent (Key.F6.WithShift)
.Then (() => Assert.True (v5.HasFocus))
.RaiseKeyDownEvent (Key.F6.WithShift)
.Then (() => Assert.True (v3.HasFocus))
.RaiseKeyDownEvent (Key.F6)
.Then (() => Assert.True (v5.HasFocus))
.RaiseKeyDownEvent (Key.F6)
.Then (() => Assert.True (v1.HasFocus))
.RaiseKeyDownEvent (Key.F6)
.Then (() => Assert.True (v3.HasFocus))
.RaiseKeyDownEvent (Key.F6.WithShift)
.Then (() => Assert.True (v1.HasFocus))
.RaiseKeyDownEvent (Key.F6.WithShift)
.Then (() => Assert.True (v5.HasFocus))
.RaiseKeyDownEvent (Key.F6.WithShift)
.Then (() => Assert.True (v3.HasFocus))
.RaiseKeyDownEvent (Key.Tab)
.Then (() => Assert.True (v4.HasFocus))
.RaiseKeyDownEvent (Key.F6)
.Then (() => Assert.True (v5.HasFocus))
.RaiseKeyDownEvent (Key.F6)
.Then (() => Assert.True (v1.HasFocus))
.RaiseKeyDownEvent (Key.F6.WithShift)
.Then (() => Assert.True (v5.HasFocus))
.RaiseKeyDownEvent (Key.Tab)
.Then (() => Assert.True (v6.HasFocus))
.RaiseKeyDownEvent (Key.F6.WithShift)
.Then (() => Assert.True (v4.HasFocus))
.RaiseKeyDownEvent (Key.F6)
.Then (() => Assert.True (v6.HasFocus))
.WriteOutLogs (_out)
.Stop ();
Assert.False (v1.HasFocus);
Assert.False (v2.HasFocus);
Assert.False (v3.HasFocus);
Assert.False (v4.HasFocus);
Assert.False (v5.HasFocus);
Assert.False (v6.HasFocus);
}
}