mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Fix test failures and general discrepancies
This commit is contained in:
@ -19,14 +19,14 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
public void TestSlidingSampleStopsOnSeek()
|
public void TestSlidingSampleStopsOnSeek()
|
||||||
{
|
{
|
||||||
DrawableSlider slider = null;
|
DrawableSlider slider = null;
|
||||||
SkinnableSound[] loopingSamples = null;
|
PoolableSkinnableSample[] loopingSamples = null;
|
||||||
SkinnableSound[] onceOffSamples = null;
|
PoolableSkinnableSample[] onceOffSamples = null;
|
||||||
|
|
||||||
AddStep("get first slider", () =>
|
AddStep("get first slider", () =>
|
||||||
{
|
{
|
||||||
slider = Editor.ChildrenOfType<DrawableSlider>().OrderBy(s => s.HitObject.StartTime).First();
|
slider = Editor.ChildrenOfType<DrawableSlider>().OrderBy(s => s.HitObject.StartTime).First();
|
||||||
onceOffSamples = slider.ChildrenOfType<SkinnableSound>().Where(s => !s.Looping).ToArray();
|
onceOffSamples = slider.ChildrenOfType<PoolableSkinnableSample>().Where(s => !s.Looping).ToArray();
|
||||||
loopingSamples = slider.ChildrenOfType<SkinnableSound>().Where(s => s.Looping).ToArray();
|
loopingSamples = slider.ChildrenOfType<PoolableSkinnableSample>().Where(s => s.Looping).ToArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("start playback", () => EditorClock.Start());
|
AddStep("start playback", () => EditorClock.Start());
|
||||||
@ -36,15 +36,15 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
if (!slider.Tracking.Value)
|
if (!slider.Tracking.Value)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!loopingSamples.Any(s => s.IsPlaying))
|
if (!loopingSamples.Any(s => s.Playing))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
EditorClock.Seek(20000);
|
EditorClock.Seek(20000);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("non-looping samples are playing", () => onceOffSamples.Length == 4 && loopingSamples.All(s => s.IsPlayed || s.IsPlaying));
|
AddAssert("non-looping samples are playing", () => onceOffSamples.Length == 4 && loopingSamples.All(s => s.Played || s.Playing));
|
||||||
AddAssert("looping samples are not playing", () => loopingSamples.Length == 1 && loopingSamples.All(s => s.IsPlayed && !s.IsPlaying));
|
AddAssert("looping samples are not playing", () => loopingSamples.Length == 1 && loopingSamples.All(s => s.Played && !s.Playing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,14 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
public void TestAllSamplesStopDuringSeek()
|
public void TestAllSamplesStopDuringSeek()
|
||||||
{
|
{
|
||||||
DrawableSlider slider = null;
|
DrawableSlider slider = null;
|
||||||
SkinnableSound[] samples = null;
|
PoolableSkinnableSample[] samples = null;
|
||||||
ISamplePlaybackDisabler sampleDisabler = null;
|
ISamplePlaybackDisabler sampleDisabler = null;
|
||||||
|
|
||||||
AddUntilStep("get variables", () =>
|
AddUntilStep("get variables", () =>
|
||||||
{
|
{
|
||||||
sampleDisabler = Player;
|
sampleDisabler = Player;
|
||||||
slider = Player.ChildrenOfType<DrawableSlider>().OrderBy(s => s.HitObject.StartTime).FirstOrDefault();
|
slider = Player.ChildrenOfType<DrawableSlider>().OrderBy(s => s.HitObject.StartTime).FirstOrDefault();
|
||||||
samples = slider?.ChildrenOfType<SkinnableSound>().ToArray();
|
samples = slider?.ChildrenOfType<PoolableSkinnableSample>().ToArray();
|
||||||
|
|
||||||
return slider != null;
|
return slider != null;
|
||||||
});
|
});
|
||||||
@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
if (!slider.Tracking.Value)
|
if (!slider.Tracking.Value)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!samples.Any(s => s.IsPlaying))
|
if (!samples.Any(s => s.Playing))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Player.ChildrenOfType<GameplayClockContainer>().First().Seek(40000);
|
Player.ChildrenOfType<GameplayClockContainer>().First().Seek(40000);
|
||||||
|
@ -43,7 +43,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestStoppedSoundDoesntResumeAfterPause()
|
public void TestStoppedSoundDoesntResumeAfterPause()
|
||||||
{
|
{
|
||||||
AddStep("start sample with looping", () => skinnableSound.Looping = true);
|
AddStep("start sample with looping", () =>
|
||||||
|
{
|
||||||
|
skinnableSound.Looping = true;
|
||||||
|
skinnableSound.Play();
|
||||||
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for sample to start playing", () => skinnableSound.IsPlaying);
|
AddUntilStep("wait for sample to start playing", () => skinnableSound.IsPlaying);
|
||||||
|
|
||||||
@ -62,7 +66,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestLoopingSoundResumesAfterPause()
|
public void TestLoopingSoundResumesAfterPause()
|
||||||
{
|
{
|
||||||
AddStep("start sample with looping", () => skinnableSound.Looping = true);
|
AddStep("start sample with looping", () =>
|
||||||
|
{
|
||||||
|
skinnableSound.Looping = true;
|
||||||
|
skinnableSound.Play();
|
||||||
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for sample to start playing", () => skinnableSound.IsPlaying);
|
AddUntilStep("wait for sample to start playing", () => skinnableSound.IsPlaying);
|
||||||
|
|
||||||
|
@ -155,7 +155,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
lastSampleValue = value;
|
lastSampleValue = value;
|
||||||
|
|
||||||
lastSampleTime = Clock.CurrentTime;
|
lastSampleTime = Clock.CurrentTime;
|
||||||
|
|
||||||
var channel = sample.Play();
|
var channel = sample.Play();
|
||||||
|
@ -117,19 +117,25 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
activeChannel = Sample.Play();
|
activeChannel = Sample.Play();
|
||||||
activeChannel.Looping = Looping;
|
activeChannel.Looping = Looping;
|
||||||
|
|
||||||
|
Played = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stops the sample.
|
/// Stops the sample.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Stop() => activeChannel?.Stop();
|
public void Stop()
|
||||||
|
{
|
||||||
|
activeChannel?.Stop();
|
||||||
|
activeChannel = null;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the sample is currently playing.
|
/// Whether the sample is currently playing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Playing => activeChannel?.Playing ?? false;
|
public bool Playing => activeChannel?.Playing ?? false;
|
||||||
|
|
||||||
public bool Played => !activeChannel?.Playing ?? false;
|
public bool Played { get; private set; }
|
||||||
|
|
||||||
private bool looping;
|
private bool looping;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user