Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c96c3553 authored by Ted Wang's avatar Ted Wang
Browse files

Add missing return and test for volume check

feature: #stability
Bug: 167648114
Test: atest net_test_avrcp
Change-Id: I6dce4c7afb78a93dca8ba7fcbd02aa5350f18c1a
Merged-In: I6dce4c7afb78a93dca8ba7fcbd02aa5350f18c1a
parent 1892a884
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -412,8 +412,9 @@ void Device::SetVolume(int8_t volume) {
  // TODO (apanicke): Implement logic for Multi-AVRCP
  DEVICE_VLOG(1) << __func__ << ": volume=" << (int)volume;
  if (volume == volume_) {
    DEVICE_VLOG(3) << __func__
                   << ": Ignoring volume change same as current volume level";
    DEVICE_LOG(WARNING)
        << __func__ << ": Ignoring volume change same as current volume level";
    return;
  }
  auto request = SetAbsoluteVolumeRequestBuilder::MakeBuilder(volume);

+13 −0
Original line number Diff line number Diff line
@@ -1351,6 +1351,19 @@ TEST_F(AvrcpDeviceTest, volumeRejectedTest) {
  EXPECT_CALL(response_cb, Call(_, _, _)).Times(0);
}

TEST_F(AvrcpDeviceTest, setVolumeOnceTest) {
  int vol = 0x48;

  auto set_abs_vol = SetAbsoluteVolumeRequestBuilder::MakeBuilder(vol);

  // Ensure that SetVolume only been call once.
  EXPECT_CALL(response_cb, Call(_, false, matchPacket(std::move(set_abs_vol))))
      .Times(1);

  test_device->SetVolume(vol);
  test_device->SetVolume(vol);
}

TEST_F(AvrcpDeviceTest, playPushedActiveDeviceTest) {
  MockMediaInterface interface;
  NiceMock<MockA2dpInterface> a2dp_interface;