1# -*- coding: utf-8 -*- 2import os 3import sys 4import time 5import test_utils 6import test_constants 7import filecmp 8 9display_name = "main_display" 10folder_name = "default_folder" 11screen_name = "main_screen" 12 13test_generic_scroll_wheel_output_files = [ 14"test_generic_scroll_wheel_specifications.c", 15"test_generic_scroll_wheel_specifications.h"] 16 17def get_test_header(): 18 notes = "* Generic Scroll Wheel Test *\n" 19 notes += "* *\n" 20 notes += "* Add and Edit Generic Scroll Wheel *\n" 21 return notes 22 23def run_new_project_create(project_name): 24 25 # create a new project 26 test_utils.toolbar_create() 27 test_utils.set_new_project_path(test_utils.DEFAULT_OUTPUT_FILE_PATH) 28 test_utils.set_new_project_name(project_name) 29 test_utils.save_new_project_create() 30 31 # configure project 32 test_utils.configure_project() 33 test_utils.configure_x_res(640) 34 test_utils.configure_y_res(480) 35 test_utils.configure_minor_version(1) 36 test_utils.configure_service_pack(7) 37 test_utils.configure_display_name(display_name) 38 test_utils.save_project_configure() 39 40 # close message dialog when create new project 41 test_utils.close_message_dialog() 42 43 test_utils.toolbar_save() 44 45def add_main_screen(): 46 #---------------------------------------# 47 #add main screen to display # 48 #---------------------------------------# 49 50 test_utils.select_project_tree_node("window") 51 52 test_utils.edit_widget_props("ID_XPOS", 0) 53 test_utils.edit_widget_props("ID_YPOS", 0) 54 test_utils.edit_widget_props("ID_WIDTH", 640) 55 test_utils.edit_widget_props("ID_HEIGHT", 480) 56 test_utils.edit_widget_props("ID_WIDGET_NAME", screen_name) 57 58 test_utils.add_pixelmaps('Custom', '..\\pixelmaps\\', 'fill.png') 59 test_utils.add_pixelmaps('Custom', '..\\pixelmaps\\', 'yellow_bg.png') 60 61def add_edit_generic_scroll_wheel(): 62 #---------------------------------------# 63 #add and edti widget scroll wheel # 64 #---------------------------------------# 65 test_utils.select_project_tree_node(screen_name) 66 test_utils.add_widget('GX_TYPE_GENERIC_SCROLL_WHEEL') 67 widget_name = "generic_scroll_wheel" 68 69 test_utils.edit_widget_props("ID_XPOS", 16) 70 test_utils.edit_widget_props("ID_YPOS", 19) 71 test_utils.edit_widget_props("ID_WIDTH", 179) 72 test_utils.edit_widget_props("ID_HEIGHT", 213) 73 test_utils.edit_widget_props("ID_WIDGET_NAME", widget_name) 74 test_utils.edit_widget_props('ID_SCROLL_WHEEL_SELECTED_ROW', 0) 75 test_utils.edit_widget_props('ID_SCROLL_WHEEL_ROW_HEIHGT', 40) 76 test_utils.edit_widget_props('ID_SCROLL_WHEEL_START_ALPHA', 240) 77 test_utils.edit_widget_props('ID_SCROLL_WHEEL_END_ALPHA', 20) 78 test_utils.edit_widget_props('ID_SCROLL_WHEEL_TOTAL_ROWS', 8) 79 80 # set wallpaper 81 test_utils.edit_widget_props("ID_PIXELMAP_0", "YELLOW_BG") 82 83 # set selected background 84 test_utils.edit_widget_props("ID_PIXELMAP_1", "FILL") 85 test_utils.compare_result() 86 87 # Add child widget to widget scroll wheel 88 for index in range(0, 8): 89 test_utils.select_project_tree_node(widget_name) 90 test_utils.add_widget('GX_TYPE_NUMERIC_PROMPT') 91 test_utils.edit_widget_props('ID_TRANSPARENT', 1) 92 test_utils.edit_widget_props('ID_NUMERIC_PROMPT_VALUE', index) 93 test_utils.compare_result() 94 95 test_utils.select_project_tree_node(widget_name) 96 test_utils.edit_widget_props('ID_SCROLL_WHEEL_ROW_HEIHGT', 45) 97 test_utils.compare_result() 98 99 test_utils.select_project_tree_node(widget_name) 100 test_utils.edit_widget_props('ID_SCROLL_WHEEL_SELECTED_ROW', 4) 101 test_utils.compare_result() 102 103 test_utils.select_project_tree_node(widget_name) 104 test_utils.edit_widget_props('ID_SCROLL_WHEEL_SELECTED_ROW', 8) 105 106 test_utils.select_project_tree_node(widget_name) 107 test_utils.edit_widget_props('ID_SCROLL_WHEEL_SELECTED_ROW', 7) 108 test_utils.compare_result() 109 110 test_utils.select_project_tree_node(widget_name) 111 test_utils.toolbar_copy() 112 test_utils.select_project_tree_node(screen_name) 113 test_utils.toolbar_paste() 114 test_utils.select_project_tree_node(widget_name + "_1") 115 test_utils.edit_widget_props("ID_XPOS", 16) 116 test_utils.edit_widget_props("ID_YPOS", 243) 117 test_utils.compare_result() 118 119 #-----------------------------------------------------------# 120 # add generic scroll wheel with callback, without wrap style# 121 #-----------------------------------------------------------# 122 test_utils.select_project_tree_node(screen_name) 123 test_utils.add_widget('GX_TYPE_GENERIC_SCROLL_WHEEL') 124 widget_name = "generic_scroll_wheel_nowrap" 125 126 test_utils.edit_widget_props("ID_XPOS", 230) 127 test_utils.edit_widget_props("ID_YPOS", 101) 128 test_utils.edit_widget_props("ID_WIDTH", 188) 129 test_utils.edit_widget_props("ID_HEIGHT", 239) 130 test_utils.edit_widget_props("ID_WIDGET_NAME", widget_name) 131 test_utils.edit_widget_props('ID_SCROLL_WHEEL_TOTAL_ROWS', 8) 132 test_utils.edit_widget_props('ID_CALLBACK_NAME', 'generic_scroll_callback') 133 test_utils.edit_widget_props("ID_PIXELMAP_0", "YELLOW_BG") 134 test_utils.edit_widget_props("ID_PIXELMAP_1", "FILL") 135 test_utils.compare_result() 136 137 #----------------------------------------------------------# 138 # add generic scroll wheel with callback, with wrap style # 139 #----------------------------------------------------------# 140 test_utils.select_project_tree_node(widget_name) 141 test_utils.toolbar_copy() 142 test_utils.select_project_tree_node(screen_name) 143 test_utils.toolbar_paste() 144 test_utils.select_project_tree_node(widget_name + "_1") 145 test_utils.edit_widget_props("ID_XPOS", 433) 146 test_utils.edit_widget_props("ID_YPOS", 101) 147 test_utils.edit_widget_props("ID_LIST_WRAP", 1) 148 test_utils.compare_result() 149 150 151def run_generic_scroll_wheel_tests(generate, screenshot): 152 153 test_utils.output_test_header(get_test_header()) 154 test_utils.setup(generate, screenshot, 'test_generic_scroll_wheel_golden_file') 155 156 print('create new project') 157 run_new_project_create("test_generic_scroll_wheel") 158 159 print('add main screen') 160 add_main_screen() 161 162 print('add and edit generic scroll wheel') 163 add_edit_generic_scroll_wheel() 164 165 test_utils.toolbar_save() 166 test_utils.generate_all() 167 test_utils.click_generate_button() 168 test_utils.cmp_output_files(test_generic_scroll_wheel_output_files) 169 170 test_utils.write_end('Generic Scroll Wheel Tests')