1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-08 01:23:05 +08:00

Update tests to not use positional data (nunit runs at an incompatible window size)

This commit is contained in:
Dean Herbert 2020-03-18 15:38:19 +09:00
parent 2ca225877f
commit 336d927157

View File

@ -4,6 +4,7 @@
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
@ -38,7 +39,7 @@ namespace osu.Game.Tournament.Tests.Screens
Ladder.CurrentMatch.Value = Ladder.Matches.First(); Ladder.CurrentMatch.Value = Ladder.Matches.First();
}); });
AddAssert("ensure layout width is 2", () => screen.ChildrenOfType<TournamentBeatmapPanel>().ElementAt(2).Y > 0); assertTwoWide();
} }
[Test] [Test]
@ -58,7 +59,7 @@ namespace osu.Game.Tournament.Tests.Screens
Ladder.CurrentMatch.Value = Ladder.Matches.First(); Ladder.CurrentMatch.Value = Ladder.Matches.First();
}); });
AddAssert("ensure layout width is 2", () => screen.ChildrenOfType<TournamentBeatmapPanel>().ElementAt(2).Y > 0); assertTwoWide();
} }
[Test] [Test]
@ -78,7 +79,7 @@ namespace osu.Game.Tournament.Tests.Screens
Ladder.CurrentMatch.Value = Ladder.Matches.First(); Ladder.CurrentMatch.Value = Ladder.Matches.First();
}); });
AddAssert("ensure layout width is 3", () => screen.ChildrenOfType<TournamentBeatmapPanel>().ElementAt(2).Y == 0); assertThreeWide();
} }
[Test] [Test]
@ -98,9 +99,15 @@ namespace osu.Game.Tournament.Tests.Screens
Ladder.CurrentMatch.Value = Ladder.Matches.First(); Ladder.CurrentMatch.Value = Ladder.Matches.First();
}); });
AddAssert("ensure layout width is 2", () => screen.ChildrenOfType<TournamentBeatmapPanel>().ElementAt(2).Y > 0); assertTwoWide();
} }
private void assertTwoWide() =>
AddAssert("ensure layout width is 2", () => screen.ChildrenOfType<FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>>>().First().Padding.Left > 0);
private void assertThreeWide() =>
AddAssert("ensure layout width is 3", () => screen.ChildrenOfType<FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>>>().First().Padding.Left == 0);
[Test] [Test]
public void TestManyMods() public void TestManyMods()
{ {
@ -118,7 +125,7 @@ namespace osu.Game.Tournament.Tests.Screens
Ladder.CurrentMatch.Value = Ladder.Matches.First(); Ladder.CurrentMatch.Value = Ladder.Matches.First();
}); });
AddAssert("ensure layout width is 3", () => screen.ChildrenOfType<TournamentBeatmapPanel>().ElementAt(2).Y == 0); assertThreeWide();
} }
private void addBeatmap(string mods = "nm") private void addBeatmap(string mods = "nm")