1import os
2import sys
3import time
4import test_utils
5import test_constants
6import logging
7
8standalone_binres_load_16bpp_xml_files = [
9"font_1bpp.xml",
10"font_4bpp.xml",
11"font_8bpp.xml",
12"pixelmap_565rgb.xml",
13"pixelmap_8bit_palette.xml",
14"pixelmap_compress_4444argb.xml",
15"pixelmap_raw_4444argb.xml",
16"pixelmap_compress_alphamap.xml",
17"pixelmap_raw_alphamap.xml"
18]
19
20standalone_binres_load_8bpp_xml_files = [
21"pixelmap_folder_1.xml",
22"pixelmap_fish.xml"
23]
24
25standalone_binres_load_extended_unicode_32bpp_xml_files = [
26"font_old_italic_1bpp.xml",
27"font_old_italic_4bpp.xml",
28"font_old_italic_8bpp.xml",
29"pixelmaps.xml"
30]
31
32def get_test_header():
33
34    notes =  "*            Studio Resource XML Tests                *\n"
35    notes += "*                                                     *\n"
36    notes += "* Test Resource XML generation                        *\n"
37    notes += "* Test Resource XML content                           *\n"
38    return notes
39
40def run_resource_xml_tests(generate, screenshot):
41
42    test_utils.output_test_header(get_test_header())
43    test_utils.setup(generate, screenshot, 'test_resource_xml')
44
45    # Test Resource XML generation for project standalone_binres_load_16bpp
46    test_utils.open_project('..\..\example_internal\standalone_binres_load_16bpp\standalone_binres_load_16bpp.gxp')
47    test_utils.click_resource_item("RES_TYPE_FONT", "FONT_1BPP")
48    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "font_1bpp.xml")
49    test_utils.click_resource_item("RES_TYPE_FONT", "FONT_4BPP")
50    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "font_4bpp.xml")
51    test_utils.click_resource_item("RES_TYPE_FONT", "FONT_8BPP")
52    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "font_8bpp.xml")
53    test_utils.click_pixelmap_folder("CUSTOM_PIXELMAP_FOLDER", "565rgb")
54    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "pixelmap_565rgb.xml")
55    test_utils.click_pixelmap_folder("CUSTOM_PIXELMAP_FOLDER", "8bit palette")
56    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "pixelmap_8bit_palette.xml")
57    test_utils.click_resource_item("RES_TYPE_PIXELMAP", "COMPRESS_4444ARGB")
58    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "pixelmap_compress_4444argb.xml")
59    test_utils.click_resource_item("RES_TYPE_PIXELMAP", "RAW_4444ARGB")
60    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "pixelmap_raw_4444argb.xml")
61    test_utils.click_resource_item("RES_TYPE_PIXELMAP", "COMPRESS_ALPHAMAP")
62    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "pixelmap_compress_alphamap.xml")
63    test_utils.click_resource_item("RES_TYPE_PIXELMAP", "RAW_ALPHAMAP")
64    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "pixelmap_raw_alphamap.xml")
65
66    test_utils.cmp_xml_files(standalone_binres_load_16bpp_xml_files, test_utils.DEFAULT_OUTPUT_FILE_PATH, '..\..\example_internal\standalone_binres_load_16bpp\\')
67
68    # Test Resource XML generation for project standalone_binres_load_8bpp
69    test_utils.open_project('..\..\example_internal\standalone_binres_load_8bpp\standalone_binres_load_8bpp.gxp')
70    test_utils.click_pixelmap_folder("CUSTOM_PIXELMAP_FOLDER", "Folder_1")
71    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "pixelmap_folder_1.xml")
72    test_utils.click_resource_item("RES_TYPE_PIXELMAP", "FISH")
73    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "pixelmap_fish.xml")
74
75    test_utils.cmp_xml_files(standalone_binres_load_8bpp_xml_files, test_utils.DEFAULT_OUTPUT_FILE_PATH, '..\..\example_internal\standalone_binres_load_8bpp\\')
76
77    # Test Resource XML generation for project standalone_binres_load_extended_unicode_32bpp
78    test_utils.open_project('..\..\example_internal\standalone_binres_load_extended_unicode_32bpp\standalone_binres_load_extended_unicode_32bpp.gxp')
79    test_utils.click_resource_item("RES_TYPE_FONT", "OLD_ITALIC_1BPP")
80    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "font_old_italic_1bpp.xml")
81    test_utils.click_resource_item("RES_TYPE_FONT", "OLD_ITALIC_4BPP")
82    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "font_old_italic_4bpp.xml")
83    test_utils.click_resource_item("RES_TYPE_FONT", "OLD_ITALIC_8BPP")
84    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "font_old_italic_8bpp.xml")
85    test_utils.click_pixelmap_folder("CUSTOM_PIXELMAP_FOLDER", "Custom")
86    test_utils.generate_xml(test_utils.DEFAULT_OUTPUT_FILE_PATH + "pixelmaps.xml")
87
88    test_utils.cmp_xml_files(standalone_binres_load_extended_unicode_32bpp_xml_files, test_utils.DEFAULT_OUTPUT_FILE_PATH, '..\..\example_internal\standalone_binres_load_extended_unicode_32bpp\\')
89
90    test_utils.write_end("Test Resource XML Generation")
91
92