1import test_utils
2import test_constants
3
4folder_name = "default_folder"
5
6project_list = [
7'generic_1bpp.gxp',
8'generic_4bpp.gxp',
9'generic_8bpp.gxp'
10]
11
12def get_test_header():
13    notes =  "*              Studio Copy/Paste Widgets Test         *\n"
14    notes += "*                                                     *\n"
15    notes += "* Copy and Paste widgets with custom colors           *\n"
16    notes += "* Copy and Paste widgets with custom fonts            *\n"
17    notes += "* Copy and Paste widgets with unique strings          *\n"
18    notes += "* Copy and Paste to widgets without children          *\n"
19    notes += "* Copy and Paste to widgets with children             *\n"
20    notes += "* Copy and Paste widgets to display node              *\n"
21    notes += "* Copy and Paste widgets to child widgets             *\n"
22    return notes
23
24
25def run_copy_paste(copied, src_project, target_project):
26    test_utils.open_project(src_project)
27    test_utils.select_project_tree_node(copied)
28    test_utils.toolbar_copy()
29    test_utils.open_project(target_project)
30    test_utils.select_project_tree_node(folder_name)
31    #copy and paste to display node
32    test_utils.toolbar_paste()
33    test_utils.select_project_tree_node('window')
34    #copy and paste to widget with children
35    test_utils.toolbar_paste()
36    test_utils.select_project_tree_node('window_1')
37    #copy and paste to widget without children
38    if (target_project in project_list) and (copied != 'window'):
39        test_utils.toolbar_paste_no_wait()
40        test_utils.close_message_dialog()
41        test_utils.deselect()
42        test_utils.dirty_root_window()
43        test_utils.compare_result()
44    else:
45        test_utils.toolbar_paste()
46
47def run_copy_paste_between_projects_tests(generate, screenshot):
48    test_utils.output_test_header(get_test_header())
49    test_utils.setup(generate, screenshot, 'test_copy_paste_between_projects_golden_file')
50
51    #Copy from 1bpp to other formats
52    print('copy from generic_1bpp.gxp to generic_16bpp.gxp')
53    run_copy_paste('prompt_1', 'generic_1bpp.gxp', 'generic_16bpp.gxp')
54    run_copy_paste('horizontal_list_1', 'generic_1bpp.gxp', 'generic_16bpp.gxp')
55    run_copy_paste('window', 'generic_1bpp.gxp', 'generic_16bpp.gxp')
56
57    print('copy from generic_1bpp.gxp to generic_8bpp.gxp')
58    run_copy_paste('prompt_1', 'generic_1bpp.gxp', 'generic_8bpp.gxp')
59    run_copy_paste('horizontal_list_1', 'generic_1bpp.gxp', 'generic_8bpp.gxp')
60    run_copy_paste('window', 'generic_1bpp.gxp', 'generic_8bpp.gxp')
61
62    #Copy from  other formats to 1bpp
63    print('copy from generic_16bpp.gxp to generic_1bpp.gxp')
64    run_copy_paste('prompt_1', 'generic_16bpp.gxp', 'generic_1bpp.gxp')
65    run_copy_paste('horizontal_list_1', 'generic_16bpp.gxp', 'generic_1bpp.gxp')
66    run_copy_paste('window', 'generic_16bpp.gxp', 'generic_1bpp.gxp')
67
68    print('copy from generic_8bpp.gxp')
69    run_copy_paste('prompt_1', 'generic_8bpp.gxp', 'generic_1bpp.gxp')
70    run_copy_paste('horizontal_list_1', 'generic_8bpp.gxp', 'generic_1bpp.gxp')
71    run_copy_paste('window', 'generic_8bpp.gxp', 'generic_1bpp.gxp')
72
73    #Copy from 4bpp to other formats
74    print('copy from generic_4bpp.gxp to generic_16bpp.gxp')
75    run_copy_paste('prompt_1', 'generic_4bpp.gxp', 'generic_16bpp.gxp')
76    run_copy_paste('horizontal_list_1', 'generic_4bpp.gxp', 'generic_16bpp.gxp')
77    run_copy_paste('window', 'generic_4bpp.gxp', 'generic_16bpp.gxp')
78
79    print('copy from generic_4bpp.gxp to generic_8bpp.gxp')
80    run_copy_paste('prompt_1', 'generic_4bpp.gxp', 'generic_8bpp.gxp')
81    run_copy_paste('horizontal_list_1', 'generic_4bpp.gxp', 'generic_8bpp.gxp')
82    run_copy_paste('window', 'generic_4bpp.gxp', 'generic_8bpp.gxp')
83
84    #Copy from  other formats to 4bpp
85    print('copy from generic_16bpp.gxp to generic_4bpp.gxp')
86    run_copy_paste('prompt_1', 'generic_16bpp.gxp', 'generic_4bpp.gxp')
87    run_copy_paste('horizontal_list_1', 'generic_16bpp.gxp', 'generic_4bpp.gxp')
88    run_copy_paste('window', 'generic_16bpp.gxp', 'generic_4bpp.gxp')
89
90    print('copy from generic_8bpp.gxp to generic_4bpp.gxp')
91    run_copy_paste('prompt_1', 'generic_8bpp.gxp', 'generic_4bpp.gxp')
92    run_copy_paste('horizontal_list_1', 'generic_8bpp.gxp', 'generic_4bpp.gxp')
93    run_copy_paste('window', 'generic_8bpp.gxp', 'generic_4bpp.gxp')
94
95    print('copy from generic_8bpp.gxp to generic_16bpp.gxp')
96    run_copy_paste('prompt_1', 'generic_8bpp.gxp', 'generic_16bpp.gxp')
97    run_copy_paste('horizontal_list_1', 'generic_8bpp.gxp', 'generic_16bpp.gxp')
98    run_copy_paste('window', 'generic_8bpp.gxp', 'generic_16bpp.gxp')
99
100    print('copy from generic_8bpp.gxp to genric_32bpp.gxp')
101    run_copy_paste('prompt_1', 'generic_8bpp.gxp', 'generic_32bpp.gxp')
102    run_copy_paste('horizontal_list_1', 'generic_8bpp.gxp', 'generic_32bpp.gxp')
103    run_copy_paste('window', 'generic_8bpp.gxp', 'generic_32bpp.gxp')
104
105    print('copy from generic_8bpp.gxp to generic_332rgb.gxp')
106    run_copy_paste('prompt_1', 'generic_8bpp.gxp', 'generic_332rgb.gxp')
107    run_copy_paste('horizontal_list_1', 'generic_8bpp.gxp', 'generic_332rgb.gxp')
108    run_copy_paste('window', 'generic_8bpp.gxp', 'generic_332rgb.gxp')
109
110    print('copy from generic_8bpp.gxp to synergy_16bpp.gxp')
111    run_copy_paste('prompt_1', 'generic_8bpp.gxp', 'synergy_16bpp.gxp')
112    run_copy_paste('horizontal_list_1', 'generic_8bpp.gxp', 'synergy_16bpp.gxp')
113    run_copy_paste('window', 'generic_8bpp.gxp', 'synergy_16bpp.gxp')
114
115    print('copy from generic_16bpp.gxp to generic_8bpp.gxp')
116    run_copy_paste('window', 'generic_16bpp.gxp', 'generic_8bpp.gxp')
117
118    print('copy from generic_16bpp.gxp to generic_332rgb.gxp')
119    run_copy_paste('window', 'generic_16bpp.gxp', 'generic_332rgb.gxp')
120
121    print('copy from generic_16bpp.gxp to generic_32bpp.gxp')
122    run_copy_paste('window', 'generic_16bpp.gxp', 'generic_32bpp.gxp')
123
124    print('copy from generic_16bpp.gxp to synergy_16bpp.gxp')
125    run_copy_paste('window', 'generic_16bpp.gxp', 'synergy_16bpp.gxp')
126
127    print('copy from generic_16bpp.gxp to synergy_32bpp.gxp')
128    run_copy_paste('window', 'generic_16bpp.gxp', 'synergy_32bpp.gxp')
129
130    test_utils.write_end('Copy/Paste Between Projects Tests')
131