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

Commit 845d9fc8 authored by Ram Mohan M's avatar Ram Mohan M Committed by Pawin Vongmasa
Browse files

Add portMode configuration test

Configuration of port mode of a component is allowed only when the
component is in loaded state. When the component is in idle/execute
state this operation is denied. This commit adds a test fixture that
verifies this.

Test: make vts -j99 BUILD_GOOGLE_VTS=true TARGET_PRODUCT=aosp_arm64 \
&& vts-tradefed run commandAndExit vts \
--skip-all-system-status-check --primary-abi-only \
--skip-preconditions --module VtsHalMediaOmxV1_0Test -l INFO

Bug: 63796949

Merged-In: Ib958c671873fe1d9bb4227ce3e7214f948469f19
Change-Id: Ib958c671873fe1d9bb4227ce3e7214f948469f19
parent eff1140e
Loading
Loading
Loading
Loading
+61 −0
Original line number Diff line number Diff line
@@ -556,6 +556,67 @@ TEST_F(ComponentHidlTest, Flush) {
                            kPortIndexInput, kPortIndexOutput);
}

// test port mode configuration when the component is in various states
TEST_F(ComponentHidlTest, PortModeConfig) {
    description("Test Port Mode Configuration");
    if (disableTest) return;
    android::hardware::media::omx::V1_0::Status status;
    uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
    Message msg;

    status = setRole(omxNode, gEnv->getRole().c_str());
    ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
    OMX_PORT_PARAM_TYPE params;
    if (compClass == audio_decoder || compClass == audio_encoder) {
        status = getParam(omxNode, OMX_IndexParamAudioInit, &params);
    } else {
        status = getParam(omxNode, OMX_IndexParamVideoInit, &params);
    }
    if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
        ASSERT_EQ(params.nPorts, 2U);
        kPortIndexInput = params.nStartPortNumber;
        kPortIndexOutput = kPortIndexInput + 1;
    }

    android::Vector<BufferInfo> iBuffer, oBuffer;

    // set port mode
    PortMode portMode[2];
    initPortMode(portMode, isSecure, compClass);
    status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
    EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
    status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
    EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);

    // set state to idle
    changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer,
                            kPortIndexInput, kPortIndexOutput, portMode);
    // Only Allow Port Mode configuration in loaded state
    status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
    EXPECT_NE(status, ::android::hardware::media::omx::V1_0::Status::OK);
    status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
    EXPECT_NE(status, ::android::hardware::media::omx::V1_0::Status::OK);

    // set state to executing
    changeStateIdletoExecute(omxNode, observer);
    // Only Allow Port Mode configuration in loaded state
    status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
    EXPECT_NE(status, ::android::hardware::media::omx::V1_0::Status::OK);
    status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
    EXPECT_NE(status, ::android::hardware::media::omx::V1_0::Status::OK);

    // set state to idle
    changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer);
    // set state to loaded
    changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
                            kPortIndexInput, kPortIndexOutput);

    status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
    EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
    status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
    EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
}

// state transitions test
TEST_F(ComponentHidlTest, StateTransitions) {
    description("Test State Transitions Loaded<->Idle<->Execute");