1# -*- coding: utf-8 -*-
2import os
3import sys
4import time
5import test_utils
6import test_constants
7import filecmp
8
9project_name = "test_display_conf.gxp"
10
11color_depth = [
1232,
1324,
1416,
158,
164,
171
18]
19cpu_type = [
20"generic",
21"synergy"
22]
23rgb_bits = [
241555,
254444,
26332
27]
28
29def get_test_header():
30    notes =  "*          Project configure Test                     *\n"
31    notes += "*                                                     *\n"
32
33    return notes
34
35def run_new_project_create():
36    print('create new project')
37    # create a new project
38    test_utils.toolbar_create()
39    test_utils.set_new_project_path(test_utils.DEFAULT_OUTPUT_FILE_PATH)
40    test_utils.set_new_project_name('test_display_conf')
41    test_utils.save_new_project_create()
42
43    # configure project
44    test_utils.configure_project()
45    test_utils.configure_display_num(1)
46    test_utils.select_display_index(1)
47    test_utils.configure_x_res(640)
48    test_utils.configure_y_res(480)
49    test_utils.save_project_configure()
50
51    test_utils.close_message_dialog()
52
53def run_project_color_format_config():
54    print('configure display')
55
56    for cpu_index in cpu_type:
57        test_utils.configure_project()
58        test_utils.configure_cpu_type(cpu_index)
59        if(cpu_index == "synergy"):
60            test_utils.save_project_configure(test_utils.CLOSE_NO_WAIT)
61            test_utils.close_message_dialog()
62            test_utils.wait_dialog_close(test_utils.CONFIGURE_PROJECT_DIALOG)
63        else:
64            test_utils.save_project_configure()
65
66        for color_index in color_depth:
67            test_utils.configure_project()
68            test_utils.configure_display_color_depth(color_index)
69            test_utils.save_project_configure()
70            for rgb_index in rgb_bits:
71                for index in range(2):
72                    test_utils.configure_project()
73                    test_utils.configure_display_rgb_bits(rgb_index)
74                    if cpu_index =="generic":
75                        if color_index==16 and(rgb_index == 4444 or rgb_index == 1555):
76                            test_utils.save_project_configure(test_utils.CLOSE_NO_WAIT)
77                            test_utils.close_message_dialog()
78                            test_utils.wait_dialog_close(test_utils.CONFIGURE_PROJECT_DIALOG)
79                        elif color_index==8 and rgb_index == 332:
80                            test_utils.save_project_configure(test_utils.CLOSE_NO_WAIT)
81                            test_utils.close_message_dialog()
82                            test_utils.wait_dialog_close(test_utils.CONFIGURE_PROJECT_DIALOG)
83                        else:
84                            test_utils.save_project_configure()
85
86                        test_utils.toolbar_save()
87                        test_utils.close_project()
88                        test_utils.open_project(test_utils.DEFAULT_OUTPUT_FILE_PATH + project_name)
89                    else:
90                        test_utils.save_project_configure()
91
92                        test_utils.toolbar_save()
93                        test_utils.close_project()
94                        test_utils.open_project(test_utils.DEFAULT_OUTPUT_FILE_PATH + project_name)
95
96
97    test_utils.close_project()
98
99def run_project_display_configure_tests(generate, screenshot):
100    test_utils.output_test_header(get_test_header())
101    test_utils.setup(generate, screenshot, 'test_display_conf_golden_file')
102
103    run_new_project_create()
104
105    run_project_color_format_config()
106
107    test_utils.write_end("Test display config")
108