Add tests for radiobutton/checkbox JS properties. Fix bad indexing discovered as a result. Change-Id: I6241ee32d11948ed242cf8a0b9f8898e8769a869 Reviewed-on: https://pdfium-review.googlesource.com/c/45470 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/testing/resources/javascript/field.fragment b/testing/resources/javascript/field.fragment index f696018..843a813 100644 --- a/testing/resources/javascript/field.fragment +++ b/testing/resources/javascript/field.fragment
@@ -66,7 +66,8 @@ >> endobj {{object 8 0}} << - /FT /Tx + /FT /Btn + /Ff 32768 /Parent 5 0 R /T (Sub_Z) /Type /Annot @@ -75,7 +76,8 @@ >> endobj {{object 9 0}} << - /FT /Tx + /FT /Btn + /Ff 0 /Parent 5 0 R /T (Sub_B) /Type /Annot
diff --git a/testing/resources/javascript/field_properties.in b/testing/resources/javascript/field_properties.in index fdd24ab..c638d86 100644 --- a/testing/resources/javascript/field_properties.in +++ b/testing/resources/javascript/field_properties.in
@@ -1,6 +1,6 @@ {{header}} -{{header}} {{include field.fragment}} + % JS program to exexute {{object 11 0}} << {{streamlen}} @@ -89,6 +89,8 @@ try { var field = this.getField("MyField"); var button = this.getField("MyField.Sub_A"); + var radio = this.getField("MyField.Sub_Z"); + var check = this.getField("MyField.Sub_B"); app.alert('Testing properties under delay'); testRWProperty(field, "delay", false, true); // TODO(tsepez): try this case, too. @@ -96,7 +98,9 @@ app.alert('Testing properties under non-delay'); testRWProperty(field, "delay", true, false); testTextPropertiesCase(field); - testButtonPropertiesCase(button); + testPushButtonPropertiesCase(button); + testRadioButtonPropertiesCase(radio); + testCheckBoxPropertiesCase(check); } catch (e) { app.alert("Unexpected error: " + e); } @@ -119,7 +123,6 @@ testRWProperty(field, "display", 2, 3); testROProperty(field, "doc", "[object global]"); // testROProperty(field, "editable", "clams"); - // testROProperty(field, "exportValues", "clams"); testRWProperty(field, "hidden", false, true); testRIProperty(field, "fileSelect", false, true); testRIProperty(field, "fillColor", "T", ["RGB", 0, 0, 0]); @@ -131,7 +134,6 @@ testROProperty(field, "page", 0); testRIProperty(field, "password", false, 42); testRWProperty(field, "print", true, false); - // testROProperty(field, "radiosInUnison", "clams"); testRIProperty(field, "readonly", false, true); // testRWProperty(field, "rect", [0,0,0,0], [0,0,0,0]); // testROProperty(field, "required", "clams"); @@ -140,7 +142,6 @@ 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"); @@ -154,7 +155,7 @@ } } -function testButtonPropertiesCase(field) { +function testPushButtonPropertiesCase(field) { try { testRIProperty(field, "buttonAlignX", 0, 50); testRIProperty(field, "buttonAlignY", 0, 50); @@ -169,6 +170,31 @@ } } +function testRadioButtonPropertiesCase(field) { + try { + testROProperty(field, "exportValues", "N"); + testRIProperty(field, "radiosInUnison", false); + testRIProperty(field, "style", "check"); + testROProperty(field, "type", "radiobutton"); + testRIProperty(field, "value", "Off"); + testROProperty(field, "valueAsString", "Off"); + } catch (e) { + app.alert("Unexpected error: " + e); + } +} + +function testCheckBoxPropertiesCase(field) { + try { + testROProperty(field, "exportValues", "N"); + testRIProperty(field, "style", "check"); + testROProperty(field, "type", "checkbox"); + testRIProperty(field, "value", "Off"); + testROProperty(field, "valueAsString", "Off"); + } catch (e) { + app.alert("Unexpected error: " + e); + } +} + testProperties(); endstream endobj
diff --git a/testing/resources/javascript/field_properties_expected.txt b/testing/resources/javascript/field_properties_expected.txt index 1a5a6f1..3e06195 100644 --- a/testing/resources/javascript/field_properties_expected.txt +++ b/testing/resources/javascript/field_properties_expected.txt
@@ -86,3 +86,25 @@ Alert: PASS: highlight = invert Alert: PASS: type = button Alert: PASS: type threw Field.type: Operation not supported. +Alert: PASS: exportValues = N +Alert: PASS: exportValues threw Field.exportValues: Object no longer exists. +Alert: PASS: radiosInUnison = false +Alert: PASS: radiosInUnison = false +Alert: PASS: style = check +Alert: PASS: style = check +Alert: PASS: type = radiobutton +Alert: PASS: type threw Field.type: Operation not supported. +Alert: PASS: value = Off +Alert: PASS: value = Off +Alert: PASS: valueAsString = Off +Alert: PASS: valueAsString threw Field.valueAsString: Operation not supported. +Alert: PASS: exportValues = N +Alert: PASS: exportValues threw Field.exportValues: Object no longer exists. +Alert: PASS: style = check +Alert: PASS: style = check +Alert: PASS: type = checkbox +Alert: PASS: type threw Field.type: Operation not supported. +Alert: PASS: value = Off +Alert: PASS: value = Off +Alert: PASS: valueAsString = Off +Alert: PASS: valueAsString threw Field.valueAsString: Operation not supported.