1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 18:07:24 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs

78 lines
2.7 KiB
C#
Raw Normal View History

2019-03-05 16:14:30 +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.
using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
2019-03-05 16:14:30 +08:00
using osu.Game.Overlays.Direct;
using osu.Game.Rulesets;
2019-03-05 16:14:30 +08:00
using osu.Game.Rulesets.Osu;
using osuTK;
2019-03-25 00:02:36 +08:00
namespace osu.Game.Tests.Visual.Online
2019-03-05 16:14:30 +08:00
{
public class TestSceneDirectPanel : OsuTestScene
2019-03-05 16:14:30 +08:00
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(DirectGridPanel),
typeof(DirectListPanel),
typeof(IconPill)
};
private BeatmapSetInfo getBeatmapSet(RulesetInfo ruleset, bool downloadable)
{
var beatmap = CreateWorkingBeatmap(ruleset).BeatmapSetInfo;
beatmap.OnlineInfo.HasVideo = true;
beatmap.OnlineInfo.HasStoryboard = true;
beatmap.OnlineInfo.Availability = new BeatmapSetOnlineAvailability
{
DownloadDisabled = !downloadable,
ExternalLink = "http://localhost",
};
return beatmap;
}
2019-03-05 16:14:30 +08:00
[BackgroundDependencyLoader]
private void load()
{
var ruleset = new OsuRuleset().RulesetInfo;
var normal = CreateWorkingBeatmap(ruleset).BeatmapSetInfo;
normal.OnlineInfo.HasVideo = true;
normal.OnlineInfo.HasStoryboard = true;
var downloadable = getBeatmapSet(ruleset, true);
var undownloadable = getBeatmapSet(ruleset, false);
DirectPanel undownloadableGridPanel, undownloadableListPanel;
2019-03-05 16:14:30 +08:00
Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Padding = new MarginPadding(20),
Spacing = new Vector2(0, 20),
Children = new Drawable[]
{
new DirectGridPanel(normal),
new DirectGridPanel(downloadable),
undownloadableGridPanel = new DirectGridPanel(undownloadable),
new DirectListPanel(normal),
new DirectListPanel(downloadable),
undownloadableListPanel = new DirectListPanel(undownloadable),
},
2019-03-05 16:14:30 +08:00
};
AddAssert("is download button disabled on last grid panel", () => !undownloadableGridPanel.DownloadButton.Enabled.Value);
AddAssert("is download button disabled on last list panel", () => !undownloadableListPanel.DownloadButton.Enabled.Value);
2019-03-05 16:14:30 +08:00
}
}
}