InDesign.t 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Before "make install", this script should be runnable with "make test".
  2. # After "make install" it should work as "perl t/InDesign.t".
  3. BEGIN { $| = 1; print "1..4\n"; $Image::ExifTool::noConfig = 1; }
  4. END {print "not ok 1\n" unless $loaded;}
  5. # test 1: Load the module(s)
  6. use Image::ExifTool 'ImageInfo';
  7. use Image::ExifTool::InDesign;
  8. $loaded = 1;
  9. print "ok 1\n";
  10. use t::TestLib;
  11. my $testname = 'InDesign';
  12. my $testnum = 1;
  13. # test 2: Extract information from InDesign.indd
  14. {
  15. ++$testnum;
  16. my $exifTool = new Image::ExifTool;
  17. my $info = $exifTool->ImageInfo('t/images/InDesign.indd');
  18. print 'not ' unless check($exifTool, $info, $testname, $testnum);
  19. print "ok $testnum\n";
  20. }
  21. # tests 3-4: Write some XMP tags then delete all XMP (writes empty XMP record)
  22. {
  23. ++$testnum;
  24. my $exifTool = new Image::ExifTool;
  25. $exifTool->SetNewValue(Author => 'Phil Harvey');
  26. $exifTool->SetNewValue(ImageDescription => 'A description');
  27. my $testfile = "t/${testname}_${testnum}_failed.indd";
  28. unlink $testfile;
  29. $exifTool->WriteInfo('t/images/InDesign.indd', $testfile);
  30. my $info = $exifTool->ImageInfo($testfile);
  31. my $not;
  32. unless (check($exifTool, $info, $testname, $testnum)) {
  33. print 'not ';
  34. $not = 1;
  35. }
  36. print "ok $testnum\n";
  37. ++$testnum;
  38. $exifTool->Options(PrintConv => 0);
  39. $exifTool->SetNewValue();
  40. $exifTool->SetNewValue('XMP:*');
  41. my $testfile2 = "t/${testname}_${testnum}_failed.indd";
  42. unlink $testfile2;
  43. $exifTool->WriteInfo($testfile, $testfile2);
  44. $info = $exifTool->ImageInfo($testfile2);
  45. if (check($exifTool, $info, $testname, $testnum)) {
  46. unlink $testfile unless $not;
  47. unlink $testfile2;
  48. } else {
  49. print 'not ';
  50. }
  51. print "ok $testnum\n";
  52. }
  53. # end