1# -*- coding: utf-8 -*-
2import os
3import sys
4import time
5import test_utils
6
7def get_test_header():
8    notes =  "*          Text Input Text Set Test                   *\n"
9    notes += "*                                                     *\n"
10    notes += "* Set Chinese text(larger than input buffer size) to  *\n"
11    notes += "*   multi line text input                             *\n"
12    notes += "* Set Chinese text(larger than input buffer size) to  *\n"
13    notes += "*   single line text input                            *\n"
14    notes += "* Resize multi line text input to make the text total *\n"
15    notes += "*   lines larger than maximum cached lines            *\n"
16    notes += "* Set English text(larger than input buffer size) to  *\n"
17    notes += "*   multi line text input                             *\n"
18    notes += "* Set English text(larger than input buffer size) to  *\n"
19    notes += "*   single line text input                            *\n"
20    notes += "* Test if input text update when edit string table    *\n"
21    return notes
22
23def run_text_input_text_set_tests(generate, screenshot):
24
25    test_utils.output_test_header(get_test_header())
26    test_utils.setup(generate, screenshot, 'test_text_input_text_set_golden_file')
27
28    test_utils.open_project('test_text_input_text_set.gxp')
29
30    # set Chinese text that is larger than input buffer size to ML input widget
31    test_utils.select_project_tree_node('ml_text_input')
32    test_utils.edit_widget_props("ID_STRING_ID", "MULTI_LINE_TEXT")
33    test_utils.compare_result()
34
35    # resize multi line text input to make the text total lines larger than maximum cached lines
36    test_utils.select_project_tree_node('ml_text_input')
37    test_utils.edit_widget_props("ID_WIDTH", 69)
38    test_utils.compare_result()
39
40    # set Chinese text that is larger than input buffer size to SL input widget
41    test_utils.select_project_tree_node('sl_text_input')
42    test_utils.edit_widget_props("ID_STRING_ID", "SINGLE_LINE_TEXT")
43    test_utils.compare_result()
44
45    # set English text that is larger than input buffer size
46    test_utils.select_project_tree_node('ml_text_input')
47    test_utils.edit_widget_props('ID_BUFFER_SIZE', 3)
48
49    test_utils.edit_string()
50    test_utils.select_string(0)
51    test_utils.edit_top_string('123')
52    test_utils.select_string(0)
53    test_utils.save_string_edit()
54    test_utils.compare_result()
55
56    test_utils.edit_string()
57    test_utils.select_string(0)
58    test_utils.edit_top_string('000')
59    test_utils.select_string(0)
60    test_utils.cancel_string_edit()
61    test_utils.compare_result()
62
63    # set English text that is larget than input buffer size to SL input widget
64    test_utils.select_project_tree_node('sl_text_input')
65    test_utils.edit_widget_props('ID_BUFFER_SIZE', 3)
66
67    test_utils.edit_string()
68    test_utils.select_string(1)
69    test_utils.edit_top_string('123')
70    test_utils.select_string(1)
71    test_utils.save_string_edit()
72    test_utils.compare_result()
73
74    test_utils.edit_string()
75    test_utils.select_string(1)
76    test_utils.edit_top_string('000')
77    test_utils.select_string(1)
78    test_utils.cancel_string_edit()
79    test_utils.compare_result()
80
81    test_utils.write_end('Text Input Text Set Tests')