mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
add visual test
This commit is contained in:
@ -5,12 +5,14 @@
|
|||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.PolygonExtensions;
|
using osu.Framework.Extensions.PolygonExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -24,6 +26,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private readonly BindableDouble playerScore = new BindableDouble();
|
private readonly BindableDouble playerScore = new BindableDouble();
|
||||||
|
|
||||||
|
private Bindable<bool> configVisibility = new Bindable<bool>();
|
||||||
|
|
||||||
public TestSceneGameplayLeaderboard()
|
public TestSceneGameplayLeaderboard()
|
||||||
{
|
{
|
||||||
AddStep("toggle expanded", () =>
|
AddStep("toggle expanded", () =>
|
||||||
@ -35,6 +39,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddSliderStep("set player score", 50, 5000000, 1222333, v => playerScore.Value = v);
|
AddSliderStep("set player score", 50, 5000000, 1222333, v => playerScore.Value = v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
config.BindWith(OsuSetting.GameplayLeaderboard, configVisibility);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestLayoutWithManyScores()
|
public void TestLayoutWithManyScores()
|
||||||
{
|
{
|
||||||
@ -129,6 +139,21 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
=> AddAssert($"leaderboard height is {panelCount} panels high", () => leaderboard.DrawHeight == (GameplayLeaderboardScore.PANEL_HEIGHT + leaderboard.Spacing) * panelCount);
|
=> AddAssert($"leaderboard height is {panelCount} panels high", () => leaderboard.DrawHeight == (GameplayLeaderboardScore.PANEL_HEIGHT + leaderboard.Spacing) * panelCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestVisibility()
|
||||||
|
{
|
||||||
|
createLeaderboard();
|
||||||
|
addLocalPlayer();
|
||||||
|
|
||||||
|
AddStep("set visible true", () => configVisibility.Value = true);
|
||||||
|
AddWaitStep("wait", 1);
|
||||||
|
AddAssert("is leaderboard fully visible", () => leaderboard.FlowAlpha == 1);
|
||||||
|
|
||||||
|
AddStep("set visible false", () => configVisibility.Value = false);
|
||||||
|
AddWaitStep("wait", 1);
|
||||||
|
AddAssert("is leaderboard fully invisible", () => leaderboard.FlowAlpha == 0);
|
||||||
|
}
|
||||||
|
|
||||||
private void addLocalPlayer()
|
private void addLocalPlayer()
|
||||||
{
|
{
|
||||||
AddStep("add local player", () =>
|
AddStep("add local player", () =>
|
||||||
@ -163,6 +188,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
public float Spacing => Flow.Spacing.Y;
|
public float Spacing => Flow.Spacing.Y;
|
||||||
|
|
||||||
|
public float FlowAlpha => Flow.Alpha;
|
||||||
|
|
||||||
public bool CheckPositionByUsername(string username, int? expectedPosition)
|
public bool CheckPositionByUsername(string username, int? expectedPosition)
|
||||||
{
|
{
|
||||||
var scoreItem = Flow.FirstOrDefault(i => i.User?.Username == username);
|
var scoreItem = Flow.FirstOrDefault(i => i.User?.Username == username);
|
||||||
|
Reference in New Issue
Block a user