osu.Framework.Tests/Visual/UserInterface/TestCaseNestedMenus.cs
/// <summary>
/// Tests if hovering over a different item on the main <see cref="Menu"/> will instantly open another menu
/// and correctly changes the sub-menu items to the new items from the hovered item.
/// </summary>
Tests if hovering over a different item on the main  will instantly open another menu
and correctly changes the sub-menu items to the new items from the hovered item.
Tests if hovering over a different item on the main will instantly open another menu and correctly changes the sub - menu items to the new items from the hovered item .
[Test]
        public void TestHoverChange()
        {
            IReadOnlyList<MenuItem> currentItems = null;
            AddStep("Click item", () => { clickItem(0, 0); });
            AddStep("Get items", () => { currentItems = menus.GetSubMenu(1).Items; });
            AddAssert("Check open", () => menus.GetSubMenu(1).State == MenuState.Open);
            AddStep("Hover item", () => InputManager.MoveMouseTo(menus.GetSubStructure(0).GetMenuItems()[1]));
            AddAssert("Check open", () => menus.GetSubMenu(1).State == MenuState.Open);
            AddAssert("Check new items", () => !menus.GetSubMenu(1).Items.SequenceEqual(currentItems));
            AddAssert("Check closed", () =>
            {
                int currentSubMenu = 3;
                while (true)
                {
                    var subMenu = menus.GetSubMenu(currentSubMenu);
                    if (subMenu == null)
                        break;
                    if (subMenu.State == MenuState.Open)
                        return false;
                    currentSubMenu++;
                }
                return true;
            });
        }
[ Test ] public void TestHoverChange ( ) { IReadOnlyList < MenuItem > currentItems = null ; AddStep ( " " , ( ) => { clickItem ( 0 , 0 ) ; } ) ; AddStep ( " " , ( ) => { currentItems = menus . GetSubMenu ( 1 ) . Items ; } ) ; AddAssert ( " " , ( ) => menus . GetSubMenu ( 1 ) . State == MenuState . Open ) ; AddStep ( " " , ( ) => InputManager . MoveMouseTo ( menus . GetSubStructure ( 0 ) . GetMenuItems ( ) [ 1 ] ) ) ; AddAssert ( " " , ( ) => menus . GetSubMenu ( 1 ) . State == MenuState . Open ) ; AddAssert ( " " , ( ) => ! menus . GetSubMenu ( 1 ) . Items . SequenceEqual ( currentItems ) ) ; AddAssert ( " " , ( ) => { int currentSubMenu = 3 ; while ( true ) { var subMenu = menus . GetSubMenu ( currentSubMenu ) ; if ( subMenu == null ) break ; if ( subMenu . State == MenuState . Open ) return false ; currentSubMenu ++ ; } return true ; } ) ; }
Tests if hovering over a different item on the main  will instantly open another menu
and correctly changes the sub-menu items to the new items from the hovered item.
Tests if hovering over a different item on the main will instantly open another menu and correctly changes the sub - menu items to the new items from the hovered item .