Skip to content

Commit f4efee0

Browse files
chulspros-gattirestyled-commitsyufengwangca
authored
[Camera] Add a method in python testing framework for video and image (project-chip#39046)
* Adds a method to invoke video verification prompt in python TCs Signed-off-by: s-gatti <[email protected]> Signed-off-by: Charles Kim <[email protected]> * Adds a method to invoke image verification prompt in python TCs Signed-off-by: s-gatti <[email protected]> Signed-off-by: Charles Kim <[email protected]> * Restyled by autopep8 Signed-off-by: Charles Kim <[email protected]> * Adds a method to invoke video verification prompt in python TCs Signed-off-by: s-gatti <[email protected]> Signed-off-by: Charles Kim <[email protected]> * Update argument type in snapshot verification api Signed-off-by: s-gatti <[email protected]> Signed-off-by: Charles Kim <[email protected]> * Update src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py Co-authored-by: Yufeng Wang <[email protected]> * Remove redundant function to fix lint error Signed-off-by: Charles Kim <[email protected]> --------- Signed-off-by: s-gatti <[email protected]> Signed-off-by: Charles Kim <[email protected]> Co-authored-by: s-gatti <[email protected]> Co-authored-by: Restyled.io <[email protected]> Co-authored-by: Yufeng Wang <[email protected]>
1 parent 637d4fa commit f4efee0

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,59 @@ def wait_for_user_input(self,
16821682
logging.info("========= EOF on STDIN =========")
16831683
return None
16841684

1685+
def user_verify_snap_shot(self,
1686+
prompt_msg: str,
1687+
image: bytes) -> Optional[str]:
1688+
"""Show Image Verification Prompt and wait for user validation.
1689+
1690+
Args:
1691+
prompt_msg (str): Message for TH UI prompt and input function.
1692+
Indicates what is expected from the user.
1693+
image (bytes): Image data as bytes.
1694+
1695+
Returns:
1696+
str: User input or none if input is closed.
1697+
"""
1698+
1699+
# Convert bytes to comma separated hex string
1700+
hex_string = ', '.join(f'{byte:02x}' for byte in image)
1701+
if self.runner_hook:
1702+
self.runner_hook.show_image_prompt(
1703+
msg=prompt_msg,
1704+
img_hex_str=hex_string
1705+
)
1706+
1707+
logging.info("========= USER PROMPT for Image Verification =========")
1708+
logging.info(f">>> {prompt_msg.rstrip()} (press enter to confirm)")
1709+
try:
1710+
return input()
1711+
except EOFError:
1712+
logging.info("========= EOF on STDIN =========")
1713+
return None
1714+
1715+
def user_verify_video_stream(self,
1716+
prompt_msg: str) -> Optional[str]:
1717+
"""Show Video Verification Prompt and wait for user validation.
1718+
1719+
Args:
1720+
prompt_msg (str): Message for TH UI prompt and input function.
1721+
Indicates what is expected from the user.
1722+
1723+
Returns:
1724+
str: User input or none if input is closed.
1725+
"""
1726+
1727+
if self.runner_hook:
1728+
self.runner_hook.show_video_prompt(msg=prompt_msg)
1729+
1730+
logging.info("========= USER PROMPT for Video Stream Verification =========")
1731+
logging.info(f">>> {prompt_msg.rstrip()} (press enter to confirm)")
1732+
try:
1733+
return input()
1734+
except EOFError:
1735+
logging.info("========= EOF on STDIN =========")
1736+
return None
1737+
16851738

16861739
def _find_test_class():
16871740
"""Finds the test class in a test script.

0 commit comments

Comments
 (0)