1# -*- coding: utf-8 -*- 2import os 3import sys 4import time 5import test_utils 6import test_constants 7 8display_name = "main_display" 9folder_name = "default_folder" 10screen_name = "main_screen" 11widget_name = "rich_view" 12 13def get_test_header(): 14 notes = "* Rich Text View Widget Test *\n" 15 notes += "* *\n" 16 notes += "* Add and Edit Rich Text View *\n" 17 return notes 18 19def run_new_project_create(project_name): 20 21 # create a new project 22 test_utils.toolbar_create() 23 test_utils.set_new_project_path(test_utils.DEFAULT_OUTPUT_FILE_PATH) 24 test_utils.set_new_project_name(project_name) 25 test_utils.save_new_project_create() 26 27 # configure project 28 test_utils.configure_project() 29 test_utils.configure_x_res(640) 30 test_utils.configure_y_res(480) 31 test_utils.configure_display_name(display_name) 32 test_utils.save_project_configure() 33 34 # close message dialog when create new project 35 test_utils.close_message_dialog() 36 37 # add normal font 38 # open font folder 39 test_utils.click_resource_group('FONT_GROUP') 40 41 test_utils.add_font() 42 test_utils.set_font_path('..\\..\\fonts\\VeraBd.ttf') 43 test_utils.set_font_name('BOLD') 44 test_utils.set_font_format('GX_FONT_FORMAT_8BPP') 45 test_utils.save_font_edit() 46 47 # add selected font 48 test_utils.add_font() 49 test_utils.set_font_path('..\\..\\fonts\\VeraBI.ttf') 50 test_utils.set_font_name('BOLD_ITALIC') 51 test_utils.set_font_format('GX_FONT_FORMAT_8BPP') 52 test_utils.save_font_edit() 53 54 # add selected font 55 test_utils.add_font() 56 test_utils.set_font_path('..\\..\\fonts\\VeraIt.ttf') 57 test_utils.set_font_name('ITALIC') 58 test_utils.set_font_format('GX_FONT_FORMAT_8BPP') 59 test_utils.save_font_edit() 60 61 # close font folder 62 test_utils.click_resource_group('FONT_GROUP') 63 64 # open color group folder 65 test_utils.click_resource_group('COLOR_GROUP') 66 67 # test cancel button 68 test_utils.add_color() 69 70 # edit color 71 test_utils.set_color_name('RED') 72 test_utils.set_color_hue(12) 73 test_utils.set_color_sat(88) 74 test_utils.set_color_lum(49) 75 test_utils.save_color_edit() 76 77 # open color edit dialog 78 test_utils.add_color() 79 80 # edit color 81 test_utils.set_color_name('GREEN') 82 test_utils.set_color_red(15) 83 test_utils.set_color_green(235) 84 test_utils.set_color_blue(16) 85 test_utils.save_color_edit() 86 87 # close color group folder 88 test_utils.click_resource_group('COLOR_GROUP') 89 90 test_utils.toolbar_save() 91 92def add_main_screen(): 93 #---------------------------------------# 94 #add main screen to display # 95 #---------------------------------------# 96 97 test_utils.select_project_tree_node("window") 98 99 test_utils.edit_widget_props("ID_XPOS", 0) 100 test_utils.edit_widget_props("ID_YPOS", 0) 101 test_utils.edit_widget_props("ID_WIDTH", 640) 102 test_utils.edit_widget_props("ID_HEIGHT", 480) 103 test_utils.edit_widget_props("ID_WIDGET_NAME", screen_name) 104 105 106def add_edit_rich_text_view(): 107 #---------------------------------------# 108 #add and edti numeric scroll wheel # 109 #---------------------------------------# 110 test_utils.select_project_tree_node(screen_name) 111 test_utils.add_widget('GX_TYPE_RICH_TEXT_VIEW') 112 113 test_utils.edit_widget_props("ID_XPOS", 10) 114 test_utils.edit_widget_props("ID_YPOS", 10) 115 test_utils.edit_widget_props("ID_WIDTH", 160) 116 test_utils.edit_widget_props("ID_HEIGHT", 240) 117 test_utils.edit_widget_props("ID_WIDGET_NAME", widget_name) 118 test_utils.compare_result() 119 120 # edit numeric scroll wheel properties 121 test_utils.select_project_tree_node(widget_name) 122 test_utils.edit_widget_props("ID_NORMAL_TEXT_COLOR", "TEXT") 123 test_utils.edit_widget_props('ID_FONT_SELECT_0', 'TEXT_INPUT') 124 test_utils.edit_widget_props_post('ID_RICH_TEXT_VIEW_TEXT_EDIT', 1) 125 test_utils.wait_dialog_open(test_utils.RICH_TEXT_EDIT_DIALOG) 126 string = "<b>bold</b>\r" 127 string += "<i>italic</i>\r" 128 string += "<b><i>bold italic</i></b>\r" 129 string += "<u>underline</u>\r" 130 string += "<align left>left align</align>\r" 131 string += "<align right>right align</align>\r" 132 string += "<f GX_FONT_ID_BOLD_ITALIC>font</f>\r" 133 string += "<hc GX_COLOR_ID_GREEN>highlight</hc>\r" 134 string += "<c GX_COLOR_ID_RED>text color</c>" 135 test_utils.edit_rich_text_view_string(string) 136 test_utils.save_rich_text_edit() 137 test_utils.edit_widget_props('ID_FONT_SELECT_1', 'BOLD') 138 test_utils.edit_widget_props('ID_FONT_SELECT_2', 'ITALIC') 139 test_utils.edit_widget_props('ID_FONT_SELECT_3', 'BOLD_ITALIC') 140 141 test_utils.compare_result() 142 143 # test copy paste 144 test_utils.select_project_tree_node(widget_name) 145 test_utils.toolbar_copy() 146 test_utils.select_project_tree_node(screen_name) 147 test_utils.toolbar_paste() 148 149 # test undo 150 # undo paste 151 test_utils.undo() 152 #undo bold italic font set 153 test_utils.undo() 154 #undo italic set 155 test_utils.undo() 156 #undo bold font set 157 test_utils.undo() 158 #undo string set 159 test_utils.undo() 160 161 test_utils.select_project_tree_node(widget_name) 162 test_utils.edit_widget_props("ID_STRING_ID", "STRING_2") 163 test_utils.edit_widget_props('ID_FONT_SELECT_1', 'BOLD') 164 165 166def edit_rich_text_view_fonts(): 167 # change font height 168 test_utils.select_project_tree_node(widget_name) 169 test_utils.click_resource_group('FONT_GROUP') 170 test_utils.edit_font('BOLD_ITALIC') 171 test_utils.set_font_path('..\\..\\fonts\\VeraBI.ttf') 172 test_utils.set_font_name('BOLD_ITALIC') 173 test_utils.set_font_height(26) 174 test_utils.save_font_edit() 175 test_utils.compare_result() 176 177 # edit font name 178 test_utils.edit_font('BOLD_ITALIC') 179 test_utils.set_font_name('NEW_BOLD_ITALIC') 180 test_utils.save_font_edit() 181 test_utils.compare_result() 182 183 # delete font 184 test_utils.delete_font('BOLD') 185 test_utils.compare_result() 186 test_utils.click_resource_group('FONT_GROUP') 187 188def edit_rich_text_view_colors(): 189 # change color 190 test_utils.click_resource_group('COLOR_GROUP') 191 test_utils.edit_color('RED') 192 test_utils.set_color_name('RED') 193 test_utils.set_color_hue(100) 194 test_utils.set_color_sat(88) 195 test_utils.set_color_lum(49) 196 test_utils.save_color_edit() 197 test_utils.compare_result() 198 199 # edit color name 200 test_utils.edit_color('RED') 201 test_utils.set_color_name('NEW_RED') 202 test_utils.save_color_edit() 203 test_utils.compare_result() 204 205 # delete color 206 test_utils.delete_color('GREEN') 207 test_utils.compare_result() 208 test_utils.click_resource_group('COLOR_GROUP') 209 210def run_rich_text_view_tests(generate, screenshot): 211 212 test_utils.output_test_header(get_test_header()) 213 test_utils.setup(generate, screenshot, 'test_rich_text_view_golden_file') 214 215 print('create new project') 216 run_new_project_create("test_rich_text_view") 217 218 print('add main screen') 219 add_main_screen() 220 221 print('add and edit rich text view widget') 222 add_edit_rich_text_view() 223 224 print('edit rich text view colors') 225 edit_rich_text_view_colors() 226 227 print('edit rich text view fonts') 228 edit_rich_text_view_fonts() 229 230 test_utils.toolbar_save() 231 test_utils.write_end('Rich Text View Widget Tests')