~ubuntu-branches/ubuntu/natty/gst-entrans/natty

« back to all changes in this revision

Viewing changes to common/coverage/coverage-report.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2010-09-13 19:49:29 UTC
  • Revision ID: james.westby@ubuntu.com-20100913194929-qz90a14xyxln9yfz
Tags: upstream-0.10.2
ImportĀ upstreamĀ versionĀ 0.10.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="utf-8"?>
 
2
<!--
 
3
#
 
4
# Copyright (C) 2006 Daniel Berrange
 
5
#
 
6
# This program is free software; you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation; either version 2 of the License, or
 
9
# (at your option) any later version.
 
10
#
 
11
# This program is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with this program; if not, write to the Free Software
 
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
-->
 
20
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
21
                version="1.0">
 
22
 
 
23
  <xsl:output method="html"/>
 
24
 
 
25
  <xsl:template match="coverage">
 
26
    <html>
 
27
      <head>
 
28
        <title>Coverage report</title>
 
29
        <style type="text/css">
 
30
          tbody tr.odd td.label {
 
31
            border-top: 1px solid rgb(128,128,128);
 
32
            border-bottom: 1px solid rgb(128,128,128);
 
33
          }
 
34
          tbody tr.odd td.label {
 
35
            background: rgb(200,200,200);
 
36
          }
 
37
          
 
38
          thead, tfoot {
 
39
            background: rgb(60,60,60);
 
40
            color: white;
 
41
            font-weight: bold;
 
42
          }
 
43
 
 
44
          tr td.perfect {
 
45
            background: rgb(0,255,0);
 
46
            color: black;
 
47
          }
 
48
          tr td.excellant {
 
49
            background: rgb(140,255,140);
 
50
            color: black;
 
51
          }
 
52
          tr td.good {
 
53
            background: rgb(160,255,0);
 
54
            color: black;
 
55
          }
 
56
          tr td.poor {
 
57
            background: rgb(255,160,0);
 
58
            color: black;
 
59
          }
 
60
          tr td.bad {
 
61
            background: rgb(255,140,140);
 
62
            color: black;
 
63
          }
 
64
          tr td.terrible {
 
65
            background: rgb(255,0,0);
 
66
            color: black;
 
67
          }
 
68
        </style>
 
69
      </head>
 
70
      <body>
 
71
        <h1>Coverage report</h1>
 
72
        <xsl:apply-templates/>
 
73
      </body>
 
74
    </html>
 
75
  </xsl:template>
 
76
 
 
77
  <xsl:template match="functions">
 
78
    <h2>Function coverage</h2>
 
79
    <xsl:call-template name="content">
 
80
      <xsl:with-param name="type" select="'function'"/>
 
81
    </xsl:call-template>
 
82
  </xsl:template>
 
83
  
 
84
 
 
85
  <xsl:template match="files">
 
86
    <h2>File coverage</h2>
 
87
    <xsl:call-template name="content">
 
88
      <xsl:with-param name="type" select="'file'"/>
 
89
    </xsl:call-template>
 
90
  </xsl:template>
 
91
 
 
92
  <xsl:template name="content">
 
93
    <xsl:param name="type"/>
 
94
    <table>
 
95
      <thead>
 
96
        <tr>
 
97
          <th>Name</th>
 
98
          <th>Lines</th>
 
99
          <th>Branches</th>
 
100
          <th>Conditions</th>
 
101
          <th>Calls</th>
 
102
        </tr>
 
103
      </thead>
 
104
      <tbody>
 
105
        <xsl:for-each select="entry">
 
106
          <xsl:call-template name="entry">
 
107
            <xsl:with-param name="type" select="$type"/>
 
108
            <xsl:with-param name="class">
 
109
              <xsl:choose>
 
110
                <xsl:when test="position() mod 2">
 
111
                  <xsl:text>odd</xsl:text>
 
112
                </xsl:when>
 
113
                <xsl:otherwise>
 
114
                  <xsl:text>even</xsl:text>
 
115
                </xsl:otherwise>
 
116
              </xsl:choose>
 
117
            </xsl:with-param>
 
118
          </xsl:call-template>
 
119
        </xsl:for-each>
 
120
      </tbody>
 
121
      <tfoot>
 
122
        <xsl:for-each select="summary">
 
123
          <xsl:call-template name="entry">
 
124
            <xsl:with-param name="type" select="'summary'"/>
 
125
            <xsl:with-param name="class">
 
126
              <xsl:choose>
 
127
                <xsl:when test="position() mod 2">
 
128
                  <xsl:text>odd</xsl:text>
 
129
                </xsl:when>
 
130
                <xsl:otherwise>
 
131
                  <xsl:text>even</xsl:text>
 
132
                </xsl:otherwise>
 
133
              </xsl:choose>
 
134
            </xsl:with-param>
 
135
          </xsl:call-template>
 
136
        </xsl:for-each>
 
137
      </tfoot>
 
138
    </table>
 
139
  </xsl:template>
 
140
  
 
141
  <xsl:template name="entry">
 
142
    <xsl:param name="type"/>
 
143
    <xsl:param name="class"/>
 
144
    <tr class="{$class}">
 
145
      <xsl:choose>
 
146
        <xsl:when test="$type = 'function'">
 
147
          <td class="label"><a href="{@details}.html#{@name}"><xsl:value-of select="@name"/></a></td>
 
148
        </xsl:when>
 
149
        <xsl:when test="$type = 'file'">
 
150
          <td class="label"><a href="{@details}.html"><xsl:value-of select="@name"/></a></td>
 
151
        </xsl:when>
 
152
        <xsl:otherwise>
 
153
          <td class="label">Summary</td>
 
154
        </xsl:otherwise>
 
155
      </xsl:choose>
 
156
 
 
157
      <xsl:if test="count(lines)">
 
158
        <xsl:apply-templates select="lines"/>
 
159
      </xsl:if>
 
160
      <xsl:if test="not(count(lines))">
 
161
        <xsl:call-template name="missing"/>
 
162
      </xsl:if>
 
163
 
 
164
      <xsl:if test="count(branches)">
 
165
        <xsl:apply-templates select="branches"/>
 
166
      </xsl:if>
 
167
      <xsl:if test="not(count(branches))">
 
168
        <xsl:call-template name="missing"/>
 
169
      </xsl:if>
 
170
 
 
171
      <xsl:if test="count(conditions)">
 
172
        <xsl:apply-templates select="conditions"/>
 
173
      </xsl:if>
 
174
      <xsl:if test="not(count(conditions))">
 
175
        <xsl:call-template name="missing"/>
 
176
      </xsl:if>
 
177
 
 
178
      <xsl:if test="count(calls)">
 
179
        <xsl:apply-templates select="calls"/>
 
180
      </xsl:if>
 
181
      <xsl:if test="not(count(calls))">
 
182
        <xsl:call-template name="missing"/>
 
183
      </xsl:if>
 
184
 
 
185
    </tr>
 
186
  </xsl:template>
 
187
  
 
188
  <xsl:template match="lines">
 
189
    <xsl:call-template name="row"/>
 
190
  </xsl:template>
 
191
 
 
192
  <xsl:template match="branches">
 
193
    <xsl:call-template name="row"/>
 
194
  </xsl:template>
 
195
 
 
196
  <xsl:template match="conditions">
 
197
    <xsl:call-template name="row"/>
 
198
  </xsl:template>
 
199
 
 
200
  <xsl:template match="calls">
 
201
    <xsl:call-template name="row"/>
 
202
  </xsl:template>
 
203
 
 
204
  <xsl:template name="missing">
 
205
    <td></td>
 
206
  </xsl:template>
 
207
 
 
208
  <xsl:template name="row">
 
209
    <xsl:variable name="quality">
 
210
      <xsl:choose>
 
211
        <xsl:when test="@coverage = 100">
 
212
          <xsl:text>perfect</xsl:text>
 
213
        </xsl:when>
 
214
        <xsl:when test="@coverage >= 80.0">
 
215
          <xsl:text>excellant</xsl:text>
 
216
        </xsl:when>
 
217
        <xsl:when test="@coverage >= 60.0">
 
218
          <xsl:text>good</xsl:text>
 
219
        </xsl:when>
 
220
        <xsl:when test="@coverage >= 40.0">
 
221
          <xsl:text>poor</xsl:text>
 
222
        </xsl:when>
 
223
        <xsl:when test="@coverage >= 20.0">
 
224
          <xsl:text>bad</xsl:text>
 
225
        </xsl:when>
 
226
        <xsl:otherwise>
 
227
          <xsl:text>terrible</xsl:text>
 
228
        </xsl:otherwise>
 
229
      </xsl:choose>
 
230
    </xsl:variable>
 
231
    
 
232
    <td class="{$quality}"><xsl:value-of select="@coverage"/>% of <xsl:value-of select="@count"/></td>
 
233
  </xsl:template>
 
234
 
 
235
</xsl:stylesheet>