1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-30 22:22:55 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneFavouriteButton.cs

66 lines
2.1 KiB
C#
Raw Normal View History

2019-11-13 10:59:03 +08:00
// 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.
2022-06-17 15:37:17 +08:00
#nullable disable
2019-11-13 10:59:03 +08:00
using NUnit.Framework;
2019-11-13 11:09:18 +08:00
using osu.Framework.Graphics;
2019-11-13 10:59:03 +08:00
using osu.Framework.Testing;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
2019-11-13 10:59:03 +08:00
using osu.Game.Overlays.BeatmapSet.Buttons;
2019-11-13 11:09:18 +08:00
using osuTK;
2019-11-13 10:59:03 +08:00
namespace osu.Game.Tests.Visual.Online
{
2022-11-24 13:32:20 +08:00
public partial class TestSceneFavouriteButton : OsuTestScene
2019-11-13 10:59:03 +08:00
{
private FavouriteButton favourite;
[SetUpSteps]
public void SetUpSteps()
{
2019-11-13 11:09:18 +08:00
AddStep("create button", () => Child = favourite = new FavouriteButton
{
RelativeSizeAxes = Axes.None,
Size = new Vector2(50),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
2019-11-13 10:59:03 +08:00
}
[Test]
public void TestLoggedOutIn()
{
AddStep("set valid beatmap", () => favourite.BeatmapSet.Value = new APIBeatmapSet { OnlineID = 88 });
2019-11-13 10:59:03 +08:00
AddStep("log out", () => API.Logout());
checkEnabled(false);
AddStep("log in", () =>
{
API.Login("test", "test");
((DummyAPIAccess)API).AuthenticateSecondFactor("abcdefgh");
});
2019-11-13 10:59:03 +08:00
checkEnabled(true);
}
[Test]
public void TestBeatmapChange()
{
AddStep("log in", () =>
{
API.Login("test", "test");
((DummyAPIAccess)API).AuthenticateSecondFactor("abcdefgh");
});
AddStep("set valid beatmap", () => favourite.BeatmapSet.Value = new APIBeatmapSet { OnlineID = 88 });
2019-11-13 10:59:03 +08:00
checkEnabled(true);
AddStep("set invalid beatmap", () => favourite.BeatmapSet.Value = new APIBeatmapSet());
2019-11-13 11:09:18 +08:00
checkEnabled(false);
2019-11-13 10:59:03 +08:00
}
private void checkEnabled(bool expected)
{
AddAssert("is " + (expected ? "enabled" : "disabled"), () => favourite.Enabled.Value == expected);
}
}
}