1import os 2import sys 3import time 4import test_utils 5import test_constants 6import logging 7 8all_widgets_execute_output_files = [ 9"all_widgets_execute_resources.c", 10"all_widgets_execute_resources.h", 11"all_widgets_execute_specifications.c", 12"all_widgets_execute_specifications.h" 13] 14 15def get_test_header(): 16 17 notes = "* Studio Trigger Edit Tests *\n" 18 notes += "* *\n" 19 notes += "* Test trigger add/edit/edit *\n" 20 notes += "* Test empty screen flow check when flow count is 0 *\n" 21 return notes 22 23def run_trigger_merge(): 24 # open screen flow edit dialog 25 test_utils.configure_screen_flow() 26 27 # open trigger list edit dialog 28 test_utils.edit_trigger_list('popup_modal') 29 30 #-----------------------------------------------------# 31 # Add trigger # 32 #-----------------------------------------------------# 33 test_utils.add_trigger() 34 test_utils.set_trigger_type('TRIGGER_TYPE_CHILD_SIGNAL') 35 event_type = '(IDB_OK, GX_EVENT_FOCUS_GAINED)' 36 test_utils.set_event_type(event_type) 37 test_utils.save_trigger_edit_dialog() 38 39 #-----------------------------------------------------# 40 # Edit action # 41 #-----------------------------------------------------# 42 test_utils.select_trigger_list_row(2) 43 test_utils.edit_action('gx_signal'+ event_type.lower()) 44 test_utils.add_action('Window Execute Stop') 45 test_utils.select_target('popup_modal') 46 test_utils.save_trigger_action_edit_dialog() 47 48 #-----------------------------------------------------# 49 # Edit trigger # 50 #-----------------------------------------------------# 51 test_utils.edit_trigger() 52 test_utils.set_event_type('(IDB_OK, GX_EVENT_CLICKED)') 53 test_utils.save_trigger_edit_dialog(test_utils.CLOSE_NO_WAIT)# duplicate trigger exist, ask user if they want to do merging 54 test_utils.click_yes_to_please_confirm_dialog()# click yes to merge dupliate triggers 55 56 # wait trigger edit dialog close 57 test_utils.wait_dialog_close(test_utils.TRIGGER_EDIT_DIALOG) 58 59 test_utils.select_trigger_list_row(0) 60 test_utils.edit_trigger() 61 test_utils.set_event_type('(IDB_CANCEL, GX_EVENT_CLICKED)') 62 test_utils.save_trigger_edit_dialog(test_utils.CLOSE_NO_WAIT)# duplicate trigger exist, ask user if they want to do merging 63 test_utils.click_yes_to_please_confirm_dialog()# click yes to merge dupliate triggers 64 65 # wait trigger edit dialog close 66 test_utils.wait_dialog_close(test_utils.TRIGGER_EDIT_DIALOG) 67 68 # save trigger list edit dialog 69 test_utils.save_trigger_list_edit_dialog() 70 71 # save screen flow edit dialog 72 test_utils.save_screen_flow_edit_dialog() 73 74def run_trigger_delete(): 75 # open screen flow edit dialog 76 test_utils.configure_screen_flow() 77 78 # open trigger list edit dialog 79 test_utils.edit_trigger_list('menu_screen') 80 81 test_utils.delete_trigger() 82 83 test_utils.save_trigger_list_edit_dialog() 84 85 test_utils.save_screen_flow_edit_dialog() 86 87def run_trigger_edit(): 88 # open screen flow edit dialog 89 test_utils.configure_screen_flow() 90 91 # open trigger list edit dialog 92 test_utils.edit_trigger_list('menu_screen') 93 94 #-----------------------------------------------------# 95 # Add trigger # 96 #-----------------------------------------------------# 97 test_utils.add_trigger() 98 test_utils.set_trigger_type('TRIGGER_TYPE_CHILD_SIGNAL') 99 event_type = '(IDB_NEXT, GX_EVENT_CLICKED)' 100 test_utils.set_event_type(event_type) 101 test_utils.save_trigger_edit_dialog() 102 103 #-----------------------------------------------------# 104 # Edit action # 105 #-----------------------------------------------------# 106 test_utils.edit_action('gx_signal' + event_type.lower()) 107 test_utils.add_action('Animation') 108 test_utils.select_target('menu_screen') 109 test_utils.check_target_show_child_widgets(1) 110 test_utils.select_target('text_view') 111 112 # set animation parameters 113 test_utils.edit_action_name("menu_screen_fade_out") 114 test_utils.edit_animation_info('ANIMATION_ID', 'ANIMATION_ID_MENU_SCREEN_FADE_OUT') 115 test_utils.edit_animation_info('ANIMATION_START_X', '-5') 116 test_utils.edit_animation_info('ANIMATION_START_X', '5') 117 test_utils.edit_animation_info('ANIMATION_START_Y', '-5') 118 test_utils.edit_animation_info('ANIMATION_START_Y', '5') 119 test_utils.edit_animation_info('ANIMATION_END_X', '-200') 120 test_utils.edit_animation_info('ANIMATION_END_X', '200') 121 test_utils.edit_animation_info('ANIMATION_END_Y', '-50') 122 test_utils.edit_animation_info('ANIMATION_END_Y', '50') 123 test_utils.edit_animation_info('ANIMATION_STEPS', '20') 124 test_utils.edit_animation_info('ANIMATION_TICK_RATE', '2') 125 test_utils.edit_animation_info('ANIMATION_DELAY_BEFORE', '1') 126 test_utils.edit_animation_info('ANIMATION_START_ALPHA', '200') 127 test_utils.edit_animation_info('ANIMATION_END_ALPHA', '10') 128 test_utils.check_detach_target(1) 129 130 # set easing function 131 test_utils.configure_easing_function() 132 test_utils.select_easing_function('sine ease in') 133 test_utils.save_easing_function_select_dialog() 134 135 test_utils.add_action('Animation') 136 test_utils.delete_action() 137 test_utils.save_trigger_action_edit_dialog() 138 139 #-----------------------------------------------------# 140 # Add trigger # 141 #-----------------------------------------------------# 142 test_utils.add_trigger() 143 test_utils.set_trigger_type('TRIGGER_TYPE_SYSTEM_EVENT') 144 event_type = 'GX_EVENT_PEN_DOWN' 145 test_utils.set_event_type(event_type) 146 test_utils.save_trigger_edit_dialog() 147 148 #-----------------------------------------------------# 149 # Edit action # 150 #-----------------------------------------------------# 151 test_utils.select_trigger_list_row(1) 152 test_utils.edit_action(event_type.lower()) 153 test_utils.add_action('Detach') 154 test_utils.check_target_show_child_widgets(1) 155 test_utils.select_target('title_4') 156 test_utils.save_trigger_action_edit_dialog() 157 158 #-----------------------------------------------------# 159 # Add trigger # 160 #-----------------------------------------------------# 161 test_utils.add_trigger() 162 test_utils.set_trigger_type('TRIGGER_TYPE_USER_EVENT') 163 event_type = 'USER_EVENT_ID' 164 test_utils.set_event_type(event_type) 165 test_utils.save_trigger_edit_dialog() 166 167 #-----------------------------------------------------# 168 # Edit action # 169 #-----------------------------------------------------# 170 test_utils.select_trigger_list_row(2) 171 test_utils.edit_action(event_type.lower()) 172 test_utils.add_action('Detach') 173 test_utils.check_target_show_child_widgets(1) 174 test_utils.select_target('title_4') 175 test_utils.save_trigger_action_edit_dialog() 176 177 #edit system event trigger 178 test_utils.select_trigger_list_row(1) 179 test_utils.edit_trigger() 180 test_utils.save_trigger_edit_dialog() 181 182 #edit user event trigger 183 test_utils.select_trigger_list_row(2) 184 test_utils.edit_trigger() 185 test_utils.save_trigger_edit_dialog() 186 187 # save trigger list edit dialog 188 test_utils.save_trigger_list_edit_dialog() 189 190 # save screen flow edit dialog 191 test_utils.save_screen_flow_edit_dialog() 192 193def run_notify_message_test(): 194 195 test_utils.select_project_tree_node('test_button_window') 196 test_utils.delete_widget() 197 198 #delete a widget whose id name is referenced by a trigger 199 test_utils.select_project_tree_node('next_button') 200 test_utils.post_delete_widget() 201 #a confirm dialog will show up, id name IDB_NEXT is referenced by a trigger, 202 #remove the id name will invalid the trigger, continue? 203 204 #cancel delete 205 test_utils.click_no_to_please_confirm_dialog() 206 test_utils.compare_result() 207 208 #delete next button 209 test_utils.select_project_tree_node('next_button') 210 test_utils.post_delete_widget() 211 test_utils.click_yes_to_please_confirm_dialog() 212 213 #wait next button been deleted 214 while test_utils.select_project_tree_node('next_button'): 215 time.sleep(1) 216 217 test_utils.compare_result() 218 219 #change widget id name that is referenced by a trigger 220 test_utils.select_project_tree_node('text_button_1') 221 test_utils.edit_widget_props('ID_WIDGET_ID', 'ID_TEXT_BUTTON_test') 222 test_utils.edit_widget_props_post('ID_WIDGET_ID', '') 223 test_utils.click_no_to_please_confirm_dialog() 224 225 #delete a top level widget 226 test_utils.select_project_tree_node('gauge_screen') 227 test_utils.post_delete_widget() 228 test_utils.click_no_to_please_confirm_dialog() 229 230 #delete a folder 231 test_utils.select_project_tree_node('default_folder') 232 test_utils.post_delete_folder() 233 test_utils.click_no_to_please_confirm_dialog() 234 235def run_animation_id_add_remove(): 236 #--------------------------------------------------------------------------------------------# 237 # Test if animation ID is added to dictionay when cancel screen flow edit dialog # 238 #--------------------------------------------------------------------------------------------# 239 test_utils.configure_screen_flow() 240 test_utils.edit_trigger_list('sprite_screen') 241 242 #-----------------------------------------------------# 243 # Add trigger # 244 #-----------------------------------------------------# 245 test_utils.add_trigger() 246 test_utils.set_trigger_type('TRIGGER_TYPE_SYSTEM_EVENT') 247 event_type = 'GX_EVENT_PEN_DOWN' 248 test_utils.set_event_type(event_type) 249 test_utils.save_trigger_edit_dialog() 250 251 #-----------------------------------------------------# 252 # Edit action # 253 #-----------------------------------------------------# 254 # add 2 animation 255 test_utils.select_trigger_list_row(1) 256 test_utils.edit_action(event_type.lower()) 257 test_utils.add_action('Animation') 258 test_utils.edit_action_name("animation_0") 259 test_utils.edit_animation_info('ANIMATION_ID', 'TEST_ANIMATION_ID_0') 260 test_utils.save_trigger_action_edit_dialog() 261 262 test_utils.save_trigger_list_edit_dialog() 263 test_utils.cancel_screen_flow_edit_dialog() 264 265 #--------------------------------------------------------------------------------------------# 266 # Test if animation ID is removed from dictionary when animation is delete # 267 # Test if animation ID is removed from dictionary when trigger is delete # 268 #--------------------------------------------------------------------------------------------# 269 270 # open screen flow edit dialog 271 test_utils.configure_screen_flow() 272 273 # open trigger list edit dialog 274 test_utils.edit_trigger_list('text_screen') 275 276 #-----------------------------------------------------# 277 # Add trigger # 278 #-----------------------------------------------------# 279 test_utils.add_trigger() 280 test_utils.set_trigger_type('TRIGGER_TYPE_SYSTEM_EVENT') 281 event_type = 'GX_EVENT_PEN_DOWN' 282 test_utils.set_event_type(event_type) 283 test_utils.save_trigger_edit_dialog() 284 285 #-----------------------------------------------------# 286 # Edit action # 287 #-----------------------------------------------------# 288 # add 2 animation 289 test_utils.select_trigger_list_row(1) 290 test_utils.edit_action(event_type) 291 test_utils.add_action('Animation') 292 test_utils.edit_action_name("animation_1") 293 test_utils.edit_animation_info('ANIMATION_ID', 'TEST_ANIMATION_ID_1') 294 test_utils.add_action('Animation') 295 test_utils.edit_action_name("animation_2") 296 test_utils.edit_animation_info('ANIMATION_ID', 'TEST_ANIMATION_ID_2') 297 298 # delete aniamtion_1 299 test_utils.select_action("animation_1") 300 test_utils.delete_action() 301 test_utils.save_trigger_action_edit_dialog() 302 303 #-----------------------------------------------------# 304 # Add trigger # 305 #-----------------------------------------------------# 306 test_utils.add_trigger() 307 test_utils.set_trigger_type('TRIGGER_TYPE_SYSTEM_EVENT') 308 event_type = 'GX_EVENT_PEN_UP' 309 test_utils.set_event_type(event_type) 310 test_utils.save_trigger_edit_dialog() 311 312 #-----------------------------------------------------# 313 # Edit action # 314 #-----------------------------------------------------# 315 # add 1 animation 316 test_utils.select_trigger_list_row(2) 317 test_utils.edit_action(event_type.lower()) 318 test_utils.add_action('Animation') 319 test_utils.edit_action_name("animation_3") 320 test_utils.edit_animation_info('ANIMATION_ID', 'TEST_ANIMATION_ID_3') 321 test_utils.save_trigger_action_edit_dialog() 322 323 # delete the added trigger 324 test_utils.select_trigger_list_row(2) 325 test_utils.delete_trigger() 326 327 test_utils.save_trigger_list_edit_dialog() 328 329 #--------------------------------------------------------------------------------------------# 330 # Test if animation ID is removed from dictionay when flow item is delete # 331 #--------------------------------------------------------------------------------------------# 332 test_utils.edit_trigger_list('gauge_screen') 333 334 #-----------------------------------------------------# 335 # Add trigger # 336 #-----------------------------------------------------# 337 test_utils.add_trigger() 338 test_utils.set_trigger_type('TRIGGER_TYPE_SYSTEM_EVENT') 339 event_type = 'GX_EVENT_PEN_DOWN' 340 test_utils.set_event_type(event_type) 341 test_utils.save_trigger_edit_dialog() 342 343 #-----------------------------------------------------# 344 # Edit action # 345 #-----------------------------------------------------# 346 # add 1 animation 347 test_utils.select_trigger_list_row(1) 348 test_utils.edit_action(event_type.lower()) 349 test_utils.add_action('Animation') 350 test_utils.edit_action_name("animation_4") 351 test_utils.edit_animation_info('ANIMATION_ID', 'TEST_ANIMATION_ID_4') 352 353 test_utils.save_trigger_action_edit_dialog() 354 test_utils.save_trigger_list_edit_dialog() 355 test_utils.save_screen_flow_edit_dialog() 356 357 test_utils.select_project_tree_node('gauge_screen') 358 test_utils.post_delete_widget() 359 test_utils.click_yes_to_please_confirm_dialog() 360 361 #--------------------------------------------------------------------------------------------# 362 # Test if animation ID is added to dictionay when cancel trigger edit dialog # 363 #--------------------------------------------------------------------------------------------# 364 test_utils.configure_screen_flow() 365 test_utils.edit_trigger_list('text_screen') 366 367 #-----------------------------------------------------# 368 # Add trigger # 369 #-----------------------------------------------------# 370 test_utils.add_trigger() 371 test_utils.set_trigger_type('TRIGGER_TYPE_SYSTEM_EVENT') 372 event_type = 'GX_EVENT_PEN_UP' 373 test_utils.set_event_type(event_type) 374 test_utils.save_trigger_edit_dialog() 375 376 #-----------------------------------------------------# 377 # Edit action # 378 #-----------------------------------------------------# 379 # add 2 animation 380 test_utils.select_trigger_list_row(1) 381 test_utils.edit_action(event_type) 382 test_utils.add_action('Animation') 383 test_utils.edit_action_name("animation_5") 384 test_utils.edit_animation_info('ANIMATION_ID', 'TEST_ANIMATION_ID_5') 385 386 test_utils.add_action('Animation') 387 test_utils.edit_action_name("animation_6") 388 test_utils.edit_animation_info('ANIMATION_ID', 'TEST_ANIMATION_ID_6') 389 390 test_utils.cancel_trigger_action_edit_dialog() 391 test_utils.select_trigger_list_row(1) 392 test_utils.delete_trigger() 393 test_utils.save_trigger_list_edit_dialog() 394 test_utils.save_screen_flow_edit_dialog() 395 396 397 #--------------------------------------------------------------------------------------------# 398 # Test if animation ID is added to dictionay when cancel trigger list edit dialog # 399 #--------------------------------------------------------------------------------------------# 400 test_utils.configure_screen_flow() 401 test_utils.edit_trigger_list('text_screen') 402 403 #-----------------------------------------------------# 404 # Add trigger # 405 #-----------------------------------------------------# 406 test_utils.add_trigger() 407 test_utils.set_trigger_type('TRIGGER_TYPE_SYSTEM_EVENT') 408 event_type = 'GX_EVENT_HIDE' 409 test_utils.set_event_type(event_type) 410 test_utils.save_trigger_edit_dialog() 411 412 #-----------------------------------------------------# 413 # Edit action # 414 #-----------------------------------------------------# 415 # add 2 animation 416 test_utils.select_trigger_list_row(1) 417 test_utils.edit_action(event_type.lower()) 418 test_utils.add_action('Animation') 419 test_utils.edit_action_name("animation_7") 420 test_utils.edit_animation_info('ANIMATION_ID', 'TEST_ANIMATION_ID_7') 421 422 test_utils.save_trigger_action_edit_dialog() 423 test_utils.cancel_trigger_list_edit_dialog() 424 test_utils.save_screen_flow_edit_dialog() 425 426 #--------------------------------------------------------------------------------------------# 427 # Test if animation ID is removed from dictionay when rename animation id name # 428 #--------------------------------------------------------------------------------------------# 429 test_utils.configure_screen_flow() 430 test_utils.edit_trigger_list('sprite_screen') 431 432 #-----------------------------------------------------# 433 # Add trigger # 434 #-----------------------------------------------------# 435 test_utils.add_trigger() 436 test_utils.set_trigger_type('TRIGGER_TYPE_SYSTEM_EVENT') 437 event_type = 'GX_EVENT_PEN_DOWN' 438 test_utils.set_event_type(event_type) 439 test_utils.save_trigger_edit_dialog() 440 441 #-----------------------------------------------------# 442 # Edit action # 443 #-----------------------------------------------------# 444 # add 2 animation 445 test_utils.select_trigger_list_row(1) 446 test_utils.edit_action(event_type.lower()) 447 test_utils.add_action('Animation') 448 test_utils.edit_action_name("animation_8") 449 test_utils.edit_animation_info('ANIMATION_ID', 'TEST_ANIMATION_ID_8') 450 451 test_utils.add_action('Animation') 452 test_utils.edit_action_name("animation_9") 453 test_utils.edit_animation_info('ANIMATION_ID', 'TEST_ANIMATION_ID_9') 454 455 test_utils.select_action('animation_8') 456 test_utils.edit_animation_info('ANIMATION_ID', 'TEST_ANIMATION_ID_10') 457 458 test_utils.save_trigger_action_edit_dialog() 459 test_utils.save_trigger_list_edit_dialog() 460 test_utils.save_screen_flow_edit_dialog() 461 462 #--------------------------------------------------------------------------------------------# 463 # Test remove animation id name # 464 #--------------------------------------------------------------------------------------------# 465 test_utils.configure_screen_flow() 466 test_utils.edit_trigger_list('sprite_screen') 467 468 #-----------------------------------------------------# 469 # Add trigger # 470 #-----------------------------------------------------# 471 test_utils.add_trigger() 472 test_utils.set_trigger_type('TRIGGER_TYPE_SYSTEM_EVENT') 473 event_type = 'GX_EVENT_KEY_DOWN' 474 test_utils.set_event_type(event_type) 475 test_utils.save_trigger_edit_dialog() 476 477 #-----------------------------------------------------# 478 # Edit action # 479 #-----------------------------------------------------# 480 # add 2 animation 481 test_utils.select_trigger_list_row(2) 482 test_utils.edit_action(event_type.lower()) 483 test_utils.add_action('Animation') 484 test_utils.edit_action_name("animation_11") 485 test_utils.edit_animation_info('ANIMATION_ID', 'TEST_ANIMATION_ID_11') 486 487 test_utils.add_action('Animation') 488 test_utils.edit_action_name("animation_12") 489 test_utils.edit_animation_info('ANIMATION_ID', 'TEST_ANIMATION_ID_12') 490 491 test_utils.select_action('animation_11') 492 test_utils.edit_animation_info('ANIMATION_ID', '') 493 494 test_utils.save_trigger_action_edit_dialog() 495 test_utils.save_trigger_list_edit_dialog() 496 test_utils.save_screen_flow_edit_dialog() 497 498def run_check_empty_screen_flow_test(): 499 test_utils.open_project('all_widgets_execute.gxp') 500 501 # delete all top level widget 502 test_utils.select_project_tree_node('button_screen') 503 test_utils.post_delete_widget() 504 test_utils.click_yes_to_please_confirm_dialog() 505 506 test_utils.select_project_tree_node('gauge_screen') 507 test_utils.post_delete_widget() 508 test_utils.click_yes_to_please_confirm_dialog() 509 510 test_utils.select_project_tree_node('indicator_screen') 511 test_utils.post_delete_widget() 512 test_utils.click_yes_to_please_confirm_dialog() 513 514 test_utils.select_project_tree_node('menu_screen') 515 test_utils.post_delete_widget() 516 test_utils.click_yes_to_please_confirm_dialog() 517 518 test_utils.select_project_tree_node('popup_modal') 519 test_utils.post_delete_widget() 520 test_utils.click_yes_to_please_confirm_dialog() 521 522 test_utils.select_project_tree_node('scroll_wheel_screen') 523 test_utils.post_delete_widget() 524 test_utils.click_yes_to_please_confirm_dialog() 525 526 test_utils.select_project_tree_node('sprite_screen') 527 test_utils.post_delete_widget() 528 test_utils.click_yes_to_please_confirm_dialog() 529 530 test_utils.select_project_tree_node('text_screen') 531 test_utils.post_delete_widget() 532 test_utils.click_yes_to_please_confirm_dialog() 533 534 test_utils.select_project_tree_node('window_screen') 535 test_utils.post_delete_widget() 536 test_utils.click_yes_to_please_confirm_dialog() 537 test_utils.compare_result() 538 539 # generate all resources 540 test_utils.generate_all() 541 test_utils.click_generate_button() 542 543def run_trigger_edit_tests(generate, screenshot): 544 545 test_utils.output_test_header(get_test_header()) 546 test_utils.setup(generate, screenshot, 'test_trigger_edit_golden_file') 547 548 # open test project 549 test_utils.open_project('all_widgets_execute.gxp') 550 551 print("run trigger merge") 552 run_trigger_merge() 553 554 print("run trigger delete") 555 run_trigger_delete() 556 557 print("run trigger edit") 558 run_trigger_edit() 559 560 print("run notify message test") 561 run_notify_message_test() 562 563 print("run animation id add remove test") 564 run_animation_id_add_remove() 565 566 # test output files 567 test_utils.generate_all() 568 test_utils.click_generate_button() 569 test_utils.cmp_output_files(all_widgets_execute_output_files) 570 571 print("run check empty screen flow test") 572 run_check_empty_screen_flow_test() 573 574 test_utils.write_end("Test Trigger Edit") 575 576 577