mirror of https://github.com/ppy/osu
Add test coverage
This commit is contained in:
parent
964ed01abb
commit
7db7bcc283
|
@ -10,10 +10,13 @@
|
|||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Screens.Select.Carousel;
|
||||
using osu.Game.Tests.Online;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.SongSelect
|
||||
{
|
||||
|
@ -41,17 +44,7 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
|
|||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("create carousel", () =>
|
||||
{
|
||||
Child = carousel = new BeatmapCarousel
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
BeatmapSets = new List<BeatmapSetInfo>
|
||||
{
|
||||
(testBeatmapSetInfo = TestResources.CreateTestBeatmapSetInfo()),
|
||||
}
|
||||
};
|
||||
});
|
||||
AddStep("create carousel", () => Child = createCarousel());
|
||||
|
||||
AddUntilStep("wait for load", () => carousel.BeatmapSetsLoaded);
|
||||
|
||||
|
@ -152,5 +145,60 @@ public void TestDownloadFailed()
|
|||
|
||||
AddUntilStep("wait for button enabled", () => getUpdateButton()?.Enabled.Value == true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUpdateLocalBeatmap()
|
||||
{
|
||||
DialogOverlay dialogOverlay = null!;
|
||||
|
||||
AddStep("create carousel with dialog overlay", () =>
|
||||
{
|
||||
dialogOverlay = new DialogOverlay();
|
||||
|
||||
Child = new DependencyProvidingContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
CachedDependencies = new (Type, object)[] { (typeof(IDialogOverlay), dialogOverlay), },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
createCarousel(),
|
||||
dialogOverlay,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("setup beatmap state", () =>
|
||||
{
|
||||
testBeatmapSetInfo.Beatmaps.First().OnlineMD5Hash = "different hash";
|
||||
testBeatmapSetInfo.Beatmaps.First().LastOnlineUpdate = DateTimeOffset.Now;
|
||||
testBeatmapSetInfo.Status = BeatmapOnlineStatus.LocallyModified;
|
||||
|
||||
carousel.UpdateBeatmapSet(testBeatmapSetInfo);
|
||||
});
|
||||
|
||||
AddStep("click button", () => getUpdateButton()?.TriggerClick());
|
||||
|
||||
AddAssert("dialog displayed", () => dialogOverlay.CurrentDialog is UpdateLocalConfirmationDialog);
|
||||
AddStep("click confirmation", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(dialogOverlay.CurrentDialog.ChildrenOfType<PopupDialogButton>().First());
|
||||
InputManager.PressButton(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("update started", () => beatmapDownloader.GetExistingDownload(testBeatmapSetInfo) != null);
|
||||
AddStep("release mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||
}
|
||||
|
||||
private BeatmapCarousel createCarousel()
|
||||
{
|
||||
return carousel = new BeatmapCarousel
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
BeatmapSets = new List<BeatmapSetInfo>
|
||||
{
|
||||
(testBeatmapSetInfo = TestResources.CreateTestBeatmapSetInfo()),
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue