• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" encoding="utf-8"?>
2<!--
3 * Copyright (C) 2010 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 -->
17
18<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
19<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
20    <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
21    <xsl:template match="/">
22        <html>
23            <head>
24                <script type="text/javascript">
25                    function toggleVisibility(id) {
26                        element = document.getElementById(id);
27                        if (element.style.display == "none") {
28                            element.style.display = "";
29                        } else {
30                            element.style.display = "none";
31                        }
32                    }
33                </script>
34                <style type="text/css">
35                    body {
36                        background-color: #CCCCCC;
37                        font-family: sans-serif;
38                        margin: 10px;
39                    }
40
41                    .info {
42                        margin-bottom: 10px;
43                    }
44
45                    .apks, .package, .class {
46                        cursor: pointer;
47                        text-decoration: underline;
48                    }
49
50                    .packageDetails {
51                        padding-left: 20px;
52                    }
53
54                    .classDetails {
55                        padding-left: 40px;
56                    }
57
58                    .method {
59                        font-family: courier;
60                        white-space: nowrap;
61                    }
62
63                    .red {
64                        background-color: #FF0000;
65                    }
66
67                    .yellow {
68                        background-color: #FFFF00;
69                    }
70
71                    .green {
72                        background-color: #00FF00;
73                    }
74                </style>
75            </head>
76            <body>
77                <h1>CTS API Coverage</h1>
78                <div class="info">
79                    Generated: <xsl:value-of select="api-coverage/@generatedTime" />
80                </div>
81                <div class="apks" onclick="toggleVisibility('sourceApks')">
82                    Source APKs (<xsl:value-of select="count(api-coverage/debug/sources/apk)" />)
83                </div>
84                <div id="sourceApks" style="display: none">
85                    <ul>
86                        <xsl:for-each select="api-coverage/debug/sources/apk">
87                            <li><xsl:value-of select="@path" /></li>
88                        </xsl:for-each>
89                    </ul>
90                </div>
91                <ul>
92                    <xsl:for-each select="api-coverage/api/package">
93                        <xsl:call-template name="packageOrClassListItem">
94                            <xsl:with-param name="bulletClass" select="'package'" />
95                        </xsl:call-template>
96                        <div class="packageDetails" id="{@name}" style="display: none">
97                            <ul>
98                                <xsl:for-each select="class">
99                                    <xsl:call-template name="packageOrClassListItem">
100                                        <xsl:with-param name="bulletClass" select="'class'" />
101                                    </xsl:call-template>
102                                    <div class="classDetails" id="{@name}" style="display: none">
103                                        <xsl:for-each select="constructor">
104                                            <xsl:call-template name="methodListItem" />
105                                        </xsl:for-each>
106                                        <xsl:for-each select="method">
107                                            <xsl:call-template name="methodListItem" />
108                                        </xsl:for-each>
109                                    </div>
110                                </xsl:for-each>
111                            </ul>
112                        </div>
113                    </xsl:for-each>
114                </ul>
115            </body>
116        </html>
117    </xsl:template>
118
119    <xsl:template name="packageOrClassListItem">
120        <xsl:param name="bulletClass" />
121
122        <xsl:variable name="colorClass">
123            <xsl:choose>
124                <xsl:when test="@coveragePercentage &lt;= 50">red</xsl:when>
125                <xsl:when test="@coveragePercentage &lt;= 80">yellow</xsl:when>
126                <xsl:otherwise>green</xsl:otherwise>
127            </xsl:choose>
128        </xsl:variable>
129
130        <li class="{$bulletClass}" onclick="toggleVisibility('{@name}')">
131            <span class="{$colorClass}">
132                <b><xsl:value-of select="@name" /></b>
133                &nbsp;<xsl:value-of select="@coveragePercentage" />%
134                &nbsp;(<xsl:value-of select="@numCovered" />/<xsl:value-of select="@numTotal" />)
135            </span>
136        </li>
137    </xsl:template>
138
139  <xsl:template name="methodListItem">
140    <span class="method">
141      <xsl:choose>
142        <xsl:when test="@covered = 'true'">[X]</xsl:when>
143        <xsl:otherwise>[ ]</xsl:otherwise>
144      </xsl:choose>
145      <xsl:if test="@returnType != ''">&nbsp;<xsl:value-of select="@returnType" /></xsl:if>
146      <b>&nbsp;<xsl:value-of select="@name" /></b><xsl:call-template name="formatParameters" />
147    </span>
148    <br />
149  </xsl:template>
150
151  <xsl:template name="formatParameters">(<xsl:for-each select="parameter">
152      <xsl:value-of select="@type" />
153      <xsl:if test="not(position() = last())">,&nbsp;</xsl:if>
154    </xsl:for-each>)
155  </xsl:template>
156
157</xsl:stylesheet>
158
159