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

Add failing test coverage for save after safeties addition

This commit is contained in:
Bartłomiej Dach 2022-01-23 19:50:02 +01:00
parent 4f1aac9345
commit afc48d86df
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
3 changed files with 11 additions and 5 deletions

View File

@ -109,6 +109,7 @@ namespace osu.Game.Tests.Visual.Editing
&& set != null
&& set.PerformRead(s => s.Beatmaps.Single().ID == beatmap.ID);
});
AddAssert("can save again", () => Editor.Save());
AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo));
AddUntilStep("wait for created", () =>

View File

@ -378,12 +378,16 @@ namespace osu.Game.Screens.Edit
Clipboard.Content.Value = state.ClipboardContent;
});
protected void Save()
/// <summary>
/// Saves the currently edited beatmap.
/// </summary>
/// <returns>Whether the save was successful.</returns>
protected bool Save()
{
if (!canSave)
{
notifications?.Post(new SimpleErrorNotification { Text = "Saving is not supported for this ruleset yet, sorry!" });
return;
return false;
}
try
@ -395,12 +399,13 @@ namespace osu.Game.Screens.Edit
{
// can fail e.g. due to duplicated difficulty names.
Logger.Error(ex, ex.Message);
return;
return false;
}
// no longer new after first user-triggered save.
isNewBeatmap = false;
updateLastSavedHash();
return true;
}
protected override void Update()
@ -809,7 +814,7 @@ namespace osu.Game.Screens.Edit
{
var fileMenuItems = new List<MenuItem>
{
new EditorMenuItem("Save", MenuItemType.Standard, Save)
new EditorMenuItem("Save", MenuItemType.Standard, () => Save())
};
if (RuntimeInfo.IsDesktop)

View File

@ -97,7 +97,7 @@ namespace osu.Game.Tests.Visual
public new void Redo() => base.Redo();
public new void Save() => base.Save();
public new bool Save() => base.Save();
public new void Cut() => base.Cut();