mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:52:55 +08:00
Extract assert step addition out of assertion method
This commit is contained in:
parent
21ca9c8431
commit
71da960000
@ -43,37 +43,34 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
public void TestEmptyDefaultBeatmapSkinFallsBack()
|
public void TestEmptyDefaultBeatmapSkinFallsBack()
|
||||||
{
|
{
|
||||||
CreateSkinTest(DefaultLegacySkin.Info, () => new TestWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)).Skin);
|
CreateSkinTest(DefaultLegacySkin.Info, () => new TestWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)).Skin);
|
||||||
AssertComponentsFromExpectedSource(SkinnableTarget.MainHUDComponents, () => skinManager.CurrentSkin.Value);
|
AddAssert("hud from default legacy skin", () => AssertComponentsFromExpectedSource(SkinnableTarget.MainHUDComponents, skinManager.CurrentSkin.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func<ISkin> beatmapSkin)
|
protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func<ISkin> getBeatmapSkin)
|
||||||
{
|
{
|
||||||
CreateTest(() =>
|
CreateTest(() =>
|
||||||
{
|
{
|
||||||
AddStep("setup skins", () =>
|
AddStep("setup skins", () =>
|
||||||
{
|
{
|
||||||
skinManager.CurrentSkinInfo.Value = gameCurrentSkin;
|
skinManager.CurrentSkinInfo.Value = gameCurrentSkin;
|
||||||
currentBeatmapSkin = beatmapSkin();
|
currentBeatmapSkin = getBeatmapSkin();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void AssertComponentsFromExpectedSource(SkinnableTarget target, Func<ISkin> expectedSource)
|
protected bool AssertComponentsFromExpectedSource(SkinnableTarget target, ISkin expectedSource)
|
||||||
{
|
{
|
||||||
AddAssert($"{target} from {expectedSource.GetType().Name}", () =>
|
var expectedComponentsContainer = (SkinnableTargetComponentsContainer)expectedSource.GetDrawableComponent(new SkinnableTargetComponent(target));
|
||||||
{
|
|
||||||
var expectedComponentsContainer = (SkinnableTargetComponentsContainer)expectedSource().GetDrawableComponent(new SkinnableTargetComponent(target));
|
|
||||||
|
|
||||||
Add(expectedComponentsContainer);
|
Add(expectedComponentsContainer);
|
||||||
expectedComponentsContainer?.UpdateSubTree();
|
expectedComponentsContainer?.UpdateSubTree();
|
||||||
var expectedInfo = expectedComponentsContainer?.CreateSkinnableInfo();
|
var expectedInfo = expectedComponentsContainer?.CreateSkinnableInfo();
|
||||||
Remove(expectedComponentsContainer);
|
Remove(expectedComponentsContainer);
|
||||||
|
|
||||||
var actualInfo = Player.ChildrenOfType<SkinnableTargetContainer>().First(s => s.Target == target)
|
var actualInfo = Player.ChildrenOfType<SkinnableTargetContainer>().First(s => s.Target == target)
|
||||||
.ChildrenOfType<SkinnableTargetComponentsContainer>().Single().CreateSkinnableInfo();
|
.ChildrenOfType<SkinnableTargetComponentsContainer>().Single().CreateSkinnableInfo();
|
||||||
|
|
||||||
return almostEqual(actualInfo, expectedInfo, 2f);
|
return almostEqual(actualInfo, expectedInfo, 2f);
|
||||||
});
|
|
||||||
|
|
||||||
static bool almostEqual(SkinnableInfo info, SkinnableInfo other, float positionTolerance) =>
|
static bool almostEqual(SkinnableInfo info, SkinnableInfo other, float positionTolerance) =>
|
||||||
other != null
|
other != null
|
||||||
|
Loading…
Reference in New Issue
Block a user