blob: 38877874535b941b5f88c137b0c8e043cf5a438b [file] [log] [blame]
Haibo Huang49cc9302020-04-27 16:14:24 -07001{{header}}
2{{include field.fragment}}
kumarashishg826308d2023-06-23 13:21:22 +00003% JS program to execute
Haibo Huang49cc9302020-04-27 16:14:24 -07004{{object 16 0}} <<
5 {{streamlen}}
6>>
7stream
8{{include property_test_helpers.js}}
9function testProperties() {
10 try {
11 var field = this.getField("MyField");
12 var text = this.getField("MyField.MyText");
13 var button = this.getField("MyField.MyPushButton");
kumarashishg826308d2023-06-23 13:21:22 +000014 var badbutton = this.getField("MyField.MyBadPushButton");
Haibo Huang49cc9302020-04-27 16:14:24 -070015 var radio = this.getField("MyField.MyRadio");
16 var list = this.getField("MyField.MyMultiSelect");
17 var check = this.getField("MyField.MyCheckBox");
18 var file = this.getField("MyField.MyFile");
19 app.alert('Testing properties under delay');
20 testRWProperty(field, "delay", false, true);
21 // TODO(tsepez): try this case, too.
22 app.alert('Testing properties under non-delay');
23 testRWProperty(field, "delay", true, false);
24 testFieldPropertiesCase(field);
25 testTextPropertiesCase(text);
26 testPushButtonPropertiesCase(button);
kumarashishg826308d2023-06-23 13:21:22 +000027 testBadPushButtonPropertiesCase(badbutton);
Haibo Huang49cc9302020-04-27 16:14:24 -070028 testRadioButtonPropertiesCase(radio);
29 testCheckBoxPropertiesCase(check);
30 testListBoxPropertiesCase(list);
31 testFileSelectPropertiesCase(file);
32 } catch (e) {
33 app.alert("Unexpected error: " + e);
34 }
35}
36
37function testFieldPropertiesCase(field) {
38 testROProperty(field, "name", "MyField");
39 // TODO(tsepez): this is rect of first child somehow.
40 testRWProperty(field, "rect", [200,221,220,201], [100,121,120,101]);
41 // Put it back to where it started.
42 testRWProperty(field, "rect", [100,121,120,101], [200,221,220,201]);
43}
44
45function testTextPropertiesCase(field) {
46 try {
47 // TODO(tsepez): devise tests and uncomment.
48 testRIProperty(field, "alignment", "left", "center");
49 testRWProperty(field, "borderStyle", "solid", "inset");
50 testRIProperty(field, "calcOrderIndex", -1, 100);
51 testRIProperty(field, "charLimit", 0, 100);
52 testRIProperty(field, "comb", false, true);
53 // testRIProperty(field, "commitOnSelChange", false, true);
54 // testROProperty(field, "currentValueIndices", "clams");
55 testXXProperty(field, "defaultStyle");
56 testRIProperty(field, "defaultValue", "grue", "clams");
57 testRIProperty(field, "doNotScroll", false, true);
58 testRIProperty(field, "doNotSpellCheck", false, true);
59 testRWProperty(field, "display", 2, 3);
60 testROProperty(field, "doc", "[object global]");
61 // testROProperty(field, "editable", "clams");
62 testRWProperty(field, "hidden", false, true);
63 testRIProperty(field, "fileSelect", false, true);
64 testRIProperty(field, "fillColor", "T", ["RGB", 0, 0, 0]);
65 testRWProperty(field, "lineWidth", 1, 4);
66 testRIProperty(field, "multiline", false, true);
67 // testROProperty(field, "multipleSelection", "clams");
68 testROProperty(field, "name", "MyField.MyText");
69 // testROProperty(field, "numItems", "clams");
70 testROProperty(field, "page", 0);
71 testRIProperty(field, "password", false, 42);
72 testRWProperty(field, "print", true, false);
kumarashishg826308d2023-06-23 13:21:22 +000073 testRWProperty(field, "readonly", false, true);
Haibo Huang49cc9302020-04-27 16:14:24 -070074 testROProperty(field, "rect", [200,221,220,201]);
75 // testROProperty(field, "required", "clams");
76 testRIProperty(field, "richText", false, true);
77 testRIProperty(field, "richValue", undefined, "clams");
78 testRIProperty(field, "rotation", 0, 42);
79 testRIProperty(field, "source", undefined, "clams");
80 testRIProperty(field, "strokeColor", "T", ["RGB", 0, 0, 0]);
81 testRIProperty(field, "submitName", undefined, "clams");
82 testRIProperty(field, "textColor", "T", ["RGB", 0, 0, 0]);
83 // testROProperty(field, "textFont", "clams");
84 testRIProperty(field, "textSize", 0, 32);
85 testROProperty(field, "type", "text");
86 testRIProperty(field, "userName", "");
87 testRWProperty(field, "value", "bleen", "clams");
88 testROProperty(field, "valueAsString", "clams"); // Set by previous line.
89 } catch (e) {
90 app.alert("Unexpected error: " + e);
91 }
92}
93
94function testPushButtonPropertiesCase(field) {
95 try {
96 testRIProperty(field, "buttonAlignX", 0, 50);
97 testRIProperty(field, "buttonAlignY", 0, 50);
98 testRIProperty(field, "buttonFitBounds", false);
kumarashishg826308d2023-06-23 13:21:22 +000099 testRIProperty(field, "buttonPosition", 4);
Haibo Huang49cc9302020-04-27 16:14:24 -0700100 testRIProperty(field, "buttonScaleHow", 0);
101 testRIProperty(field, "buttonScaleWhen", 0);
102 testRIProperty(field, "highlight", "invert");
103 testROProperty(field, "type", "button");
104 } catch (e) {
105 app.alert("Unexpected error: " + e);
106 }
107}
108
kumarashishg826308d2023-06-23 13:21:22 +0000109function testBadPushButtonPropertiesCase(field) {
110 try {
111 testRIProperty(field, "buttonPosition", 7); // not checked.
112 } catch (e) {
113 app.alert("Unexpected error: " + e);
114 }
115}
116
Haibo Huang49cc9302020-04-27 16:14:24 -0700117function testRadioButtonPropertiesCase(field) {
118 try {
kumarashishg826308d2023-06-23 13:21:22 +0000119 testROProperty(field, "exportValues", "Yes");
Haibo Huang49cc9302020-04-27 16:14:24 -0700120 testRIProperty(field, "radiosInUnison", false);
kumarashishg826308d2023-06-23 13:21:22 +0000121 testRIProperty(field, "style", "circle");
Haibo Huang49cc9302020-04-27 16:14:24 -0700122 testROProperty(field, "type", "radiobutton");
123 testRIProperty(field, "value", "Off");
124 testROProperty(field, "valueAsString", "Off");
125 } catch (e) {
126 app.alert("Unexpected error: " + e);
127 }
128}
129
130function testCheckBoxPropertiesCase(field) {
131 try {
kumarashishg826308d2023-06-23 13:21:22 +0000132 testROProperty(field, "exportValues", "Yes");
Haibo Huang49cc9302020-04-27 16:14:24 -0700133 testRIProperty(field, "style", "check");
134 testROProperty(field, "type", "checkbox");
135 testRIProperty(field, "value", "Off");
136 testROProperty(field, "valueAsString", "Off");
137 } catch (e) {
138 app.alert("Unexpected error: " + e);
139 }
140}
141
142function testListBoxPropertiesCase(field) {
143 try {
144 testRWProperty(field, "currentValueIndices", 2, 1);
145 } catch (e) {
146 app.alert("Unexpected error: " + e);
147 }
148}
149
150function testFileSelectPropertiesCase(field) {
151 try {
152 testRIProperty(field, "fileSelect", true);
153 } catch (e) {
154 app.alert("Unexpected error: " + e);
155 }
156}
157
158testProperties();
159endstream
160endobj
161{{xref}}
162{{trailer}}
163{{startxref}}
164%%EOF