diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/BaseHitObjectPropertyChangeHandlerTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/BaseHitObjectPropertyChangeHandlerTest.cs new file mode 100644 index 000000000..0563e1042 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/BaseHitObjectPropertyChangeHandlerTest.cs @@ -0,0 +1,18 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers; +using osu.Game.Rulesets.Objects; + +namespace osu.Game.Rulesets.Karaoke.Tests.Editor.ChangeHandlers +{ + public abstract class BaseHitObjectPropertyChangeHandlerTest : BaseHitObjectChangeHandlerTest + where TChangeHandler : HitObjectPropertyChangeHandler, new() where THitObject : HitObject + { + protected void TriggerHandlerChangedWithChangeForbiddenException(Action c) + { + TriggerHandlerChangedWithException.ChangeForbiddenException>(c); + } + } +} diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/LockChangeHandlerTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/LockChangeHandlerTest.cs index 492bb27bb..513aed2be 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/LockChangeHandlerTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/LockChangeHandlerTest.cs @@ -4,11 +4,12 @@ using NUnit.Framework; using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers; using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Rulesets.Karaoke.Objects.Properties; using osu.Game.Rulesets.Karaoke.Objects.Types; namespace osu.Game.Rulesets.Karaoke.Tests.Editor.ChangeHandlers { - public class LockChangeHandlerTest : BaseHitObjectChangeHandlerTest + public class LockChangeHandlerTest : BaseHitObjectPropertyChangeHandlerTest { [Test] public void TestLock() @@ -55,5 +56,18 @@ public void TestUnlock() Assert.AreEqual(LockState.None, hasLock.Lock); }); } + + [Test] + public void TestLockToReferenceLyric() + { + PrepareHitObject(new Lyric + { + Text = "カラオケ", + ReferenceLyric = new Lyric(), + ReferenceLyricConfig = new SyncLyricConfig(), + }); + + TriggerHandlerChangedWithChangeForbiddenException(c => c.Lock(LockState.Full)); + } } } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Lyrics/LyricPropertyChangeHandlerTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Lyrics/LyricPropertyChangeHandlerTest.cs index ce59fed3c..1c95a0895 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Lyrics/LyricPropertyChangeHandlerTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Lyrics/LyricPropertyChangeHandlerTest.cs @@ -1,14 +1,13 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -using System; using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Objects.Properties; namespace osu.Game.Rulesets.Karaoke.Tests.Editor.ChangeHandlers.Lyrics { - public abstract class LyricPropertyChangeHandlerTest : BaseHitObjectChangeHandlerTest + public abstract class LyricPropertyChangeHandlerTest : BaseHitObjectPropertyChangeHandlerTest where TChangeHandler : LyricPropertyChangeHandler, new() { protected Lyric PrepareLyricWithSyncConfig(Lyric referencedLyric, IReferenceLyricPropertyConfig? config = null, bool selected = true) @@ -23,10 +22,5 @@ protected Lyric PrepareLyricWithSyncConfig(Lyric referencedLyric, IReferenceLyri return lyric; } - - protected void TriggerHandlerChangedWithChangeForbiddenException(Action c) - { - TriggerHandlerChangedWithException(c); - } } } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Notes/NotePropertyChangeHandlerTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Notes/NotePropertyChangeHandlerTest.cs index 36591b9ad..e1c5a2fb8 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Notes/NotePropertyChangeHandlerTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Notes/NotePropertyChangeHandlerTest.cs @@ -4,10 +4,11 @@ using NUnit.Framework; using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Notes; using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Rulesets.Karaoke.Objects.Properties; namespace osu.Game.Rulesets.Karaoke.Tests.Editor.ChangeHandlers.Notes { - public class NotePropertyChangeHandlerTest : BaseHitObjectChangeHandlerTest + public class NotePropertyChangeHandlerTest : BaseHitObjectPropertyChangeHandlerTest { [Test] public void TestChangeText() @@ -71,5 +72,22 @@ public void TestChangeDisplayStateToNonVisible() Assert.AreEqual(new Tone(), h.Tone); }); } + + [Test] + [Ignore("Waiting to implement the lock rules.")] + public void TestWithReferenceLyric() + { + PrepareHitObject(new Note + { + Text = "カラオケ", + ReferenceLyric = new Lyric + { + ReferenceLyric = new Lyric(), + ReferenceLyricConfig = new ReferenceLyricConfig() + } + }); + + TriggerHandlerChangedWithChangeForbiddenException(c => c.ChangeText("からおけ")); + } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ChangeHandlers/LockChangeHandler.cs b/osu.Game.Rulesets.Karaoke/Edit/ChangeHandlers/LockChangeHandler.cs index 38ccd67e3..950d56de0 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ChangeHandlers/LockChangeHandler.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ChangeHandlers/LockChangeHandler.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Objects.Types; @@ -25,11 +26,10 @@ public void Unlock() protected override bool IsWritePropertyLocked(KaraokeHitObject hitObject) { - // todo: implement. return hitObject switch { - Lyric => false, - Note => false, + Lyric lyric => HitObjectWritableUtils.IsWriteLyricPropertyLocked(lyric, nameof(Lyric.Lock)), + Note note => HitObjectWritableUtils.IsWriteNotePropertyLocked(note, nameof(Lyric.Lock)), _ => throw new NotSupportedException() }; }