Skip to content

Commit

Permalink
It's time to collect all generators into same change handler.
Browse files Browse the repository at this point in the history
means revert the change in the karaoke-dev#1958.
  • Loading branch information
andy840119 committed Sep 27, 2023
1 parent 3d519c8 commit 5d5e5dc
Show file tree
Hide file tree
Showing 22 changed files with 587 additions and 603 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,6 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Editor.ChangeHandlers.Lyrics;

public partial class LyricLanguageChangeHandlerTest : LyricPropertyChangeHandlerTest<LyricLanguageChangeHandler>
{
protected override bool IncludeAutoGenerator => true;

#region Auto-Generate

[Test]
public void TestDetectLanguage()
{
PrepareHitObject(() => new Lyric
{
Text = "カラオケ",
});

TriggerHandlerChanged(c => c.AutoGenerate());

AssertSelectedHitObject(h =>
{
Assert.AreEqual(new CultureInfo("ja"), h.Language);
});
}

[Test]
public void TestDetectLanguageWithNonSupportedLyric()
{
PrepareHitObject(() => new Lyric
{
Text = "???",
});

TriggerHandlerChanged(c => c.AutoGenerate());

AssertSelectedHitObject(h =>
{
Assert.IsNull(h.Language);
});
}

#endregion

[Test]
public void TestSetLanguageToJapanese()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,70 +1,10 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics;
using osu.Game.Rulesets.Karaoke.Edit.Generator;
using osu.Game.Rulesets.Karaoke.Edit.Utils;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Screens.Edit;

namespace osu.Game.Rulesets.Karaoke.Tests.Editor.ChangeHandlers.Lyrics;

public partial class LyricNotesChangeHandlerTest : LyricPropertyChangeHandlerTest<LyricNotesChangeHandler>
{
protected override bool IncludeAutoGenerator => true;

#region Note

[Test]
public void TestAutoGenerateNotes()
{
PrepareHitObject(() => new Lyric
{
Text = "カラオケ",
TimeTags = new[]
{
new TimeTag(new TextIndex(0), 0),
new TimeTag(new TextIndex(1), 1000),
new TimeTag(new TextIndex(2), 2000),
new TimeTag(new TextIndex(3), 3000),
new TimeTag(new TextIndex(3, TextIndex.IndexState.End), 4000),
},
});

TriggerHandlerChanged(c => c.AutoGenerate());

AssertSelectedHitObject(h =>
{
var actualNotes = getMatchedNotes(h);
Assert.AreEqual(4, actualNotes.Length);

Assert.AreEqual("カ", actualNotes[0].Text);
Assert.AreEqual("ラ", actualNotes[1].Text);
Assert.AreEqual("オ", actualNotes[2].Text);
Assert.AreEqual("ケ", actualNotes[3].Text);
});
}

[Test]
public void TestAutoGenerateNotesWithNonSupportedLyric()
{
PrepareHitObject(() => new Lyric
{
Text = "カラオケ",
});

TriggerHandlerChangedWithException<GeneratorNotSupportedException>(c => c.AutoGenerate());
}

private Note[] getMatchedNotes(Lyric lyric)
{
var editorBeatmap = Dependencies.Get<EditorBeatmap>();
return EditorBeatmapUtils.GetNotesByLyric(editorBeatmap, lyric).ToArray();
}

#endregion
}
Loading

0 comments on commit 5d5e5dc

Please sign in to comment.