Skip to content

Commit

Permalink
Add failing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte committed Nov 24, 2023
1 parent 7a6d7e2 commit f4f4e31
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions osu.Framework.Tests/Visual/UserInterface/TestSceneDropdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,23 @@ public void TestItemReplacementDoesNotAffectScroll()
AddAssert("scroll is unchanged", () => testDropdown.ChildrenOfType<BasicScrollContainer>().Single().Target == 200);
}

[Test]
public void TestClearItemsInBindableWhileNotPresent()
{
TestDropdown testDropdown = null!;
BindableList<TestModel?> bindableList = null!;

AddStep("setup dropdown", () => testDropdown = setupDropdowns(1)[0]);

AddStep("bind source", () => testDropdown.ItemSource = bindableList = new BindableList<TestModel?>());
AddStep("add many items", () => bindableList.AddRange(Enumerable.Range(0, 20).Select(i => (TestModel)$"test {i}")));

AddStep("hide dropdown", () => testDropdown.Hide());
AddStep("clear items", () => bindableList.Clear());
AddStep("show dropdown", () => testDropdown.Show());
AddAssert("dropdown menu empty", () => !testDropdown.Menu.DrawableMenuItems.Any());
}

/// <summary>
/// Adds an item before a dropdown is loaded, and ensures item labels are assigned correctly.
/// </summary>
Expand Down

0 comments on commit f4f4e31

Please sign in to comment.