|
| 1 | +package decoder |
| 2 | + |
| 3 | +import ( |
| 4 | + "bytes" |
| 5 | + "io/ioutil" |
| 6 | + "os" |
| 7 | + "testing" |
| 8 | + |
| 9 | + "github.com/feedbooks/r2-streamer-go/models" |
| 10 | + "github.com/feedbooks/r2-streamer-go/parser" |
| 11 | + . "github.com/smartystreets/goconvey/convey" |
| 12 | +) |
| 13 | + |
| 14 | +var testPublication models.Publication |
| 15 | +var testFonts []byte |
| 16 | + |
| 17 | +func init() { |
| 18 | + |
| 19 | + testPublication, _ = parser.Parse("../test/readium-test-files/functional/smoke-tests/SmokeTestFXL") |
| 20 | + ft, _ := os.Open("../test/readium-test-files/functional/smoke-tests/SmokeTestFXL/fonts/cut-cut.woff") |
| 21 | + testFonts, _ = ioutil.ReadAll(ft) |
| 22 | +} |
| 23 | + |
| 24 | +func TestAdobeFonts(t *testing.T) { |
| 25 | + |
| 26 | + f, _ := os.Open("../test/readium-test-files/functional/smoke-tests/SmokeTestFXL/fonts/cut-cut.adb.woff") |
| 27 | + |
| 28 | + Convey("Given cut-cut.adb.woff fonts", t, func() { |
| 29 | + fd, _ := DecodeAdobeFont(testPublication, models.Link{}, f) |
| 30 | + buff, _ := ioutil.ReadAll(fd) |
| 31 | + Convey("The adobe fonts is deobfuscated", func() { |
| 32 | + So(bytes.Equal(buff, testFonts), ShouldBeTrue) |
| 33 | + }) |
| 34 | + |
| 35 | + }) |
| 36 | + |
| 37 | +} |
| 38 | + |
| 39 | +func TestIdpfFonts(t *testing.T) { |
| 40 | + |
| 41 | + f, _ := os.Open("../test/readium-test-files/functional/smoke-tests/SmokeTestFXL/fonts/cut-cut.obf.woff") |
| 42 | + |
| 43 | + Convey("Given cut-cut.obf.woff fonts", t, func() { |
| 44 | + fd, _ := DecodeIdpfFont(testPublication, models.Link{}, f) |
| 45 | + buff, _ := ioutil.ReadAll(fd) |
| 46 | + Convey("The idpf fonts is deobfuscated", func() { |
| 47 | + So(bytes.Equal(buff, testFonts), ShouldBeTrue) |
| 48 | + }) |
| 49 | + |
| 50 | + }) |
| 51 | + |
| 52 | +} |
0 commit comments