From d5fe7e20be19cc8431382ccd5b74e87d7091dfa9 Mon Sep 17 00:00:00 2001 From: Denis Titovets Date: Thu, 10 Jul 2025 21:58:05 +0300 Subject: [PATCH] Fix tests (they're using `LocalisableString`s now) --- .../SongSelect/TestSceneCollectionDropdown.cs | 18 ++++++++++-------- .../TestSceneCollectionDropdown.cs | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneCollectionDropdown.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneCollectionDropdown.cs index 470bb52fd2..db004b1d0d 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneCollectionDropdown.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneCollectionDropdown.cs @@ -11,11 +11,13 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; +using osu.Framework.Localisation; using osu.Framework.Platform; using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Collections; using osu.Game.Graphics.UserInterface; +using osu.Game.Localisation; using osu.Game.Overlays; using osu.Game.Rulesets; using osu.Game.Tests.Resources; @@ -61,12 +63,12 @@ namespace osu.Game.Tests.Visual.SongSelect }; }); - // [Test] - // public void TestEmptyCollectionFilterContainsAllBeatmaps() - // { - // assertCollectionDropdownContains("All beatmaps"); - // assertCollectionHeaderDisplays("All beatmaps"); - // } + [Test] + public void TestEmptyCollectionFilterContainsAllBeatmaps() + { + assertCollectionDropdownContains(CollectionsStrings.AllBeatmaps); + assertCollectionHeaderDisplays(CollectionsStrings.AllBeatmaps); + } [Test] public void TestCollectionAddedToDropdown() @@ -235,13 +237,13 @@ namespace osu.Game.Tests.Visual.SongSelect private BeatmapCollection getFirstCollection() => Realm.Run(r => r.All().First()); - private void assertCollectionHeaderDisplays(string collectionName, bool shouldDisplay = true) + private void assertCollectionHeaderDisplays(LocalisableString collectionName, bool shouldDisplay = true) => AddUntilStep($"collection dropdown header displays '{collectionName}'", () => shouldDisplay == dropdown.ChildrenOfType().Any(h => h.ChildrenOfType().Any(t => t.Text == collectionName))); private void assertFirstButtonIs(IconUsage icon) => AddUntilStep($"button is {icon.Icon.ToString()}", () => getAddOrRemoveButton(1).Icon.Equals(icon)); - private void assertCollectionDropdownContains(string collectionName, bool shouldContain = true) => + private void assertCollectionDropdownContains(LocalisableString collectionName, bool shouldContain = true) => AddUntilStep($"collection dropdown {(shouldContain ? "contains" : "does not contain")} '{collectionName}'", // A bit of a roundabout way of going about this, see: https://github.com/ppy/osu-framework/issues/3871 + https://github.com/ppy/osu-framework/issues/3872 () => shouldContain == dropdown.ChildrenOfType().Any(i => i.ChildrenOfType().OfType().First().Text == collectionName)); diff --git a/osu.Game.Tests/Visual/SongSelectV2/TestSceneCollectionDropdown.cs b/osu.Game.Tests/Visual/SongSelectV2/TestSceneCollectionDropdown.cs index 219915db8c..1240394f7a 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/TestSceneCollectionDropdown.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/TestSceneCollectionDropdown.cs @@ -11,11 +11,13 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; +using osu.Framework.Localisation; using osu.Framework.Platform; using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Collections; using osu.Game.Graphics.UserInterface; +using osu.Game.Localisation; using osu.Game.Overlays; using osu.Game.Rulesets; using osu.Game.Tests.Resources; @@ -62,12 +64,12 @@ namespace osu.Game.Tests.Visual.SongSelectV2 }; }); - // [Test] - // public void TestEmptyCollectionFilterContainsAllBeatmaps() - // { - // assertCollectionDropdownContains("All beatmaps"); - // assertCollectionHeaderDisplays("All beatmaps"); - // } + [Test] + public void TestEmptyCollectionFilterContainsAllBeatmaps() + { + assertCollectionDropdownContains(CollectionsStrings.AllBeatmaps); + assertCollectionHeaderDisplays(CollectionsStrings.AllBeatmaps); + } [Test] public void TestCollectionAddedToDropdown() @@ -236,13 +238,13 @@ namespace osu.Game.Tests.Visual.SongSelectV2 private BeatmapCollection getFirstCollection() => Realm.Run(r => r.All().First()); - private void assertCollectionHeaderDisplays(string collectionName, bool shouldDisplay = true) + private void assertCollectionHeaderDisplays(LocalisableString collectionName, bool shouldDisplay = true) => AddUntilStep($"collection dropdown header displays '{collectionName}'", () => shouldDisplay == dropdown.ChildrenOfType().Any(h => h.ChildrenOfType().Any(t => t.Text == collectionName))); private void assertFirstButtonIs(IconUsage icon) => AddUntilStep($"button is {icon.Icon.ToString()}", () => getAddOrRemoveButton(1).Icon.Equals(icon)); - private void assertCollectionDropdownContains(string collectionName, bool shouldContain = true) => + private void assertCollectionDropdownContains(LocalisableString collectionName, bool shouldContain = true) => AddUntilStep($"collection dropdown {(shouldContain ? "contains" : "does not contain")} '{collectionName}'", // A bit of a roundabout way of going about this, see: https://github.com/ppy/osu-framework/issues/3871 + https://github.com/ppy/osu-framework/issues/3872 () => shouldContain == dropdown.ChildrenOfType().Any(i => i.ChildrenOfType().OfType().First().Text == collectionName));