@@ -3,54 +3,78 @@ module Tests.Writers.Powerpoint (tests) where
33import Tests.Writers.OOXML (ooxmlTest)
44import Text.Pandoc
55import Test.Tasty
6+import System.FilePath
7+
8+-- templating is important enough, and can break enough things, that
9+-- we want to run all our tests with both default formatting and a
10+-- template.
11+
12+modifyPptxName :: FilePath -> FilePath
13+modifyPptxName fp =
14+ addExtension (dropExtension fp ++ "_templated") "pptx"
15+
16+pptxTests :: String -> WriterOptions -> FilePath -> FilePath -> (TestTree, TestTree)
17+pptxTests name opts native pptx =
18+ let referenceDoc = "pptx/reference_depth.pptx"
19+ in
20+ ( ooxmlTest
21+ writePowerpoint
22+ name
23+ opts{writerReferenceDoc=Nothing}
24+ native
25+ pptx
26+ , ooxmlTest
27+ writePowerpoint
28+ name
29+ opts{writerReferenceDoc=Just referenceDoc}
30+ native
31+ (modifyPptxName pptx)
32+ )
33+
34+groupPptxTests :: [(TestTree, TestTree)] -> [TestTree]
35+groupPptxTests pairs =
36+ let (noRefs, refs) = unzip pairs
37+ in
38+ [ testGroup "Default slide formatting" noRefs
39+ , testGroup "With `--reference-doc` pptx file" refs
40+ ]
641
7−pptxTest :: String -> WriterOptions -> FilePath -> FilePath -> TestTree
8−pptxTest = ooxmlTest writePowerpoint
942
1043tests :: [TestTree]
11−tests = [ pptxTest
12− "Inline formatting"
13− def
14− "pptx/inline_formatting.native"
15− "pptx/inline_formatting.pptx"
16− , pptxTest
17− "Slide breaks (default slide-level)"
18− def
19− "pptx/slide_breaks.native"
20− "pptx/slide_breaks.pptx"
21− , pptxTest
22− "slide breaks (slide-level set to 1)"
23− def{ writerSlideLevel = Just 1 }
24− "pptx/slide_breaks.native"
25− "pptx/slide_breaks_slide_level_1.pptx"
26− , pptxTest
27− "table of contents"
28− def{ writerTableOfContents = True }
29− "pptx/slide_breaks.native"
30− "pptx/slide_breaks_toc.pptx"
31− , pptxTest
32− "end notes"
33− def
34− "pptx/endnotes.native"
35− "pptx/endnotes.pptx"
36− , pptxTest
37− "end notes, with table of contents"
38− def { writerTableOfContents = True }
39− "pptx/endnotes.native"
40− "pptx/endnotes_toc.pptx"
41− , pptxTest
42− "images"
43− def
44− "pptx/images.native"
45− "pptx/images.pptx"
46− , pptxTest
47− "two-column layout"
48− def
49− "pptx/two_column.native"
50− "pptx/two_column.pptx"
51− , pptxTest
52− "speaker notes"
53− def
54− "pptx/speaker_notes.native"
55− "pptx/speaker_notes.pptx"
56− ]
44+tests = groupPptxTests [ pptxTests "Inline formatting"
45+ def
46+ "pptx/inline_formatting.native"
47+ "pptx/inline_formatting.pptx"
48+ , pptxTests "Slide breaks (default slide-level)"
49+ def
50+ "pptx/slide_breaks.native"
51+ "pptx/slide_breaks.pptx"
52+ , pptxTests "slide breaks (slide-level set to 1)"
53+ def{ writerSlideLevel = Just 1 }
54+ "pptx/slide_breaks.native"
55+ "pptx/slide_breaks_slide_level_1.pptx"
56+ , pptxTests "table of contents"
57+ def{ writerTableOfContents = True }
58+ "pptx/slide_breaks.native"
59+ "pptx/slide_breaks_toc.pptx"
60+ , pptxTests "end notes"
61+ def
62+ "pptx/endnotes.native"
63+ "pptx/endnotes.pptx"
64+ , pptxTests "end notes, with table of contents"
65+ def { writerTableOfContents = True }
66+ "pptx/endnotes.native"
67+ "pptx/endnotes_toc.pptx"
68+ , pptxTests "images"
69+ def
70+ "pptx/images.native"
71+ "pptx/images.pptx"
72+ , pptxTests "two-column layout"
73+ def
74+ "pptx/two_column.native"
75+ "pptx/two_column.pptx"
76+ , pptxTests "speaker notes"
77+ def
78+ "pptx/speaker_notes.native"
79+ "pptx/speaker_notes.pptx"
80+ ]