osu.Framework.Tests/Visual/UserInterface/TestCaseNestedMenus.cs
/// <summary>
/// Opens some menus and then changes the selected item.
/// </summary>
Opens some menus and then changes the selected item.
Opens some menus and then changes the selected item .
[Test]
        public void TestSelectedState()
        {
            AddStep("Click item", () => clickItem(0, 2));
            AddAssert("Check open", () => menus.GetSubMenu(1).State == MenuState.Open);
            AddStep("Hover item", () => InputManager.MoveMouseTo(menus.GetSubStructure(1).GetMenuItems()[1]));
            AddAssert("Check closed 1", () => menus.GetSubMenu(2)?.State != MenuState.Open);
            AddAssert("Check open", () => menus.GetSubMenu(2).State == MenuState.Open);
            AddAssert("Check selected index 1", () => menus.GetSubStructure(1).GetSelectedIndex() == 1);
            AddStep("Change selection", () => menus.GetSubStructure(1).SetSelectedState(0, MenuItemState.Selected));
            AddAssert("Check selected index", () => menus.GetSubStructure(1).GetSelectedIndex() == 0);
            AddStep("Change selection", () => menus.GetSubStructure(1).SetSelectedState(2, MenuItemState.Selected));
            AddAssert("Check selected index 2", () => menus.GetSubStructure(1).GetSelectedIndex() == 2);
            AddStep("Close menus", () => menus.GetSubMenu(0).Close());
            AddAssert("Check selected index 4", () => menus.GetSubStructure(1).GetSelectedIndex() == -1);
        }
[ Test ] public void TestSelectedState ( ) { AddStep ( " " , ( ) => clickItem ( 0 , 2 ) ) ; AddAssert ( " " , ( ) => menus . GetSubMenu ( 1 ) . 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 ( " " , ( ) => menus . GetSubStructure ( 1 ) . GetSelectedIndex ( ) == 1 ) ; AddStep ( " " , ( ) => menus . GetSubStructure ( 1 ) . SetSelectedState ( 0 , MenuItemState . Selected ) ) ; AddAssert ( " " , ( ) => menus . GetSubStructure ( 1 ) . GetSelectedIndex ( ) == 0 ) ; AddStep ( " " , ( ) => menus . GetSubStructure ( 1 ) . SetSelectedState ( 2 , MenuItemState . Selected ) ) ; AddAssert ( " " , ( ) => menus . GetSubStructure ( 1 ) . GetSelectedIndex ( ) == 2 ) ; AddStep ( " " , ( ) => menus . GetSubMenu ( 0 ) . Close ( ) ) ; AddAssert ( " " , ( ) => menus . GetSubStructure ( 1 ) . GetSelectedIndex ( ) == - 1 ) ; }
Opens some menus and then changes the selected item.
Opens some menus and then changes the selected item .