2020-04-11 09:24:34 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
2021-01-18 20:24:10 +08:00
|
|
|
using osu.Framework.Audio.Sample;
|
2020-04-11 09:24:34 +08:00
|
|
|
using osu.Framework.Configuration.Tracking;
|
2021-06-21 05:09:47 +08:00
|
|
|
using osu.Framework.Graphics.Shaders;
|
2020-04-11 09:24:34 +08:00
|
|
|
using osu.Framework.Graphics.Textures;
|
|
|
|
using osu.Framework.IO.Stores;
|
2020-06-15 16:47:31 +08:00
|
|
|
using osu.Framework.Testing;
|
2020-04-11 09:24:34 +08:00
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Configuration;
|
|
|
|
using osu.Game.Rulesets.Difficulty;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
using osu.Game.Tests.Resources;
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Testing
|
|
|
|
{
|
2020-06-15 16:47:31 +08:00
|
|
|
/// <summary>
|
|
|
|
/// A test scene ensuring the dependencies for the
|
|
|
|
/// provided ruleset below are cached at the base implementation.
|
|
|
|
/// </summary>
|
|
|
|
[HeadlessTest]
|
|
|
|
public class TestSceneRulesetDependencies : OsuTestScene
|
2020-04-11 09:24:34 +08:00
|
|
|
{
|
2020-06-15 16:47:31 +08:00
|
|
|
protected override Ruleset CreateRuleset() => new TestRuleset();
|
|
|
|
|
2020-04-11 09:24:34 +08:00
|
|
|
[Test]
|
|
|
|
public void TestRetrieveTexture()
|
|
|
|
{
|
|
|
|
AddAssert("ruleset texture retrieved", () =>
|
|
|
|
Dependencies.Get<TextureStore>().Get(@"test-image") != null);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestRetrieveSample()
|
|
|
|
{
|
|
|
|
AddAssert("ruleset sample retrieved", () =>
|
|
|
|
Dependencies.Get<ISampleStore>().Get(@"test-sample") != null);
|
|
|
|
}
|
|
|
|
|
2021-06-21 05:09:47 +08:00
|
|
|
[Test]
|
|
|
|
public void TestRetrieveShader()
|
|
|
|
{
|
|
|
|
AddAssert("ruleset shaders retrieved", () =>
|
|
|
|
Dependencies.Get<ShaderManager>().LoadRaw(@"sh_TestVertex.vs") != null &&
|
|
|
|
Dependencies.Get<ShaderManager>().LoadRaw(@"sh_TestFragment.fs") != null);
|
|
|
|
}
|
|
|
|
|
2020-04-11 09:24:34 +08:00
|
|
|
[Test]
|
|
|
|
public void TestResolveConfigManager()
|
|
|
|
{
|
|
|
|
AddAssert("ruleset config resolved", () =>
|
|
|
|
Dependencies.Get<TestRulesetConfigManager>() != null);
|
|
|
|
}
|
|
|
|
|
2021-06-25 14:22:34 +08:00
|
|
|
public class TestRuleset : Ruleset
|
2020-04-11 09:24:34 +08:00
|
|
|
{
|
|
|
|
public override string Description => string.Empty;
|
|
|
|
public override string ShortName => string.Empty;
|
|
|
|
|
|
|
|
public TestRuleset()
|
|
|
|
{
|
|
|
|
// temporary ID to let RulesetConfigCache pass our
|
|
|
|
// config manager to the ruleset dependencies.
|
2021-11-22 13:26:24 +08:00
|
|
|
RulesetInfo.OnlineID = -1;
|
2020-04-11 09:24:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public override IResourceStore<byte[]> CreateResourceStore() => new NamespacedResourceStore<byte[]>(TestResources.GetStore(), @"Resources");
|
|
|
|
public override IRulesetConfigManager CreateConfig(SettingsStore settings) => new TestRulesetConfigManager();
|
|
|
|
|
2020-06-15 16:47:31 +08:00
|
|
|
public override IEnumerable<Mod> GetModsFor(ModType type) => Array.Empty<Mod>();
|
|
|
|
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => null;
|
|
|
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => null;
|
2021-11-15 17:19:23 +08:00
|
|
|
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => null;
|
2020-04-11 09:24:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private class TestRulesetConfigManager : IRulesetConfigManager
|
|
|
|
{
|
2020-06-15 16:47:31 +08:00
|
|
|
public void Load()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool Save() => true;
|
|
|
|
|
|
|
|
public TrackedSettings CreateTrackedSettings() => new TrackedSettings();
|
|
|
|
|
|
|
|
public void LoadInto(TrackedSettings settings)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
}
|
2020-04-11 09:24:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|