diff --git a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/MockSonyCoordinator.java b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/MockSonyCoordinator.java index 7dee4feaf..b071cd7f6 100644 --- a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/MockSonyCoordinator.java +++ b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/MockSonyCoordinator.java @@ -22,6 +22,7 @@ import java.util.Set; import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; @@ -44,7 +45,13 @@ public class MockSonyCoordinator extends SonyHeadphonesCoordinator { capabilities.add(capability); } + @Override public Set getCapabilities() { return capabilities; } + + @Override + public Set getCapabilities(final GBDevice device) { + return getCapabilities(); + } } diff --git a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/v2/SonyProtocolImplV2Test.java b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/v2/SonyProtocolImplV2Test.java index 45ebab847..769c5cc63 100644 --- a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/v2/SonyProtocolImplV2Test.java +++ b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/v2/SonyProtocolImplV2Test.java @@ -24,6 +24,7 @@ import static nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphon import static nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.SonyTestUtils.assertRequests; import static nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.SonyTestUtils.handleMessage; +import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -35,6 +36,7 @@ import java.util.Map; import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences; +import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWF1000XM4Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode; @@ -48,16 +50,35 @@ import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.SpeakT import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.SpeakToChatEnabled; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.VoiceNotifications; import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.Request; +import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.MockSonyCoordinator; import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.v1.params.BatteryType; public class SonyProtocolImplV2Test { + private final MockSonyCoordinator coordinator = new MockSonyCoordinator(); private final SonyProtocolImplV2 protocol = new SonyProtocolImplV2(null) { @Override protected SonyHeadphonesCoordinator getCoordinator() { - return new SonyWF1000XM4Coordinator(); + return coordinator; } }; + @Before + public void before() { + coordinator.getCapabilities().clear(); + // Same as the WF-1000XM4 + coordinator.getCapabilities().addAll(Arrays.asList( + SonyHeadphonesCapabilities.BatteryDual, + SonyHeadphonesCapabilities.BatteryCase, + SonyHeadphonesCapabilities.AmbientSoundControl, + SonyHeadphonesCapabilities.WindNoiseReduction, + SonyHeadphonesCapabilities.EqualizerSimple, + SonyHeadphonesCapabilities.AudioUpsampling, + SonyHeadphonesCapabilities.ButtonModesLeftRight, + SonyHeadphonesCapabilities.PauseWhenTakenOff, + SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff + )); + } + @Test public void getAmbientSoundControl() { // TODO