+/*
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Haesu Gwon <haesu.gwon@samsung.com>
+ *
+ * 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.
+ */
+
+#include <glib.h>
+#include <string.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+#include <iostream>
+#include <system_info.h>
+#include <hal-hdcp.h>
+
+static int gRet;
+static void *gHalHandle;
+static const char *gSocketIp = "192.168.0.1";
+static int gPortIp = 100;
+
+/*
+ * main class
+ */
+class HdcpHalTest : public testing::Test
+{
+ public:
+ virtual void SetUp()
+ {
+ gRet = hal_hdcp_init(&gHalHandle);
+ if (gRet == HAL_HDCP_ERROR_NONE) {
+ std::cout << "HDCP HAL init - handle: " << gHalHandle << std::endl;
+ return;
+ }
+
+ std::cout << "HDCP HAL init failed " << gRet << std::endl;
+ }
+
+ virtual void TearDown()
+ {
+ if (gHalHandle) {
+ std::cout << "HDCP HAL deinit - handle: " << gHalHandle << std::endl;
+ gRet = hal_hdcp_deinit(gHalHandle);
+ gHalHandle = nullptr;
+ }
+ }
+};
+
+/**
+ * @testcase InitP
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Positive, Initialize HDCP HAL handle
+ * @apicovered hal_hdcp_init
+ * @passcase when hal_hdcp_init returns HAL_HDCP_ERROR_NONE and the handle "gHalHandle" is not a null pointer
+ * @failcase when handle "gHalHandle" is a null pointer
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, InitP)
+{
+ ASSERT_NE(gHalHandle, nullptr);
+}
+
+/**
+ * @testcase InitN
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Initialize HDCP HAL handle
+ * @apicovered hal_hdcp_init
+ * @passcase when input handle of hal_hdcp_init is a null pointer and hal_hdcp_init returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase when hal_hdcp_init does not returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, InitN)
+{
+ gRet = hal_hdcp_init(nullptr);
+ EXPECT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase DeinitP
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Positive, Deinitialize HDCP HAL handle
+ * @apicovered hal_hdcp_init, hal_hdcp_deinit
+ * @passcase when hal_hdcp_deinit returns HAL_HDCP_ERROR_NONE
+ * @failcase when hal_hdcp_deinit does not return HAL_HDCP_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, DeinitP)
+{
+ void *hal_handle = nullptr;
+
+ gRet = hal_hdcp_init(&hal_handle);
+
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+ ASSERT_NE(hal_handle, nullptr);
+
+ if (hal_handle) {
+ gRet = hal_hdcp_deinit(hal_handle);
+ EXPECT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+ hal_handle = nullptr;
+ }
+}
+
+/**
+ * @testcase DeinitN
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Deinitialize HDCP HAL handle
+ * @apicovered hal_hdcp_init, hal_hdcp_deinit
+ * @passcase when hal_hdcp_deinit returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase when hal_hdcp_deinit does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, DeinitN)
+{
+ gRet = hal_hdcp_deinit(nullptr);
+ EXPECT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase HdcpSetCommandP
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Positive, Set command
+ * @apicovered hal_hdcp_set_batch_command
+ * @passcase when hal_hdcp_set_batch_command returns HAL_HDCP_ERROR_NONE
+ * @failcase when hal_hdcp_set_batch_command does not return HAL_HDCP_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpSetBatchCommandP)
+{
+ hal_hdcp_batch_command_control_s batch_command;
+ batch_command.command_set_flag |= HAL_HDCP_COMMAND_CUSTOM;
+ batch_command.custom.name = "custom_command_name";
+ batch_command.custom.value = (void*)10;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_set_batch_command(gHalHandle, &batch_command, nullptr);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpSetBatchCommandN
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Set command
+ * @apicovered hal_hdcp_set_batch_command
+ * @passcase when hal_hdcp_set_batch_command returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase when hal_hdcp_set_batch_command does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpSetBatchCommandN)
+{
+ hal_hdcp_batch_command_control_s batch_command;
+ batch_command.command_set_flag |= HAL_HDCP_COMMAND_CUSTOM;
+ batch_command.custom.name = "custom_command_name";
+ batch_command.custom.value = (void*)10;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_set_batch_command(nullptr, &batch_command, nullptr);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_set_batch_command(gHalHandle, nullptr, nullptr);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpOpenP
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Positive, Open HDCP
+ * @apicovered hal_hdcp_open
+ * @passcase when hal_hdcp_open returns HAL_HDCP_ERROR_NONE
+ * @failcase when hal_hdcp_open does not return HAL_HDCP_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpOpenP)
+{
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpCloseP
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Positive, Close HDCP
+ * @apicovered hal_hdcp_close
+ * @passcase when hal_hdcp_close returns HAL_HDCP_ERROR_NONE
+ * @failcase when hal_hdcp_close does not return HAL_HDCP_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpCloseP)
+{
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpCloseN
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Close HDCP
+ * @apicovered hal_hdcp_close
+ * @passcase when hal_hdcp_open is not called and hal_hdcp_close returns HAL_HDCP_ERROR_INVALID_STATE
+ * @failcase when hal_hdcp_close does not return HAL_HDCP_ERROR_INVALID_STATE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpCloseN1)
+{
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_STATE);
+}
+
+/**
+ * @testcase HdcpCloseN
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Close HDCP
+ * @apicovered hal_hdcp_close
+ * @passcase when hal_hdcp_close returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase when hal_hdcp_close does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpCloseN2)
+{
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(nullptr);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase HdcpStartReceiverP
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Positive, Start HDCP receiver
+ * @apicovered hal_hdcp_start_receiver
+ * @passcase when hal_hdcp_start_receiver returns HAL_HDCP_ERROR_NONE
+ * @failcase when hal_hdcp_start_receiver does not return HAL_HDCP_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpStartReceiverP)
+{
+ uint32_t hdcp_id = 0;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_receiver(gHalHandle, 100, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpStartReceiverN
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Start HDCP receiver
+ * @apicovered hal_hdcp_start_receiver
+ * @passcase when hal_hdcp_start_receiver returns HAL_HDCP_ERROR_INVALID_STATE
+ * @failcase when hal_hdcp_start_receiver does not return HAL_HDCP_ERROR_INVALID_STATE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpStartReceiverN1)
+{
+ uint32_t hdcp_id = 0;
+
+ gRet = hal_hdcp_start_receiver(gHalHandle, 100, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_STATE);
+}
+
+/**
+ * @testcase HdcpStartReceiverN2
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Start HDCP receiver
+ * @apicovered hal_hdcp_start_receiver
+ * @passcase when hal_hdcp_start_receiver returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase when hal_hdcp_start_receiver does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpStartReceiverN2)
+{
+ uint32_t hdcp_id = 0;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_receiver(nullptr, 100, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_start_receiver(gHalHandle, 100, nullptr);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpStopReceiverP
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Positive, Stop HDCP receiver
+ * @apicovered hal_hdcp_stop_receiver
+ * @passcase when hal_hdcp_stop_receiver returns HAL_HDCP_ERROR_NONE
+ * @failcase when hal_hdcp_stop_receiver does not return HAL_HDCP_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpStopReceiverP)
+{
+ uint32_t hdcp_id = 0;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_receiver(gHalHandle, 100, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_stop_receiver(gHalHandle, hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpStopReceiverN1
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Stop HDCP receiver
+ * @apicovered hal_hdcp_stop_receiver
+ * @passcase when hal_hdcp_stop_receiver returns HAL_HDCP_ERROR_INVALID_STATE
+ * @failcase when hal_hdcp_stop_receiver does not return HAL_HDCP_ERROR_INVALID_STATE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpStopReceiverN1)
+{
+ uint32_t hdcp_id = 0;
+
+ gRet = hal_hdcp_stop_receiver(gHalHandle, hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_STATE);
+}
+
+/**
+ * @testcase HdcpStopReceiverN2
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Stop HDCP receiver
+ * @apicovered hal_hdcp_stop_receiver
+ * @passcase when hal_hdcp_stop_receiver returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase when hal_hdcp_stop_receiver does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpStopReceiverN2)
+{
+ uint32_t hdcp_id = 0;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_receiver(gHalHandle, 100, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_stop_receiver(nullptr, hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpStartTransmitterP
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Positive, Start HDCP transmitter
+ * @apicovered hal_hdcp_start_transmitter
+ * @passcase when hal_hdcp_start_transmitter returns HAL_HDCP_ERROR_NONE
+ * @failcase when hal_hdcp_start_transmitter does not return HAL_HDCP_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpStartTransmitterP)
+{
+ uint32_t hdcp_id = 0;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpStartTransmitterN1
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Start HDCP transmitter
+ * @apicovered hal_hdcp_start_transmitter
+ * @passcase when hal_hdcp_start_transmitter returns HAL_HDCP_ERROR_INVALID_STATE
+ * @failcase when hal_hdcp_start_transmitter does not return HAL_HDCP_ERROR_INVALID_STATE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpStartTransmitterN1)
+{
+ uint32_t hdcp_id = 0;
+
+ gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_STATE);
+}
+
+/**
+ * @testcase HdcpStartTransmitterN2
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Start HDCP transmitter
+ * @apicovered hal_hdcp_start_transmitter
+ * @passcase when hal_hdcp_start_transmitter returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase when hal_hdcp_start_transmitter does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpStartTransmitterN2)
+{
+ uint32_t hdcp_id = 0;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_transmitter(nullptr, gSocketIp, gPortIp, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpStopTransmitterP
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Positive, Stop HDCP transmitter
+ * @apicovered hal_hdcp_stop_transmitter
+ * @passcase when hal_hdcp_stop_transmitter returns HAL_HDCP_ERROR_NONE
+ * @failcase when hal_hdcp_stop_transmitter does not return HAL_HDCP_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpStopTransmitterP)
+{
+ uint32_t hdcp_id = 0;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpStopTransmitterN1
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Stop HDCP transmitter
+ * @apicovered hal_hdcp_stop_transmitter
+ * @passcase when hal_hdcp_stop_transmitter returns HAL_HDCP_ERROR_INVALID_STATE
+ * @failcase when hal_hdcp_stop_transmitter does not return HAL_HDCP_ERROR_INVALID_STATE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpStopTransmitterN1)
+{
+ uint32_t hdcp_id = 0;
+
+ gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_STATE);
+}
+
+/**
+ * @testcase HdcpStopTransmitterN2
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Stop HDCP transmitter
+ * @apicovered hal_hdcp_stop_transmitter
+ * @passcase when hal_hdcp_stop_transmitter returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase when hal_hdcp_stop_transmitter does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpStopTransmitterN2)
+{
+ uint32_t hdcp_id = 0;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_stop_transmitter(nullptr, hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpAllocateBufferP
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Positive, Allocate output buffer
+ * @apicovered hal_hdcp_allocate_output_buffer
+ * @passcase when hal_hdcp_allocate_output_buffer returns HAL_HDCP_ERROR_NONE
+ * @failcase when hal_hdcp_allocate_output_buffer does not return HAL_HDCP_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpAllocateBufferP)
+{
+ uint32_t hdcp_id = 0;
+ hal_hdcp_buffer_s output;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpAllocateBufferN
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Allocate output buffer
+ * @apicovered hal_hdcp_allocate_output_buffer
+ * @passcase when hal_hdcp_allocate_output_buffer returns HAL_HDCP_ERROR_NONE
+ * @failcase when hal_hdcp_allocate_output_buffer does not return HAL_HDCP_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpAllocateBufferN)
+{
+ uint32_t hdcp_id = 0;
+ hal_hdcp_buffer_s output;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_allocate_output_buffer(nullptr, 1000, false, &output);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_allocate_output_buffer(gHalHandle, 1000, false, nullptr);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpReleaseBufferP
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Positive, Release output buffer
+ * @apicovered hal_hdcp_release_output_buffer
+ * @passcase when hal_hdcp_release_output_buffer returns HAL_HDCP_ERROR_NONE
+ * @failcase when hal_hdcp_release_output_buffer does not return HAL_HDCP_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpReleaseBufferP)
+{
+ uint32_t hdcp_id = 0;
+ hal_hdcp_buffer_s output;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_release_output_buffer(gHalHandle, &output);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpReleaseBufferN
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Release output buffer
+ * @apicovered hal_hdcp_release_output_buffer
+ * @passcase when hal_hdcp_release_output_buffer returns HAL_HDCP_ERROR_NONE
+ * @failcase when hal_hdcp_release_output_buffer does not return HAL_HDCP_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpReleaseBufferN)
+{
+ uint32_t hdcp_id = 0;
+ hal_hdcp_buffer_s output;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_release_output_buffer(nullptr, &output);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_release_output_buffer(gHalHandle, nullptr);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpDecryptP
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Positive, Decrypt HDCP data
+ * @apicovered hal_hdcp_decrypt
+ * @passcase when hal_hdcp_decrypt returns HAL_HDCP_ERROR_NONE
+ * @failcase when hal_hdcp_decrypt does not return HAL_HDCP_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpDecryptP)
+{
+ uint32_t hdcp_id = 0;
+ hal_hdcp_buffer_s input, output;
+ uint32_t decrypt_info;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ input.size = 100;
+ gRet = hal_hdcp_decrypt(gHalHandle, &input, (void *)&decrypt_info, &output);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpDecryptN1
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Decrypt HDCP data
+ * @apicovered hal_hdcp_decrypt
+ * @passcase when hal_hdcp_decrypt returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase when hal_hdcp_decrypt does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpDecryptN1)
+{
+ uint32_t hdcp_id = 0;
+ hal_hdcp_buffer_s output;
+ int decrypt_info;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_decrypt(gHalHandle, nullptr, (void *)&decrypt_info, &output);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpEncryptP
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Positive, Encrypt HDCP data
+ * @apicovered hal_hdcp_encrypt
+ * @passcase when hal_hdcp_encrypt returns HAL_HDCP_ERROR_NONE
+ * @failcase when hal_hdcp_encrypt does not return HAL_HDCP_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpEncryptP)
+{
+ uint32_t hdcp_id = 0;
+ hal_hdcp_buffer_s input, output;
+ uint32_t encrypt_info;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ input.size = 100;
+ gRet = hal_hdcp_encrypt(gHalHandle, &input, hdcp_id, (void *)&encrypt_info, &output);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+/**
+ * @testcase HdcpEncryptN1
+ * @since HAL_MODULE_HDCP 1.0
+ * @author SR(haesu.gwon)
+ * @reviewer SR(gilbok)
+ * @type auto
+ * @description Negative, Encrypt HDCP data
+ * @apicovered hal_hdcp_encrypt
+ * @passcase when hal_hdcp_encrypt returns HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @failcase when hal_hdcp_encrypt does not return HAL_HDCP_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(HdcpHalTest, HdcpEncryptN1)
+{
+ uint32_t hdcp_id = 0;
+ hal_hdcp_buffer_s input, output;
+ uint32_t encrypt_info;
+ input.size = 100;
+
+ gRet = hal_hdcp_open(gHalHandle, HAL_HDCP_DEVICE_RECEIVER, HAL_HDCP_VERSION_2_0);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_encrypt(gHalHandle, nullptr, hdcp_id, (void *)&encrypt_info, &output);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_encrypt(gHalHandle, &input, hdcp_id, nullptr, &output);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_encrypt(gHalHandle, &input, hdcp_id, (void *)&encrypt_info, nullptr);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_INVALID_PARAMETER);
+
+ gRet = hal_hdcp_stop_transmitter(gHalHandle, hdcp_id);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+
+ gRet = hal_hdcp_close(gHalHandle);
+ ASSERT_EQ(gRet, HAL_HDCP_ERROR_NONE);
+}
+
+int main(int argc, char **argv)
+{
+ testing::InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}