mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 19:13:21 +08:00
Add test coverage
This commit is contained in:
parent
964ed01abb
commit
7db7bcc283
@ -10,10 +10,13 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.Dialog;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
using osu.Game.Screens.Select.Carousel;
|
using osu.Game.Screens.Select.Carousel;
|
||||||
using osu.Game.Tests.Online;
|
using osu.Game.Tests.Online;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.SongSelect
|
namespace osu.Game.Tests.Visual.SongSelect
|
||||||
{
|
{
|
||||||
@ -41,17 +44,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
public void SetUpSteps()
|
public void SetUpSteps()
|
||||||
{
|
{
|
||||||
AddStep("create carousel", () =>
|
AddStep("create carousel", () => Child = createCarousel());
|
||||||
{
|
|
||||||
Child = carousel = new BeatmapCarousel
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
BeatmapSets = new List<BeatmapSetInfo>
|
|
||||||
{
|
|
||||||
(testBeatmapSetInfo = TestResources.CreateTestBeatmapSetInfo()),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
AddUntilStep("wait for load", () => carousel.BeatmapSetsLoaded);
|
AddUntilStep("wait for load", () => carousel.BeatmapSetsLoaded);
|
||||||
|
|
||||||
@ -152,5 +145,60 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
AddUntilStep("wait for button enabled", () => getUpdateButton()?.Enabled.Value == true);
|
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
Block a user