From c0fa63f0cb75a4a3b5d4222ebcd4db51c2a0ad82 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 19 Mar 2023 19:50:54 +0800 Subject: [PATCH] Add Framework which provides a test runner with resources from the test project. And note that this runner only create if not open the visual test windows. --- .../Visual/BackgroundGridTestScene.cs | 3 +-- .../Visual/FrameworkTestScene.cs | 18 ++++++++++++++++++ .../Visual/FrameworkTestSceneTestRunner.cs | 18 ++++++++++++++++++ .../Sprites/TestSceneKaraokeSpriteText.cs | 3 +-- .../Visual/Sprites/TestSceneLyricSpriteText.cs | 4 ++-- 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 osu.Framework.Font.Tests/Visual/FrameworkTestScene.cs create mode 100644 osu.Framework.Font.Tests/Visual/FrameworkTestSceneTestRunner.cs diff --git a/osu.Framework.Font.Tests/Visual/BackgroundGridTestScene.cs b/osu.Framework.Font.Tests/Visual/BackgroundGridTestScene.cs index 70c375f..f92c12d 100644 --- a/osu.Framework.Font.Tests/Visual/BackgroundGridTestScene.cs +++ b/osu.Framework.Font.Tests/Visual/BackgroundGridTestScene.cs @@ -11,13 +11,12 @@ using osu.Framework.Graphics.Shaders; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; -using osu.Framework.Testing; using osuTK; using osuTK.Graphics; namespace osu.Framework.Font.Tests.Visual; -public abstract partial class BackgroundGridTestScene : TestScene +public abstract partial class BackgroundGridTestScene : FrameworkTestScene { protected const int GRID_SIZE = 30; diff --git a/osu.Framework.Font.Tests/Visual/FrameworkTestScene.cs b/osu.Framework.Font.Tests/Visual/FrameworkTestScene.cs new file mode 100644 index 0000000..dfa7411 --- /dev/null +++ b/osu.Framework.Font.Tests/Visual/FrameworkTestScene.cs @@ -0,0 +1,18 @@ +// Copyright (c) karaoke.dev . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Testing; + +namespace osu.Framework.Font.Tests.Visual; + +/// +/// All the test scene with resource should inherit this class. +/// +public abstract partial class FrameworkTestScene : TestScene +{ + /// + /// This runner will be created only if run the unit-test. + /// + /// + protected override ITestSceneTestRunner CreateRunner() => new FrameworkTestSceneTestRunner(); +} diff --git a/osu.Framework.Font.Tests/Visual/FrameworkTestSceneTestRunner.cs b/osu.Framework.Font.Tests/Visual/FrameworkTestSceneTestRunner.cs new file mode 100644 index 0000000..cd68008 --- /dev/null +++ b/osu.Framework.Font.Tests/Visual/FrameworkTestSceneTestRunner.cs @@ -0,0 +1,18 @@ +// Copyright (c) karaoke.dev . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.IO.Stores; +using osu.Framework.Testing; + +namespace osu.Framework.Font.Tests.Visual; + +public partial class FrameworkTestSceneTestRunner : TestSceneTestRunner +{ + [BackgroundDependencyLoader] + private void load() + { + Resources.AddStore(new NamespacedResourceStore(new DllResourceStore(typeof(FrameworkTestSceneTestRunner).Assembly), "Resources")); + Resources.AddStore(new NamespacedResourceStore(new ShaderResourceStore(), "Resources")); + } +} diff --git a/osu.Framework.Font.Tests/Visual/Sprites/TestSceneKaraokeSpriteText.cs b/osu.Framework.Font.Tests/Visual/Sprites/TestSceneKaraokeSpriteText.cs index 1809438..e33cfe4 100644 --- a/osu.Framework.Font.Tests/Visual/Sprites/TestSceneKaraokeSpriteText.cs +++ b/osu.Framework.Font.Tests/Visual/Sprites/TestSceneKaraokeSpriteText.cs @@ -13,13 +13,12 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Shaders; using osu.Framework.Graphics.Sprites; -using osu.Framework.Testing; using osuTK; using osuTK.Graphics; namespace osu.Framework.Font.Tests.Visual.Sprites; -public partial class TestSceneKaraokeSpriteText : TestScene +public partial class TestSceneKaraokeSpriteText : FrameworkTestScene { private readonly TestKaraokeSpriteText karaokeSpriteText; private readonly SpriteText transformAmountSpriteText; diff --git a/osu.Framework.Font.Tests/Visual/Sprites/TestSceneLyricSpriteText.cs b/osu.Framework.Font.Tests/Visual/Sprites/TestSceneLyricSpriteText.cs index e393875..bc700d6 100644 --- a/osu.Framework.Font.Tests/Visual/Sprites/TestSceneLyricSpriteText.cs +++ b/osu.Framework.Font.Tests/Visual/Sprites/TestSceneLyricSpriteText.cs @@ -6,12 +6,11 @@ using osu.Framework.Font.Tests.Helper; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; -using osu.Framework.Testing; using osuTK; namespace osu.Framework.Font.Tests.Visual.Sprites; -public partial class TestSceneLyricSpriteText : TestScene +public partial class TestSceneLyricSpriteText : FrameworkTestScene { [TestCase("karaoke", null, null)] [TestCase("カラオケ", new[] { "[0,1]:か", "[1,2]:ら", "[2,3]:お", "[3,4]:け" }, null)] @@ -235,6 +234,7 @@ internal partial class DefaultLyricSpriteText : LyricSpriteText public DefaultLyricSpriteText(bool ruby = true, bool romaji = true) { Text = "カラオケ"; + Font = FontUsage.Default; if (ruby) {