Skip to content

Commit

Permalink
Fix the broken test case.
Browse files Browse the repository at this point in the history
Should assign the property in the referenced lyric instead.
  • Loading branch information
andy840119 committed Aug 29, 2022
1 parent ad93176 commit a61e99d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Editor.ChangeHandlers.Lyrics
public abstract class LyricPropertyChangeHandlerTest<TChangeHandler> : BaseHitObjectChangeHandlerTest<TChangeHandler, Lyric>
where TChangeHandler : LyricPropertyChangeHandler, new()
{
protected void PrepareLyricWithSyncConfig(Lyric hitObject, bool selected = true)
protected Lyric PrepareLyricWithSyncConfig(Lyric referencedLyric, IReferenceLyricPropertyConfig? config = null, bool selected = true)
{
// allow to pre-assign the config.
hitObject.ReferenceLyric = new Lyric();
hitObject.ReferenceLyricConfig ??= new SyncLyricConfig();
var lyric = new Lyric
{
ReferenceLyric = referencedLyric,
ReferenceLyricConfig = config ?? new SyncLyricConfig()
};

PrepareHitObjects(new[] { hitObject }, selected);
PrepareHitObjects(new[] { lyric }, selected);

return lyric;
}

protected void TriggerHandlerChangedWithChangeForbiddenException(Action<TChangeHandler> c)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,9 @@ public void TestWithReferenceLyric(bool syncSinger)
{
Name = "Singer1",
};
PrepareLyricWithSyncConfig(new Lyric
PrepareLyricWithSyncConfig(new Lyric(), new SyncLyricConfig
{
ReferenceLyricConfig = new SyncLyricConfig
{
SyncSingerProperty = syncSinger
}
SyncSingerProperty = syncSinger
});

if (syncSinger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,20 +420,29 @@ public void TestShiftingException(TextIndex.IndexState state, ShiftingDirection
[TestCase(false)]
public void TestWithReferenceLyric(bool syncTimeTag)
{
var timeTag = new TimeTag(new TextIndex(), 1000);
PrepareLyricWithSyncConfig(new Lyric
var lyric = PrepareLyricWithSyncConfig(new Lyric
{
Text = "カラオケ",
TimeTags = new[]
{
timeTag
},
ReferenceLyricConfig = new SyncLyricConfig
{
SyncTimeTagProperty = syncTimeTag
new TimeTag(new TextIndex(), 1000)
}
}, new SyncLyricConfig
{
SyncTimeTagProperty = syncTimeTag
});

// should add the time-tag by hand because it does not sync from thr referenced lyric.
if (!syncTimeTag)
{
lyric.TimeTags = new[]
{
new TimeTag(new TextIndex(), 2000)
};
}

var timeTag = lyric.TimeTags.First();

if (syncTimeTag)
{
TriggerHandlerChangedWithChangeForbiddenException(c => c.SetTimeTagTime(timeTag, 2000));
Expand Down

0 comments on commit a61e99d

Please sign in to comment.