2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-12-12 21:44:12 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-12-22 19:33:52 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2018-03-02 14:34:31 +08:00
|
|
|
|
using NUnit.Framework;
|
2017-12-12 21:44:12 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2017-12-22 19:33:52 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Osu;
|
2017-12-12 21:44:12 +08:00
|
|
|
|
using osu.Game.Screens.Select;
|
2017-12-22 19:33:52 +08:00
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
2017-12-12 21:44:12 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
|
{
|
2018-03-02 14:34:31 +08:00
|
|
|
|
[TestFixture]
|
2017-12-20 20:47:45 +08:00
|
|
|
|
public class TestCaseBeatmapInfoWedge : OsuTestCase
|
2017-12-12 21:44:12 +08:00
|
|
|
|
{
|
2017-12-23 00:38:22 +08:00
|
|
|
|
private RulesetStore rulesets;
|
2017-12-22 19:33:52 +08:00
|
|
|
|
private TestBeatmapInfoWedge infoWedge;
|
|
|
|
|
private readonly List<Beatmap> beatmaps = new List<Beatmap>();
|
2017-12-12 21:44:12 +08:00
|
|
|
|
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
|
|
|
|
|
2017-12-22 19:33:52 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuGameBase game, RulesetStore rulesets)
|
2017-12-12 21:44:12 +08:00
|
|
|
|
{
|
2017-12-23 00:38:22 +08:00
|
|
|
|
this.rulesets = rulesets;
|
|
|
|
|
|
2017-12-22 19:33:52 +08:00
|
|
|
|
beatmap.BindTo(game.Beatmap);
|
2017-12-23 00:38:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2017-12-12 21:44:12 +08:00
|
|
|
|
|
2017-12-22 19:33:52 +08:00
|
|
|
|
Add(infoWedge = new TestBeatmapInfoWedge
|
2017-12-12 21:44:12 +08:00
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(0.5f, 245),
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-12-26 19:18:47 +08:00
|
|
|
|
Margin = new MarginPadding { Top = 20 }
|
2017-12-12 21:44:12 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddStep("show", () =>
|
|
|
|
|
{
|
|
|
|
|
infoWedge.State = Visibility.Visible;
|
|
|
|
|
infoWedge.UpdateBeatmap(beatmap);
|
|
|
|
|
});
|
2017-12-22 19:33:52 +08:00
|
|
|
|
|
2017-12-26 19:18:47 +08:00
|
|
|
|
AddWaitStep(3);
|
|
|
|
|
|
|
|
|
|
AddStep("hide", () => { infoWedge.State = Visibility.Hidden; });
|
|
|
|
|
|
|
|
|
|
AddWaitStep(3);
|
|
|
|
|
|
|
|
|
|
AddStep("show", () => { infoWedge.State = Visibility.Visible; });
|
|
|
|
|
|
2017-12-22 19:33:52 +08:00
|
|
|
|
foreach (var rulesetInfo in rulesets.AvailableRulesets)
|
2017-12-12 21:44:12 +08:00
|
|
|
|
{
|
2017-12-22 19:33:52 +08:00
|
|
|
|
var ruleset = rulesetInfo.CreateInstance();
|
|
|
|
|
beatmaps.Add(createTestBeatmap(rulesetInfo));
|
|
|
|
|
|
|
|
|
|
var name = rulesetInfo.ShortName;
|
|
|
|
|
selectBeatmap(name);
|
|
|
|
|
|
2017-12-23 18:56:53 +08:00
|
|
|
|
// TODO: adjust cases once more info is shown for other gamemodes
|
2017-12-22 19:33:52 +08:00
|
|
|
|
switch (ruleset)
|
|
|
|
|
{
|
|
|
|
|
case OsuRuleset osu:
|
|
|
|
|
testOsuBeatmap(osu);
|
2017-12-23 18:56:53 +08:00
|
|
|
|
testInfoLabels(5);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
testInfoLabels(2);
|
2017-12-22 19:33:52 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
testNullBeatmap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void testOsuBeatmap(OsuRuleset ruleset)
|
|
|
|
|
{
|
|
|
|
|
AddAssert("check version", () => infoWedge.Info.VersionLabel.Text == $"{ruleset.ShortName}Version");
|
|
|
|
|
AddAssert("check title", () => infoWedge.Info.TitleLabel.Text == $"{ruleset.ShortName}Source — {ruleset.ShortName}Title");
|
|
|
|
|
AddAssert("check artist", () => infoWedge.Info.ArtistLabel.Text == $"{ruleset.ShortName}Artist");
|
|
|
|
|
AddAssert("check author", () => infoWedge.Info.MapperContainer.Children.OfType<OsuSpriteText>().Any(s => s.Text == $"{ruleset.ShortName}Author"));
|
2017-12-23 18:56:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void testInfoLabels(int expectedCount)
|
|
|
|
|
{
|
|
|
|
|
AddAssert("check infolabels exists", () => infoWedge.Info.InfoLabelContainer.Children.Any());
|
|
|
|
|
AddAssert("check infolabels count", () => infoWedge.Info.InfoLabelContainer.Children.Count == expectedCount);
|
2017-12-22 19:33:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void testNullBeatmap()
|
|
|
|
|
{
|
|
|
|
|
selectNullBeatmap();
|
|
|
|
|
AddAssert("check empty version", () => string.IsNullOrEmpty(infoWedge.Info.VersionLabel.Text));
|
|
|
|
|
AddAssert("check default title", () => infoWedge.Info.TitleLabel.Text == beatmap.Default.BeatmapInfo.Metadata.Title);
|
|
|
|
|
AddAssert("check default artist", () => infoWedge.Info.ArtistLabel.Text == beatmap.Default.BeatmapInfo.Metadata.Artist);
|
|
|
|
|
AddAssert("check empty author", () => !infoWedge.Info.MapperContainer.Children.Any());
|
2017-12-23 18:56:53 +08:00
|
|
|
|
AddAssert("check no infolabels", () => !infoWedge.Info.InfoLabelContainer.Children.Any());
|
2017-12-22 19:33:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void selectBeatmap(string name)
|
|
|
|
|
{
|
2017-12-26 19:13:55 +08:00
|
|
|
|
var infoBefore = infoWedge.Info;
|
|
|
|
|
|
2017-12-22 19:33:52 +08:00
|
|
|
|
AddStep($"select {name} beatmap", () =>
|
|
|
|
|
{
|
|
|
|
|
beatmap.Value = new TestWorkingBeatmap(beatmaps.First(b => b.BeatmapInfo.Ruleset.ShortName == name));
|
|
|
|
|
infoWedge.UpdateBeatmap(beatmap);
|
2017-12-12 21:44:12 +08:00
|
|
|
|
});
|
2017-12-26 19:13:55 +08:00
|
|
|
|
|
|
|
|
|
AddUntilStep(() => infoWedge.Info != infoBefore, "wait for async load");
|
2017-12-12 21:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-22 19:33:52 +08:00
|
|
|
|
private void selectNullBeatmap()
|
2017-12-12 21:44:12 +08:00
|
|
|
|
{
|
2017-12-22 19:33:52 +08:00
|
|
|
|
AddStep("select null beatmap", () =>
|
|
|
|
|
{
|
|
|
|
|
beatmap.Value = beatmap.Default;
|
|
|
|
|
infoWedge.UpdateBeatmap(beatmap);
|
|
|
|
|
});
|
2017-12-12 21:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-22 19:33:52 +08:00
|
|
|
|
private Beatmap createTestBeatmap(RulesetInfo ruleset)
|
2017-12-12 21:44:12 +08:00
|
|
|
|
{
|
2017-12-23 18:56:53 +08:00
|
|
|
|
List<HitObject> objects = new List<HitObject>();
|
|
|
|
|
for (double i = 0; i < 50000; i += 1000)
|
|
|
|
|
objects.Add(new HitObject { StartTime = i });
|
|
|
|
|
|
2017-12-22 19:33:52 +08:00
|
|
|
|
return new Beatmap
|
|
|
|
|
{
|
|
|
|
|
BeatmapInfo = new BeatmapInfo
|
|
|
|
|
{
|
|
|
|
|
Metadata = new BeatmapMetadata
|
|
|
|
|
{
|
|
|
|
|
AuthorString = $"{ruleset.ShortName}Author",
|
|
|
|
|
Artist = $"{ruleset.ShortName}Artist",
|
|
|
|
|
Source = $"{ruleset.ShortName}Source",
|
|
|
|
|
Title = $"{ruleset.ShortName}Title"
|
|
|
|
|
},
|
|
|
|
|
Ruleset = ruleset,
|
|
|
|
|
StarDifficulty = 6,
|
|
|
|
|
Version = $"{ruleset.ShortName}Version"
|
|
|
|
|
},
|
2017-12-23 18:56:53 +08:00
|
|
|
|
HitObjects = objects
|
2017-12-22 19:33:52 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2017-12-12 21:44:12 +08:00
|
|
|
|
|
2017-12-22 19:33:52 +08:00
|
|
|
|
private class TestBeatmapInfoWedge : BeatmapInfoWedge
|
|
|
|
|
{
|
|
|
|
|
public new BufferedWedgeInfo Info => base.Info;
|
2017-12-12 21:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|