A game framework written with osu! in mind.
at master 53 lines 1.7 kB view raw
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2// See the LICENCE file in the repository root for full licence text. 3 4using NUnit.Framework; 5using osu.Framework.Graphics; 6using osu.Framework.Graphics.UserInterface; 7using osu.Framework.Testing; 8 9namespace osu.Framework.Tests.Visual.UserInterface 10{ 11 public class TestSceneUnclosableMenu : MenuTestScene 12 { 13 protected override Menu CreateMenu() => new TestMenu 14 { 15 Anchor = Anchor.Centre, 16 Origin = Anchor.Centre, 17 State = MenuState.Open, 18 Items = new[] { new MenuItem("Item #1") { Items = new[] { new MenuItem("Sub-item #1") } } } 19 }; 20 21 private class TestMenu : BasicMenu 22 { 23 protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new TestDrawableMenuItem(item); 24 25 protected override Menu CreateSubMenu() => new TestMenu(); 26 27 public TestMenu() 28 : base(Direction.Vertical) 29 { 30 } 31 32 private class TestDrawableMenuItem : BasicDrawableMenuItem 33 { 34 public override bool CloseMenuOnClick => false; 35 36 public TestDrawableMenuItem(MenuItem item) 37 : base(item) 38 { 39 } 40 } 41 } 42 43 [Test] 44 public void TestClickMenuUnclosableItem() 45 { 46 AddStep("click item", () => ClickItem(0, 0)); 47 AddStep("click item", () => ClickItem(1, 0)); 48 AddAssert("menu not closed", () => 49 Menus.GetSubMenu(0).State == MenuState.Open && 50 Menus.GetSubMenu(1).State == MenuState.Open); 51 } 52 } 53}