1# -*- coding: utf-8 -*- 2import os 3import sys 4import time 5import test_utils 6import test_constants 7import filecmp 8 9test_resources_edit_16bpp_output_files = [ 10"test_resources_edit_16bpp_fish.c", 11"test_resources_edit_16bpp_custom_maps.c", 12"test_resources_edit_16bpp_resources.c", 13"test_resources_edit_16bpp_resources.h"] 14 15test_resources_edit_8bpp_output_files = [ 16"test_resources_edit_8bpp_fish.c", 17"test_resources_edit_8bpp_custom_maps.c", 18"test_resources_edit_8bpp_resources.c", 19"test_resources_edit_8bpp_resources.h",] 20 21test_resources_edit_24bpp_output_files = [ 22"test_resources_edit_24bpp_fish.c", 23"test_resources_edit_24bpp_custom_maps.c", 24"test_resources_edit_24bpp_resources.c", 25"test_resources_edit_24bpp_resources.h",] 26 27test_resources_edit_export_xliff_files = [ 28'EnglishtoJapanese_v1.2.xliff', 29'EnglishtoJapanese_v2.0.xliff'] 30 31display_name = 'display_1' 32folder_name = 'default_folder' 33bad_name = 'bAd #1 name' # Name check test. 34 35display_color_format = 'INVALID' 36 37def run_font_edit(): 38 # open font folder 39 test_utils.click_resource_group('FONT_GROUP') 40 41 # test cancel button 42 test_utils.add_font() 43 test_utils.cancel_font_edit() 44 45 # open font NotoSansHans-Regular.otf 46 test_utils.add_font() 47 test_utils.set_font_path('..\\..\\fonts\\NotoSansHans-Regular.otf') 48 test_utils.set_font_name(test_constants.FONT_NOTOSANSHANS) 49 test_utils.set_font_format('GX_FONT_FORMAT_1BPP') 50 test_utils.set_font_height(10) 51 # parameters: page_index, page_enabled, range_start, range_end 52 test_utils.set_page_range(0, 1, '0020', '007e') 53 test_utils.save_font_edit() 54 55 # add font Vera.ttf 56 test_utils.add_font() 57 test_utils.set_font_path('..\\..\\fonts\\Vera.ttf') 58 test_utils.set_font_name(test_constants.FONT_VERA) 59 test_utils.set_font_format('GX_FONT_FORMAT_4BPP') 60 test_utils.set_font_height(10) 61 test_utils.save_font_edit() 62 63 # add font VeraBd.ttf 64 test_utils.add_font() 65 test_utils.set_font_path('..\\..\\fonts\\VeraBd.ttf') 66 test_utils.set_font_name(test_constants.FONT_VERABD) 67 test_utils.set_font_format('GX_FONT_FORMAT_8BPP') 68 test_utils.set_font_height(100) 69 test_utils.set_page_range(0, 1, '0030', '0030') 70 test_utils.save_font_edit() 71 72 # add font VeraBI.ttf 73 test_utils.add_font() 74 test_utils.set_font_path('..\\..\\fonts\\VeraBI.ttf') 75 test_utils.set_font_name(test_constants.FONT_VERABI) 76 test_utils.set_font_format('GX_FONT_FORMAT_1BPP') 77 test_utils.set_font_height(50) 78 test_utils.set_page_range(1, 1, '0100', '0110') 79 test_utils.save_font_edit() 80 81 #Name check and cancel check 82 test_utils.edit_font(test_constants.FONT_VERABD) 83 test_utils.set_font_path('..\\..\\fonts\\VeraBI.ttf') 84 test_utils.cancel_font_edit() 85 test_utils.edit_font(test_constants.FONT_VERABD) 86 test_utils.set_font_name(test_constants.FONT_VERABI) 87 test_utils.save_font_edit(test_utils.CLOSE_NO_WAIT) 88 test_utils.close_error_dialog() 89 test_utils.save_font_edit() 90 91 #Test font path edit 92 test_utils.add_font() 93 test_utils.set_font_path('..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\fonts\\VeraBI.ttf') 94 test_utils.set_font_name("Test_font_path") 95 test_utils.save_font_edit() 96 print("Calling close_error_dialog second time") 97 test_utils.close_error_dialog() 98 print("back from close error dialog, calling delete font") 99 test_utils.delete_font("Test_font_path") 100 101 # cloce font folder 102 test_utils.click_resource_group('FONT_GROUP') 103 104def run_color_edit(): 105 # open color group folder 106 test_utils.click_resource_group('COLOR_GROUP') 107 108 # test cancel button 109 test_utils.add_color() 110 test_utils.cancel_color_edit() 111 112 #---------------------------------------------------------# 113 # Add "green" color # 114 #---------------------------------------------------------# 115 116 # open color edit dialog 117 test_utils.add_color() 118 119 # edit color 120 test_utils.set_color_name('green') 121 test_utils.set_color_red(15) 122 test_utils.set_color_green(235) 123 test_utils.set_color_blue(16) 124 test_utils.save_color_edit() 125 126 #---------------------------------------------------------# 127 # Add "red" color # 128 #---------------------------------------------------------# 129 130 # open color edit dialog 131 test_utils.add_color() 132 133 # edit color 134 test_utils.set_color_name('red') 135 test_utils.set_color_hue(12) 136 test_utils.set_color_sat(88) 137 test_utils.set_color_lum(49) 138 test_utils.save_color_edit() 139 140 #---------------------------------------------------------# 141 # ID Name and cancel button check # 142 #---------------------------------------------------------# 143 test_utils.edit_color('green') 144 test_utils.set_color_name(bad_name) 145 test_utils.save_color_edit(test_utils.CLOSE_NO_WAIT) 146 test_utils.close_message_dialog() 147 test_utils.set_color_name('red') 148 test_utils.save_color_edit(test_utils.CLOSE_NO_WAIT) 149 test_utils.close_message_dialog() 150 test_utils.save_color_edit() 151 152 # close color group folder 153 test_utils.click_resource_group('COLOR_GROUP') 154 155def run_8bit_palette_color_edit(): 156 157 #open theme configure dialog 158 test_utils.configure_themes() 159 160 #open palette edit dialog 161 test_utils.edit_palette() 162 163 #change predefined palette entry from 45 to 47 164 test_utils.set_predefined_palette_entry(47) 165 166 #set green color to palette index 45 167 test_utils.set_palette_color(45, 15, 235, 16) 168 169 #set red color to palette index 46 170 test_utils.set_palette_color(46, 235, 47, 15) 171 172 test_utils.save_palette_edit() 173 174 test_utils.save_theme_configure() 175 176 # open color group folder 177 test_utils.click_resource_group('COLOR_GROUP') 178 179 # test cancel button 180 test_utils.add_color() 181 test_utils.cancel_color_edit() 182 183 #---------------------------------------------------------# 184 # Add "green" color # 185 #---------------------------------------------------------# 186 187 # open color edit dialog 188 test_utils.add_color() 189 190 # edit color 191 test_utils.set_color_name('green') 192 test_utils.set_palette_color_index(45) 193 test_utils.save_color_edit() 194 195 #---------------------------------------------------------# 196 # Add "red" color # 197 #---------------------------------------------------------# 198 199 # open color edit dialog 200 test_utils.add_color() 201 202 # edit color 203 test_utils.set_color_name('red') 204 test_utils.set_palette_color_index(46) 205 test_utils.save_color_edit() 206 207 #---------------------------------------------------------# 208 # ID Name and cancel button check # 209 #---------------------------------------------------------# 210 test_utils.edit_color('green') 211 test_utils.set_color_name(bad_name) 212 test_utils.save_color_edit(test_utils.CLOSE_NO_WAIT) 213 test_utils.close_message_dialog() 214 test_utils.set_color_name('red') 215 test_utils.save_color_edit(test_utils.CLOSE_NO_WAIT) 216 test_utils.close_message_dialog() 217 test_utils.save_color_edit() 218 219 # close color group folder 220 test_utils.click_resource_group('COLOR_GROUP') 221 222#edit pixelmap add and edit 223def run_pixelmap_edit(): 224 # add three pixelmap folder 225 test_utils.add_pixelmap_folder() 226 test_utils.save_folder_name_edit() 227 228 test_utils.add_pixelmap_folder() 229 test_utils.set_folder_name('folder_delete_test_1') 230 test_utils.save_folder_name_edit() 231 232 test_utils.add_pixelmap_folder() 233 test_utils.set_folder_name('folder_test_1') 234 test_utils.save_folder_name_edit() 235 236 test_utils.add_pixelmap_folder() 237 test_utils.save_folder_name_edit() 238 239 test_utils.add_pixelmap_folder() 240 test_utils.set_folder_name('folder_delete_test_2') 241 test_utils.save_folder_name_edit() 242 243 test_utils.add_pixelmap_folder() 244 test_utils.set_folder_name('folder_test_2') 245 test_utils.save_folder_name_edit() 246 247 test_utils.add_pixelmap_folder() 248 test_utils.set_folder_name('folder_test_3') 249 test_utils.save_folder_name_edit() 250 251 test_utils.add_pixelmaps('Custom', '..\\pixelmaps\\', 'fish.png') 252 test_utils.add_pixelmaps('Custom', '..\\pixelmaps\\', 'Gaugemeter.png,i_emptyfill_middle.png') 253 test_utils.add_pixelmaps('Custom', '..\\pixelmaps\\', 'i_emptyfill_middle_horizontal.png') 254 test_utils.add_pixelmaps('folder_test_3', '..\\pixelmaps\\', 'i_history_lg.png,i_indicator.png') 255 test_utils.add_pixelmaps('folder_test_3', '..\\pixelmaps\\', 'i_indicator_horizontal.png') 256 test_utils.add_pixelmaps('folder_test_3', '..\\pixelmaps\\', 'i_orangefill_middle.png') 257 test_utils.add_pixelmaps('folder_test_2', '..\\pixelmaps\\', 'i_orangefill_middle_horizontal.png') 258 test_utils.add_pixelmaps('folder_test_2', '..\\pixelmaps\\', 'needle.png') 259 test_utils.add_pixelmaps('folder_test_2', '..\\pixelmaps\\', 'orange_button.png') 260 test_utils.add_pixelmaps('folder_test_2', '..\\pixelmaps\\', 'save_icon.png') 261 test_utils.add_pixelmaps('folder_test_2', '..\\pixelmaps\\', 'tfield_fill_small.png') 262 test_utils.add_pixelmaps('folder_test_1', '..\\pixelmaps\\', 'tfield_left_small.png') 263 test_utils.add_pixelmaps('folder_test_1', '..\\pixelmaps\\', 'tfield_right_small.png') 264 test_utils.add_pixelmaps('folder_test_1', '..\\pixelmaps\\', 'top_bar_background.png') 265 test_utils.add_pixelmaps('folder_test_1', '..\\pixelmaps\\', 'radiobutton_on.png') 266 test_utils.add_pixelmaps('folder_test_1', '..\\pixelmaps\\', 'i_orangefill_left.png') 267 test_utils.add_pixelmaps('folder_test_1', '..\\pixelmaps\\', 'i_orangefill_bottom.png') 268 test_utils.add_pixelmaps('folder_test_1', '..\\pixelmaps\\', 'i_medicationsred_lg.png') 269 270 test_utils.add_pixelmaps('folder_delete_test_2', '..\\pixelmaps\\', 'i_emptyfill_top.png') 271 test_utils.add_pixelmaps('folder_delete_test_2', '..\\pixelmaps\\', 'i_emptyfill_right.png') 272 test_utils.add_pixelmaps('folder_delete_test_2', '..\\pixelmaps\\', 'horizontal_fill_bkgnd.png') 273 test_utils.add_pixelmaps('folder_delete_test_1', '..\\pixelmaps\\', 'checkbox_on.png') 274 test_utils.add_pixelmaps('folder_delete_test_1', '..\\pixelmaps\\', 'checkbox_off.png') 275 test_utils.add_pixelmaps('folder_delete_test_1', '..\\pixelmaps\\', 'button_disabled.png') 276 test_utils.add_pixelmaps('folder_delete_test_1', '..\\pixelmaps\\', 'black_pause.png') 277 278 test_utils.click_resource_group('PIXELMAP_GROUP') 279 280 test_utils.edit_pixelmap('FISH') 281 test_utils.check_raw_format(0) 282 test_utils.check_compress(0) 283 test_utils.check_alpha(0) 284 test_utils.check_dither(0) 285 test_utils.check_custom_output(1) 286 287 if display_color_format == 'GX_COLOR_FORMAT_565RGB': 288 print('Setting output file to 16bpp_fish_maps.c') 289 test_utils.set_custom_output_file('test_resources_edit_16bpp_fish.c') 290 test_utils.set_output_format('GX_COLOR_FORMAT_565RGB') 291 else: 292 if display_color_format == 'GX_COLOR_FORMAT_24XRGB': 293 print('Setting output file to 24bpp_fish_custom_maps.c') 294 test_utils.set_custom_output_file('test_resources_edit_24bpp_fish.c') 295 test_utils.set_output_format('GX_COLOR_FORMAT_565RGB') 296 else: 297 if display_color_format == 'GX_COLOR_FORMAT_8BIT_PALETTE': 298 print('Setting output file to 8bpp_fish.c') 299 test_utils.set_custom_output_file('test_resources_edit_8bpp_fish.c') 300 301 test_utils.save_pixelmap_edit() 302 303 test_utils.edit_pixelmap('GAUGEMETER') 304 test_utils.check_raw_format(0) 305 test_utils.check_compress(1) 306 test_utils.check_alpha(1) 307 test_utils.check_dither(0) 308 test_utils.set_output_format('GX_COLOR_FORMAT_565RGB') 309 test_utils.save_pixelmap_edit() 310 311 test_utils.edit_pixelmap('I_EMPTYFILL_MIDDLE') 312 test_utils.check_raw_format(0) 313 test_utils.check_compress(0) 314 test_utils.check_alpha(1) 315 test_utils.check_dither(0) 316 test_utils.set_output_format('GX_COLOR_FORMAT_565RGB') 317 test_utils.save_pixelmap_edit() 318 319 test_utils.edit_pixelmap('I_EMPTYFILL_MIDDLE_HORIZONTAL') 320 test_utils.check_raw_format(0) 321 test_utils.check_compress(0) 322 test_utils.check_alpha(0) 323 test_utils.check_dither(1) 324 test_utils.set_output_format('GX_COLOR_FORMAT_8BIT_ALPHAMAP') 325 test_utils.save_pixelmap_edit() 326 327 test_utils.edit_pixelmap('I_HISTORY_LG') 328 test_utils.check_raw_format(0) 329 test_utils.check_compress(1) 330 test_utils.check_alpha(1) 331 test_utils.check_dither(0) 332 test_utils.check_custom_output(1) 333 334 if display_color_format == 'GX_COLOR_FORMAT_565RGB': 335 print('Setting output file to 16bpp_custom_maps.c') 336 test_utils.set_custom_output_file('test_resources_edit_16bpp_custom_maps.c') 337 else: 338 if display_color_format == 'GX_COLOR_FORMAT_24XRGB': 339 print('Setting output file to 24bpp_custom_maps.c') 340 test_utils.set_custom_output_file('test_resources_edit_24bpp_custom_maps.c') 341 else: 342 if display_color_format == 'GX_COLOR_FORMAT_8BIT_PALETTE': 343 print('Setting output file to 8bpp_custom_maps.c') 344 test_utils.set_custom_output_file('test_resources_edit_8bpp_custom_maps.c') 345 346 test_utils.set_output_format('GX_COLOR_FORMAT_8BIT_PALETTE') 347 test_utils.set_palette_type('PALETTE_TYPE_PRIVATE') 348 test_utils.save_pixelmap_edit() 349 350 test_utils.edit_pixelmap('I_INDICATOR') 351 test_utils.check_raw_format(0) 352 test_utils.check_compress(1) 353 test_utils.check_alpha(1) 354 test_utils.check_dither(1) 355 test_utils.check_custom_output(1) 356 357 if display_color_format == 'GX_COLOR_FORMAT_565RGB': 358 print('Setting output file to 16bpp_custom_maps.c') 359 test_utils.set_custom_output_file('test_resources_edit_16bpp_custom_maps.c') 360 else: 361 if display_color_format == 'GX_COLOR_FORMAT_24XRGB': 362 print('Setting output file to 24bpp_custom_maps.c') 363 test_utils.set_custom_output_file('test_resources_edit_24bpp_custom_maps.c') 364 else: 365 if display_color_format == 'GX_COLOR_FORMAT_8BIT_PALETTE': 366 print('Setting output file to 8bpp_custom_maps.c') 367 test_utils.set_custom_output_file('test_resources_edit_8bpp_custom_maps.c') 368 369 test_utils.set_output_format('GX_COLOR_FORMAT_8BIT_PALETTE') 370 test_utils.set_palette_type('PALETTE_TYPE_SHARED') 371 test_utils.save_pixelmap_edit() 372 373 test_utils.edit_pixelmap('I_INDICATOR_HORIZONTAL') 374 test_utils.check_raw_format(0) 375 test_utils.check_compress(0) 376 test_utils.check_alpha(1) 377 test_utils.check_dither(1) 378 test_utils.set_output_format('GX_COLOR_FORMAT_565RGB') 379 test_utils.save_pixelmap_edit() 380 381 test_utils.edit_pixelmap('I_ORANGEFILL_MIDDLE') 382 test_utils.check_raw_format(0) 383 test_utils.check_compress(1) 384 test_utils.check_alpha(1) 385 test_utils.check_dither(1) 386 test_utils.set_output_format('GX_COLOR_FORMAT_565RGB') 387 test_utils.save_pixelmap_edit() 388 389 test_utils.edit_pixelmap('I_ORANGEFILL_MIDDLE_HORIZONTAL') 390 test_utils.check_raw_format(1) 391 test_utils.check_compress(1) 392 test_utils.check_alpha(1) 393 test_utils.check_dither(1) 394 test_utils.set_output_format('GX_COLOR_FORMAT_565RGB') 395 test_utils.save_pixelmap_edit() 396 397 test_utils.edit_pixelmap('NEEDLE') 398 test_utils.check_raw_format(1) 399 test_utils.check_compress(1) 400 test_utils.check_alpha(1) 401 test_utils.check_dither(1) 402 test_utils.set_output_format('GX_COLOR_FORMAT_565RGB') 403 test_utils.save_pixelmap_edit() 404 405 test_utils.edit_pixelmap('ORANGE_BUTTON') 406 test_utils.check_raw_format(0) 407 test_utils.check_compress(0) 408 test_utils.check_alpha(1) 409 test_utils.check_dither(0) 410 test_utils.set_output_format('GX_COLOR_FORMAT_565RGB') 411 test_utils.save_pixelmap_edit() 412 413 test_utils.edit_pixelmap('SAVE_ICON') 414 test_utils.check_raw_format(0) 415 test_utils.check_compress(1) 416 test_utils.check_alpha(0) 417 test_utils.check_dither(0) 418 test_utils.set_output_format('GX_COLOR_FORMAT_565RGB') 419 test_utils.save_pixelmap_edit() 420 421 test_utils.edit_pixelmap('TFIELD_FILL_SMALL') 422 test_utils.check_raw_format(0) 423 test_utils.check_compress(0) 424 test_utils.check_alpha(1) 425 test_utils.check_dither(1) 426 test_utils.set_output_format('GX_COLOR_FORMAT_565RGB') 427 test_utils.save_pixelmap_edit() 428 429 test_utils.edit_pixelmap('TFIELD_LEFT_SMALL') 430 test_utils.check_raw_format(0) 431 test_utils.check_compress(1) 432 test_utils.check_alpha(1) 433 test_utils.check_dither(0) 434 test_utils.set_output_format('GX_COLOR_FORMAT_565RGB') 435 test_utils.save_pixelmap_edit() 436 437 test_utils.edit_pixelmap('TFIELD_RIGHT_SMALL') 438 test_utils.check_raw_format(0) 439 test_utils.check_compress(1) 440 test_utils.check_alpha(0) 441 test_utils.check_dither(1) 442 test_utils.set_output_format('GX_COLOR_FORMAT_565RGB') 443 test_utils.save_pixelmap_edit() 444 445 #Name check and cancel edit 446 test_utils.edit_pixelmap('FISH') 447 test_utils.check_raw_format(0) 448 test_utils.check_compress(1) 449 test_utils.check_compress(1) 450 test_utils.check_alpha(1) 451 test_utils.check_dither(1) 452 test_utils.set_output_format('GX_COLOR_FORMAT_32ARGB') 453 test_utils.cancel_pixelmap_edit() 454 test_utils.edit_pixelmap('FISH') 455 test_utils.set_image_id_name(bad_name) 456 test_utils.save_pixelmap_edit(test_utils.CLOSE_NO_WAIT) 457 test_utils.close_message_dialog() 458 test_utils.cancel_pixelmap_edit() 459 test_utils.edit_pixelmap('FISH') 460 test_utils.set_image_id_name('TFIELD_RIGHT_SMALL') 461 test_utils.save_pixelmap_edit(test_utils.CLOSE_NO_WAIT) 462 test_utils.close_error_dialog() 463 test_utils.save_pixelmap_edit() 464 465 466 test_utils.delete_pixelmap('BLACK_PAUSE') 467 test_utils.delete_pixelmap('HORIZONTAL_FILL_BKGND') 468 469 #delete a non-existent pixelmap: 470 test_utils.delete_pixelmap('DOES_NOTT_EXIST'); 471 472 test_utils.disable_pixelmap('NEEDLE') 473 test_utils.disable_pixelmap('SAVE_ICON') 474 test_utils.enable_pixelmap('NEEDLE') 475 476 test_utils.remove_pixelmap_folder('folder_delete_test_1') 477 test_utils.remove_pixelmap_folder('folder_delete_test_2') 478 479 test_utils.click_pixelmap_folder('CUSTOM_PIXELMAP_FOLDER', 'folder_test_1') 480 test_utils.disable_pixelmap_folder() 481 482 test_utils.click_resource_group('PIXELMAP_GROUP') 483 484def run_string_edit(): 485 486 # test cancel button 487 test_utils.edit_string() 488 test_utils.cancel_string_edit() 489 490 # add strings 491 test_utils.edit_string() 492 test_utils.sort_string(test_constants.STRING_SORT_TYPE_ENGLISH) 493 test_utils.add_string() 494 test_utils.edit_top_string('button') 495 test_utils.toggle_three_column_mode() 496 #按钮 497 test_utils.edit_bottom_string('按钮') 498 test_utils.increment_trans_language() 499 #ボタン 500 test_utils.edit_bottom_string('ボタン') 501 test_utils.increment_trans_language() 502 test_utils.toggle_three_column_mode() 503 504 test_utils.add_string() 505 test_utils.edit_top_string('text_button') 506 507 test_utils.add_string() 508 test_utils.edit_top_string('multi\rline\rbutton') 509 510 test_utils.add_string() 511 test_utils.edit_top_string('checkbox') 512 test_utils.toggle_three_column_mode() 513 #チェックボックス 514 test_utils.edit_bottom_string('チェックボックス') 515 test_utils.decrement_trans_language() 516 #复选框 517 test_utils.edit_bottom_string('复选框') 518 test_utils.decrement_trans_language() 519 test_utils.toggle_three_column_mode() 520 521 test_utils.add_string() 522 test_utils.edit_top_string('radio') 523 524 test_utils.add_string() 525 test_utils.edit_top_string('radio_button') 526 527 test_utils.add_string() 528 test_utils.edit_top_string('prompt') 529 530 test_utils.add_string() 531 test_utils.edit_top_string('transparent prompt with thin border') 532 533 test_utils.add_string() 534 test_utils.edit_top_string('transparent prompt with no border') 535 536 test_utils.add_string() 537 test_utils.edit_top_string('pixelmap prompt') 538 539 test_utils.add_string() 540 test_utils.edit_top_string('initial text') 541 542 test_utils.add_string() 543 test_utils.edit_top_string('text_view') 544 545 test_utils.add_string() 546 test_utils.edit_top_string('text view') 547 548 test_utils.add_string() 549 test_utils.edit_top_string('text input') 550 551 test_utils.add_string() 552 test_utils.edit_string_id('STRING_LEFT_ALIGNMENT') 553 test_utils.edit_top_string('left\ralignment') 554 555 test_utils.add_string() 556 test_utils.edit_string_id('STRING_RIGHT_ALIGNMENT') 557 test_utils.edit_top_string('right\ralignment') 558 559 test_utils.save_string_edit() 560 561 #test name exists 562 test_utils.edit_string() 563 test_utils.select_string(2) 564 test_utils.edit_string_id('STRING_RIGHT_ALIGNMENT') 565 test_utils.save_string_edit(test_utils.CLOSE_NO_WAIT) 566 test_utils.close_error_dialog() 567 test_utils.cancel_string_edit() 568 569 #test bad name 570 test_utils.edit_string() 571 test_utils.select_string(4) 572 test_utils.edit_string_id(bad_name) 573 test_utils.save_string_edit(test_utils.CLOSE_NO_WAIT) 574 test_utils.close_message_dialog() 575 test_utils.cancel_string_edit() 576 577 578 #test cancel settings 579 test_utils.click_resource_group('STRING_GROUP') 580 test_utils.edit_string() 581 test_utils.select_string(4) 582 test_utils.edit_string_id('test_cancel') 583 test_utils.cancel_string_edit() 584 585 # delete strings 586 test_utils.edit_string() 587 test_utils.select_string(2) 588 test_utils.delete_string() 589 test_utils.select_string(4) 590 test_utils.delete_string() 591 592 # export xliff file 593 test_utils.export_string() 594 test_utils.cancel_string_export() 595 596 test_utils.export_string() 597 test_utils.set_string_export_src_language('English') 598 test_utils.set_string_export_target_language('Japanese') 599 test_utils.select_string_export_format('xliff') 600 test_utils.set_xliff_version('version_1.2') 601 test_utils.set_string_export_filename('EnglishtoJapanese_v1.2.xliff') 602 test_utils.set_string_export_path(test_utils.DEFAULT_OUTPUT_FILE_PATH) 603 test_utils.save_string_export() 604 605 test_utils.export_string() 606 test_utils.set_string_export_src_language('English') 607 test_utils.set_string_export_target_language('Japanese') 608 test_utils.select_string_export_format('xliff') 609 test_utils.set_xliff_version('version_2.0') 610 test_utils.set_string_export_filename('EnglishtoJapanese_v2.0.xliff') 611 test_utils.set_string_export_path(test_utils.DEFAULT_OUTPUT_FILE_PATH) 612 test_utils.save_string_export() 613 614 test_utils.cmp_files(test_resources_edit_export_xliff_files, test_utils.compare_xliff_file) 615 616 # import xliff file 617 test_utils.import_string('EnglishtoChinese.xliff') 618 619 test_utils.save_string_edit() 620 621def run_new_project_create(project_name): 622 623 # close current project 624 # Menu '&Edit' and '&Insert' should be disabled when project is closed 625 test_utils.close_project() 626 passed = True 627 test_type = 'Check menu status' 628 error_msg = '' 629 if test_utils.get_menu_status('&Edit') == test_constants.MENU_ENABLED: 630 passed = False 631 error_msg += 'menu "&Edit" should be disabled\n' 632 if test_utils.get_menu_status('&Insert') == test_constants.MENU_ENABLED: 633 passed = False 634 error_msg += 'menu "&Insert" should be disabled\n' 635 636 test_utils.set_test_results(passed, test_type, error_msg) 637 638 # test cancel button 639 test_utils.toolbar_create() 640 test_utils.cancel_new_project_create() 641 642 # create a new project 643 test_utils.toolbar_create() 644 test_utils.set_new_project_path(test_utils.DEFAULT_OUTPUT_FILE_PATH) 645 test_utils.set_new_project_name(project_name) 646 test_utils.save_new_project_create() 647 648 # close message dialog when create new and delete default folder 649 test_utils.close_message_dialog() 650 test_utils.select_project_tree_node("default_folder") 651 test_utils.delete_folder(0) 652 653 # Menu '&Edit' and '&Insert' should be enabled when project is opened 654 passed = True 655 test_type = 'Check menu status' 656 error_msg = '' 657 if test_utils.get_menu_status('&Edit') == test_constants.MENU_DISABLED: 658 passed = False 659 error_msg += 'menu "&Edit" should be enabled\n' 660 if test_utils.get_menu_status('&Insert') == test_constants.MENU_DISABLED: 661 passed = False 662 error_msg += 'menu "&Insert" should be enabled\n' 663 664 test_utils.set_test_results(passed, test_type, error_msg) 665 666def run_project_configure(display_format): 667 668 # test cancel button 669 test_utils.configure_project() 670 test_utils.cancel_project_configure() 671 672 # configure project 673 test_utils.configure_project() 674 test_utils.configure_x_res(640) 675 test_utils.configure_y_res(480) 676 test_utils.configure_display_name(display_name) 677 test_utils.configure_display_color_format(display_format) 678 test_utils.configure_minor_version(2) 679 test_utils.configure_service_pack(5) 680 test_utils.save_project_configure() 681 682 test_utils.configure_project() 683 test_utils.configure_display_name(bad_name) 684 test_utils.save_project_configure(test_utils.CLOSE_NO_WAIT) 685 test_utils.close_message_dialog() 686 test_utils.cancel_project_configure() 687 688 # calculate checksum 689 test_utils.compare_result() 690 691 #Create default folder for project 692 test_utils.select_project_tree_node(display_name) 693 test_utils.insert_folder() 694 695# add "Chinese" 696# add "Japanese" 697def run_languges_configure(): 698 test_utils.configure_languages() 699 700 #add three languages 701 test_utils.add_language() 702 test_utils.add_language() 703 test_utils.add_language() 704 705 #set the second language to "Chinese" 706 test_utils.select_language_index(2) 707 test_utils.select_language_id('Chinese') 708 709 #set the third language to "Japanese" 710 test_utils.select_language_index(3) 711 test_utils.select_language_id('Japanese') 712 713 #delete the fourth language 714 test_utils.select_language_index(4) 715 test_utils.delete_language() 716 717 #save modifications 718 test_utils.save_language_configure() 719 720def run_theme_configure(): 721 test_utils.configure_themes() 722 test_utils.set_theme_name('theme_1') 723 test_utils.save_theme_configure() 724 725 test_utils.configure_themes() 726 test_utils.set_theme_name(bad_name) 727 test_utils.save_theme_configure(test_utils.CLOSE_NO_WAIT) 728 test_utils.close_message_dialog() 729 test_utils.cancel_theme_configure() 730 731def get_test_header(): 732 notes = "* Studio Add/Edit Resources Test *\n" 733 notes += "* *\n" 734 notes += "* Add and Edit colors *\n" 735 notes += "* Add and Edit fonts *\n" 736 notes += "* Add and Edit pixelmaps *\n" 737 notes += "* Add and Edit languages *\n" 738 notes += "* Add and Edit strings *\n" 739 notes += "* Verify output files match golden file content *\n" 740 return notes 741 742def run_edit_resources(new_project_name, display_format, golden_files): 743 744 global display_color_format 745 746 print('create new project') 747 run_new_project_create(new_project_name) 748 749 print('configure project') 750 run_project_configure(display_format) 751 752 display_color_format = display_format 753 754 print('configure theme') 755 run_theme_configure() 756 757 print('configure language') 758 run_languges_configure() 759 760 print('run color add and edit') 761 762 if display_format == 'GX_COLOR_FORMAT_8BIT_PALETTE': 763 run_8bit_palette_color_edit() 764 else: 765 run_color_edit() 766 767 print('run font add and edit') 768 run_font_edit() 769 770 print('run pixelmap add and edit') 771 run_pixelmap_edit() 772 773 print('run string add and edit') 774 run_string_edit() 775 776 print('save project') 777 test_utils.toolbar_save() 778 779 test_utils.generate_all() 780 test_utils.click_generate_button() 781 test_utils.cmp_output_files(golden_files) 782 783def run_resources_edit_tests(generate, screenshot): 784 785 test_utils.output_test_header(get_test_header()) 786 test_utils.setup(generate, screenshot, 'test_resources_edit_golden_file') 787 788 print('Running edit-resources at 16 565 format') 789 run_edit_resources("test_resources_edit_16bpp", 'GX_COLOR_FORMAT_565RGB', test_resources_edit_16bpp_output_files) 790 791 print('Running edit-resources at 8bpp palette format') 792 run_edit_resources("test_resources_edit_8bpp", 'GX_COLOR_FORMAT_8BIT_PALETTE', test_resources_edit_8bpp_output_files) 793 794 print('Running edit-resources at 24 bpp rgb format') 795 run_edit_resources("test_resources_edit_24bpp", 'GX_COLOR_FORMAT_24XRGB', test_resources_edit_24bpp_output_files) 796 797 test_utils.write_end('Edit Resources Tests') 798