[TCT][Tool][Non-ACR] UI modifications and void support added 56/303656/2
authorUtkarsh Tiwari <utk.tiwari@samsung.com>
Wed, 3 Jan 2024 05:47:56 +0000 (11:17 +0530)
committerUtkarsh Tiwari <utk.tiwari@samsung.com>
Thu, 4 Jan 2024 10:52:27 +0000 (16:22 +0530)
Change-Id: Ib252d22725535d5659d0f17b254d2f6dcfc04b9f
Signed-off-by: Utkarsh Tiwari <utk.tiwari@samsung.com>
tool/TC_Assistant_Tool/check_if_tc_exists.py
tool/TC_Assistant_Tool/enum_finder.py
tool/TC_Assistant_Tool/header_file_parse.py
tool/TC_Assistant_Tool/list_all_apis.py
tool/TC_Assistant_Tool/tct_assistance.py
tool/TC_Assistant_Tool/template_tc.py
tool/TC_Assistant_Tool/template_tc_negative.py
tool/TC_Assistant_Tool/validate_api.py

index f7d0ddbd693da561c7b5a92db435b13b7ae39643..09c15e86079659de334eb244dfe31be4045f04e2 100644 (file)
@@ -10,7 +10,7 @@ def check_if_tc_already_exists(MODULE_NAME, HEADER_FILE_NAME, FILE_NAME_C, API_N
     DIR =  CURRENT_PATH + "src/utc/"
     ROOTSTRAPS_DIR = get_latest_rootstrap() + "/"
     if MODULE_NAME == 'bluetooth':
-       MODULE_NAME = 'network'
+        MODULE_NAME = 'network'
     MODULE_NAME = get_api_header_file_contained_folder_name(ROOTSTRAPS_DIR, HEADER_FILE_NAME)
     with open(DIR + "/" + MODULE_NAME + "/" + FILE_NAME_C,"r") as file_one:
         for line in file_one:
index 74d1c63cc60f208776a34c58a98a7927011c74cd..466d2590fe0c0707e3636ce82a05422ace5002a6 100644 (file)
@@ -8,7 +8,8 @@ def check_api_header_file_location(HEADER_FILE_NAME, API_SEARCH):
     DIR = get_latest_rootstrap()
     with open(DIR + "//"  + HEADER_FILE_NAME,"r") as file_one:
         for line_no, line in enumerate(file_one):
-            if line.find("int" + " " + API_SEARCH + "(") != -1:
+            line = line.strip()
+            if (line.find(API_SEARCH + "(") != -1 or line.find(API_SEARCH + " (") != -1) and line[:1] != '*':
                 return True
     return False
 
index ce04e4f3dbe76ac5d8c91b2c55516ddca06c2e72..02ee121987eb867cfcf579b07133d62140f15ad8 100644 (file)
@@ -8,14 +8,14 @@ def input_output_text_extract(MODULE_NAME, HEADER_FILE_NAME, API_SEARCH):
     api_info = []
     DIR = get_latest_rootstrap()
     if MODULE_NAME == 'bluetooth':
-       MODULE_NAME = 'network'
-
+        MODULE_NAME = 'network'
     line_no = 0
     flag = False
     with open(DIR + "/" + HEADER_FILE_NAME,"r") as file_one:
         for line in file_one:
             line_no += 1
-            if line.find("int" + " " + API_SEARCH) != -1:
+            line = line.strip()
+            if (line.find(API_SEARCH + "(") != -1 or line.find(API_SEARCH + " (") != -1) and line[:1] != '*':
                 api_info.append(line)
                 flag = True
                 break
@@ -82,3 +82,4 @@ def api_description_extract(MODULE_NAME, HEADER_FILE_NAME, API_SEARCH):
 
     return desc
 
+
index 7e4012b06f2ae07267a0bc9bb2eeb1cb7a644d95..7110a3af37d4661717482fdcc4494b3c377b34b6 100644 (file)
@@ -9,6 +9,7 @@ def extract_all_apis_text(MODULE_NAME, HEADER_FILE_NAME):
 
     with open(DIR + "/" + HEADER_FILE_NAME,"r") as file_one:
         for line in file_one:
+            line = line.strip()
             if line.find("int" + " " ) != -1:
                 if "typedef" not in line:
                     api_info.append(line)
index 4d9556b6d51c72e8323fe9a93af779180f2fd1a3..76f4e771de31b58ba4e4d6558008b0836d8a03c6 100644 (file)
@@ -61,7 +61,11 @@ import tkinter
 import tkinter as tk\r
 from tkinter.ttk import Progressbar\r
 from update_module_mapper_file import *\r
-base = Tk()\r
+import customtkinter\r
+from CTkMessagebox import CTkMessagebox\r
+customtkinter.set_appearance_mode("#d3d3d3")\r
+customtkinter.set_default_color_theme("blue")\r
+base = customtkinter.CTk()\r
 style = ttk.Style()\r
 \r
 # initializing log file\r
@@ -526,6 +530,7 @@ def get_response(message):
                             return "ThankYou for providing input." + "\n" + "TC already exists for API: " + API_SEARCH + "\n" + "Please try writing again." + "\n\n[ To navigate, please type 'Back' ]"\r
 \r
                     api_return_values = get_api_return_values()\r
+                    # print("api_return_values", api_return_values)\r
                     api_params = get_api_parameters(API_NAMES)\r
                     for k, v in api_return_values.items():\r
                         for i in API_NAMES:\r
@@ -624,13 +629,13 @@ def get_response(message):
 \r
         elif intent == 'prepostinfo':\r
             enum_dict_pre_post = {}\r
-            \r
+\r
             header_files_dict = get_header_files(MODULE_NAME)\r
             pre_post_api_names = message\r
             ## print("pre post details---------------", pre_post_api_names)\r
             NEGATIVE_TC_COUNT = 10\r
             last_stage_index = 4\r
-            \r
+\r
             # get_pre_post_api_list_info(API_NAMES, MODULE_NAME, pre_post_api_names)\r
             #CURR_API_IND = 0\r
             ## print("api length", API_NAMES)\r
@@ -749,7 +754,8 @@ def get_response(message):
                             ## print("enum_dict",enum_dict)\r
                             ## print("enum_dict_pre_post",enum_dict_pre_post)\r
                             ## print("feature_name",feature_name)\r
-                            get_tc_template_code = tc_code_write1(RET_TYPE, MODULE_NAME, API_NAMES[API_IDX], PRE_POST_API_LIST, PRE_POST_API_ARGS_LIST, FUNC_API_ALL_ARGS[API_IDX], HEADER_FILE_CONTAINED_FOLDER, enum_dict, enum_dict_pre_post, feature_name, callback_duplicate_check)\r
+                            # print("RET_TYPE ", RET_TYPE)\r
+                            get_tc_template_code = tc_code_write1(get_all_api_list, MODULE_NAME, API_NAMES[API_IDX], PRE_POST_API_LIST, PRE_POST_API_ARGS_LIST, FUNC_API_ALL_ARGS[API_IDX], HEADER_FILE_CONTAINED_FOLDER, enum_dict, enum_dict_pre_post, feature_name, callback_duplicate_check)\r
                             ## print("get_tc_template_code",get_tc_template_code)\r
                             appended_code = appended_code + "\n" + get_tc_template_code\r
                             ## print("tc_code from tct_assistance ")\r
@@ -758,7 +764,7 @@ def get_response(message):
                             #appended_negative_tc_code = appended_negative_tc_code + appended_code\r
                             # print("TARGET_API_INPUT_PARAMS_LIST",TARGET_API_INPUT_PARAMS_LIST)\r
                             if len(TARGET_API_INPUT_PARAMS_LIST) > 0:\r
-                                appended_negative_tc_code = appended_negative_tc_code + get_tc_template_code + "\n" + all_negative_tc_combined(RET_TYPE, MODULE_NAME, API_NAMES[API_IDX], PRE_POST_API_LIST, PRE_POST_API_ARGS_LIST, FUNC_API_ALL_ARGS[API_IDX], HEADER_FILE_CONTAINED_FOLDER, 10, feature_name, enum_dict, enum_dict_pre_post) + "\n"\r
+                                appended_negative_tc_code = appended_negative_tc_code + get_tc_template_code + "\n" + all_negative_tc_combined(get_all_api_list, MODULE_NAME, API_NAMES[API_IDX], PRE_POST_API_LIST, PRE_POST_API_ARGS_LIST, FUNC_API_ALL_ARGS[API_IDX], HEADER_FILE_CONTAINED_FOLDER, 10, feature_name, enum_dict, enum_dict_pre_post) + "\n"\r
                                 flag_check_negative = True\r
                                 input_params.append(len(TARGET_API_INPUT_PARAMS_LIST))\r
                                 TARGET_API_INPUT_PARAMS_LIST.clear()\r
@@ -991,6 +997,19 @@ def select_all(event):
     EntryBox.see(INSERT)\r
     return 'break'\r
 \r
+def autoscroll_to_end():\r
+    ChatLog.insert(END,"\n")\r
+    if scrollbar.get()[1]==1.0:\r
+        ChatLog.see(END)\r
+    if scrollbar.get()[0] > 0.0 and scrollbar.get()[1]!=1.0 :\r
+        ChatLog.see(END)\r
+        return\r
+    if scrollbar.get()[0] == 0.0 and scrollbar.get()[1] <= 1.0:\r
+        ChatLog.see(END)\r
+    if scrollbar.get()[0] == 1.0 and scrollbar.get()[1] != 1.0:\r
+        ChatLog.see(END)\r
+    base.after(1,autoscroll_to_end)\r
+\r
 def send(event=None):\r
     msg = EntryBox.get("1.0",'end-1c').strip()\r
     EntryBox.delete("0.0",END)\r
@@ -1008,14 +1027,17 @@ def send(event=None):
         ChatLog.tag_configure('tag-left', justify='left')\r
         ChatLog.tag_configure('tag-right', justify='right')\r
         ChatLog.insert(END, '\n')\r
-        User = Label(ChatLog,text=f"You: "+msg,background='#d0ffff', justify='left', padx=10, pady=5,font=("Malgun Gothic", 11 ),wraplength=500, cursor="hand1")\r
+        User = customtkinter.CTkLabel(ChatLog,text=f"You: "+msg, fg_color='#0066CC',corner_radius=10,text_color='white', justify='left', padx=10, pady=5,font=("Malgun Gothic", 13 ),wraplength=500, cursor="hand1")\r
         ChatLog.insert('end', '\n ','tag-right')\r
         ChatLog.window_create('end', window=User)\r
         ChatLog.insert(END, '\n')\r
         ChatLog.yview(END)\r
+        ChatLog.yview_moveto('0.0')\r
+        ChatLog.see(tk.END)\r
+        autoscroll_to_end()\r
         if msg.lower() == "exit":\r
             res = "Thanks, Goodbye !!"\r
-            User = Label(ChatLog,text="Assistant: "+res,background='#ffffd0', justify='left', padx=10, pady=5,font=("Malgun Gothic", 11 ),wraplength=500, cursor="hand1")\r
+            User = customtkinter.CTkLabel(ChatLog,text="Assistant: "+res, fg_color='#C0C0C0',corner_radius=10,text_color='black', justify='left', padx=10, pady=5,font=("Malgun Gothic", 13 ),wraplength=500, cursor="hand1")\r
             ChatLog.insert('end', '\n') # space to move Label to the right\r
             ChatLog.window_create('end', window=User)\r
             ChatLog.insert(END, '\n')\r
@@ -1036,7 +1058,7 @@ def send(event=None):
         log_info_save(logger, "Assitant", res)\r
         if res == "exit":\r
             res = "Thanks, Goodbye !!"\r
-            User = Label(ChatLog,text="Assistant: "+res,background='#ffffd0', justify='left', padx=10, pady=5,font=("Malgun Gothic", 11 ),wraplength=500, cursor="hand1")\r
+            User = customtkinter.CTkLabel(ChatLog,text="Assistant: "+res, fg_color='#C0C0C0',corner_radius=10,text_color='black', justify='left', padx=10, pady=5,font=("Malgun Gothic", 13 ),wraplength=500, cursor="hand1")\r
             ChatLog.insert('end', '\n') # space to move Label to the right\r
             ChatLog.window_create('end', window=User)\r
             ChatLog.insert(END, '\n')\r
@@ -1045,12 +1067,14 @@ def send(event=None):
             #time.sleep(2)\r
             base.after(1000,base.quit)\r
         elif msg.lower() != 'exit' and res != 'exit':\r
-            Bot = Label(ChatLog,text="Assistant: "+res,background='#ffffd0', justify='left', padx=10, pady=5,font=("Malgun Gothic", 11 ),wraplength=500, cursor="hand1")\r
+            Bot = customtkinter.CTkLabel(ChatLog,text="Assistant: "+res, fg_color='#C0C0C0',corner_radius=10,text_color='black', justify='left', padx=10, pady=5,font=("Malgun Gothic", 13 ),wraplength=500, cursor="hand1")\r
             ChatLog.insert('end', '\n') # space to move Label to the right\r
             ChatLog.window_create('end', window=Bot)\r
             ChatLog.insert(END, '\n')\r
             ChatLog.config(state=NORMAL)\r
             ChatLog.yview(END)\r
+            ChatLog.yview_moveto('0.0')\r
+            ChatLog.see(tk.END)\r
         User.bind("<Button-1>", lambda e:copy_text(msg))\r
         Bot.bind("<Button-1>", lambda e:copy_text(res))\r
 \r
@@ -1061,26 +1085,27 @@ def send(event=None):
 def helpText():\r
     # subprocess.call([opener, '/home/sri/tctapi/7.0/api/tool/TC_Assistant/HELP_TEXT.txt'])\r
     #Creates a Button to Open the Toplevel Window which opens a popup to display all the instructions\r
-    top= Toplevel(base)\r
-    top.geometry("750x820")\r
+    top= customtkinter.CTkToplevel(base)\r
+    top.geometry("700x720")\r
     top.title("Help Guide")\r
     with open('HELP_TEXT.txt', 'r') as file:\r
         data = file.read()\r
 \r
-    scroll_bar_help = Scrollbar(top)\r
-    scroll_bar_help.pack( side = RIGHT, fill = Y )\r
-    mylist = Text(top, bd=0, bg="light grey", height="50", width="30", font="Arial",wrap=WORD)\r
+    mylist = customtkinter.CTkTextbox(top, bg_color="#EBEBEB", height=720, width=30,wrap=WORD)\r
+    scroll_bar_help = customtkinter.CTkScrollbar(top,  command=mylist.yview,height=656)\r
     mylist.insert(END, data)\r
     mylist.pack(fill = BOTH )\r
-    mylist.config(state=DISABLED)\r
-    scroll_bar_help.config( command = mylist.yview )\r
+    mylist.configure(state=DISABLED)\r
     mylist['yscrollcommand'] = scroll_bar_help.set\r
 \r
 \r
 def on_closing():\r
-    if messagebox.askokcancel("Quit", "Do you want to quit?"):\r
-       ## print("TC Assistant tool is closed..Goodbye..!!")\r
-        sys.exit()\r
+    # get yes/no answers\r
+    msg = CTkMessagebox(title="Exit?", message="Do you want to close the program?",\r
+                        icon="question", option_1="No", option_2="Yes", option_3="")\r
+    response = msg.get()\r
+\r
+    if response=="Yes":\r
         base.destroy()\r
 \r
 \r
@@ -1091,46 +1116,46 @@ base.call('wm', 'iconphoto', base._w, ImageTk.PhotoImage(file=CURRENT_PATH_IMG +
 base.geometry("600x800")\r
 base.resizable(width=FALSE, height=FALSE)\r
 # base.eval('tk::PlaceWindow . center')\r
+base.grid_rowconfigure(0, weight=1)\r
+base.grid_columnconfigure(0, weight=1)\r
 center(base)\r
 \r
-ChatLog = Text(base, bd=0, bg="white", height="8", width="10", font="Arial",wrap=WORD)\r
-ChatLog.pack(fill=BOTH)\r
+ChatLog = Text(base, bd=0, relief=FLAT, bg='#d3d3d3',  highlightthickness=0, font="Arial",wrap=WORD)\r
+ChatLog.pack(fill=BOTH,  expand=True)\r
 \r
 welcomeText = "Hey, Welcome to TC Assistance System. Tell me how would you like to proceed? \n > You can add a new UTC in existing module [Type: 'existing']\n > You can add UTC in new module [Type: 'new']\n"\r
 \r
 log_info_save(logger, "Assitant", welcomeText)\r
 \r
-Bot = Label(ChatLog,text="Assistant: "+welcomeText,background='#ffffd0', justify='left', padx=10, pady=5,font=("Malgun Gothic", 11),wraplength=500, cursor="hand2")\r
+Bot = customtkinter.CTkLabel(ChatLog,text="Assistant: "+welcomeText, justify='left', fg_color='#C0C0C0',text_color='black',corner_radius=10,font=("Malgun Gothic", 13),wraplength=500, cursor="hand2")\r
 ChatLog.insert('end', '\n ')\r
 ChatLog.window_create('end', window=Bot)\r
 ChatLog.insert(END, '\n')\r
 \r
 ChatLog.config(state=DISABLED)\r
 \r
-scrollbar = Scrollbar(base, command=ChatLog.yview)\r
-ChatLog['yscrollcommand'] = scrollbar.set\r
-\r
-SendButton = Button(base, font=("Verdana", 11, 'bold'), text="Send", width="9", height=5,\r
-                    bd=5, bg="#6495ED", activebackground="#6495ED", fg='#ffffff',\r
-                    command=send, relief="raised")\r
+scrollbar = customtkinter.CTkScrollbar(base, command=ChatLog.yview,height=656, orientation = 'vertical')\r
+ChatLog.configure(yscrollcommand=scrollbar.set)\r
 \r
+my_font = customtkinter.CTkFont("Malgun Gothic", 15, weight='bold')\r
+SendButton = customtkinter.CTkButton(base, text="Send",  width=115, height=60, border_width=0,font=my_font,command=send)\r
 \r
-EntryBox = Text(base, bd=1, bg="white", width="29", height="5", font=("Malgun Gothic", 12))\r
+EntryBox = customtkinter.CTkTextbox(base, corner_radius=10, fg_color="#d3d3d3",text_color='#141414', border_width=0.5 , border_color="#343434", font=("Malgun Gothic", 15),width=455, height=70)\r
 EntryBox.focus_set()\r
 EntryBox.pack()\r
 \r
-copyrightText = Label(base,text='Copyright (c) 2023 Samsung Electronics Co., Ltd.',justify='right',padx=4,font=("Verdana",10))\r
-\r
-helpButton = Button(base,font=("Verdana",10),text='Help',width=5,height=2,bg='black',activebackground='grey',fg='white',command= helpText)\r
+copyrightText = customtkinter.CTkLabel(base,text='Copyright (c) 2023 Samsung Electronics Co., Ltd.',justify='right',padx=4)\r
 \r
+helpButton = customtkinter.CTkButton(base,text='Help',width=115,fg_color='#757575',hover_color="#343434",text_color='white',command= helpText)\r
+ChatLog.yview(END)\r
 \r
-scrollbar.place(x=576, y=22, height=656)\r
+scrollbar.place(x=576, y=22)\r
 ChatLog.place(x=6, y=22, height=656, width=570)\r
-EntryBox.place(x=6, y=680, height=80, width=455)\r
-SendButton.place(x=461, y=678, height=83)\r
+EntryBox.place(x=6, y=690)\r
+SendButton.place(x=470, y=688)\r
 copyrightText.place(x=6, y=770)\r
-helpButton.place(x=530,y=765,height=30,width=60)\r
-progress.place(width=150)\r
+helpButton.place(x=470,y=765)\r
+progress.place(width=150)\r
 progress.pack(fill=X, ipady=2)\r
 base.bind('<Return>',send)\r
 base.protocol("WM_DELETE_WINDOW", on_closing)\r
index f6669ae25b8a610885c02962d4c83c5702eec0ec..ebd8232f6fdd8242b379b8b477bfeb9773b6f114 100644 (file)
@@ -266,6 +266,7 @@ def concat_params(CURR_API, v, check_if_param_is_in_or_out_dict, inp_out_params_
     else:
         return FUNC_ARGS
 
+
 def combined_func_args(lst):
     return set(lst)
 
@@ -361,7 +362,6 @@ def tc_code_write1(RET_TYPE, MODULE_NAME, API_NAME, PRE_POST_API_LIST, PRE_POST_
 
     TARGET_API_NAME_CB = API_NAME
     callback_func_combined = ""
-    # print("aaaaaaaaaaaaca",all_callback_args)
     for cb_name in all_callback_args:
         for header_file in header_files_dict:
             #print("header_files_dict",header_files_dict)
@@ -377,35 +377,39 @@ def tc_code_write1(RET_TYPE, MODULE_NAME, API_NAME, PRE_POST_API_LIST, PRE_POST_
 
     # callback_duplicate_check = callback_duplicate_check + all_callback_args
     # print("callback_func_combined")
+    API_NAME = API_NAME.strip()
+    # print("RET_TYPE - ", RET_TYPE, "API_NAME - ", API_NAME)
+
     tc_code0 = (
-        "/**\n"
-        f"* @testcase         utc_{API_NAME}_p\n"
-        "* @since_tizen      8_0\n"
-     "* @type             Positive\n"
-        f"* @description     {api_desc}\n"
-        "* @scenario        \n"
-        "*/\n")
-    tc_code = (
-    f"{RET_TYPE} utc_{API_NAME}_p(void)\n"
-    "{\n"
-    "    int ret;\n")
-    # tc_code4 = (
-    # f"    {k};"
-    # "\n"
-    # for k in all_comb_args_set)
-    # ## print("#########")
-    # ## print(inp_out_params_list_updated)
-    ## print("all_comb_args_set from tc_code")
-    # print("inp_out_params_list_updated final",inp_out_params_list_updated)
+        "/**\n"
+        f"* @testcase         utc_{API_NAME}_p\n"
+        "* @since_tizen      8_0\n"
+        "* @type             Positive\n"
+        f"* @description     {api_desc}\n"
+        "* @scenario        \n"
+        "*/\n")
+
+
+    if RET_TYPE[API_NAME] != 'void':
+        tc_code = (
+            f"int utc_{API_NAME}_p(void)\n"
+            "{\n"
+            f"    {RET_TYPE[API_NAME]} ret;\n")
+    else:
+        tc_code = (
+            f"int utc_{API_NAME}_p(void)\n"
+            "{\n"
+            f"    int ret;\n")
+
+
     tc_code4 = iniatialize_variables(inp_out_params_list_updated, all_comb_args_set, enum_dict, enum_dict_pre_post)
     # print("tc_code_4", tc_code4)
 
     tc_code6 = callback_func_combined
-    # f"    {i}" for i in pre_apis
-    # f"{PRE_POST_API_ARGS_LIST[i]}"
+
     check_if_param_is_in_or_out_dict = init_params_in_out_dict(inp_out_params_list_updated)
     # function call to iniatialize
-    # print("inp_out_params_list_updated",inp_out_params_list_updated) 
+    # print("inp_out_params_list_updated",inp_out_params_list_updated)
     list_target_api_in_params(API_NAME, check_if_param_is_in_or_out_dict, inp_out_params_list_updated)
 
     if MODULE_NAME == "nsd":
@@ -413,42 +417,53 @@ def tc_code_write1(RET_TYPE, MODULE_NAME, API_NAME, PRE_POST_API_LIST, PRE_POST_
     if MODULE_NAME == "email":
         MODULE_NAME = "emails"
 
-    tc_code1 = (f"    ret = {i}({concat_params(i, PRE_POST_API_ARGS_LIST[i], check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n    assert_eq(ret, TIZEN_ERROR_NONE);\n\n" for i in pre_apis)
+    tc_code1 = (f"    ret = {i}({concat_params(i, PRE_POST_API_ARGS_LIST[i], check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n    assert_eq(ret, TIZEN_ERROR_NONE);\n\n" if RET_TYPE[i] != 'void' else f"    {i}({concat_params(i, PRE_POST_API_ARGS_LIST[i], check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n\n" for i in pre_apis)
+
+
     # print("tc_code1",tc_code1)
     tc_code_feature = ""
-    if feature_name != "":
-        x = feature_name.split('/')
-        length = len(x)
-        key_word = x[length - 1]
-        key_word=key_word.replace('.','_')
-
-        tc_code_feature = (f"    bool {key_word}_supported = false; \n\n"
-                           f"    ret = system_info_get_platform_bool(\"{feature_name}\", &{key_word}_supported);\n"
-                           f"    if({key_word}_supported == false)" + "{\n"
-                           f"        ret = {API_NAME}({concat_params(API_NAME, TARGET_API_ARGS, check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n"
-        f"        assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED);\n"
-        f"        return 0;\n"
-        "    }\n\n")
-
-    ## print("tc_code_feature",tc_code_feature)
-    # print("lAPI_NAME",API_NAME, "TARGET_API_ARGS",TARGET_API_ARGS, "check_if_param_is_in_or_out_dict",check_if_param_is_in_or_out_dict, "inp_out_params_list_updated",inp_out_params_list_updated, "all_callback_args",all_callback_args, "IDX_CALLBACK",IDX_CALLBACK)
-    tc_code2 = (f"    ret = {API_NAME}({concat_params(API_NAME, TARGET_API_ARGS, check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n"
-    f"    assert_eq(ret, TIZEN_ERROR_NONE);\n\n")
-    tc_code3 = (f"    ret = {j}({concat_params(j, PRE_POST_API_ARGS_LIST[j], check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n    assert_eq(ret, TIZEN_ERROR_NONE);\n\n"
-    # f"    return 0;\n"
-    # "}\n"
+    if RET_TYPE[API_NAME] != 'void':
+        if feature_name != "":
+            x = feature_name.split('/')
+            length = len(x)
+            key_word = x[length - 1]
+            key_word=key_word.replace('.','_')
+
+            tc_code_feature = (f"    bool {key_word}_supported = false; \n\n"
+                            f"    ret = system_info_get_platform_bool(\"{feature_name}\", &{key_word}_supported);\n"
+                            f"    if({key_word}_supported == false)" + "{\n"
+                            f"        ret = {API_NAME}({concat_params(API_NAME, TARGET_API_ARGS, check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n"
+                            f"        assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED);\n"
+                            f"        return 0;\n"
+                            "    }\n\n")
+
+    # print("tc_code_feature",tc_code_feature)
+
+    if RET_TYPE[API_NAME] == 'void':
+        tc_code2 = (f"    {API_NAME}({concat_params(API_NAME, TARGET_API_ARGS, check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n\n")
+
+    else:
+        tc_code2 = (f"    ret = {API_NAME}({concat_params(API_NAME, TARGET_API_ARGS, check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n    assert_eq(ret, TIZEN_ERROR_NONE);\n\n")
+
+    # print("tc_code2",tc_code2)
+
+    tc_code3 = (f"    ret = {j}({concat_params(j, PRE_POST_API_ARGS_LIST[j], check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n    assert_eq(ret, TIZEN_ERROR_NONE);\n\n" if RET_TYPE[j] != 'void' else f"    {j}({concat_params(j, PRE_POST_API_ARGS_LIST[j], check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n\n"
+
     for j in post_apis)
-    ## print("tc code 3", ''.join(tc_code3))
+
+
+
+    # print("tc code 3", ''.join(tc_code3))
     tc_code5 = (f"    return 0;\n"
     "}\n")
-    ## print("tc code 5", tc_code5)
+    # print("tc code 5", tc_code5)
     ## print("tc_code_6", tc_code6)
     ## print("checking tccode1")
     ## print(''.join(tc_code1))
     ## print("\n" + ''.join(tc_code1))
     ## print("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^66")
-    ## print("checking tc")
-    ## print(tc_code6 + "\n\n" + tc_code0 + tc_code + tc_code4 + "\n" + ''.join(tc_code1) + tc_code_feature + tc_code2 + ''.join(tc_code3) + tc_code5)
+    # print("checking tc")
+    # print("\n" + tc_code6 + "\n\n" + tc_code0 + tc_code + tc_code4 + "\n" + ''.join(tc_code1) + tc_code_feature + tc_code2 + ''.join(tc_code3) + tc_code5)
     return "\n" + tc_code6 + "\n\n" + tc_code0 + tc_code + tc_code4 + "\n" + ''.join(tc_code1) + tc_code_feature + tc_code2 + ''.join(tc_code3) + tc_code5
 
 
index 4b3c1fb61543ed5ecdf60e94947a66767619b905..236b0fb0a8fca95c333b88c1e29b6e9c6f59c0e3 100644 (file)
@@ -26,7 +26,7 @@ def check_if_str_or_int(inp_string):
         return "NULL"
     else:
         return "None"
-    
+
 #NULL in case of handle, -1 for int or float or double
 def check_if_str_or_int_neg(list_of_all_params_with_retval, inp_string):
     for val in list_of_all_params_with_retval:
@@ -47,7 +47,7 @@ def iniatialize_variables(inp_out_params_list_updated, all_comb_args_set, enum_d
     for pos, ele in enumerate(all_comb_args_set):
         if ele.find("_cb")>0:
             all_comb_args_set[pos] =""
-        elif ele.split()[-1] in check_if_param_is_in_or_out_dict: 
+        elif ele.split()[-1] in check_if_param_is_in_or_out_dict:
             dict_value = check_if_param_is_in_or_out_dict[ele.split()[-1]]
             ele1 = ele
             if dict_value == "in" and "char" in ele:
@@ -85,12 +85,12 @@ def iniatialize_variables(inp_out_params_list_updated, all_comb_args_set, enum_d
             all_comb_args_set.remove(all_comb_args_set[pos])
             # break
         store_last_word_of_args.append(ele.split()[-1])
-    ## print("iniatialized variables 2")      
+    ## print("iniatialized variables 2")
 
     for i in all_comb_args_set:
         if i == 'void' or i == 'void;' or i == '' or i == ' ' or i == ';':
             all_comb_args_set.remove(i)
-    
+
     for pos, i in enumerate(all_comb_args_set):
         # print("reached till here tc_code4 part 0")
         # print(all_comb_args_set)
@@ -104,7 +104,7 @@ def iniatialize_variables(inp_out_params_list_updated, all_comb_args_set, enum_d
         flag = 0
         flag_pre_post = 0
 
-        # print("reached till here tc_code4 part 1",enum_dict)    
+        # print("reached till here tc_code4 part 1",enum_dict)
         for ele, val in enum_dict.items():
             # print("entered", ele, val)
             for ele1, val1 in val.items():
@@ -117,7 +117,7 @@ def iniatialize_variables(inp_out_params_list_updated, all_comb_args_set, enum_d
                     flag = 1
                     break
             if flag == 1:
-                break 
+                break
         # print("reached till here tc_code4 part 2",enum_dict_pre_post)
         if "=" not in all_comb_args_set[pos]:
             for ele, val in enum_dict_pre_post.items():
@@ -132,7 +132,7 @@ def iniatialize_variables(inp_out_params_list_updated, all_comb_args_set, enum_d
                         flag = 1
                         break
                 if flag == 1:
-                    break 
+                    break
         # print("reached till here tc_code4 part 3")
         # print("all arguments sequential ", i)
         if i == "void" or i == "void;" or i == "" or i == " ":
@@ -143,7 +143,7 @@ def iniatialize_variables(inp_out_params_list_updated, all_comb_args_set, enum_d
     f"    {k};"
     "\n"
     for k in all_comb_args_set)
-    
+
     # print(tc_code4)
     return ''.join(tc_code4)
 
@@ -163,7 +163,7 @@ def concat_params(CURR_API, v, check_if_param_is_in_or_out_dict, inp_out_params_
     # print("COMBINED_API_ARGS_DICT_CB", COMBINED_API_ARGS_DICT_CB)
     for j in range(0, len(v)):
         if (v[j].split()[-1]).replace('*', '') in check_if_param_is_in_or_out_dict:
-            
+
            for ij in inp_out_params_list_updated[CURR_API]:
                 key = list(ij.keys())[0]
                 value = ij[key]
@@ -247,7 +247,7 @@ def concat_params_target(CURR_API, v, check_if_param_is_in_or_out_dict, inp_out_
     else:
         return FUNC_ARGS
 
-def combined_func_args(lst): 
+def combined_func_args(lst):
     return set(lst)
 
 def init_params_in_out_dict(inp_out_params_list_updated):
@@ -266,7 +266,7 @@ def calc_count_of_in_params(API_NAME, inp_out_params_list_updated):
         in_out_array = inp_out_params_list_updated[API_NAME]
     else:
         in_out_array = []
-        
+
     for ele in in_out_array:
         key = list(ele.keys())[0]
         val = ele[key]
@@ -329,7 +329,7 @@ def tc_code_write_negative(RET_TYPE, MODULE_NAME, API_NAME, PRE_POST_API_LIST, P
         if "_cb" in ele:
             all_callback_args.append(ele.split(" ")[0])
 
-    
+
     header_files_dict = get_header_files(MODULE_NAME)
     # for ever file in the dictionary we have to check if all the api names provided by the user exists or not
     # we will take api names one by one and check in all the files if it exists or not
@@ -339,7 +339,7 @@ def tc_code_write_negative(RET_TYPE, MODULE_NAME, API_NAME, PRE_POST_API_LIST, P
     for API_SEARCH in post_apis:
         for HEADER_FILE_NAME in header_files_dict:
             inp_out_params_list_updated = input_output_params_extract(MODULE_NAME, HEADER_FILE_NAME, API_SEARCH, inp_out_params_list_updated)
-    for HEADER_FILE_NAME in header_files_dict:    
+    for HEADER_FILE_NAME in header_files_dict:
         inp_out_params_list_updated = input_output_params_extract(MODULE_NAME, HEADER_FILE_NAME, API_NAME, inp_out_params_list_updated)
     api_desc = api_description_extract(MODULE_NAME, HEADER_FILE_NAME, API_NAME)
 
@@ -374,17 +374,30 @@ def tc_code_write_negative(RET_TYPE, MODULE_NAME, API_NAME, PRE_POST_API_LIST, P
         "* @scenario        \n"
         "*/\n")
 
-    if INPUT_PARAMETERS_COUNT > 1:
-        tc_code = (
-        f"{RET_TYPE} utc_{API_NAME}_n{NEGATIVE_TC_COUNT}(void)\n"
-        "{\n"
-        "    int ret;\n")
+
+    if RET_TYPE[API_NAME] == 'void':
+        if INPUT_PARAMETERS_COUNT > 1:
+            tc_code = (
+            f"int utc_{API_NAME}_n{NEGATIVE_TC_COUNT}(void)\n"
+            "{\n"
+            f"    int ret;\n")
+        else:
+            tc_code = (
+            f"int utc_{API_NAME}_n(void)\n"
+            "{\n"
+            f"    int ret;\n")
     else:
-        tc_code = (
-        f"{RET_TYPE} utc_{API_NAME}_n(void)\n"
-        "{\n"
-        "    int ret;\n")
-    
+        if INPUT_PARAMETERS_COUNT > 1:
+            tc_code = (
+            f"int utc_{API_NAME}_n{NEGATIVE_TC_COUNT}(void)\n"
+            "{\n"
+            f"    {RET_TYPE[API_NAME]} ret;\n")
+        else:
+            tc_code = (
+            f"int utc_{API_NAME}_n(void)\n"
+            "{\n"
+            f"    {RET_TYPE[API_NAME]} ret;\n")
+
     tc_code4 = iniatialize_variables(inp_out_params_list_updated, all_comb_args_set, enum_dict, enum_dict_pre_post)
 
 
@@ -393,8 +406,10 @@ def tc_code_write_negative(RET_TYPE, MODULE_NAME, API_NAME, PRE_POST_API_LIST, P
     if MODULE_NAME == "email":
         MODULE_NAME = "emails"
 
-    tc_code1 = (f"    ret = {i}({concat_params(i, PRE_POST_API_ARGS_LIST[i], check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n    assert_eq(ret, TIZEN_ERROR_NONE);\n\n" for i in pre_apis)
-    
+
+    tc_code1 = (f"    ret = {i}({concat_params(i, PRE_POST_API_ARGS_LIST[i], check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n    assert_eq(ret, TIZEN_ERROR_NONE);\n\n" if RET_TYPE[i] != 'void' else f"    {i}({concat_params(i, PRE_POST_API_ARGS_LIST[i], check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n\n" for i in pre_apis)
+
+
     # add invalid parameters to negative tc target api
     for HEADER_FILE_NAME in header_files_dict:
         RETVAL_INVALID_PARAMETERS = get_retval_of_invalid_params(MODULE_NAME, HEADER_FILE_NAME, API_NAME)
@@ -402,26 +417,33 @@ def tc_code_write_negative(RET_TYPE, MODULE_NAME, API_NAME, PRE_POST_API_LIST, P
             break
 
     tc_code_feature = ""
-    if feature_name != "":
-        x = feature_name.split('/')
-        length = len(x)
-        key_word = x[length - 1]
-        key_word=key_word.replace('.','_')
-
-        tc_code_feature = (f"    bool {key_word}_supported = false; \n\n"
-                           f"    ret = system_info_get_platform_bool(\"{feature_name}\", &{key_word}_supported);\n"
-                           f"    if({key_word}_supported == false)" + "{\n"
-                           f"        ret = {API_NAME}({concat_params_target(API_NAME, FUNC_ARGS, check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK, INPUT_PARAMETER_MARKED_NULL, all_comb_args_set,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n"
-        f"        assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED);\n"
-        f"        return 0;\n"
-        "    }\n\n")
-    tc_code2 = (f"    ret = {API_NAME}({concat_params_target(API_NAME, FUNC_ARGS, check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK, INPUT_PARAMETER_MARKED_NULL, all_comb_args_set,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n"
-    f"    assert_eq(ret, {RETVAL_INVALID_PARAMETERS});\n\n")
-
-    tc_code3 = (f"    ret = {j}({concat_params(j, PRE_POST_API_ARGS_LIST[j], check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n    assert_eq(ret, TIZEN_ERROR_NONE);\n\n"
+    if RET_TYPE[API_NAME] != 'void':
+        if feature_name != "":
+            x = feature_name.split('/')
+            length = len(x)
+            key_word = x[length - 1]
+            key_word=key_word.replace('.','_')
+
+            tc_code_feature = (f"    bool {key_word}_supported = false; \n\n"
+                            f"    ret = system_info_get_platform_bool(\"{feature_name}\", &{key_word}_supported);\n"
+                            f"    if({key_word}_supported == false)" + "{\n"
+                            f"        ret = {API_NAME}({concat_params_target(API_NAME, FUNC_ARGS, check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK, INPUT_PARAMETER_MARKED_NULL, all_comb_args_set,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n"
+            f"        assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED);\n"
+            f"        return 0;\n"
+            "    }\n\n")
+
+    if RET_TYPE[API_NAME] == 'void':
+        tc_code2 = (f"    {API_NAME}({concat_params_target(API_NAME, FUNC_ARGS, check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK, INPUT_PARAMETER_MARKED_NULL, all_comb_args_set,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n\n")
+    else:
+        tc_code2 = (f"    ret = {API_NAME}({concat_params_target(API_NAME, FUNC_ARGS, check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK, INPUT_PARAMETER_MARKED_NULL, all_comb_args_set,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n"
+        f"    assert_eq(ret, {RETVAL_INVALID_PARAMETERS});\n\n")
+
+
+    tc_code3 = (f"    ret = {j}({concat_params(j, PRE_POST_API_ARGS_LIST[j], check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n    assert_eq(ret, TIZEN_ERROR_NONE);\n\n" if RET_TYPE[j] != 'void' else f"    {j}({concat_params(j, PRE_POST_API_ARGS_LIST[j], check_if_param_is_in_or_out_dict, inp_out_params_list_updated, all_callback_args, IDX_CALLBACK,  PRE_POST_API_ARGS_LIST, TARGET_API_ARGS, TARGET_API_NAME_CB)});\n\n"
 
     for j in post_apis)
 
+
     tc_code5 = (f"    return 0;\n"
     "}\n")
 
@@ -444,7 +466,7 @@ def all_negative_tc_combined(RET_TYPE, MODULE_NAME, API_NAME, PRE_POST_API_LIST,
             get_no_of_negative_tc_count(INPUT_PARAMETERS_COUNT)
             break
     flag = 0
-        
+
     return negative_tc_code
 
 
index d11435b74ef993d35114daae86eeb6d40bb1ef24..68270232d26795aa3071fdcad34cb7f7046f603b 100644 (file)
@@ -30,7 +30,8 @@ def check_api_in_module(HEADER_FILE_NAME, API_SEARCH):
     with open(DIR + "//"  + HEADER_FILE_NAME,"r") as file_one:\r
         updated_line_multiple=''\r
         for line_no, line in enumerate(file_one):\r
-            if line.find("int" + " " + API_SEARCH + "(") != -1:\r
+            line = line.strip()\r
+            if (line.find(API_SEARCH + "(") != -1 or line.find(API_SEARCH + " (") != -1) and line[:1] != '*':\r
                 found_api = True\r
                 updated_line  = line.strip()\r
 \r