mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Merge branch 'master' into fix-password-popover-focus
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays.BeatmapSet;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
@ -22,7 +23,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
AddStep("set undownloadable beatmapset with link", () => container.BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Availability = new BeatmapSetOnlineAvailability
|
||||
{
|
||||
@ -40,7 +41,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
AddStep("set undownloadable beatmapset without link", () => container.BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Availability = new BeatmapSetOnlineAvailability
|
||||
{
|
||||
@ -57,7 +58,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
AddStep("set parts-removed beatmapset with link", () => container.BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Availability = new BeatmapSetOnlineAvailability
|
||||
{
|
||||
@ -75,7 +76,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
AddStep("set normal beatmapset", () => container.BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Availability = new BeatmapSetOnlineAvailability
|
||||
{
|
||||
|
@ -11,6 +11,7 @@ using osu.Game.Users;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
@ -63,7 +64,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Id = 3,
|
||||
},
|
||||
},
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Preview = @"https://b.ppy.sh/preview/12345.mp3",
|
||||
PlayCount = 123,
|
||||
@ -134,7 +135,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Id = 3,
|
||||
},
|
||||
},
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Availability = new BeatmapSetOnlineAvailability
|
||||
{
|
||||
@ -224,7 +225,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Id = 3,
|
||||
}
|
||||
},
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Covers = new BeatmapSetOnlineCovers(),
|
||||
},
|
||||
@ -309,7 +310,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Id = 3,
|
||||
},
|
||||
},
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Preview = @"https://b.ppy.sh/preview/123.mp3",
|
||||
HasVideo = true,
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.BeatmapSet;
|
||||
using osu.Game.Screens.Select.Details;
|
||||
@ -57,7 +58,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
}
|
||||
},
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Status = BeatmapSetOnlineStatus.Ranked
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays.BeatmapListing.Panels;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Tests.Resources;
|
||||
@ -74,7 +75,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
ID = 1,
|
||||
OnlineBeatmapSetID = 241526,
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Availability = new BeatmapSetOnlineAvailability
|
||||
{
|
||||
|
@ -7,6 +7,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays.BeatmapListing.Panels;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Users;
|
||||
@ -31,7 +32,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Id = 3,
|
||||
},
|
||||
},
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Availability = new BeatmapSetOnlineAvailability
|
||||
{
|
||||
@ -86,7 +87,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Id = 3,
|
||||
}
|
||||
},
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
HasVideo = true,
|
||||
HasStoryboard = true,
|
||||
|
@ -3,11 +3,7 @@
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Overlays.Profile.Header.Components;
|
||||
using osu.Game.Users;
|
||||
|
||||
@ -16,48 +12,50 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[TestFixture]
|
||||
public class TestSceneUserProfilePreviousUsernames : OsuTestScene
|
||||
{
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
private PreviousUsernames container;
|
||||
|
||||
private readonly Bindable<User> user = new Bindable<User>();
|
||||
|
||||
public TestSceneUserProfilePreviousUsernames()
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
Child = new PreviousUsernames
|
||||
Child = container = new PreviousUsernames
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
User = { BindTarget = user },
|
||||
};
|
||||
});
|
||||
|
||||
User[] users =
|
||||
{
|
||||
new User { PreviousUsernames = new[] { "username1" } },
|
||||
new User { PreviousUsernames = new[] { "longusername", "longerusername" } },
|
||||
new User { PreviousUsernames = new[] { "test", "angelsim", "verylongusername" } },
|
||||
new User { PreviousUsernames = new[] { "ihavenoidea", "howcani", "makethistext", "anylonger" } },
|
||||
new User { PreviousUsernames = Array.Empty<string>() },
|
||||
null
|
||||
};
|
||||
|
||||
AddStep("single username", () => user.Value = users[0]);
|
||||
AddStep("two usernames", () => user.Value = users[1]);
|
||||
AddStep("three usernames", () => user.Value = users[2]);
|
||||
AddStep("four usernames", () => user.Value = users[3]);
|
||||
AddStep("no username", () => user.Value = users[4]);
|
||||
AddStep("null user", () => user.Value = users[5]);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
[Test]
|
||||
public void TestVisibility()
|
||||
{
|
||||
base.LoadComplete();
|
||||
AddAssert("Is Hidden", () => container.Alpha == 0);
|
||||
|
||||
AddStep("online user (Angelsim)", () =>
|
||||
{
|
||||
var request = new GetUserRequest(1777162);
|
||||
request.Success += user => this.user.Value = user;
|
||||
api.Queue(request);
|
||||
});
|
||||
AddStep("1 username", () => container.User.Value = users[0]);
|
||||
AddUntilStep("Is visible", () => container.Alpha == 1);
|
||||
|
||||
AddStep("2 usernames", () => container.User.Value = users[1]);
|
||||
AddUntilStep("Is visible", () => container.Alpha == 1);
|
||||
|
||||
AddStep("3 usernames", () => container.User.Value = users[2]);
|
||||
AddUntilStep("Is visible", () => container.Alpha == 1);
|
||||
|
||||
AddStep("4 usernames", () => container.User.Value = users[3]);
|
||||
AddUntilStep("Is visible", () => container.Alpha == 1);
|
||||
|
||||
AddStep("No username", () => container.User.Value = users[4]);
|
||||
AddUntilStep("Is hidden", () => container.Alpha == 0);
|
||||
|
||||
AddStep("Null user", () => container.User.Value = users[5]);
|
||||
AddUntilStep("Is hidden", () => container.Alpha == 0);
|
||||
}
|
||||
|
||||
private static readonly User[] users =
|
||||
{
|
||||
new User { Id = 1, PreviousUsernames = new[] { "username1" } },
|
||||
new User { Id = 2, PreviousUsernames = new[] { "longusername", "longerusername" } },
|
||||
new User { Id = 3, PreviousUsernames = new[] { "test", "angelsim", "verylongusername" } },
|
||||
new User { Id = 4, PreviousUsernames = new[] { "ihavenoidea", "howcani", "makethistext", "anylonger" } },
|
||||
new User { Id = 5, PreviousUsernames = Array.Empty<string>() },
|
||||
null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,63 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Settings
|
||||
{
|
||||
public class TestSceneRestoreDefaultValueButton : OsuTestScene
|
||||
{
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
private float scale = 1;
|
||||
|
||||
private readonly Bindable<float> current = new Bindable<float>
|
||||
{
|
||||
Default = default,
|
||||
Value = 1,
|
||||
};
|
||||
|
||||
[Test]
|
||||
public void TestBasic()
|
||||
{
|
||||
RestoreDefaultValueButton<float> restoreDefaultValueButton = null;
|
||||
|
||||
AddStep("create button", () => Child = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.GreySeafoam
|
||||
},
|
||||
restoreDefaultValueButton = new RestoreDefaultValueButton<float>
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Scale = new Vector2(scale),
|
||||
Current = current,
|
||||
}
|
||||
}
|
||||
});
|
||||
AddSliderStep("set scale", 1, 4, 1, scale =>
|
||||
{
|
||||
this.scale = scale;
|
||||
if (restoreDefaultValueButton != null)
|
||||
restoreDefaultValueButton.Scale = new Vector2(scale);
|
||||
});
|
||||
AddToggleStep("toggle default state", state => current.Value = state ? default : 1);
|
||||
AddToggleStep("toggle disabled state", state => current.Disabled = state);
|
||||
}
|
||||
}
|
||||
}
|
@ -5,6 +5,9 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
@ -29,9 +32,10 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
Value = "test"
|
||||
}
|
||||
};
|
||||
|
||||
restoreDefaultValueButton = textBox.ChildrenOfType<RestoreDefaultValueButton<string>>().Single();
|
||||
});
|
||||
AddUntilStep("wait for loaded", () => textBox.IsLoaded);
|
||||
AddStep("retrieve restore default button", () => restoreDefaultValueButton = textBox.ChildrenOfType<RestoreDefaultValueButton<string>>().Single());
|
||||
|
||||
AddAssert("restore button hidden", () => restoreDefaultValueButton.Alpha == 0);
|
||||
|
||||
AddStep("change value from default", () => textBox.Current.Value = "non-default");
|
||||
@ -41,6 +45,48 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
AddUntilStep("restore button hidden", () => restoreDefaultValueButton.Alpha == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSetAndClearLabelText()
|
||||
{
|
||||
SettingsTextBox textBox = null;
|
||||
RestoreDefaultValueButton<string> restoreDefaultValueButton = null;
|
||||
OsuTextBox control = null;
|
||||
|
||||
AddStep("create settings item", () =>
|
||||
{
|
||||
Child = textBox = new SettingsTextBox
|
||||
{
|
||||
Current = new Bindable<string>
|
||||
{
|
||||
Default = "test",
|
||||
Value = "test"
|
||||
}
|
||||
};
|
||||
});
|
||||
AddUntilStep("wait for loaded", () => textBox.IsLoaded);
|
||||
AddStep("retrieve components", () =>
|
||||
{
|
||||
restoreDefaultValueButton = textBox.ChildrenOfType<RestoreDefaultValueButton<string>>().Single();
|
||||
control = textBox.ChildrenOfType<OsuTextBox>().Single();
|
||||
});
|
||||
|
||||
AddStep("set non-default value", () => restoreDefaultValueButton.Current.Value = "non-default");
|
||||
AddAssert("default value button centre aligned to control size", () => Precision.AlmostEquals(restoreDefaultValueButton.Parent.DrawHeight, control.DrawHeight, 1));
|
||||
|
||||
AddStep("set label", () => textBox.LabelText = "label text");
|
||||
AddAssert("default value button centre aligned to label size", () =>
|
||||
{
|
||||
var label = textBox.ChildrenOfType<OsuSpriteText>().Single(spriteText => spriteText.Text == "label text");
|
||||
return Precision.AlmostEquals(restoreDefaultValueButton.Parent.DrawHeight, label.DrawHeight, 1);
|
||||
});
|
||||
|
||||
AddStep("clear label", () => textBox.LabelText = default);
|
||||
AddAssert("default value button centre aligned to control size", () => Precision.AlmostEquals(restoreDefaultValueButton.Parent.DrawHeight, control.DrawHeight, 1));
|
||||
|
||||
AddStep("set warning text", () => textBox.WarningText = "This is some very important warning text! Hopefully it doesn't break the alignment of the default value indicator...");
|
||||
AddAssert("default value button centre aligned to control size", () => Precision.AlmostEquals(restoreDefaultValueButton.Parent.DrawHeight, control.DrawHeight, 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that the reset to default button uses the correct implementation of IsDefault to determine whether it should be shown or not.
|
||||
/// Values have been chosen so that after being set, Value != Default (but they are close enough that the difference is negligible compared to Precision).
|
||||
@ -64,9 +110,9 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
Precision = 0.1f,
|
||||
}
|
||||
};
|
||||
|
||||
restoreDefaultValueButton = sliderBar.ChildrenOfType<RestoreDefaultValueButton<float>>().Single();
|
||||
});
|
||||
AddUntilStep("wait for loaded", () => sliderBar.IsLoaded);
|
||||
AddStep("retrieve restore default button", () => restoreDefaultValueButton = sliderBar.ChildrenOfType<RestoreDefaultValueButton<float>>().Single());
|
||||
|
||||
AddAssert("restore button hidden", () => restoreDefaultValueButton.Alpha == 0);
|
||||
|
||||
|
@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.BeatmapListing;
|
||||
using osuTK;
|
||||
@ -111,7 +112,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
private static readonly BeatmapSetInfo beatmap_set = new BeatmapSetInfo
|
||||
{
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Covers = new BeatmapSetOnlineCovers
|
||||
{
|
||||
@ -122,7 +123,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
private static readonly BeatmapSetInfo no_cover_beatmap_set = new BeatmapSetInfo
|
||||
{
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Covers = new BeatmapSetOnlineCovers
|
||||
{
|
||||
|
@ -11,6 +11,7 @@ using osu.Game.Users;
|
||||
using System;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
@ -69,7 +70,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Id = 100
|
||||
}
|
||||
},
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Covers = new BeatmapSetOnlineCovers
|
||||
{
|
||||
@ -90,7 +91,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Id = 100
|
||||
}
|
||||
},
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Covers = new BeatmapSetOnlineCovers
|
||||
{
|
||||
@ -115,7 +116,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Id = 100
|
||||
}
|
||||
},
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Covers = new BeatmapSetOnlineCovers
|
||||
{
|
||||
@ -136,7 +137,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Id = 100
|
||||
}
|
||||
},
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Covers = new BeatmapSetOnlineCovers
|
||||
{
|
||||
|
20
osu.Game.Tests/Visual/UserInterface/TestSceneOsuDropdown.cs
Normal file
20
osu.Game.Tests/Visual/UserInterface/TestSceneOsuDropdown.cs
Normal file
@ -0,0 +1,20 @@
|
||||
// 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 osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneOsuDropdown : ThemeComparisonTestScene
|
||||
{
|
||||
protected override Drawable CreateContent() =>
|
||||
new OsuEnumDropdown<BeatmapSetOnlineStatus>
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 150
|
||||
};
|
||||
}
|
||||
}
|
@ -1,80 +1,67 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneOsuTextBox : OsuTestScene
|
||||
public class TestSceneOsuTextBox : ThemeComparisonTestScene
|
||||
{
|
||||
private readonly OsuNumberBox numberBox;
|
||||
private IEnumerable<OsuNumberBox> numberBoxes => this.ChildrenOfType<OsuNumberBox>();
|
||||
|
||||
public TestSceneOsuTextBox()
|
||||
protected override Drawable CreateContent() => new FillFlowContainer
|
||||
{
|
||||
Child = new Container
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Padding = new MarginPadding(50f),
|
||||
Spacing = new Vector2(0f, 50f),
|
||||
Children = new[]
|
||||
{
|
||||
Masking = true,
|
||||
CornerRadius = 10f,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(15f),
|
||||
Children = new Drawable[]
|
||||
new OsuTextBox
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.DarkSlateGray,
|
||||
Alpha = 0.75f,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Padding = new MarginPadding(50f),
|
||||
Spacing = new Vector2(0f, 50f),
|
||||
Children = new[]
|
||||
{
|
||||
new OsuTextBox
|
||||
{
|
||||
Width = 500f,
|
||||
PlaceholderText = "Normal textbox",
|
||||
},
|
||||
new OsuPasswordTextBox
|
||||
{
|
||||
Width = 500f,
|
||||
PlaceholderText = "Password textbox",
|
||||
},
|
||||
numberBox = new OsuNumberBox
|
||||
{
|
||||
Width = 500f,
|
||||
PlaceholderText = "Number textbox"
|
||||
}
|
||||
}
|
||||
}
|
||||
RelativeSizeAxes = Axes.X,
|
||||
PlaceholderText = "Normal textbox",
|
||||
},
|
||||
new OsuPasswordTextBox
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
PlaceholderText = "Password textbox",
|
||||
},
|
||||
new OsuNumberBox
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
PlaceholderText = "Number textbox"
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
[Test]
|
||||
public void TestNumberBox()
|
||||
{
|
||||
clearTextbox(numberBox);
|
||||
AddStep("enter numbers", () => numberBox.Text = "987654321");
|
||||
expectedValue(numberBox, "987654321");
|
||||
AddStep("create themed content", () => CreateThemedContent(OverlayColourScheme.Red));
|
||||
|
||||
clearTextbox(numberBox);
|
||||
AddStep("enter text + single number", () => numberBox.Text = "1 hello 2 world 3");
|
||||
expectedValue(numberBox, "123");
|
||||
clearTextboxes(numberBoxes);
|
||||
AddStep("enter numbers", () => numberBoxes.ForEach(numberBox => numberBox.Text = "987654321"));
|
||||
expectedValue(numberBoxes, "987654321");
|
||||
|
||||
clearTextbox(numberBox);
|
||||
clearTextboxes(numberBoxes);
|
||||
AddStep("enter text + single number", () => numberBoxes.ForEach(numberBox => numberBox.Text = "1 hello 2 world 3"));
|
||||
expectedValue(numberBoxes, "123");
|
||||
|
||||
clearTextboxes(numberBoxes);
|
||||
}
|
||||
|
||||
private void clearTextbox(OsuTextBox textBox) => AddStep("clear textbox", () => textBox.Text = null);
|
||||
private void expectedValue(OsuTextBox textBox, string value) => AddAssert("expected textbox value", () => textBox.Text == value);
|
||||
private void clearTextboxes(IEnumerable<OsuTextBox> textBoxes) => AddStep("clear textbox", () => textBoxes.ForEach(textBox => textBox.Text = null));
|
||||
private void expectedValue(IEnumerable<OsuTextBox> textBoxes, string value) => AddAssert("expected textbox value", () => textBoxes.All(textbox => textbox.Text == value));
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
@ -22,21 +23,21 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[Test]
|
||||
public void TestLocal([Values] BeatmapSetCoverType coverType)
|
||||
{
|
||||
AddStep("setup cover", () => Child = new UpdateableBeatmapSetCover(coverType)
|
||||
AddStep("setup cover", () => Child = new UpdateableOnlineBeatmapSetCover(coverType)
|
||||
{
|
||||
BeatmapSet = CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
});
|
||||
|
||||
AddUntilStep("wait for load", () => this.ChildrenOfType<BeatmapSetCover>().SingleOrDefault()?.IsLoaded ?? false);
|
||||
AddUntilStep("wait for load", () => this.ChildrenOfType<OnlineBeatmapSetCover>().SingleOrDefault()?.IsLoaded ?? false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUnloadAndReload()
|
||||
{
|
||||
OsuScrollContainer scroll = null;
|
||||
List<UpdateableBeatmapSetCover> covers = new List<UpdateableBeatmapSetCover>();
|
||||
List<UpdateableOnlineBeatmapSetCover> covers = new List<UpdateableOnlineBeatmapSetCover>();
|
||||
|
||||
AddStep("setup covers", () =>
|
||||
{
|
||||
@ -65,7 +66,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
var coverType = coverTypes[i % coverTypes.Count];
|
||||
|
||||
var cover = new UpdateableBeatmapSetCover(coverType)
|
||||
var cover = new UpdateableOnlineBeatmapSetCover(coverType)
|
||||
{
|
||||
BeatmapSet = setInfo,
|
||||
Height = 100,
|
||||
@ -84,7 +85,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
}
|
||||
});
|
||||
|
||||
var loadedCovers = covers.Where(c => c.ChildrenOfType<BeatmapSetCover>().SingleOrDefault()?.IsLoaded ?? false);
|
||||
var loadedCovers = covers.Where(c => c.ChildrenOfType<OnlineBeatmapSetCover>().SingleOrDefault()?.IsLoaded ?? false);
|
||||
|
||||
AddUntilStep("some loaded", () => loadedCovers.Any());
|
||||
AddStep("scroll to end", () => scroll.ScrollToEnd());
|
||||
@ -94,9 +95,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[Test]
|
||||
public void TestSetNullBeatmapWhileLoading()
|
||||
{
|
||||
TestUpdateableBeatmapSetCover updateableCover = null;
|
||||
TestUpdateableOnlineBeatmapSetCover updateableCover = null;
|
||||
|
||||
AddStep("setup cover", () => Child = updateableCover = new TestUpdateableBeatmapSetCover
|
||||
AddStep("setup cover", () => Child = updateableCover = new TestUpdateableOnlineBeatmapSetCover
|
||||
{
|
||||
BeatmapSet = CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -111,10 +112,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[Test]
|
||||
public void TestCoverChangeOnNewBeatmap()
|
||||
{
|
||||
TestUpdateableBeatmapSetCover updateableCover = null;
|
||||
BeatmapSetCover initialCover = null;
|
||||
TestUpdateableOnlineBeatmapSetCover updateableCover = null;
|
||||
OnlineBeatmapSetCover initialCover = null;
|
||||
|
||||
AddStep("setup cover", () => Child = updateableCover = new TestUpdateableBeatmapSetCover(0)
|
||||
AddStep("setup cover", () => Child = updateableCover = new TestUpdateableOnlineBeatmapSetCover(0)
|
||||
{
|
||||
BeatmapSet = createBeatmapWithCover("https://assets.ppy.sh/beatmaps/1189904/covers/cover.jpg"),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -122,38 +123,38 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Alpha = 0.4f
|
||||
});
|
||||
|
||||
AddUntilStep("cover loaded", () => updateableCover.ChildrenOfType<BeatmapSetCover>().Any());
|
||||
AddStep("store initial cover", () => initialCover = updateableCover.ChildrenOfType<BeatmapSetCover>().Single());
|
||||
AddUntilStep("cover loaded", () => updateableCover.ChildrenOfType<OnlineBeatmapSetCover>().Any());
|
||||
AddStep("store initial cover", () => initialCover = updateableCover.ChildrenOfType<OnlineBeatmapSetCover>().Single());
|
||||
AddUntilStep("wait for fade complete", () => initialCover.Alpha == 1);
|
||||
|
||||
AddStep("switch beatmap",
|
||||
() => updateableCover.BeatmapSet = createBeatmapWithCover("https://assets.ppy.sh/beatmaps/1079428/covers/cover.jpg"));
|
||||
AddUntilStep("new cover loaded", () => updateableCover.ChildrenOfType<BeatmapSetCover>().Except(new[] { initialCover }).Any());
|
||||
AddUntilStep("new cover loaded", () => updateableCover.ChildrenOfType<OnlineBeatmapSetCover>().Except(new[] { initialCover }).Any());
|
||||
}
|
||||
|
||||
private static BeatmapSetInfo createBeatmapWithCover(string coverUrl) => new BeatmapSetInfo
|
||||
{
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
OnlineInfo = new APIBeatmapSet
|
||||
{
|
||||
Covers = new BeatmapSetOnlineCovers { Cover = coverUrl }
|
||||
}
|
||||
};
|
||||
|
||||
private class TestUpdateableBeatmapSetCover : UpdateableBeatmapSetCover
|
||||
private class TestUpdateableOnlineBeatmapSetCover : UpdateableOnlineBeatmapSetCover
|
||||
{
|
||||
private readonly int loadDelay;
|
||||
|
||||
public TestUpdateableBeatmapSetCover(int loadDelay = 10000)
|
||||
public TestUpdateableOnlineBeatmapSetCover(int loadDelay = 10000)
|
||||
{
|
||||
this.loadDelay = loadDelay;
|
||||
}
|
||||
|
||||
protected override Drawable CreateDrawable(BeatmapSetInfo model)
|
||||
protected override Drawable CreateDrawable(IBeatmapSetOnlineInfo model)
|
||||
{
|
||||
if (model == null)
|
||||
return null;
|
||||
|
||||
return new TestBeatmapSetCover(model, loadDelay)
|
||||
return new TestOnlineBeatmapSetCover(model, loadDelay)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -163,11 +164,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
private class TestBeatmapSetCover : BeatmapSetCover
|
||||
private class TestOnlineBeatmapSetCover : OnlineBeatmapSetCover
|
||||
{
|
||||
private readonly int loadDelay;
|
||||
|
||||
public TestBeatmapSetCover(BeatmapSetInfo set, int loadDelay)
|
||||
public TestOnlineBeatmapSetCover(IBeatmapSetOnlineInfo set, int loadDelay)
|
||||
: base(set)
|
||||
{
|
||||
this.loadDelay = loadDelay;
|
||||
|
@ -0,0 +1,69 @@
|
||||
// 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.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public abstract class ThemeComparisonTestScene : OsuGridTestScene
|
||||
{
|
||||
protected ThemeComparisonTestScene()
|
||||
: base(1, 2)
|
||||
{
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Cell(0, 0).AddRange(new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.GreySeafoam
|
||||
},
|
||||
CreateContent()
|
||||
});
|
||||
}
|
||||
|
||||
protected void CreateThemedContent(OverlayColourScheme colourScheme)
|
||||
{
|
||||
var colourProvider = new OverlayColourProvider(colourScheme);
|
||||
|
||||
Cell(0, 1).Clear();
|
||||
Cell(0, 1).Add(new DependencyProvidingContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
CachedDependencies = new (Type, object)[]
|
||||
{
|
||||
(typeof(OverlayColourProvider), colourProvider)
|
||||
},
|
||||
Children = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colourProvider.Background4
|
||||
},
|
||||
CreateContent()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract Drawable CreateContent();
|
||||
|
||||
[Test]
|
||||
public void TestAllColourSchemes()
|
||||
{
|
||||
foreach (var scheme in Enum.GetValues(typeof(OverlayColourScheme)).Cast<OverlayColourScheme>())
|
||||
AddStep($"set {scheme} scheme", () => CreateThemedContent(scheme));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user