Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 1 | {{header}} |
| 2 | {{include field.fragment}} |
kumarashishg | 826308d | 2023-06-23 13:21:22 +0000 | [diff] [blame] | 3 | % JS program to execute |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 4 | {{object 16 0}} << |
| 5 | {{streamlen}} |
| 6 | >> |
| 7 | stream |
| 8 | {{include property_test_helpers.js}} |
| 9 | function testProperties() { |
| 10 | try { |
| 11 | var field = this.getField("MyField"); |
| 12 | var text = this.getField("MyField.MyText"); |
| 13 | var button = this.getField("MyField.MyPushButton"); |
kumarashishg | 826308d | 2023-06-23 13:21:22 +0000 | [diff] [blame] | 14 | var badbutton = this.getField("MyField.MyBadPushButton"); |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 15 | 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); |
kumarashishg | 826308d | 2023-06-23 13:21:22 +0000 | [diff] [blame] | 27 | testBadPushButtonPropertiesCase(badbutton); |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 28 | testRadioButtonPropertiesCase(radio); |
| 29 | testCheckBoxPropertiesCase(check); |
| 30 | testListBoxPropertiesCase(list); |
| 31 | testFileSelectPropertiesCase(file); |
| 32 | } catch (e) { |
| 33 | app.alert("Unexpected error: " + e); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | function 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 | |
| 45 | function 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); |
kumarashishg | 826308d | 2023-06-23 13:21:22 +0000 | [diff] [blame] | 73 | testRWProperty(field, "readonly", false, true); |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 74 | 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 | |
| 94 | function testPushButtonPropertiesCase(field) { |
| 95 | try { |
| 96 | testRIProperty(field, "buttonAlignX", 0, 50); |
| 97 | testRIProperty(field, "buttonAlignY", 0, 50); |
| 98 | testRIProperty(field, "buttonFitBounds", false); |
kumarashishg | 826308d | 2023-06-23 13:21:22 +0000 | [diff] [blame] | 99 | testRIProperty(field, "buttonPosition", 4); |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 100 | 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 | |
kumarashishg | 826308d | 2023-06-23 13:21:22 +0000 | [diff] [blame] | 109 | function testBadPushButtonPropertiesCase(field) { |
| 110 | try { |
| 111 | testRIProperty(field, "buttonPosition", 7); // not checked. |
| 112 | } catch (e) { |
| 113 | app.alert("Unexpected error: " + e); |
| 114 | } |
| 115 | } |
| 116 | |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 117 | function testRadioButtonPropertiesCase(field) { |
| 118 | try { |
kumarashishg | 826308d | 2023-06-23 13:21:22 +0000 | [diff] [blame] | 119 | testROProperty(field, "exportValues", "Yes"); |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 120 | testRIProperty(field, "radiosInUnison", false); |
kumarashishg | 826308d | 2023-06-23 13:21:22 +0000 | [diff] [blame] | 121 | testRIProperty(field, "style", "circle"); |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 122 | 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 | |
| 130 | function testCheckBoxPropertiesCase(field) { |
| 131 | try { |
kumarashishg | 826308d | 2023-06-23 13:21:22 +0000 | [diff] [blame] | 132 | testROProperty(field, "exportValues", "Yes"); |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 133 | 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 | |
| 142 | function testListBoxPropertiesCase(field) { |
| 143 | try { |
| 144 | testRWProperty(field, "currentValueIndices", 2, 1); |
| 145 | } catch (e) { |
| 146 | app.alert("Unexpected error: " + e); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | function testFileSelectPropertiesCase(field) { |
| 151 | try { |
| 152 | testRIProperty(field, "fileSelect", true); |
| 153 | } catch (e) { |
| 154 | app.alert("Unexpected error: " + e); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | testProperties(); |
| 159 | endstream |
| 160 | endobj |
| 161 | {{xref}} |
| 162 | {{trailer}} |
| 163 | {{startxref}} |
| 164 | %%EOF |