1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.rendering.internal.html5

File HTML5ChainingRendererTest.java

 

Code metrics

0
22
4
1
97
59
4
0.18
5.5
4
1

Classes

Class Line # Actions
HTML5ChainingRendererTest 43 22 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.internal.html5;
21   
22    import java.util.HashMap;
23    import java.util.Map;
24   
25    import org.junit.Before;
26    import org.junit.Test;
27    import org.xwiki.rendering.internal.renderer.xhtml.image.XHTMLImageRenderer;
28    import org.xwiki.rendering.internal.renderer.xhtml.link.XHTMLLinkRenderer;
29    import org.xwiki.rendering.internal.renderer.html5.HTML5ChainingRenderer;
30    import org.xwiki.rendering.listener.Format;
31    import org.xwiki.rendering.listener.chaining.ListenerChain;
32    import org.xwiki.rendering.renderer.printer.DefaultWikiPrinter;
33   
34    import static org.junit.Assert.assertEquals;
35    import static org.mockito.Mockito.mock;
36   
37    /**
38    * Test class for {@link org.xwiki.rendering.internal.renderer.html5.HTML5ChainingRenderer}.
39    *
40    * @version $Id: 0d4cd31b58597234c914ba1981b3f92b86badcbd $
41    * @since 7.1M1
42    */
 
43    public class HTML5ChainingRendererTest
44    {
45    private XHTMLLinkRenderer linkRenderer;
46   
47    private XHTMLImageRenderer imageRenderer;
48   
49    private ListenerChain listenerChain;
50   
51    private HTML5ChainingRenderer chainingRenderer;
52   
53    private DefaultWikiPrinter printer;
54   
 
55  3 toggle @Before
56    public void setUp() throws Exception
57    {
58  3 linkRenderer = mock(XHTMLLinkRenderer.class);
59  3 imageRenderer = mock(XHTMLImageRenderer.class);
60  3 listenerChain = new ListenerChain();
61  3 chainingRenderer = new HTML5ChainingRenderer(linkRenderer, imageRenderer, listenerChain);
62  3 printer = new DefaultWikiPrinter();
63  3 chainingRenderer.setPrinter(printer);
64    }
65   
 
66  1 toggle @Test
67    public void testWithoutMonospace() throws Exception
68    {
69  1 Map<String, String> parameters = new HashMap<>();
70  1 chainingRenderer.beginFormat(Format.BOLD, parameters);
71  1 chainingRenderer.onWord("hello");
72  1 chainingRenderer.endFormat(Format.BOLD, parameters);
73  1 assertEquals("<strong>hello</strong>", printer.toString());
74    }
75   
 
76  1 toggle @Test
77    public void testWithMonospace() throws Exception
78    {
79  1 Map<String, String> parameters = new HashMap<>();
80  1 chainingRenderer.beginFormat(Format.MONOSPACE, parameters);
81  1 chainingRenderer.onWord("hello");
82  1 chainingRenderer.endFormat(Format.MONOSPACE, parameters);
83  1 assertEquals("<span class=\"monospace\">hello</span>", printer.toString());
84    }
85   
 
86  1 toggle @Test
87    public void testWithMonospaceAndParameters() throws Exception
88    {
89  1 Map<String, String> parameters = new HashMap<>();
90  1 parameters.put("class", "myClass");
91  1 chainingRenderer.beginFormat(Format.MONOSPACE, parameters);
92  1 chainingRenderer.onWord("hello");
93  1 chainingRenderer.endFormat(Format.MONOSPACE, parameters);
94  1 assertEquals("<span class=\"monospace myClass\">hello</span>", printer.toString());
95    }
96   
97    }