public void FocusNearestView_Ensure_Focus_Ordered() { var top = new Toplevel(); var win = new Window(); var winSubview = new View("WindowSubview") { CanFocus = true }; win.Add(winSubview); top.Add(win); var frm = new FrameView(); var frmSubview = new View("FrameSubview") { CanFocus = true }; frm.Add(frmSubview); top.Add(frm); top.ProcessKey(new KeyEvent(Key.Tab, new KeyModifiers())); Assert.Equal($"WindowSubview", top.MostFocused.Text); top.ProcessKey(new KeyEvent(Key.Tab, new KeyModifiers())); Assert.Equal("FrameSubview", top.MostFocused.Text); top.ProcessKey(new KeyEvent(Key.Tab, new KeyModifiers())); Assert.Equal($"WindowSubview", top.MostFocused.Text); top.ProcessKey(new KeyEvent(Key.BackTab | Key.ShiftMask, new KeyModifiers())); Assert.Equal("FrameSubview", top.MostFocused.Text); top.ProcessKey(new KeyEvent(Key.BackTab | Key.ShiftMask, new KeyModifiers())); Assert.Equal($"WindowSubview", top.MostFocused.Text); }