summaryrefslogtreecommitdiff
path: root/testing/resources/javascript/field.in
diff options
context:
space:
mode:
Diffstat (limited to 'testing/resources/javascript/field.in')
-rw-r--r--testing/resources/javascript/field.in173
1 files changed, 169 insertions, 4 deletions
diff --git a/testing/resources/javascript/field.in b/testing/resources/javascript/field.in
index 62496abd1a..588ae334e5 100644
--- a/testing/resources/javascript/field.in
+++ b/testing/resources/javascript/field.in
@@ -92,7 +92,7 @@ endobj
{{streamlen}}
>>
stream
-function TestGetField() {
+function testGetField() {
try {
var field = this.getField("MyField");
app.alert("field is " + field.name);
@@ -104,7 +104,8 @@ function TestGetField() {
app.alert("Unexpected error: " + e);
}
}
-function TestGetArray() {
+
+function testGetArray() {
try {
var subs = this.getField("MyField").getArray();
app.alert("found " + subs.length + " sub-fields:");
@@ -115,8 +116,172 @@ function TestGetArray() {
app.alert("Unexpected error: " + e);
}
}
-TestGetField();
-TestGetArray();
+
+function testReadProperty(field, prop, expected) {
+ try {
+ var actual = field[prop];
+ if (actual == expected) {
+ app.alert('PASS: ' + prop + ' = ' + actual);
+ } else {
+ app.alert('FAIL: ' + prop + ' = ' + actual + ', expected = ' + expected);
+ }
+ } catch (e) {
+ app.alert('ERROR: ' + e.toString());
+ }
+}
+
+function testUnreadableProperty(field, prop) {
+ try {
+ var value = field[prop];
+ app.alert('FAIL: ' + prop + ', expected to throw error');
+ } catch (e) {
+ app.alert('PASS: ' + prop + ' threw error ' + e.toString());
+ }
+}
+
+function testWriteProperty(field, prop, newValue) {
+ try {
+ field[prop] = newValue;
+ var actual = field[prop];
+ if (actual == newValue) {
+ app.alert('PASS: ' + prop + ' = ' + actual);
+ } else {
+ app.alert('FAIL: ' + prop + ' = ' + actual + ', expected = ' + newValue);
+ }
+ } catch (e) {
+ app.alert('ERROR: ' + e.toString());
+ }
+}
+
+function testWriteIgnoredProperty(field, prop, expected, newValue) {
+ try {
+ field[prop] = newValue;
+ var actual = field[prop];
+ if (actual == expected) {
+ app.alert('PASS: ' + prop + ' = ' + actual);
+ } else {
+ app.alert('FAIL: ' + prop + ' = ' + actual + ', expected = ' + expected);
+ }
+ } catch (e) {
+ app.alert('ERROR: ' + e.toString());
+ }
+}
+
+function testUnwritableProperty(field, prop, newValue) {
+ try {
+ field[prop] = newValue;
+ app.alert('FAIL: ' + prop + ' = ' + newValue + ', expected to throw error');
+ } catch (e) {
+ app.alert('PASS: ' + prop + ' threw error ' + e.toString());
+ }
+}
+
+function testRWProperty(field, prop, expected, newValue) {
+ testReadProperty(field, prop, expected);
+ testWriteProperty(field, prop, newValue);
+}
+
+function testRIProperty(field, prop, expected, newValue) {
+ testReadProperty(field, prop, expected);
+ testWriteIgnoredProperty(field, prop, expected, newValue);
+}
+
+function testROProperty(field, prop, expected) {
+ testReadProperty(field, prop, expected);
+ testUnwritableProperty(field, prop, 42);
+}
+
+function testXXProperty(field, prop) {
+ testUnreadableProperty(field, prop);
+ testUnwritableProperty(field, prop, 42);
+}
+
+function testProperties() {
+ try {
+ var field = this.getField("MyField");
+ app.alert('Testing properties under delay');
+ testRWProperty(field, "delay", false, true);
+ // TODO(tsepez): try this case, too.
+ // testPropertiesCase(field);
+ app.alert('Testing properties under non-delay');
+ testRWProperty(field, "delay", true, false);
+ testPropertiesCase(field);
+ } catch (e) {
+ app.alert("Unexpected error: " + e);
+ }
+}
+
+function testPropertiesCase(field) {
+ try {
+ // TODO(tsepez): devise tests and uncomment.
+ testRIProperty(field, "alignment", "left", "center");
+ // testRWProperty(field, "borderStyle", "solid", "inset");
+ // testROProperty(field, "buttonAlignX", "clams");
+ // testROProperty(field, "buttonAlignY", "clams");
+ // testROProperty(field, "buttonFitBounds", "clams");
+ // testROProperty(field, "buttonPosition", "clams");
+ // testROProperty(field, "buttonScaleHow", "clams");
+ // testROProperty(field, "buttonScaleWhen", "clams");
+ testRIProperty(field, "calcOrderIndex", -1, 100);
+ testRIProperty(field, "charLimit", 0, 100);
+ testRIProperty(field, "comb", false, true);
+ // testRIProperty(field, "commitOnSelChange", false, true);
+ // testROProperty(field, "currentValueIndices", "clams");
+ testXXProperty(field, "defaultStyle");
+ // testROProperty(field, "defaultValue", "clams");
+ testRIProperty(field, "doNotScroll", false, true);
+ testRIProperty(field, "doNotSpellCheck", false, true);
+ // testROProperty(field, "display", "clams");
+ testROProperty(field, "doc", "[object global]");
+ // testROProperty(field, "editable", "clams");
+ // testROProperty(field, "exportValues", "clams");
+ // testROProperty(field, "hidden", "clams");
+ testRIProperty(field, "fileSelect", false, true);
+ testRIProperty(field, "fillColor", "T", ["RGB", 0, 0, 0]);
+ // testROProperty(field, "lineWidth", "clams");
+ // testROProperty(field, "highlight", "clams");
+ testRIProperty(field, "multiline", false, true);
+ // testROProperty(field, "multipleSelection", "clams");
+ testROProperty(field, "name", "MyField");
+ // testROProperty(field, "numItems", "clams");
+ testROProperty(field, "page", -1);
+ testRIProperty(field, "password", false, 42);
+ // testROProperty(field, "print", "clams");
+ // testROProperty(field, "radiosInUnison", "clams");
+ testRIProperty(field, "readonly", false, true);
+ // testRWProperty(field, "rect", [0,0,0,0], [0,0,0,0]);
+ // testROProperty(field, "required", "clams");
+ testRIProperty(field, "richText", false, true);
+ testRIProperty(field, "richValue", undefined, "clams");
+ testRIProperty(field, "rotation", 0, 42);
+ testRIProperty(field, "source", undefined, "clams");
+ testRIProperty(field, "strokeColor", "T", ["RGB", 0, 0, 0]);
+ // testROProperty(field, "style", "clams");
+ testRIProperty(field, "submitName", undefined, "clams");
+ testRIProperty(field, "textColor", "T", ["RGB", 0, 0, 0]);
+ // testROProperty(field, "textFont", "clams");
+ testRIProperty(field, "textSize", 0, 32);
+ testROProperty(field, "type", "text");
+ testRIProperty(field, "userName", "");
+ testRIProperty(field, "value", "", "clams");
+ testROProperty(field, "valueAsString", "");
+ } catch (e) {
+ app.alert("Unexpected error: " + e);
+ }
+}
+
+function testMethods() {
+ try {
+ var field = this.getField("MyField");
+ } catch (e) {
+ app.alert("Unexpected error: " + e);
+ }
+}
+
+testGetField();
+testGetArray();
+testProperties();
+testMethods();
endstream
endobj
{{xref}}