mirror of
https://github.com/ppy/osu
synced 2024-12-16 11:56:31 +00:00
Assert storyboard visibilty at both steps of toggle
This commit is contained in:
parent
14ffd9efe8
commit
882fff1631
@ -141,25 +141,16 @@ namespace osu.Game.Tests.Visual
|
|||||||
public void StoryboardBackgroundVisibilityTest()
|
public void StoryboardBackgroundVisibilityTest()
|
||||||
{
|
{
|
||||||
performSetup();
|
performSetup();
|
||||||
AddStep("Enable storyboard", () =>
|
createFakeStoryboard();
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.IsStoryboardVisible());
|
||||||
|
AddStep("Disable storyboard", () =>
|
||||||
{
|
{
|
||||||
player.ReplacesBackground.Value = true;
|
player.ReplacesBackground.Value = false;
|
||||||
player.StoryboardEnabled.Value = true;
|
player.StoryboardEnabled.Value = false;
|
||||||
player.CurrentStoryboardContainer.Add(new SpriteText
|
|
||||||
{
|
|
||||||
Size = new Vector2(250, 50),
|
|
||||||
Alpha = 1,
|
|
||||||
Colour = Color4.White,
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Text = "THIS IS A STORYBOARD",
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
waitForDim();
|
waitForDim();
|
||||||
AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.CurrentStoryboardContainer.Alpha == 1);
|
AddAssert("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && player.IsStoryboardInvisible());
|
||||||
AddStep("Disable storyboard", () => player.ReplacesBackground.Value = false);
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Background is visible", () => songSelect.IsBackgroundVisible());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -169,16 +160,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
public void StoryboardTransitionTest()
|
public void StoryboardTransitionTest()
|
||||||
{
|
{
|
||||||
performSetup();
|
performSetup();
|
||||||
AddStep("Enable storyboard", () =>
|
createFakeStoryboard();
|
||||||
{
|
|
||||||
player.ReplacesBackground.Value = true;
|
|
||||||
player.StoryboardEnabled.Value = true;
|
|
||||||
player.CurrentStoryboardContainer.Add(new Box
|
|
||||||
{
|
|
||||||
Alpha = 1,
|
|
||||||
Colour = Color4.Tomato
|
|
||||||
});
|
|
||||||
});
|
|
||||||
AddUntilStep(() =>
|
AddUntilStep(() =>
|
||||||
{
|
{
|
||||||
if (songSelect.IsCurrentScreen()) return true;
|
if (songSelect.IsCurrentScreen()) return true;
|
||||||
@ -265,6 +247,17 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
private void waitForDim() => AddWaitStep(5, "Wait for dim");
|
private void waitForDim() => AddWaitStep(5, "Wait for dim");
|
||||||
|
|
||||||
|
private void createFakeStoryboard() => AddStep("Enable storyboard", () =>
|
||||||
|
{
|
||||||
|
player.ReplacesBackground.Value = true;
|
||||||
|
player.StoryboardEnabled.Value = true;
|
||||||
|
player.CurrentStoryboardContainer.Add(new Box
|
||||||
|
{
|
||||||
|
Alpha = 1,
|
||||||
|
Colour = Color4.Tomato
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
private void performSetup(bool allowPause = false)
|
private void performSetup(bool allowPause = false)
|
||||||
{
|
{
|
||||||
createSongSelect();
|
createSongSelect();
|
||||||
@ -344,6 +337,16 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||||
|
|
||||||
|
protected override UserDimContainer CreateStoryboardContainer()
|
||||||
|
{
|
||||||
|
return new TestUserDimContainer(true)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 1,
|
||||||
|
EnableUserDim = { Value = true }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public UserDimContainer CurrentStoryboardContainer => StoryboardContainer;
|
public UserDimContainer CurrentStoryboardContainer => StoryboardContainer;
|
||||||
// Whether or not the player should be allowed to load.
|
// Whether or not the player should be allowed to load.
|
||||||
public bool Ready;
|
public bool Ready;
|
||||||
@ -352,6 +355,10 @@ namespace osu.Game.Tests.Visual
|
|||||||
public readonly Bindable<bool> ReplacesBackground = new Bindable<bool>();
|
public readonly Bindable<bool> ReplacesBackground = new Bindable<bool>();
|
||||||
public readonly Bindable<bool> IsPaused = new Bindable<bool>();
|
public readonly Bindable<bool> IsPaused = new Bindable<bool>();
|
||||||
|
|
||||||
|
public bool IsStoryboardVisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha == 1;
|
||||||
|
|
||||||
|
public bool IsStoryboardInvisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha <= 1;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
@ -401,12 +408,16 @@ namespace osu.Game.Tests.Visual
|
|||||||
: base(beatmap)
|
: base(beatmap)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class TestUserDimContainer : UserDimContainer
|
private class TestUserDimContainer : UserDimContainer
|
||||||
{
|
{
|
||||||
|
public TestUserDimContainer(bool isStoryboard = false)
|
||||||
|
: base(isStoryboard)
|
||||||
|
{
|
||||||
|
}
|
||||||
public Color4 CurrentColour => DimContainer.Colour;
|
public Color4 CurrentColour => DimContainer.Colour;
|
||||||
public float CurrentAlpha => DimContainer.Alpha;
|
public float CurrentAlpha => DimContainer.Alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -89,6 +89,13 @@ namespace osu.Game.Screens.Play
|
|||||||
private DrawableStoryboard storyboard;
|
private DrawableStoryboard storyboard;
|
||||||
protected UserDimContainer StoryboardContainer;
|
protected UserDimContainer StoryboardContainer;
|
||||||
|
|
||||||
|
protected virtual UserDimContainer CreateStoryboardContainer() => new UserDimContainer(true)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 1,
|
||||||
|
EnableUserDim = { Value = true }
|
||||||
|
};
|
||||||
|
|
||||||
public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true;
|
public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -176,12 +183,7 @@ namespace osu.Game.Screens.Play
|
|||||||
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded.Value,
|
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded.Value,
|
||||||
Children = new Container[]
|
Children = new Container[]
|
||||||
{
|
{
|
||||||
StoryboardContainer = new UserDimContainer(true)
|
StoryboardContainer = CreateStoryboardContainer(),
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Alpha = 1,
|
|
||||||
EnableUserDim = { Value = true }
|
|
||||||
},
|
|
||||||
new ScalingContainer(ScalingMode.Gameplay)
|
new ScalingContainer(ScalingMode.Gameplay)
|
||||||
{
|
{
|
||||||
Child = new LocalSkinOverrideContainer(working.Skin)
|
Child = new LocalSkinOverrideContainer(working.Skin)
|
||||||
|
Loading…
Reference in New Issue
Block a user