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

Commit f5035fe0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "audiosystem_tests: Skip parts of tests when speaker is not available"...

Merge "audiosystem_tests: Skip parts of tests when speaker is not available" into main am: da1dca0f am: 4942d153

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/3478696



Change-Id: I61d3fd35034f0c33160781de82d4087ec3a6a5cb
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents a9636c39 4942d153
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -412,6 +412,9 @@ TEST_F(AudioSystemTest, DevicesForRoleAndStrategy) {
                outputDevices.push_back(outputDevice);
            }
        }
        if (outputDevices.empty()) {
            GTEST_SKIP() << "No speaker device found";
        }
        EXPECT_EQ(OK, AudioSystem::setDevicesRoleForStrategy(mediaStrategy.getId(),
                                                             DEVICE_ROLE_PREFERRED, outputDevices));
        EXPECT_EQ(OK, AudioSystem::getDevicesForRoleAndStrategy(mediaStrategy.getId(),
@@ -425,8 +428,13 @@ TEST_F(AudioSystemTest, DevicesForRoleAndStrategy) {
}

TEST_F(AudioSystemTest, VolumeIndexForAttributes) {
    std::optional<audio_port_v7> speakerPort = audio_port_v7{};
    if (getPortByAttributes(AUDIO_PORT_ROLE_SINK, AUDIO_PORT_TYPE_DEVICE, AUDIO_DEVICE_OUT_SPEAKER,
                            "", *speakerPort) != OK) {
        speakerPort.reset();
    }
    AudioVolumeGroupVector groups;
    EXPECT_EQ(OK, AudioSystem::listAudioVolumeGroups(groups));
    ASSERT_EQ(OK, AudioSystem::listAudioVolumeGroups(groups));
    for (const auto& group : groups) {
        if (group.getAudioAttributes().empty()) continue;
        const audio_attributes_t attr = group.getAudioAttributes()[0];
@@ -438,16 +446,17 @@ TEST_F(AudioSystemTest, VolumeIndexForAttributes) {
        EXPECT_EQ(OK, AudioSystem::getVolumeGroupFromAudioAttributes(attr, vg));
        EXPECT_EQ(group.getId(), vg);

        if (speakerPort.has_value()) {
            int index;
        EXPECT_EQ(OK,
                  AudioSystem::getVolumeIndexForAttributes(attr, index, AUDIO_DEVICE_OUT_SPEAKER));

            EXPECT_EQ(OK, AudioSystem::getVolumeIndexForAttributes(attr, index,
                                                                   speakerPort->ext.device.type));
            int indexTest;
            EXPECT_EQ(OK, AudioSystem::getStreamVolumeIndex(streamType, &indexTest,
                                                        AUDIO_DEVICE_OUT_SPEAKER));
                                                            speakerPort->ext.device.type));
            EXPECT_EQ(index, indexTest);
        }
    }
}

TEST_F(AudioSystemTest, DevicesRoleForCapturePreset) {
    std::vector<struct audio_port_v7> ports;