Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions smoc.Tests/Ui/NowPlayingBarTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,23 @@ public void Volume_VolumeCommand_NoArguments_DoesNothing() {
_mockPlaybackQueue.Verify();
}

/// <summary>
/// Tests that setting a volume beyond 200% does nothing.
/// </summary>
[Fact]
public void Volume_VolumeCommand_TooLarge_DoesNothing() {
_mockPlaybackQueue.SetupSet((ps) => ps.Volume = It.IsAny<float>()).Verifiable(Times.Never());
using var context = NewNowPlayingContext()
.Then((_) => _commandService.ExecuteCommand("v/201"));
_mockPlaybackQueue.Verify();
}

/// <summary>
/// Tests that the volume command sets the volume correctly to 200%.
/// </summary>
[Fact]
public void Volume_VolumeCommand_SetsVolumeToMax() {
_mockPlaybackQueue.SetupSet((ps) => ps.Volume = 2.0f).Verifiable(Times.Once());
using var context = NewNowPlayingContext()
.Then((_) => _commandService.ExecuteCommand("v/200"));
_mockPlaybackQueue.Verify();
Expand Down
2 changes: 1 addition & 1 deletion smoc/Services/Audio/IAudioService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Smoc.Services.Audio;
public interface IAudioService : IDisposable {

/// <summary>
/// Gets or sets the master volume (0.0 to 1.0).
/// Gets or sets the master volume (0.0 to 2.0).
/// </summary>
float Volume { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion smoc/Services/IPlaybackQueueService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public interface IPlaybackQueueService : IDisposable {
int CurrentPlaybackIndex { get; }

/// <summary>
/// Gets or sets the master volume (0.0 to 1.0).
/// Gets or sets the master volume (0.0 to 2.0).
/// </summary>
float Volume { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions smoc/Ui/NowPlayingBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ private void OnSetVolumeCommand(string command, string args) {
return;
}

if (!int.TryParse(splitArgs[0], out int volume) || volume < 0 || volume > 100) {
if (!int.TryParse(splitArgs[0], out int volume) || volume < 0 || volume > 200) {
Logging.Warning($"Invalid volume: {splitArgs[0]}");
_mainWindow.DisplayError($"invalid volume: {splitArgs[0]} ([0-100] expected)");
_mainWindow.DisplayError($"invalid volume: {splitArgs[0]} ([0-200] expected)");
return;
}

Expand Down
Loading