mirror of
https://github.com/ppy/osu
synced 2025-01-10 08:09:40 +00:00
Create a new player every time a test is performed.
This commit is contained in:
parent
65cdac60c3
commit
918a60ebbf
@ -42,6 +42,21 @@ namespace osu.Game.Tests.Visual
|
|||||||
[Cached]
|
[Cached]
|
||||||
private BackgroundScreenStack backgroundStack;
|
private BackgroundScreenStack backgroundStack;
|
||||||
|
|
||||||
|
private void performSetup()
|
||||||
|
{
|
||||||
|
AddUntilStep(() =>
|
||||||
|
{
|
||||||
|
if (!songSelect.IsCurrentScreen())
|
||||||
|
{
|
||||||
|
songSelect.MakeCurrent();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}, "Wait for song select is current");
|
||||||
|
AddStep("Load new player to song select", () => songSelect.Push(player = new DimAccessiblePlayer { Ready = true }));
|
||||||
|
AddUntilStep(() => player?.IsLoaded ?? false, "Wait for player to load");
|
||||||
|
}
|
||||||
|
|
||||||
public TestCaseBackgroundScreenBeatmap()
|
public TestCaseBackgroundScreenBeatmap()
|
||||||
{
|
{
|
||||||
ScreenStack screen;
|
ScreenStack screen;
|
||||||
@ -58,6 +73,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
songSelect = p;
|
songSelect = p;
|
||||||
screen.Push(p);
|
screen.Push(p);
|
||||||
|
songSelect.UpdateBindables();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -85,8 +101,6 @@ namespace osu.Game.Tests.Visual
|
|||||||
AddStep("Start player loader", () => songSelect.Push(playerLoader = new DimAccessiblePlayerLoader(player = new DimAccessiblePlayer())));
|
AddStep("Start player loader", () => songSelect.Push(playerLoader = new DimAccessiblePlayerLoader(player = new DimAccessiblePlayer())));
|
||||||
AddUntilStep(() => playerLoader?.IsLoaded ?? false, "Wait for Player Loader to load");
|
AddUntilStep(() => playerLoader?.IsLoaded ?? false, "Wait for Player Loader to load");
|
||||||
AddAssert("Background retained from song select", () => songSelect.AssertBackgroundCurrent());
|
AddAssert("Background retained from song select", () => songSelect.AssertBackgroundCurrent());
|
||||||
|
|
||||||
AddStep("Update bindables", () => playerLoader.UpdateBindables());
|
|
||||||
AddStep("Trigger background preview", () =>
|
AddStep("Trigger background preview", () =>
|
||||||
{
|
{
|
||||||
InputManager.MoveMouseTo(playerLoader.ScreenPos);
|
InputManager.MoveMouseTo(playerLoader.ScreenPos);
|
||||||
@ -134,7 +148,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
[Test]
|
[Test]
|
||||||
public void DisableUserDimTest()
|
public void DisableUserDimTest()
|
||||||
{
|
{
|
||||||
AddStep("Test User Undimming", () => playerLoader.DimEnabled.Value = false);
|
performSetup();
|
||||||
|
AddStep("Test User Undimming", () => songSelect.DimEnabled.Value = false);
|
||||||
AddWaitStep(5, "Wait for dim");
|
AddWaitStep(5, "Wait for dim");
|
||||||
AddAssert("Screen is undimmed", () => songSelect.AssertUndimmed());
|
AddAssert("Screen is undimmed", () => songSelect.AssertUndimmed());
|
||||||
}
|
}
|
||||||
@ -145,7 +160,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
[Test]
|
[Test]
|
||||||
public void EnableUserDimTest()
|
public void EnableUserDimTest()
|
||||||
{
|
{
|
||||||
AddStep("Test User Dimming", () => playerLoader.DimEnabled.Value = true);
|
performSetup();
|
||||||
|
AddStep("Test User Dimming", () => songSelect.DimEnabled.Value = true);
|
||||||
AddWaitStep(5, "Wait for dim");
|
AddWaitStep(5, "Wait for dim");
|
||||||
AddAssert("Screen is dimmed", () => songSelect.AssertDimmed());
|
AddAssert("Screen is dimmed", () => songSelect.AssertDimmed());
|
||||||
}
|
}
|
||||||
@ -156,6 +172,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
[Test]
|
[Test]
|
||||||
public void PauseTest()
|
public void PauseTest()
|
||||||
{
|
{
|
||||||
|
performSetup();
|
||||||
AddStep("Transition to Pause", () =>
|
AddStep("Transition to Pause", () =>
|
||||||
{
|
{
|
||||||
if (!player.IsPaused)
|
if (!player.IsPaused)
|
||||||
@ -171,6 +188,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
[Test]
|
[Test]
|
||||||
public void TransitionTest()
|
public void TransitionTest()
|
||||||
{
|
{
|
||||||
|
performSetup();
|
||||||
AddStep("Transition to Results", () => player.Push(new FadeAccesibleResults(new ScoreInfo { User = new User { Username = "osu!" }})));
|
AddStep("Transition to Results", () => player.Push(new FadeAccesibleResults(new ScoreInfo { User = new User { Username = "osu!" }})));
|
||||||
AddWaitStep(5, "Wait for dim");
|
AddWaitStep(5, "Wait for dim");
|
||||||
AddAssert("Screen is undimmed", () => songSelect.AssertUndimmed());
|
AddAssert("Screen is undimmed", () => songSelect.AssertUndimmed());
|
||||||
@ -183,11 +201,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
[Test]
|
[Test]
|
||||||
public void TransitionOutTest()
|
public void TransitionOutTest()
|
||||||
{
|
{
|
||||||
AddStep("Exit player", () =>
|
performSetup();
|
||||||
{
|
AddStep("Exit player", () => songSelect.MakeCurrent());
|
||||||
player.MakeCurrent();
|
|
||||||
player.Exit();
|
|
||||||
});
|
|
||||||
AddWaitStep(5, "Wait for dim");
|
AddWaitStep(5, "Wait for dim");
|
||||||
AddAssert("Screen is undimmed", () => songSelect.AssertUndimmed());
|
AddAssert("Screen is undimmed", () => songSelect.AssertUndimmed());
|
||||||
}
|
}
|
||||||
@ -195,6 +210,12 @@ namespace osu.Game.Tests.Visual
|
|||||||
private class DummySongSelect : OsuScreen
|
private class DummySongSelect : OsuScreen
|
||||||
{
|
{
|
||||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground();
|
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground();
|
||||||
|
public readonly Bindable<bool> DimEnabled = new Bindable<bool>();
|
||||||
|
|
||||||
|
public void UpdateBindables()
|
||||||
|
{
|
||||||
|
DimEnabled.BindTo(((FadeAccessibleBackground)Background).EnableUserDim);
|
||||||
|
}
|
||||||
|
|
||||||
public bool AssertDimmed()
|
public bool AssertDimmed()
|
||||||
{
|
{
|
||||||
@ -258,19 +279,11 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
private class DimAccessiblePlayerLoader : PlayerLoader
|
private class DimAccessiblePlayerLoader : PlayerLoader
|
||||||
{
|
{
|
||||||
public Bindable<bool> DimEnabled = new Bindable<bool>();
|
|
||||||
|
|
||||||
public VisualSettings VisualSettingsPos => VisualSettings;
|
public VisualSettings VisualSettingsPos => VisualSettings;
|
||||||
public BackgroundScreen ScreenPos => Background;
|
public BackgroundScreen ScreenPos => Background;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BackgroundScreenStack stack { get; set; }
|
private BackgroundScreenStack stack { get; set; }
|
||||||
|
|
||||||
public void UpdateBindables()
|
|
||||||
{
|
|
||||||
DimEnabled = Background.EnableUserDim;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DimAccessiblePlayerLoader(Player player) : base(() => player)
|
public DimAccessiblePlayerLoader(Player player) : base(() => player)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
public class BackgroundScreenBeatmap : BlurrableBackgroundScreen
|
public class BackgroundScreenBeatmap : BlurrableBackgroundScreen
|
||||||
{
|
{
|
||||||
private WorkingBeatmap beatmap;
|
private WorkingBeatmap beatmap;
|
||||||
protected Bindable<double> DimLevel;
|
protected Bindable<double> DimLevel = new Bindable<double>();
|
||||||
public Bindable<bool> EnableUserDim;
|
public Bindable<bool> EnableUserDim = new Bindable<bool>();
|
||||||
public Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
public Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
||||||
|
|
||||||
protected UserDimContainer FadeContainer;
|
protected UserDimContainer FadeContainer;
|
||||||
@ -24,7 +24,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
DimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
config.BindWith(OsuSetting.DimLevel, DimLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual WorkingBeatmap Beatmap
|
public virtual WorkingBeatmap Beatmap
|
||||||
@ -39,7 +39,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
|
|
||||||
FadeContainer = new UserDimContainer { RelativeSizeAxes = Axes.Both };
|
FadeContainer = new UserDimContainer { RelativeSizeAxes = Axes.Both };
|
||||||
InternalChild = FadeContainer;
|
InternalChild = FadeContainer;
|
||||||
EnableUserDim = FadeContainer.EnableUserDim;
|
EnableUserDim.BindTo(FadeContainer.EnableUserDim);
|
||||||
|
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user