Skip to content

Commit

Permalink
Merge pull request #269 from rdkcentral/feature/issue268_CompositeIn_…
Browse files Browse the repository at this point in the history
…L3_videomodeCBSupport

gh #268 CompositeIn L3 testcase for new API
  • Loading branch information
hari22yuva authored Dec 24, 2024
2 parents d5f4284 + 0481130 commit 3829e63
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [References](#references)
- [Level 3 Test cases High Level Overview](#level-3-test-cases-high-level-overview)
- [Level 3 Python Test](#level-3-python-test-cases-high-level-overview)
- [YAML File Inputs](#yaml-file-inputs)

## Overview

Expand Down Expand Up @@ -43,6 +44,7 @@ Below are top test use-case for the Composite Input.
|2|Verify the CompositeIn active port status with callbacks|Connect a CompositeIn source device, select the CompositeIn port and check the callbacks is triggered when the active status changes(i.e like isPresented, activeport)|`dsCompositeInRegisterStatusChangeCB()`|
|3|Scale the video and verify |Play the video stream(`vts_SDR_stream`) in CompositeIn source device connected to the active CompositeIn port and scale the video resolution|`dsCompositeInScaleVideo()`|
|4|Verify the CompositeIn Signal change with callback| Connect a CompositeIn source device, select the CompositeIn port and check the callback is triggered when the change in signal status occurs(i.e like no signal , unstable signal, stable signal)|`dsCompositeInRegisterSignalChangeCB()`|
|5|Verify the CompositeIn video mode change with callback| Connect a CompositeIn source device, select the CompositeIn port, and verify that the callback is triggered when there is a change in the video mode on the source device|`dsCompositeInRegisterVideoModeUpdateCB()`|

## Level 3 Python Test Cases High Level Overview

Expand Down
66 changes: 66 additions & 0 deletions docs/pages/dsCompositeIn/ds-compositeIn-L3-TestProcedure.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [dsCompositeIn_test2_VerifyStatus_Callback.py](#dscompositein_test2_verifystatus_callbackpy)
- [dsCompositeIn_test3_ScaleAndVerify_Video.py](#dscompositein_test3_scaleandverify_videopy)
- [dsCompositeIn_test4_VerifySignal_Callback.py](#dscompositein_test4_verifysignal_callbackpy)
- [dsCompositeIn_test5_VerifyVideoMode_Callback.py](#dscompositein_test5_verifyvideomode_callbackpy)
- [dsCompositeIn_L3_Runall_Sink.py](#dscompositein_l3_runall_sinkpy)

## Acronyms, Terms and Abbreviations
Expand Down Expand Up @@ -114,6 +115,8 @@ dscompositeIn:
streams:
test4_VerifySignal_Callback:
streams:
test5_VerifyVideoMode_Callback:
streams:
```
#### Test Configuration
Expand Down Expand Up @@ -363,6 +366,69 @@ Success Criteria

Upon receiving user responses for all ports, the test will conclude and present a final result: PASS or FAIL based on the user inputs throughout the test execution.

### dsCompositeIn_test5_VerifyVideoMode_Callback.py

#### Platform Support - test05

- Sink

#### User Input Required - test05

**Yes**: User interaction is necessary to connect/Disconnect the device (This will be automated later).

#### Acceptance Criteria - test05

The test detects the video mode change of the compositeIn video.

#### Expected Results - test05

The test checks the video mode change in the composite source

Success Criteria

- Test identifies the video mode change.

#### Test Steps - test05

- Initiate the Test:

- Select and execute the Python file: **`dsCompositeIn_test5_VerifyVideoMode_Callback.py`**
- The test will automatically download all required artifacts, copying them to the designated target directory before commencing execution.

- Device Connect prompt:

The test will Request the User to connect the Source device to the Composite In port:

- Question: "Connect the compositeIn source device to Port port_type and press Y: "
- Press **Y** if the user connected the device and acknowledged it. (this will mark the step as PASS).

- Device connect confirmation:

- The test will check if the event has reached the device.
- If the event is detected will mark the step as PASS
- If the event is not detected will mark the step as FAIL

- Source video resolution change prompt:

The test will Request the User to change the resolution of video on Source device connected to the Composite In port:

- Question: "Change the resolution of video played from CompositeIn source device connected to port_type and press Y: "
- Press **Y** if the user changed the resolution and acknowledged it. (this will mark the step as PASS).

- Source video resolution change confirmation:

- The test will check if the event has reached the device.
- If the event is detected will mark the step as PASS
- If the event is not detected will mark the step as FAIL

- Repeat for All Ports:

The test will iterate through all available ports.

- Test Conclusion:

Upon receiving user responses for all ports, the test will conclude and present a final result: PASS or FAIL based on the user inputs throughout the test execution.

### dsCompositeIn_L3_Runall_Sink.py

This python file runs all the tests supported by `sink` devices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ dsCompositeIn:
test3_ScaleAndVerify_Video:
streams:
test4_VerifySignal_Callback:
streams:
test5_VerifyVideoMode_Callback:
streams:
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/env python3
#** *****************************************************************************
# *
# * If not stated otherwise in this file or this component's LICENSE file the
# * following copyright and licenses apply:
# *
# * Copyright 2024 RDK Management
# *
# * Licensed under the Apache License, Version 2.0 (the "License");
# * you may not use this file except in compliance with the License.
# * You may obtain a copy of the License at
# *
# *
# http://www.apache.org/licenses/LICENSE-2.0
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *
#* ******************************************************************************

import os
import sys
from enum import Enum, auto

dir_path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(dir_path, "../../"))

from dsCompositeInHelperClass import dsCompositeInHelperClass
from raft.framework.core.logModule import logModule

class dsCompositeIn_test5_VerifyVideoMode_Callback(dsCompositeInHelperClass):
"""
Test class to verify the videomode change callback of CompositeIn device
This class uses the `dscompositeInClass` to interact with the device's compositeIn ports,
downloading necessary test assets, selecting
CompositeIn ports, and performing verification of compositeIn output.
"""

def __init__(self, log:logModule=None):
"""
Initializes the test5_VerifyVideoMode_Callback test .
Args:
None.
"""
self.testName = "test5_VerifyVideoMode_Callback"
self.qcID = '5'
super().__init__(self.testName, self.qcID, log)

#TODO: Current version supports only manual verification.
def CheckDeviceStatus(self, manual=False, connect=False, port_type:str=0):
"""
Verifies whether Composite Source Device connected or not
Args:
port_type (str) : CompositeIn port
manual (bool, optional): Manual verification (True: manual, False: other verification methods).
Defaults to other verification methods
Returns:
bool
"""
if manual:
message = (
f"Check if CompositeIn source is connected to {port_type} and press Y:"
if connect
else f"Change the resolution of the video played from CompositeIn source device connected to {port_type} and press Y:"
)
return self.testUserResponse.getUserYN(message)
else :
#TODO: Add automation verification methods
return False

def testFunction(self):
"""
The main test function that verifies videomode change status of CompositeIn device.
This function:
- Verifies CompositeIn videomode change status through callbacks.
Returns:
bool: Final result of the test.
"""

# Initialize the dsCompositeIn module
self.testdsCompositeIn.initialise()

# Loop through the supported CompositeIn ports
for port in self.testdsCompositeIn.getSupportedPorts():

# Check the CompositeIn device connected to is active
portstr = f"dsCOMPOSITE_IN_PORT_{port}"
self.log.stepStart(f'Select {port} Port')
connect = True
result = self.CheckDeviceStatus(True, connect, portstr)
self.log.stepResult(result,f'CompositeIn Device connected {result} on {portstr}')

self.testdsCompositeIn.selectPort(portstr)
self.log.stepStart(f'Port Selcted {portstr}')

connect = False
result = self.CheckDeviceStatus(True, connect, portstr)

status = self.testdsCompositeIn.getVideoModeChangeCallbackStatus()
if status != None and portstr == status[0]:
self.log.stepResult(True,f'Videoresolution {status[1]} and VideoFramerate {status[2]} found in Callback')
else:
self.log.stepResult(False,f'Videomode change not found in Callback')

# Terminate testdsCompositeIn Module
self.testdsCompositeIn.terminate()

return result

if __name__ == '__main__':
summerLogName = os.path.splitext(os.path.basename(__file__))[0] + "_summery"
summeryLog = logModule(summerLogName, level=logModule.INFO)
test = dsCompositeIn_test5_VerifyVideoMode_Callback(summeryLog)
test.run(False)
30 changes: 30 additions & 0 deletions host/tests/dsClasses/dsCompositeIn.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,36 @@ def getPortCallbackStatus(self):

return None

def getVideoModeChangeCallbackStatus(self):
"""
Retrieves the CompositeIn videomode details from the device using a callback.
This function reads the output from the device session to detect the
video mode details. The callback message contains the port number
and the video resolution details. The function parses the message
and returns the port ,resolution, framerate and None if not present.
Args:
None.
Returns:
tuple:
- port (str): The CompositeIn port number as a string.
- videoResolution (str): Video resolution as a string.
- videoFramerate (str): Video framerate as a string.
None: If no matching signal status is found.
"""

result = self.testSession.read_until("Received VideomodeChange callback port:")
callpattern = r"Received VideomodeChange callback port: \[(\w+)\], videoResolution: \[(\w+)\], videoFrameRate: \[(\w+)\]"
match = re.search(callpattern, result)
if match:
output1 = match.group(1)
output2 = match.group(2)
output3 = match.group(3)
return output1, output2, output3

return None

def getStatus(self):
"""
Gets the status of compositeIn ports.
Expand Down
54 changes: 53 additions & 1 deletion src/test_l3_dsCompositeIn.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ static int32_t gTestID = 1;
static bool gConnectionStatus = false;
static dsCompInSignalStatus_t gSignalStatus = dsCOMP_IN_SIGNAL_STATUS_NONE;
static dsCompositeInStatus_t gStatusChange;
static dsVideoResolution_t gVideoResolution = dsVIDEO_PIXELRES_720x480;
static dsVideoFrameRate_t gFrameRate = dsVIDEO_FRAMERATE_UNKNOWN;

/* Mapping table for dsError_t */
const static ut_control_keyStringMapping_t dsError_mapTable [] = {
Expand Down Expand Up @@ -115,6 +117,34 @@ const static ut_control_keyStringMapping_t dsCompInSignalStatusMappingTable[] =
{NULL, -1}
};

/* Mapping table for dsVideoResolution_t */
const static ut_control_keyStringMapping_t dsCompInResolutionMappingTable[] = {
{"dsVIDEO_PIXELRES_720x480", (int32_t)dsVIDEO_PIXELRES_720x480},
{"dsVIDEO_PIXELRES_720x576", (int32_t)dsVIDEO_PIXELRES_720x576},
{"dsVIDEO_PIXELRES_1280x720", (int32_t)dsVIDEO_PIXELRES_1280x720},
{"dsVIDEO_PIXELRES_1366x768", (int32_t)dsVIDEO_PIXELRES_1366x768},
{"dsVIDEO_PIXELRES_1920x1080", (int32_t)dsVIDEO_PIXELRES_1920x1080},
{"dsVIDEO_PIXELRES_3840x2160", (int32_t)dsVIDEO_PIXELRES_3840x2160},
{"dsVIDEO_PIXELRES_4096x2160", (int32_t)dsVIDEO_PIXELRES_4096x2160},
{"dsVIDEO_PIXELRES_MAX", (int32_t)dsVIDEO_PIXELRES_MAX},
{NULL, -1}
};

/* Mapping table for dsVideoFrameRate_t */
const static ut_control_keyStringMapping_t dsCompInFrameRateMappingTable[] = {
{"dsVIDEO_FRAMERATE_UNKNOWN", (int32_t)dsVIDEO_FRAMERATE_UNKNOWN},
{"dsVIDEO_FRAMERATE_24", (int32_t)dsVIDEO_FRAMERATE_24},
{"dsVIDEO_FRAMERATE_25", (int32_t)dsVIDEO_FRAMERATE_25},
{"dsVIDEO_FRAMERATE_30", (int32_t)dsVIDEO_FRAMERATE_30},
{"dsVIDEO_FRAMERATE_60", (int32_t)dsVIDEO_FRAMERATE_60},
{"dsVIDEO_FRAMERATE_23dot98", (int32_t)dsVIDEO_FRAMERATE_23dot98},
{"dsVIDEO_FRAMERATE_29dot97", (int32_t)dsVIDEO_FRAMERATE_29dot97},
{"dsVIDEO_FRAMERATE_50", (int32_t)dsVIDEO_FRAMERATE_50},
{"dsVIDEO_FRAMERATE_59dot94", (int32_t)dsVIDEO_FRAMERATE_59dot94},
{"dsVIDEO_FRAMERATE_MAX", (int32_t)dsVIDEO_FRAMERATE_MAX},
{NULL, -1}
};

/* Mapping table for dsCompositeInPort_t */
const static ut_control_keyStringMapping_t dsCompositeInPortMappingTable[] = {
{"dsCOMPOSITE_IN_PORT_NONE", (int32_t)dsCOMPOSITE_IN_PORT_NONE},
Expand All @@ -124,7 +154,6 @@ const static ut_control_keyStringMapping_t dsCompositeInPortMappingTable[] = {
{NULL, -1}
};


/* Mapping table for boolean values */
const static ut_control_keyStringMapping_t bool_mapTable [] = {
{ "false", (int32_t)false },
Expand Down Expand Up @@ -205,6 +234,22 @@ static void compositeInStatusChangeCB(dsCompositeInStatus_t inputStatus)
gStatusChange = inputStatus;
}

/**
* @brief Callback function for CompositeIn port video mode change.
*
* This function is invoked whenever a video mode change occurs in the Comosite Input video.
*/
static void compositeInVideoModeChangeCB(dsCompositeInPort_t port, dsVideoPortResolution_t videoResolution)
{
UT_LOG_INFO("Received VideomodeChange callback port: [%s], videoResolution: [%s], videoFrameRate: [%s]\n",
UT_Control_GetMapString(dsCompositeInPortMappingTable, port),
UT_Control_GetMapString(dsCompInResolutionMappingTable, videoResolution.pixelResolution),
UT_Control_GetMapString(dsCompInFrameRateMappingTable, videoResolution.frameRate));

gVideoResolution = videoResolution.pixelResolution;
gFrameRate = videoResolution.frameRate;
}

/**
* @brief This test initializes the CompositeIn Module.
*
Expand Down Expand Up @@ -248,6 +293,13 @@ void test_l3_CompositeIn_initialize(void)
compositeInStatusChangeCB, UT_Control_GetMapString(dsError_mapTable, ret));
ASSERT(ret == dsERR_NONE);

/* Register videomode change callback */
UT_LOG_INFO("Calling dsCompositeInRegisterVideoModeUpdateCB(IN:CBFunc:[0x%0X])", compositeInVideoModeChangeCB);
ret = dsCompositeInRegisterVideoModeUpdateCB(compositeInVideoModeChangeCB);
UT_LOG_INFO("Result dsCompositeInRegisterVideoModeUpdateCB(IN:CBFunc:[0x%0X]) dsError_t:[%s]",
compositeInVideoModeChangeCB, UT_Control_GetMapString(dsError_mapTable, ret));
ASSERT(ret == dsERR_NONE);

UT_LOG_INFO("Out %s", __FUNCTION__);
}

Expand Down

0 comments on commit 3829e63

Please sign in to comment.