osu.Framework.Tests/Visual/UserInterface/TestCaseNestedMenus.cs
/// <summary>
/// Tests whether clicking on <see cref="Menu"/>s that have opened sub-menus don't close the sub-menus.
/// Then tests hovering in reverse order to make sure only the lower level menus close.
/// </summary>
Tests whether clicking on s that have opened sub-menus don't close the sub-menus.
Then tests hovering in reverse order to make sure only the lower level menus close.
Tests whether clicking on s that have opened sub - menus don ' t close the sub - menus . Then tests hovering in reverse order to make sure only the lower level menus close .
[Test]
        public void TestMenuClicksDontClose()
        {
            AddStep("Click item", () => clickItem(0, 1));
            AddStep("Click item", () => clickItem(1, 0));
            AddStep("Click item", () => clickItem(2, 0));
            AddStep("Click item", () => clickItem(3, 0));
            for (int i = 3; i >= 1; i--)
            {
                int menuIndex = i;
                AddStep("Hover item", () => InputManager.MoveMouseTo(menus.GetSubStructure(menuIndex).GetMenuItems()[0]));
                AddAssert("Check submenu open", () => menus.GetSubMenu(menuIndex + 1).State == MenuState.Open);
                AddStep("Click item", () => InputManager.Click(MouseButton.Left));
                AddAssert("Check all open", () =>
                {
                    for (int j = 0; j <= menuIndex; j++)
                    {
                        int menuIndex2 = j;
                        if (menus.GetSubMenu(menuIndex2)?.State != MenuState.Open)
                            return false;
                    }
                    return true;
                });
            }
        }
[ Test ] public void TestMenuClicksDontClose ( ) { AddStep ( " " , ( ) => clickItem ( 0 , 1 ) ) ; AddStep ( " " , ( ) => clickItem ( 1 , 0 ) ) ; AddStep ( " " , ( ) => clickItem ( 2 , 0 ) ) ; AddStep ( " " , ( ) => clickItem ( 3 , 0 ) ) ; for ( int i = 3 ; i >= 1 ; i -- ) { int menuIndex = i ; AddStep ( " " , ( ) => InputManager . MoveMouseTo ( menus . GetSubStructure ( menuIndex ) . GetMenuItems ( ) [ 0 ] ) ) ; AddAssert ( " " , ( ) => menus . GetSubMenu ( menuIndex + 1 ) . State == MenuState . Open ) ; AddStep ( " " , ( ) => InputManager . Click ( MouseButton . Left ) ) ; AddAssert ( " " , ( ) => { for ( int j = 0 ; j <= menuIndex ; j ++ ) { int menuIndex2 = j ; if ( menus . GetSubMenu ( menuIndex2 ) ? . State != MenuState . Open ) return false ; } return true ; } ) ; } }
Tests whether clicking on s that have opened sub-menus don't close the sub-menus.
Tests whether clicking on s that have opened sub - menus don ' t close the sub - menus .