1# -*- coding: utf-8 -*- 2import os 3import sys 4import time 5import test_utils 6import test_constants 7 8display_name = 'main_display' 9 10test_string_import_export_output_files = [ 11"test_string_import_export_resources.c", 12"test_string_import_export_resources.h"] 13 14test_csv_export_files = [ 15"EnglishtoJapaneseExport.csv", 16"EnglishtoChineseExport.csv" 17] 18 19def get_test_header(): 20 notes = "* String Import Export Test *\n" 21 notes += "* *\n" 22 notes += "* Import string from csv format file *\n" 23 notes += "* Export string to csv format file *\n" 24 return notes 25 26def run_new_project_create(project_name): 27 28 # create a new project 29 test_utils.toolbar_create() 30 test_utils.set_new_project_path(test_utils.DEFAULT_OUTPUT_FILE_PATH) 31 test_utils.set_new_project_name(project_name) 32 test_utils.save_new_project_create() 33 34 # configure project 35 test_utils.configure_project() 36 test_utils.configure_x_res(640) 37 test_utils.configure_y_res(480) 38 test_utils.configure_display_name(display_name) 39 test_utils.save_project_configure() 40 41 # close message dialog when create new and delete default_folder 42 test_utils.close_message_dialog() 43 44def csv_string_import_export(): 45 test_utils.edit_string() 46 test_utils.sort_string(test_constants.STRING_SORT_TYPE_ID) 47 test_utils.add_string() 48 test_utils.edit_top_string('test_string') 49 test_utils.save_string_edit() 50 51 # import string from csv file 52 test_utils.edit_string() 53 test_utils.import_string('EnglishtoChineseImport2.csv') 54 test_utils.cancel_string_edit() 55 56 # test_utils.edit_string() 57 test_utils.edit_string() 58 test_utils.select_string(1) 59 test_utils.toggle_three_column_mode() 60 61 test_utils.import_string('EnglishtoChineseImport1.csv') 62 test_utils.toggle_three_column_mode() 63 64 #ABOUT_GUIX 65 test_utils.select_string(1) 66 test_utils.import_string('EnglishtoChineseImport2.csv') 67 68 #export string, target language not exist 69 test_utils.export_string() 70 test_utils.set_string_export_src_language('English') 71 test_utils.set_string_export_target_language('Japanese') 72 test_utils.select_string_export_format('csv') 73 test_utils.set_string_export_filename('EnglishtoJapaneseExport.csv') 74 test_utils.set_string_export_path(test_utils.DEFAULT_OUTPUT_FILE_PATH) 75 test_utils.save_string_export() 76 77 #export string, target language exist 78 test_utils.export_string() 79 test_utils.set_string_export_src_language('English') 80 test_utils.set_string_export_target_language('Chinese') 81 test_utils.select_string_export_format('csv') 82 test_utils.set_string_export_filename('EnglishtoChineseExport.csv') 83 test_utils.set_string_export_path(test_utils.DEFAULT_OUTPUT_FILE_PATH) 84 test_utils.save_string_export() 85 86 test_utils.save_string_edit() 87 88 #import string from command line 89 print("import string from command line") 90 test_utils.toolbar_save() 91 test_utils.close_project(1) 92 studio_release = test_utils.DEFAULT_OUTPUT_FILE_PATH + "../../../../guix_studio/build/vs_2019/Release/guix_studio.exe" 93 project_pathname = test_utils.DEFAULT_OUTPUT_FILE_PATH + "/test_string_import_export.gxp" 94 studio_release = os.path.abspath(studio_release) 95 project_pathname = os.path.abspath(project_pathname) 96 print(studio_release) 97 print(project_pathname) 98 99 os.system(os.path.abspath(studio_release) + " -p " + project_pathname + " -n -r -i ../EnglishtoJapaneseImport.xliff") 100 test_utils.open_project(project_pathname, 0) 101 102 #save project 103 #est_utils.toolbar_save() 104 105 #test_utils.generate_all() 106 #test_utils.click_generate_button() 107 test_utils.cmp_output_files(test_string_import_export_output_files) 108 test_utils.cmp_normal_files(test_csv_export_files) 109 110def run_string_import_export_tests(generate, screenshot): 111 test_utils.output_test_header(get_test_header()) 112 test_utils.setup(generate, screenshot, 'test_string_import_export_golden_file') 113 114 print('create new project') 115 run_new_project_create("test_string_import_export") 116 117 print('import export string from csv file') 118 csv_string_import_export() 119 120 test_utils.write_end('String Import Export Tests')