1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 14:02:55 +08:00

Update test cases to new framework and fix old crashes

This commit is contained in:
Thomas Müller 2017-07-07 15:05:55 +03:00
parent 26c40105e2
commit 22a987f6cc
44 changed files with 139 additions and 206 deletions

@ -1 +1 @@
Subproject commit cd2b351de37f17b6d91d1fc062627208a09c3834
Subproject commit b0909ce13389ba690bfc41232d2d39bdf175e896

View File

@ -12,10 +12,8 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"Beatmap details in song select";
public override void Reset()
public TestCaseBeatmapDetailArea()
{
base.Reset();
Add(new BeatmapDetailArea
{
Anchor = Anchor.Centre,

View File

@ -15,10 +15,8 @@ namespace osu.Desktop.VisualTests.Tests
private BeatmapDetails details;
public override void Reset()
public TestCaseBeatmapDetails()
{
base.Reset();
Add(details = new BeatmapDetails
{
RelativeSizeAxes = Axes.Both,

View File

@ -13,10 +13,8 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"Beatmap options in song select";
public override void Reset()
public TestCaseBeatmapOptionsOverlay()
{
base.Reset();
var overlay = new BeatmapOptionsOverlay();
overlay.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, Color4.Purple, null, Key.Number1);

View File

@ -11,10 +11,8 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"breadcrumb > control";
public override void Reset()
public TestCaseBreadcrumbs()
{
base.Reset();
BreadcrumbControl<BreadcrumbTab> c;
Add(c = new BreadcrumbControl<BreadcrumbTab>
{

View File

@ -11,10 +11,8 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"Testing chat api and overlay";
public override void Reset()
public TestCaseChatDisplay()
{
base.Reset();
Add(new ChatOverlay
{
State = Visibility.Visible

View File

@ -23,10 +23,8 @@ namespace osu.Desktop.VisualTests.Tests
private MyContextMenuContainer container;
public override void Reset()
public TestCaseContextMenu()
{
base.Reset();
Add(container = new MyContextMenuContainer
{
Size = new Vector2(200),

View File

@ -14,10 +14,8 @@ namespace osu.Desktop.VisualTests.Tests
private DialogOverlay overlay;
public override void Reset()
public TestCaseDialogOverlay()
{
base.Reset();
Add(overlay = new DialogOverlay());
AddStep("dialog #1", () => overlay.Push(new PopupDialog

View File

@ -16,9 +16,9 @@ namespace osu.Desktop.VisualTests.Tests
private DirectOverlay direct;
private RulesetDatabase rulesets;
public override void Reset()
protected override void LoadComplete()
{
base.Reset();
base.LoadComplete();
Add(direct = new DirectOverlay());
newBeatmaps();

View File

@ -15,9 +15,9 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"Select your favourite room";
public override void Reset()
protected override void LoadComplete()
{
base.Reset();
base.LoadComplete();
DrawableRoom first;
DrawableRoom second;

View File

@ -12,10 +12,8 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => "Tournament drawings";
public override void Reset()
public TestCaseDrawings()
{
base.Reset();
Add(new Drawings
{
TeamList = new TestTeamList(),

View File

@ -34,9 +34,9 @@ namespace osu.Desktop.VisualTests.Tests
this.rulesets = rulesets;
}
public override void Reset()
protected override void LoadComplete()
{
base.Reset();
base.LoadComplete();
List<HitObject> objects = new List<HitObject>();

View File

@ -15,10 +15,8 @@ namespace osu.Desktop.VisualTests.Tests
private BarGraph graph;
public override void Reset()
public TestCaseGraph()
{
base.Reset();
Children = new[]
{
graph = new BarGraph

View File

@ -29,6 +29,49 @@ namespace osu.Desktop.VisualTests.Tests
var rateAdjustClock = new StopwatchClock(true);
framedClock = new FramedClock(rateAdjustClock);
playbackSpeed.ValueChanged += delegate { rateAdjustClock.Rate = playbackSpeed.Value; };
playbackSpeed.TriggerChange();
AddStep(@"circles", () => loadHitobjects(HitObjectType.Circle));
AddStep(@"slider", () => loadHitobjects(HitObjectType.Slider));
AddStep(@"spinner", () => loadHitobjects(HitObjectType.Spinner));
AddToggleStep(@"auto", state => { auto = state; loadHitobjects(mode); });
BasicSliderBar<double> sliderBar;
Add(new Container
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
new SpriteText { Text = "Playback Speed" },
sliderBar = new BasicSliderBar<double>
{
Width = 150,
Height = 10,
SelectionColor = Color4.Orange,
}
}
});
sliderBar.Current.BindTo(playbackSpeed);
framedClock.ProcessFrame();
var clockAdjustContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Clock = framedClock,
Children = new[]
{
playfieldContainer = new Container { RelativeSizeAxes = Axes.Both },
approachContainer = new Container { RelativeSizeAxes = Axes.Both }
}
};
Add(clockAdjustContainer);
}
private HitObjectType mode = HitObjectType.Slider;
@ -37,7 +80,7 @@ namespace osu.Desktop.VisualTests.Tests
private Container playfieldContainer;
private Container approachContainer;
private void load(HitObjectType mode)
private void loadHitobjects(HitObjectType mode)
{
this.mode = mode;
@ -83,54 +126,6 @@ namespace osu.Desktop.VisualTests.Tests
}
}
public override void Reset()
{
base.Reset();
playbackSpeed.TriggerChange();
AddStep(@"circles", () => load(HitObjectType.Circle));
AddStep(@"slider", () => load(HitObjectType.Slider));
AddStep(@"spinner", () => load(HitObjectType.Spinner));
AddToggleStep(@"auto", state => { auto = state; load(mode); });
BasicSliderBar<double> sliderBar;
Add(new Container
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
new SpriteText { Text = "Playback Speed" },
sliderBar = new BasicSliderBar<double>
{
Width = 150,
Height = 10,
SelectionColor = Color4.Orange,
}
}
});
sliderBar.Current.BindTo(playbackSpeed);
framedClock.ProcessFrame();
var clockAdjustContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Clock = framedClock,
Children = new[]
{
playfieldContainer = new Container { RelativeSizeAxes = Axes.Both },
approachContainer = new Container { RelativeSizeAxes = Axes.Both }
}
};
Add(clockAdjustContainer);
}
private int depth;
private void add(DrawableOsuHitObject h)

View File

@ -20,10 +20,8 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"Tests key counter";
public override void Reset()
public TestCaseKeyCounter()
{
base.Reset();
KeyCounterCollection kc = new KeyCounterCollection
{
Origin = Anchor.Centre,

View File

@ -207,10 +207,8 @@ namespace osu.Desktop.VisualTests.Tests
leaderboard.Scores = scores;
}
public override void Reset()
public TestCaseLeaderboard()
{
base.Reset();
Add(leaderboard = new Leaderboard
{
Origin = Anchor.Centre,

View File

@ -13,10 +13,8 @@ namespace osu.Desktop.VisualTests.Tests
{
internal class TestCaseManiaHitObjects : TestCase
{
public override void Reset()
public TestCaseManiaHitObjects()
{
base.Reset();
Add(new FillFlowContainer
{
Anchor = Anchor.Centre,

View File

@ -25,10 +25,8 @@ namespace osu.Desktop.VisualTests.Tests
protected override double TimePerAction => 200;
public override void Reset()
public TestCaseManiaPlayfield()
{
base.Reset();
Action<int, SpecialColumnPosition> createPlayfield = (cols, pos) =>
{
Clear();

View File

@ -13,10 +13,8 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"Main menu button system";
public override void Reset()
public TestCaseMenuButtonSystem()
{
base.Reset();
Add(new Box
{
ColourInfo = ColourInfo.GradientVertical(Color4.Gray, Color4.WhiteSmoke),

View File

@ -16,10 +16,8 @@ namespace osu.Desktop.VisualTests.Tests
private FailOverlay failOverlay;
private int retryCount;
public override void Reset()
public TestCaseMenuOverlays()
{
base.Reset();
retryCount = 0;
Add(pauseOverlay = new PauseContainer.PauseOverlay

View File

@ -27,9 +27,9 @@ namespace osu.Desktop.VisualTests.Tests
this.rulesets = rulesets;
}
public override void Reset()
protected override void LoadComplete()
{
base.Reset();
base.LoadComplete();
Add(modSelect = new ModSelectOverlay
{

View File

@ -18,12 +18,7 @@ namespace osu.Desktop.VisualTests.Tests
public TestCaseMusicController()
{
Clock = new FramedClock();
}
public override void Reset()
{
base.Reset();
Clock.ProcessFrame();
mc = new MusicController
{
Origin = Anchor.Centre,

View File

@ -18,10 +18,8 @@ namespace osu.Desktop.VisualTests.Tests
private NotificationManager manager;
public override void Reset()
public TestCaseNotificationManager()
{
base.Reset();
progressingNotifications.Clear();
Content.Add(manager = new NotificationManager

View File

@ -15,9 +15,9 @@ namespace osu.Desktop.VisualTests.Tests
public override string Description => @"Make it easier to see setting changes";
public override void Reset()
protected override void LoadComplete()
{
base.Reset();
base.LoadComplete();
Add(new OnScreenDisplay());

View File

@ -21,9 +21,8 @@ namespace osu.Desktop.VisualTests.Tests
private RulesetDatabase rulesets;
public override void Reset()
public TestCasePlaySongSelect()
{
base.Reset();
if (db == null)
{
storage = new TestStorage(@"TestCasePlaySongSelect");

View File

@ -33,18 +33,12 @@ namespace osu.Desktop.VisualTests.Tests
this.db = db;
}
public override void Reset()
protected override void LoadComplete()
{
base.Reset();
base.LoadComplete();
WorkingBeatmap beatmap = null;
var beatmapInfo = db.Query<BeatmapInfo>().FirstOrDefault(b => b.RulesetID == 0);
if (beatmapInfo != null)
beatmap = db.GetWorkingBeatmap(beatmapInfo);
if (beatmap?.Track == null)
{
var objects = new List<HitObject>();
int time = 1500;
@ -78,7 +72,6 @@ namespace osu.Desktop.VisualTests.Tests
};
beatmap = new TestWorkingBeatmap(b);
}
Add(new Box
{

View File

@ -15,10 +15,8 @@ namespace osu.Desktop.VisualTests.Tests
private ExampleContainer container;
public override void Reset()
public TestCaseReplaySettingsOverlay()
{
base.Reset();
Add(new ReplaySettingsOverlay()
{
Anchor = Anchor.TopRight,

View File

@ -28,9 +28,9 @@ namespace osu.Desktop.VisualTests.Tests
private WorkingBeatmap beatmap;
public override void Reset()
protected override void LoadComplete()
{
base.Reset();
base.LoadComplete();
if (beatmap == null)
{
@ -39,8 +39,6 @@ namespace osu.Desktop.VisualTests.Tests
beatmap = db.GetWorkingBeatmap(beatmapInfo);
}
base.Reset();
Add(new Results(new Score
{
TotalScore = 2845370,

View File

@ -17,9 +17,9 @@ namespace osu.Desktop.VisualTests.Tests
private RulesetDatabase rulesets;
public override void Reset()
protected override void LoadComplete()
{
base.Reset();
base.LoadComplete();
var room = new Room
{

View File

@ -15,10 +15,8 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"Tests multiple counters";
public override void Reset()
public TestCaseScoreCounter()
{
base.Reset();
int numerator = 0, denominator = 0;
ScoreCounter score = new ScoreCounter(7)

View File

@ -28,10 +28,8 @@ namespace osu.Desktop.VisualTests.Tests
private OsuSpriteText bottomLabel;
private SpriteText topTime, bottomTime;
public override void Reset()
public TestCaseScrollingHitObjects()
{
base.Reset();
timeRangeBindable = new BindableDouble(2000)
{
MinValue = 200,

View File

@ -12,11 +12,14 @@ namespace osu.Desktop.VisualTests.Tests
private SettingsOverlay settings;
public override void Reset()
public TestCaseSettings()
{
base.Reset();
Children = new[] { settings = new SettingsOverlay() };
}
protected override void LoadComplete()
{
base.LoadComplete();
settings.ToggleVisibility();
}
}

View File

@ -10,9 +10,10 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"Skip skip skippediskip";
public override void Reset()
protected override void LoadComplete()
{
base.Reset();
base.LoadComplete();
Add(new SkipButton(Clock.CurrentTime + 5000));
}
}

View File

@ -11,10 +11,8 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"social browser overlay";
public override void Reset()
public TestCaseSocial()
{
base.Reset();
SocialOverlay s = new SocialOverlay
{
Users = new[]

View File

@ -20,10 +20,8 @@ namespace osu.Desktop.VisualTests.Tests
private StopwatchClock clock;
public override void Reset()
public TestCaseSongProgress()
{
base.Reset();
clock = new StopwatchClock(true);
Add(progress = new SongProgress

View File

@ -14,10 +14,8 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"Filter for song select";
public override void Reset()
public TestCaseTabControl()
{
base.Reset();
OsuSpriteText text;
OsuTabControl<GroupMode> filter;
Add(filter = new OsuTabControl<GroupMode>

View File

@ -16,10 +16,8 @@ namespace osu.Desktop.VisualTests.Tests
private bool kiai;
public override void Reset()
public TestCaseTaikoHitObjects()
{
base.Reset();
AddToggleStep("Kiai", b =>
{
kiai = !kiai;

View File

@ -29,10 +29,8 @@ namespace osu.Desktop.VisualTests.Tests
private TaikoPlayfield playfield;
private Container playfieldContainer;
public override void Reset()
public TestCaseTaikoPlayfield()
{
base.Reset();
AddStep("Hit!", addHitJudgement);
AddStep("Miss :(", addMissJudgement);
AddStep("DrumRoll", () => addDrumRoll(false));

View File

@ -16,10 +16,8 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"Tests display of icons";
public override void Reset()
public TestCaseTextAwesome()
{
base.Reset();
FillFlowContainer flow;
Add(flow = new FillFlowContainer

View File

@ -10,10 +10,8 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"Mostly back button";
public override void Reset()
public TestCaseTwoLayerButton()
{
base.Reset();
Add(new BackButton());
}
}

View File

@ -13,10 +13,8 @@ namespace osu.Desktop.VisualTests.Tests
{
public override string Description => @"Panels for displaying a user's status";
public override void Reset()
public TestCaseUserPanel()
{
base.Reset();
UserPanel flyte;
UserPanel peppy;
Add(new FillFlowContainer

View File

@ -148,7 +148,7 @@ namespace osu.Game.Rulesets.UI
// Check if the beatmap can be converted
if (!converter.CanConvert(beatmap.Beatmap))
throw new BeatmapInvalidForRulesetException($"{nameof(Beatmap)} can't be converted for the current ruleset.");
throw new BeatmapInvalidForRulesetException($"{nameof(Beatmap)} can not be converted for the current ruleset (converter: {converter}).");
// Convert the beatmap
Beatmap = converter.Convert(beatmap.Beatmap, isForCurrentRuleset);

View File

@ -19,6 +19,10 @@ namespace osu.Game.Screens.Play
objects = value;
const int granularity = 200;
Values = new int[granularity];
if (!objects.Any())
return;
var firstHit = objects.First().StartTime;
var lastHit = (objects.Last() as IHasEndTime)?.EndTime ?? 0;
@ -28,8 +32,6 @@ namespace osu.Game.Screens.Play
var interval = (lastHit - firstHit + 1) / granularity;
var values = new int[granularity];
foreach (var h in objects)
{
IHasEndTime end = h as IHasEndTime;
@ -37,10 +39,8 @@ namespace osu.Game.Screens.Play
int startRange = (int)((h.StartTime - firstHit) / interval);
int endRange = (int)(((end?.EndTime > 0 ? end.EndTime : h.StartTime) - firstHit) / interval);
for (int i = startRange; i <= endRange; i++)
values[i]++;
}
Values = values;
Values[i]++;
}
}
}
}

View File

@ -281,10 +281,13 @@ namespace osu.Game.Screens.Select
{
base.Dispose(isDisposing);
if (database != null)
{
database.BeatmapSetAdded -= onBeatmapSetAdded;
database.BeatmapSetRemoved -= onBeatmapSetRemoved;
}
initialAddSetsTask.Cancel();
initialAddSetsTask?.Cancel();
}
private void changeBackground(WorkingBeatmap beatmap)