/**
 *  @file ins_ut_lcd.c
 *  @details config unit test
 *
 */

#include <stdlib.h>
#include "unittest.h"
//#include "unittest/device/display/LCD/ins_ut_lcd.h"
#include "ins_ut_lcd.h"
#include "ins_mw_config.h"
#include "ins_pal_error_code.h"
#include "ins_comm_log.h"

#include "SvcFlowControl.h"
#include "ins_dev_lcd.h"


#if 0
static int32_t InsUT_Device_LcdInit(int32_t argc, char **argv)
{
    int32_t RetVal = 0;
    //int32_t part = 0;

	INSLOG_E("argc = %d\n", argc);
    for(int i = 0; i < argc; i++)
    {
        INSLOG_E("argv[%d] = %s\n", i, argv[i]);
    }
    if(argc < 1)
    {
        INSLOG_W("Input para not enough!");
		INSLOG_W("show init -> lcd init!");
		INSLOG_W("show liveview -> lcd show!");
		
        return INSERR_NG;
    }
    //part = atoi(argv[0]);
    RetVal = SvcFlowControl_Exec(argv[0U]);

    return (int32_t)RetVal;
}
#endif

static int32_t InsUT_Device_LcdEnable(int32_t argc, char **argv)
{
	InsDev_Lcd_t * p_lcd_dev = InsDev_Lcd_Init(0);
    int32_t RetVal = 0;
    int32_t part = 0;

#if 0
	if(argc > 0)
	{
		INSLOG_E("argc = %d\n", argc);
	    for(int i = 0; i < argc; i++)
	    {
	        INSLOG_E("argv[%d] = %s\n", i, argv[i]);
	    }
	}
#endif
    if(argc < 1)
    {
        INSLOG_W("Input para not enough!");
		INSLOG_W("enable 0 -> lcd enable!");
		
        return INSERR_NG;
    }
    part = atoi(argv[0]);
    RetVal = (int32_t)p_lcd_dev->fpd_enable((InsDev_Lcd_HOOK_ID_e)part);

    return (int32_t)RetVal;
}

static int32_t InsUT_Device_LcdDisable(int32_t argc, char **argv)
{
	InsDev_Lcd_t * p_lcd_dev = InsDev_Lcd_Init(0);
    int32_t RetVal = 0;
    int32_t part = 0;

#if 0
	if(argc > 0)
	{
		INSLOG_E("argc = %d\n", argc);
	    for(int i = 0; i < argc; i++)
	    {
	        INSLOG_E("argv[%d] = %s\n", i, argv[i]);
	    }
	}
#endif
    if(argc < 1)
    {
        INSLOG_W("Input para not enough!");
		INSLOG_W("disable 0 -> lcd disable!");
		
        return INSERR_NG;
    }
    part = atoi(argv[0]);
    RetVal = (int32_t)p_lcd_dev->fpd_disable((InsDev_Lcd_HOOK_ID_e)part);

    return (int32_t)RetVal;
}

static int32_t InsUT_Device_LcdBackLight(int32_t argc, char **argv)
{
	InsDev_Lcd_t * p_lcd_dev = InsDev_Lcd_Init(0);
    int32_t RetVal = 0;
    int32_t part = 0;
	uint32_t enable_flag = 0;
		
#if 0
	if(argc > 0)
	{
		INSLOG_E("argc = %d\n", argc);
	    for(int i = 0; i < argc; i++)
	    {
	        INSLOG_E("argv[%d] = %s\n", i, argv[i]);
	    }
	}
#endif
    if(argc < 2)
    {
        INSLOG_W("Input para not enough!");
		INSLOG_W("backlight 0 1 -> set_backlight!");
		
        return INSERR_NG;
    }
    part = atoi(argv[0]);
	enable_flag = atoi(argv[1]);
    RetVal = (int32_t)p_lcd_dev->fpd_set_backlight((InsDev_Lcd_HOOK_ID_e)part, enable_flag);

    return (int32_t)RetVal;
}

InsUT_Unittest_CmdInfo_t g_ut_cmd_DevDisplay[INSUT_CMDCNT_DEV_LCD_DISPLAY] = 
{
	#if 0
    {InsUT_Device_LcdInit,    0, NULL, "show",       "lcd init"},
	#endif
    {InsUT_Device_LcdEnable,    0, NULL, "enable",       "lcd enable"},
    {InsUT_Device_LcdDisable,    0, NULL, "disable",       "lcd disable"},
    {InsUT_Device_LcdBackLight,    0, NULL, "backlight",       "lcd backlight"},
};

