Skip to content

Commit

Permalink
Add Framework which provides a test runner with resources from the te…
Browse files Browse the repository at this point in the history
…st project.

And note that this runner only create if not open the visual test windows.
  • Loading branch information
andy840119 committed Mar 19, 2023
1 parent 537648a commit c0fa63f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
3 changes: 1 addition & 2 deletions osu.Framework.Font.Tests/Visual/BackgroundGridTestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
18 changes: 18 additions & 0 deletions osu.Framework.Font.Tests/Visual/FrameworkTestScene.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) karaoke.dev <[email protected]>. 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;

/// <summary>
/// All the test scene with resource should inherit this class.
/// </summary>
public abstract partial class FrameworkTestScene : TestScene
{
/// <summary>
/// This runner will be created only if run the unit-test.
/// </summary>
/// <returns></returns>
protected override ITestSceneTestRunner CreateRunner() => new FrameworkTestSceneTestRunner();
}
18 changes: 18 additions & 0 deletions osu.Framework.Font.Tests/Visual/FrameworkTestSceneTestRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) karaoke.dev <[email protected]>. 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<byte[]>(new DllResourceStore(typeof(FrameworkTestSceneTestRunner).Assembly), "Resources"));
Resources.AddStore(new NamespacedResourceStore<byte[]>(new ShaderResourceStore(), "Resources"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -235,6 +234,7 @@ internal partial class DefaultLyricSpriteText : LyricSpriteText
public DefaultLyricSpriteText(bool ruby = true, bool romaji = true)
{
Text = "カラオケ";
Font = FontUsage.Default;

if (ruby)
{
Expand Down

0 comments on commit c0fa63f

Please sign in to comment.