@ -869,94 +869,62 @@ describe('Annotation layer', function() {
} ) ;
} ) ;
} ) ;
} ) ;
describe ( 'Checkbox WidgetAnnotation' , function ( ) {
describe ( 'Button WidgetAnnotation' , function ( ) {
var checkbox WidgetDict;
var button WidgetDict;
beforeEach ( function ( done ) {
beforeEach ( function ( done ) {
checkbox WidgetDict = new Dict ( ) ;
button WidgetDict = new Dict ( ) ;
checkbox WidgetDict. set ( 'Type' , Name . get ( 'Annot' ) ) ;
button WidgetDict. set ( 'Type' , Name . get ( 'Annot' ) ) ;
checkbox WidgetDict. set ( 'Subtype' , Name . get ( 'Widget' ) ) ;
button WidgetDict. set ( 'Subtype' , Name . get ( 'Widget' ) ) ;
checkbox WidgetDict. set ( 'FT' , Name . get ( 'Btn' ) ) ;
button WidgetDict. set ( 'FT' , Name . get ( 'Btn' ) ) ;
done ( ) ;
done ( ) ;
} ) ;
} ) ;
afterEach ( function ( ) {
afterEach ( function ( ) {
checkbox WidgetDict = null ;
button WidgetDict = null ;
} ) ;
} ) ;
it ( 'should have proper flags' ,
it ( 'should handle checkboxes' , function ( ) {
function ( ) {
buttonWidgetDict . set ( 'V' , Name . get ( '1' ) ) ;
var checkboxWidgetRef = new Ref ( 124 , 0 ) ;
var xref = new XRefMock ( [
{ ref : checkboxWidgetRef , data : checkboxWidgetDict , }
] ) ;
var checkboxWidgetAnnotation =
var buttonWidgetRef = new Ref ( 124 , 0 ) ;
annotationFactory . create ( xref , checkboxWidgetRef ) ;
expect ( checkboxWidgetAnnotation . data . radio ) . toEqual ( false ) ;
expect ( checkboxWidgetAnnotation . data . pushbutton ) . toEqual ( false ) ;
expect ( checkboxWidgetAnnotation . data . fieldValue ) . toEqual ( null ) ;
} ) ;
it ( 'should have a proper value' ,
function ( ) {
checkboxWidgetDict . set ( 'V' , Name . get ( '1' ) ) ;
var checkboxWidgetRef = new Ref ( 124 , 0 ) ;
var xref = new XRefMock ( [
var xref = new XRefMock ( [
{ ref : checkbox WidgetRef, data : checkbox WidgetDict, }
{ ref : buttonWidgetRef , data : buttonWidgetDict , }
] ) ;
] ) ;
var checkboxWidgetAnnotation =
var buttonWidgetAnnotation =
annotationFactory . create ( xref , checkboxWidgetRef ) ;
annotationFactory . create ( xref , buttonWidgetRef ) ;
expect ( checkboxWidgetAnnotation . data . fieldValue ) . toEqual ( '1' ) ;
expect ( buttonWidgetAnnotation . data . checkBox ) . toEqual ( true ) ;
} ) ;
expect ( buttonWidgetAnnotation . data . fieldValue ) . toEqual ( '1' ) ;
} ) ;
expect ( buttonWidgetAnnotation . data . radioButton ) . toEqual ( false ) ;
describe ( 'RadioButtonWidgetAnnotation' , function ( ) {
var radioButtonWidgetDict ;
beforeEach ( function ( done ) {
radioButtonWidgetDict = new Dict ( ) ;
radioButtonWidgetDict . set ( 'Type' , Name . get ( 'Annot' ) ) ;
radioButtonWidgetDict . set ( 'Subtype' , Name . get ( 'Widget' ) ) ;
radioButtonWidgetDict . set ( 'FT' , Name . get ( 'Btn' ) ) ;
radioButtonWidgetDict . set ( 'Ff' , AnnotationFieldFlag . RADIO ) ;
done ( ) ;
} ) ;
} ) ;
afterEach ( function ( ) {
it ( 'should handle radio buttons' , function ( ) {
radioButtonWidgetDict = null ;
var parentDict = new Dict ( ) ;
} ) ;
parentDict . set ( 'V' , Name . get ( '1' ) ) ;
it ( 'should have proper flags' ,
var normalAppearanceStateDict = new Dict ( ) ;
function ( ) {
normalAppearanceStateDict . set ( '2' , null ) ;
var radioButtonWidgetRef = new Ref ( 124 , 0 ) ;
var xref = new XRefMock ( [
{ ref : radioButtonWidgetRef , data : radioButtonWidgetDict , }
] ) ;
var radioButtonWidgetAnnotation =
var appearanceStatesDict = new Dict ( ) ;
annotationFactory . create ( xref , radioButtonWidgetRef ) ;
appearanceStatesDict . set ( 'N' , normalAppearanceStateDict ) ;
expect ( radioButtonWidgetAnnotation . data . radio ) . toEqual ( true ) ;
expect ( radioButtonWidgetAnnotation . data . pushbutton ) . toEqual ( false ) ;
expect ( radioButtonWidgetAnnotation . data . fieldValue ) . toEqual ( null ) ;
} ) ;
it ( 'should have a proper value' ,
buttonWidgetDict . set ( 'Ff' , AnnotationFieldFlag . RADIO ) ;
function ( ) {
buttonWidgetDict . set ( 'Parent' , parentDict ) ;
radioB uttonWidgetDict . set ( 'V' , Name . get ( '1' ) ) ;
buttonWidgetDict . set ( 'AP' , appearanceStatesDict ) ;
var radioB uttonWidgetRef = new Ref ( 124 , 0 ) ;
var b uttonWidgetRef = new Ref ( 124 , 0 ) ;
var xref = new XRefMock ( [
var xref = new XRefMock ( [
{ ref : radioB uttonWidgetRef, data : radioB uttonWidgetDict, }
{ ref : b uttonWidgetRef, data : b uttonWidgetDict, }
] ) ;
] ) ;
var radioButtonWidgetAnnotation =
var buttonWidgetAnnotation =
annotationFactory . create ( xref , radioButtonWidgetRef ) ;
annotationFactory . create ( xref , buttonWidgetRef ) ;
expect ( radioButtonWidgetAnnotation . data . fieldValue ) . toEqual ( '1' ) ;
expect ( buttonWidgetAnnotation . data . checkBox ) . toEqual ( false ) ;
expect ( buttonWidgetAnnotation . data . radioButton ) . toEqual ( true ) ;
expect ( buttonWidgetAnnotation . data . fieldValue ) . toEqual ( '1' ) ;
expect ( buttonWidgetAnnotation . data . buttonValue ) . toEqual ( '2' ) ;
} ) ;
} ) ;
} ) ;
} ) ;