osu.Framework.Tests/Visual/UserInterface/TestCaseNestedMenus.cs
/// <summary>
/// Tests whether hovering over a different item on a sub-menu opens a new sub-menu in a delayed fashion
/// and correctly changes the sub-menu items to the new items from the hovered item.
/// </summary>
Tests whether hovering over a different item on a sub-menu opens a new sub-menu in a delayed fashion
and correctly changes the sub-menu items to the new items from the hovered item.
Tests whether hovering over a different item on a sub - menu opens a new sub - menu in a delayed fashion and correctly changes the sub - menu items to the new items from the hovered item .
[Test]
        public void TestDelayedHoverChange()
        {
            AddStep("Click item", () => clickItem(0, 2));
            AddStep("Hover item", () => InputManager.MoveMouseTo(menus.GetSubStructure(1).GetMenuItems()[0]));
            AddAssert("Check closed", () => menus.GetSubMenu(2)?.State != MenuState.Open);
            AddAssert("Check closed", () => menus.GetSubMenu(2)?.State != MenuState.Open);
            AddStep("Hover item", () => { InputManager.MoveMouseTo(menus.GetSubStructure(1).GetMenuItems()[1]); });
            AddAssert("Check closed", () => menus.GetSubMenu(2)?.State != MenuState.Open);
            AddAssert("Check open", () => menus.GetSubMenu(2).State == MenuState.Open);
            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 TestDelayedHoverChange ( ) { AddStep ( " " , ( ) => clickItem ( 0 , 2 ) ) ; AddStep ( " " , ( ) => InputManager . MoveMouseTo ( menus . GetSubStructure ( 1 ) . GetMenuItems ( ) [ 0 ] ) ) ; AddAssert ( " " , ( ) => menus . GetSubMenu ( 2 ) ? . State != MenuState . Open ) ; AddAssert ( " " , ( ) => menus . GetSubMenu ( 2 ) ? . State != MenuState . Open ) ; AddStep ( " " , ( ) => { InputManager . MoveMouseTo ( menus . GetSubStructure ( 1 ) . GetMenuItems ( ) [ 1 ] ) ; } ) ; AddAssert ( " " , ( ) => menus . GetSubMenu ( 2 ) ? . State != MenuState . Open ) ; AddAssert ( " " , ( ) => menus . GetSubMenu ( 2 ) . State == MenuState . Open ) ; 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 whether hovering over a different item on a sub-menu opens a new sub-menu in a delayed fashion
and correctly changes the sub-menu items to the new items from the hovered item.
Tests whether hovering over a different item on a sub - menu opens a new sub - menu in a delayed fashion and correctly changes the sub - menu items to the new items from the hovered item .