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.
  • Loading branch information
andy840119 committed Mar 19, 2023
1 parent 365587b commit 7e607bb
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion osu.Framework.Font.Tests/AutomatedVisualTestGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace osu.Framework.Font.Tests;

internal partial class AutomatedVisualTestGame : TestGame
internal partial class AutomatedVisualTestGame : Game
{
public AutomatedVisualTestGame()
{
Expand Down
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
23 changes: 23 additions & 0 deletions osu.Framework.Font.Tests/Visual/FrameworkTestScene.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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;

/// <summary>
/// All the test scene with resource should inherit this class.
/// </summary>
public abstract partial class FrameworkTestScene : TestScene
{
protected override ITestSceneTestRunner CreateRunner() => new FrameworkTestSceneTestRunner();

[BackgroundDependencyLoader]
private void load(Game game)
{
// add store from main project
game.Resources.AddStore(new NamespacedResourceStore<byte[]>(new ShaderResourceStore(), "Resources"));
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
// Copyright (c) karaoke.dev <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Reflection;
using osu.Framework.Allocation;
using osu.Framework.IO.Stores;
using osu.Framework.Testing;

namespace osu.Framework.Font.Tests;
namespace osu.Framework.Font.Tests.Visual;

internal partial class TestGame : Game
public partial class FrameworkTestSceneTestRunner : TestSceneTestRunner
{
[BackgroundDependencyLoader]
private void load()
{
// add store from osu.game.resources
Resources.AddStore(new DllResourceStore(@"osu.Game.Resources.dll"));

// add store from main project
Resources.AddStore(new NamespacedResourceStore<byte[]>(new ShaderResourceStore(), "Resources"));

// add store from test project
Resources.AddStore(new NamespacedResourceStore<byte[]>(new DllResourceStore(Assembly.GetExecutingAssembly().Location), "Resources"));
Resources.AddStore(new NamespacedResourceStore<byte[]>(new DllResourceStore(typeof(FrameworkTestScene).Assembly), "Resources"));

// Add font resource
AddFont(Resources, @"Fonts/osuFont");
Expand Down
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
2 changes: 1 addition & 1 deletion osu.Framework.Font.Tests/VisualTestGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace osu.Framework.Font.Tests;

internal partial class VisualTestGame : TestGame
internal partial class VisualTestGame : Game
{
[BackgroundDependencyLoader]
private void load()
Expand Down

0 comments on commit 7e607bb

Please sign in to comment.