aboutsummaryrefslogtreecommitdiff
path: root/test/Tests/Writers/Powerpoint.hs
blob: 9c5409310301e27938f1ae16d37b9802f12e6664 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{-# LANGUAGE NoImplicitPrelude #-}
module Tests.Writers.Powerpoint (tests) where

import Prelude
import Tests.Writers.OOXML (ooxmlTest)
import Text.Pandoc
import Test.Tasty
import System.FilePath

-- templating is important enough, and can break enough things, that
-- we want to run all our tests with both default formatting and a
-- template.

modifyPptxName :: FilePath -> FilePath
modifyPptxName fp =
  addExtension (dropExtension fp ++ "_templated") "pptx"

pptxTests :: String -> WriterOptions -> FilePath -> FilePath -> (TestTree, TestTree)
pptxTests name opts native pptx =
  let referenceDoc = "pptx/reference_depth.pptx"
  in
    ( ooxmlTest
      writePowerpoint
      name
      opts{writerReferenceDoc=Nothing}
      native
      pptx
    , ooxmlTest
      writePowerpoint
      name
      opts{writerReferenceDoc=Just referenceDoc}
      native
      (modifyPptxName pptx)
    )

groupPptxTests :: [(TestTree, TestTree)] -> [TestTree]
groupPptxTests pairs =
  let (noRefs, refs) = unzip pairs
  in
    [ testGroup "Default slide formatting" noRefs
    , testGroup "With `--reference-doc` pptx file" refs
    ]


tests :: [TestTree]
tests = groupPptxTests [ pptxTests "Inline formatting"
                         def
                         "pptx/inline_formatting.native"
                         "pptx/inline_formatting.pptx"
                       , pptxTests "Slide breaks (default slide-level)"
                         def
                         "pptx/slide_breaks.native"
                         "pptx/slide_breaks.pptx"
                       , pptxTests "slide breaks (slide-level set to 1)"
                         def{ writerSlideLevel = Just 1 }
                         "pptx/slide_breaks.native"
                         "pptx/slide_breaks_slide_level_1.pptx"
                       , pptxTests "lists"
                         def
                         "pptx/lists.native"
                         "pptx/lists.pptx"
                       , pptxTests "tables"
                         def
                         "pptx/tables.native"
                         "pptx/tables.pptx"
                       , pptxTests "table of contents"
                         def{ writerTableOfContents = True }
                         "pptx/slide_breaks.native"
                         "pptx/slide_breaks_toc.pptx"
                       , pptxTests "end notes"
                         def
                         "pptx/endnotes.native"
                         "pptx/endnotes.pptx"
                       , pptxTests "end notes, with table of contents"
                         def { writerTableOfContents = True }
                         "pptx/endnotes.native"
                         "pptx/endnotes_toc.pptx"
                       , pptxTests "images"
                         def
                         "pptx/images.native"
                         "pptx/images.pptx"
                       , pptxTests "two-column layout"
                         def
                         "pptx/two_column.native"
                         "pptx/two_column.pptx"
                       , pptxTests "speaker notes"
                         def
                         "pptx/speaker_notes.native"
                         "pptx/speaker_notes.pptx"
                       , pptxTests "speaker notes after a separating block"
                         def
                         "pptx/speaker_notes_afterseps.native"
                         "pptx/speaker_notes_afterseps.pptx"
                       , pptxTests "remove empty slides"
                         def
                         "pptx/remove_empty_slides.native"
                         "pptx/remove_empty_slides.pptx"
                       , pptxTests "raw ooxml"
                         def
                         "pptx/raw_ooxml.native"
                         "pptx/raw_ooxml.pptx"
                       , pptxTests "metadata, custom properties"
                         def
                         "pptx/document-properties.native"
                         "pptx/document-properties.pptx"
                       , pptxTests "metadata, short description"
                         def
                         "pptx/document-properties-short-desc.native"
                         "pptx/document-properties-short-desc.pptx"
                       ]