Skip to content

Commit

Permalink
tests: add new unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed May 12, 2024
1 parent 8ef21bb commit 159c840
Show file tree
Hide file tree
Showing 12 changed files with 304 additions and 57 deletions.
41 changes: 41 additions & 0 deletions GalaxyBudsClient.Tests/Buds/ExtendedStatusUpdateTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using GalaxyBudsClient.Message;
using GalaxyBudsClient.Message.Decoder;
using GalaxyBudsClient.Model.Constants;

namespace GalaxyBudsClient.Tests.Buds;

[TestFixture, Description("Test ExtendedStatusUpdate parser for the 1st-gen Buds"), TestOf(typeof(ExtendedStatusUpdateDecoder))]
public class ExtendedStatusUpdateTests : MessageTests<ExtendedStatusUpdateDecoder>
{
protected override string TestDataGroup => "ExtendedStatusUpdate";

[Test, TestCaseSource(nameof(_testCases)), Description("Decode ExtendedStatusUpdate messages")]
public void Decode(TestCase testCase) => DecodeAndVerify(testCase);

private static object[] _testCases =
[
new TestCase { Revision = 3, Model = Models.Buds, ExpectedResult = new ExtendedStatusUpdateDecoder
{
TargetModel = Models.Buds,

Revision = 3,
EarType = 0,
BatteryL = 70,
BatteryR = 95,
IsCoupled = true,
MainConnection = DevicesInverted.R,
WearState = LegacyWearStates.None,
PlacementL = PlacementStates.Idle,
PlacementR = PlacementStates.Idle,
EqualizerMode = 7,
TouchpadLock = false,
TouchpadOptionL = TouchOptions.Volume,
TouchpadOptionR = TouchOptions.Volume,
SeamlessConnectionEnabled = false,
AmbientSoundEnabled = false,
AmbientSoundVolume = 2,
AmbientSoundMode = AmbientTypes.Default,
EqualizerEnabled = true
}}
];
}
Original file line number Diff line number Diff line change
@@ -1,70 +1,19 @@
using GalaxyBudsClient.Message;
using GalaxyBudsClient.Message.Decoder;
using GalaxyBudsClient.Model.Constants;

namespace GalaxyBudsClient.Tests;
namespace GalaxyBudsClient.Tests.Buds2Pro;

[TestFixture, Description("Test ExtendedStatusUpdate parsers"), TestOf(typeof(ExtendedStatusUpdateDecoder))]
[TestFixture, Description("Test ExtendedStatusUpdate parser for the Buds2 Pro"), TestOf(typeof(ExtendedStatusUpdateDecoder))]
public class ExtendedStatusUpdateTests : MessageTests<ExtendedStatusUpdateDecoder>
{
protected override string TestDataGroup => "ExtendedStatusUpdate";

[Test, TestCaseSource(nameof(_testCases)), Description("Decode ExtendedStatusUpdate message")]
[Test, TestCaseSource(nameof(_testCases)), Description("Decode ExtendedStatusUpdate messages")]
public void Decode(TestCase testCase) => DecodeAndVerify(testCase);

private static object[] _testCases =
[
new TestCase { Revision = 10, Model = Models.BudsPro, ExpectedResult = new ExtendedStatusUpdateDecoder(new SppMessage())
{
TargetModel = Models.BudsPro,

Revision = 10,
EarType = 2,
BatteryL = 89,
BatteryR = 94,
IsCoupled = true,
MainConnection = DevicesInverted.L,
WearState = LegacyWearStates.L,
EqualizerMode = 1,
TouchpadLock = false,
TouchpadOptionL = TouchOptions.NoiseControl,
TouchpadOptionR = TouchOptions.NoiseControl,
SeamlessConnectionEnabled = true,
AmbientSoundVolume = 2,
PlacementL = PlacementStates.Wearing,
PlacementR = PlacementStates.Case,
BatteryCase = 100,
OutsideDoubleTap = true,
ColorL = DeviceIds.BudsProBlack,
ColorR = DeviceIds.BudsProBlack,
AdjustSoundSync = false,
SideToneEnabled = false,
ExtraHighAmbientEnabled = false,
VoiceWakeUp = false,
VoiceWakeUpLang = 1,
FmmRevision = 3,
NoiseControlMode = NoiseControlModes.Off,
NoiseControlTouchOff = true,
NoiseControlTouchAnc = true,
NoiseControlTouchAmbient = false,
NoiseControlTouchLeftOff = true,
NoiseControlTouchLeftAnc = true,
NoiseControlTouchLeftAmbient = false,
SpeakSeamlessly = false,
NoiseReductionLevel = 1,
AutoSwitchAudioOutput = false,
DetectConversations = false,
DetectConversationsDuration = 2,
SpatialAudio = false,
HearingEnhancements = 16,
NoiseControlsWithOneEarbud = false,
AmbientCustomVolumeOn = false,
AmbientCustomVolumeLeft = 2,
AmbientCustomVolumeRight = 2,
AmbientCustomSoundTone = 2,
CallPathControl = true
}},
new TestCase { Revision = 13, Model = Models.Buds2Pro, ExpectedResult = new ExtendedStatusUpdateDecoder(new SppMessage())
new TestCase { Revision = 13, Model = Models.Buds2Pro, ExpectedResult = new ExtendedStatusUpdateDecoder
{
TargetModel = Models.Buds2Pro,

Expand Down
86 changes: 86 additions & 0 deletions GalaxyBudsClient.Tests/BudsFe/ExtendedStatusUpdateTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using GalaxyBudsClient.Message;
using GalaxyBudsClient.Message.Decoder;
using GalaxyBudsClient.Model.Constants;

namespace GalaxyBudsClient.Tests.BudsFe;

[TestFixture, Description("Test ExtendedStatusUpdate parser for the Buds FE"), TestOf(typeof(ExtendedStatusUpdateDecoder))]
public class ExtendedStatusUpdateTests : MessageTests<ExtendedStatusUpdateDecoder>
{
protected override string TestDataGroup => "ExtendedStatusUpdate";

[Test, TestCaseSource(nameof(_testCases)), Description("Decode ExtendedStatusUpdate messages")]
public void Decode(TestCase testCase) => DecodeAndVerify(testCase);

private static object[] _testCases =
[
new TestCase { Revision = 2, Model = Models.BudsFe, ExpectedResult = new ExtendedStatusUpdateDecoder
{
TargetModel = Models.BudsFe,

Revision = 2,
EarType = 6,
BatteryL = 58,
BatteryR = 89,
IsCoupled = true,
MainConnection = DevicesInverted.R,
WearState = LegacyWearStates.Both,
EqualizerMode = 0,
TouchpadLock = false,
TouchpadOptionL = TouchOptions.Volume,
TouchpadOptionR = TouchOptions.Volume,
SeamlessConnectionEnabled = true,
AmbientSoundVolume = 1,
PlacementL = PlacementStates.Wearing,
PlacementR = PlacementStates.Wearing,
BatteryCase = 0,
OutsideDoubleTap = false,
ColorL = DeviceIds.BudsFeGraphite,
ColorR = DeviceIds.BudsFeGraphite,
AdjustSoundSync = false,
SideToneEnabled = false,
ExtraHighAmbientEnabled = false,
VoiceWakeUp = false,
VoiceWakeUpLang = 3,
FmmRevision = 4,
NoiseControlMode = NoiseControlModes.Off,
NoiseControlTouchOff = true,
NoiseControlTouchAnc = true,
NoiseControlTouchAmbient = false,
NoiseControlTouchLeftOff = false,
NoiseControlTouchLeftAnc = true,
NoiseControlTouchLeftAmbient = true,
SpeakSeamlessly = false,
NoiseReductionLevel = 0,
AutoSwitchAudioOutput = false,
DetectConversations = false,
DetectConversationsDuration = 0,
SpatialAudio = false,
HearingEnhancements = 16,
SingleTapOn = true,
DoubleTapOn = true,
TripleTapOn = true,
TouchHoldOn = true,
DoubleTapForCallOn = false,
TouchHoldOnForCallOn = false,
TouchType = 0,
NoiseControlsWithOneEarbud = true,
AmbientCustomVolumeOn = true,
AmbientCustomVolumeLeft = 1,
AmbientCustomVolumeRight = 1,
AmbientCustomSoundTone = 3,
CallPathControl = true,
IsLeftCharging = false,
IsRightCharging = false,
IsCaseCharging = false,
HearingTestValue = 157,
BixbyKeyword = 0,
NeckStretchCalibration = false,
CustomizeNoiseReductionLevel = 3, // unused value; doesn't seem right
CustomizeConversationBoost = true, // unused
ExtraClearCallSound = false,
SpatialAudioHeadTracking = true,
AutoAdjustSound = true
}}
];
}
50 changes: 50 additions & 0 deletions GalaxyBudsClient.Tests/BudsLive/ExtendedStatusUpdateTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using GalaxyBudsClient.Message.Decoder;
using GalaxyBudsClient.Model.Constants;

namespace GalaxyBudsClient.Tests.BudsLive;

[TestFixture, Description("Test ExtendedStatusUpdate parser for the Buds Live"), TestOf(typeof(ExtendedStatusUpdateDecoder))]
public class ExtendedStatusUpdateTests : MessageTests<ExtendedStatusUpdateDecoder>
{
protected override string TestDataGroup => "ExtendedStatusUpdate";

[Test, TestCaseSource(nameof(_testCases)), Description("Decode ExtendedStatusUpdate messages")]
public void Decode(TestCase testCase) => DecodeAndVerify(testCase);

private static object[] _testCases =
[
new TestCase { Revision = 9, Model = Models.BudsLive, ExpectedResult = new ExtendedStatusUpdateDecoder
{
TargetModel = Models.BudsLive,

Revision = 9,
EarType = 1,
BatteryL = 15,
BatteryR = 97,
IsCoupled = true,
MainConnection = DevicesInverted.R,
WearState = LegacyWearStates.Both,
EqualizerMode = 0,
TouchpadLock = false,
TouchpadOptionL = TouchOptions.Anc,
TouchpadOptionR = TouchOptions.Anc,
SeamlessConnectionEnabled = true,
AmbientSoundVolume = 0,
PlacementL = PlacementStates.Wearing,
PlacementR = PlacementStates.Wearing,
BatteryCase = 100,
OutsideDoubleTap = false,
ColorL = DeviceIds.BudsLiveWhite,
ColorR = DeviceIds.BudsLiveWhite,
AdjustSoundSync = false,
SideToneEnabled = false,
ExtraHighAmbientEnabled = false,
VoiceWakeUp = false,
VoiceWakeUpLang = 0,
FmmRevision = 3,
NoiseCancelling = true,
HearingEnhancements = 0x10,
CallPathControl = true
}}
];
}
46 changes: 46 additions & 0 deletions GalaxyBudsClient.Tests/BudsPlus/ExtendedStatusUpdateTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using GalaxyBudsClient.Message.Decoder;
using GalaxyBudsClient.Model.Constants;

namespace GalaxyBudsClient.Tests.BudsPlus;

[TestFixture, Description("Test ExtendedStatusUpdate parser for the Buds+"), TestOf(typeof(ExtendedStatusUpdateDecoder))]
public class ExtendedStatusUpdateTests : MessageTests<ExtendedStatusUpdateDecoder>
{
protected override string TestDataGroup => "ExtendedStatusUpdate";

[Test, TestCaseSource(nameof(_testCases)), Description("Decode ExtendedStatusUpdate messages")]
public void Decode(TestCase testCase) => DecodeAndVerify(testCase);

private static object[] _testCases =
[
new TestCase { Revision = 13, Model = Models.BudsPlus, ExpectedResult = new ExtendedStatusUpdateDecoder
{
TargetModel = Models.BudsPlus,

Revision = 13,
EarType = 0,
BatteryL = 87,
BatteryR = 84,
IsCoupled = true,
MainConnection = DevicesInverted.R,
WearState = LegacyWearStates.Both,
EqualizerMode = 3,
TouchpadLock = false,
TouchpadOptionL = TouchOptions.AmbientSound,
TouchpadOptionR = TouchOptions.AmbientSound,
SeamlessConnectionEnabled = true,
AmbientSoundVolume = 0,
PlacementL = PlacementStates.Wearing,
PlacementR = PlacementStates.Wearing,
BatteryCase = 101,
OutsideDoubleTap = true,
ColorL = DeviceIds.BudsPlusBlack,
ColorR = DeviceIds.BudsPlusBlack,
AdjustSoundSync = false,
SideToneEnabled = false,
ExtraHighAmbientEnabled = false,
FmmRevision = 3,
CallPathControl = true
}}
];
}
67 changes: 67 additions & 0 deletions GalaxyBudsClient.Tests/BudsPro/ExtendedStatusUpdateTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using GalaxyBudsClient.Message.Decoder;
using GalaxyBudsClient.Model.Constants;

namespace GalaxyBudsClient.Tests.BudsPro;

[TestFixture, Description("Test ExtendedStatusUpdate parser for the Buds Pro"), TestOf(typeof(ExtendedStatusUpdateDecoder))]
public class ExtendedStatusUpdateTests : MessageTests<ExtendedStatusUpdateDecoder>
{
protected override string TestDataGroup => "ExtendedStatusUpdate";

[Test, TestCaseSource(nameof(_testCases)), Description("Decode ExtendedStatusUpdate messages")]
public void Decode(TestCase testCase) => DecodeAndVerify(testCase);

private static object[] _testCases =
[
new TestCase { Revision = 10, Model = Models.BudsPro, ExpectedResult = new ExtendedStatusUpdateDecoder
{
TargetModel = Models.BudsPro,

Revision = 10,
EarType = 2,
BatteryL = 89,
BatteryR = 94,
IsCoupled = true,
MainConnection = DevicesInverted.L,
WearState = LegacyWearStates.L,
EqualizerMode = 1,
TouchpadLock = false,
TouchpadOptionL = TouchOptions.NoiseControl,
TouchpadOptionR = TouchOptions.NoiseControl,
SeamlessConnectionEnabled = true,
AmbientSoundVolume = 2,
PlacementL = PlacementStates.Wearing,
PlacementR = PlacementStates.Case,
BatteryCase = 100,
OutsideDoubleTap = true,
ColorL = DeviceIds.BudsProBlack,
ColorR = DeviceIds.BudsProBlack,
AdjustSoundSync = false,
SideToneEnabled = false,
ExtraHighAmbientEnabled = false,
VoiceWakeUp = false,
VoiceWakeUpLang = 1,
FmmRevision = 3,
NoiseControlMode = NoiseControlModes.Off,
NoiseControlTouchOff = true,
NoiseControlTouchAnc = true,
NoiseControlTouchAmbient = false,
NoiseControlTouchLeftOff = true,
NoiseControlTouchLeftAnc = true,
NoiseControlTouchLeftAmbient = false,
SpeakSeamlessly = false,
NoiseReductionLevel = 1,
AutoSwitchAudioOutput = false,
DetectConversations = false,
DetectConversationsDuration = 2,
SpatialAudio = false,
HearingEnhancements = 16,
NoiseControlsWithOneEarbud = false,
AmbientCustomVolumeOn = false,
AmbientCustomVolumeLeft = 2,
AmbientCustomVolumeRight = 2,
AmbientCustomSoundTone = 2,
CallPathControl = true
}}
];
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 159c840

Please sign in to comment.