# -*- coding: utf-8 -*-
# $Id$
"""
Test Manager WUI - Graph Wizard
"""
__copyright__ = \
"""
Copyright (C) 2012-2014 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
General Public License (GPL) as published by the Free Software
Foundation, in version 2 as it comes in the "COPYING" file of the
VirtualBox OSE distribution. VirtualBox OSE is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
The contents of this file may alternatively be used under the terms
of the Common Development and Distribution License Version 1.0
(CDDL) only, as it comes in the "COPYING.CDDL" file of the
VirtualBox OSE distribution, in which case the provisions of the
CDDL are applicable instead of those of the GPL.
You may elect to license modified versions of this file under the
terms and conditions of either the GPL or the CDDL or both.
"""
# Python imports.
import functools;
# Validation Kit imports.
"""Construct a graph for analyzing test results (values) across builds and testboxes."""
## @name Series name parts.
## @{
## @}
WuiReportBase.__init__(self, oModel, dParams, fSubReport = fSubReport, fnDPrint = fnDPrint, oDisp = oDisp);
# Select graph implementation.
else:
#
""" Figures out the method (bitmask) to use when naming series. """
return WuiGraphWiz.kfSeriesName_TestBox;
# Start with all and drop unnecessary specs one-by-one.
else:
if [oSrs.oBuildCategory.sProduct for oSrs in aoSeries].count(aoSeries[0].oBuildCategory.sProduct) == len(aoSeries):
if [oSrs.oBuildCategory.sBranch for oSrs in aoSeries].count(aoSeries[0].oBuildCategory.sBranch) == len(aoSeries):
if [oSrs.oBuildCategory.sType for oSrs in aoSeries].count(aoSeries[0].oBuildCategory.sType) == len(aoSeries):
# Complicated.
daTestBoxes = {};
else:
break;
else:
return fRet;
""" Creates a series name from bits (kfSeriesName_xxx). """
assert fBits != 0;
sName = '';
if oSeries.idTestCaseArgs is not None:
else:
return sName;
""" Constructs a name for the graph. """
);
sName += sSampleName;
return sName;
""" Constructs a name for a sample source (collection). """
if oCollection.sValue is not None:
else:
sTestName = ', '.join(oCollection.asTests if len(oCollection.asTests[0]) else oCollection.asTests[1:]);
if sTestName == '':
# Use the testcase name if there is only one for all series.
return asSampleName[0];
return asSampleName[0];
"""
Splits the data series (ReportGraphModel.DataSeries) into one or more graphs.
Returns an array of data series arrays.
"""
# Must be at least two series for something to be splittable.
return [];
return [aoSeries,];
# Split on unit.
dUnitSeries = dict();
# Sort the per-unit series since the build category was only sorted by ID.
for iUnit in dUnitSeries:
""" __cmp__ like function. """
if iCmp != 0:
return iCmp;
if iCmp != 0:
return iCmp;
if iCmp != 0:
return iCmp;
if iCmp != 0:
return iCmp;
return 0;
# Split the per-unit series up if necessary.
aaoRet = [];
for iUnit in dUnitSeries:
return aaoRet;
"""
Configures oGraph according to user parameters and other config settings.
Returns oGraph.
"""
return oGraph;
"""
Generates the HTML for the interactive form.
Returns (sTopOfForm, sEndOfForm)
"""
#
# The top of the form.
#
sTop = '<form action="#" method="get" id="graphwiz-form">\n' \
' <input type="hidden" name="%s" value="%s"/>\n' \
' <input type="hidden" name="%s" value="%u"/>\n' \
);
sTop += ' <div id="graphwiz-nav">\n';
sTop += ' <script type="text/javascript">\n' \
' window.onresize = function(){ return graphwizOnResizeRecalcWidth("graphwiz-nav", "%s"); }\n' \
' window.onload = function(){ return graphwizOnLoadRememberWidth("graphwiz-nav"); }\n' \
' </script>\n' \
% ( WuiMain.ksParamGraphWizWidth, );
#
# Top: First row.
#
sTop += ' <div id="graphwiz-top-1">\n';
# time.
sTop += ' <div id="graphwiz-time">\n';
sTop += ' <label for="%s">Starting:</label>\n' \
' <input type="text" name="%s" id="%s" value="%s" class="graphwiz-time-input"/>\n' \
sTop += ' <label for="%s"> Going back:\n' \
' <input type="text" name="%s" id="%s" value="%s" class="graphwiz-period-input"/>\n' \
sTop += ' </div>\n';
# Graph options top row.
sTop += ' <div id="graphwiz-top-options-1">\n';
# graph type.
sTop += ' <label for="%s">Graph:</label>\n' \
' <select name="%s" id="%s">\n' \
sTop += ' <option value="%s"%s>%s</option>\n' \
sTop += ' </select>\n';
# graph size.
sTop += ' <label for="%s">Graph size:</label>\n' \
' <input type="text" name="%s" id="%s" value="%s" class="graphwiz-pixel-input"> x\n' \
' <input type="text" name="%s" id="%s" value="%s" class="graphwiz-pixel-input">\n' \
' <label for="%s">Dpi:</label>'\
' <input type="text" name="%s" id="%s" value="%s" class="graphwiz-dpi-input">\n' \
' <button type="button" onclick="%s">Defaults</button>\n' \
WuiMain.ksParamGraphWizWidth, WuiMain.ksParamGraphWizWidth, self._dParams[WuiMain.ksParamGraphWizWidth],
WuiMain.ksParamGraphWizHeight, WuiMain.ksParamGraphWizHeight, self._dParams[WuiMain.ksParamGraphWizHeight],
);
#
# Top: Second row.
#
sTop += ' <div id="graphwiz-top-2">\n';
# Submit
sFormButton = '<button type="submit">Refresh</button>\n';
# Options.
sTop += ' <div id="graphwiz-top-options-2">\n';
sTop += ' <input type="checkbox" name="%s" id="%s" value="1"%s/>\n' \
' <label for="%s">Tabular data</label>\n' \
sTop += ' <input type="checkbox" name="%s" id="%s" value="1"%s/>\n' \
' <label for="%s">xkcd-style</label>\n' \
sTop += ' <input type="hidden" name="%s" id="%s" value="1"/>\n' \
sTop += ' <input type="checkbox" name="%s" id="%s" value="1"%s title="%s"/>\n' \
' <label for="%s">Error bars,</label>\n' \
' <label for="%s">max: </label>\n' \
' <input type="text" name="%s" id="%s" value="%s" class="graphwiz-maxerrorbar-input" title="%s"/>\n' \
'Error bars shows some of the max and min results on the Y-axis.',
'Maximum number of Y-axis error bar per graph. (Too many makes it unreadable.)'
);
else:
sTop += '<input type="hidden" name="%s" id="%s" value="1">\n' \
sTop += '<input type="hidden" name="%s" id="%s" value="%u">\n' \
sTop += ' <label for="%s">Font size: </label>\n' \
' <input type="text" name="%s" id="%s" value="%s" class="graphwiz-fontsize-input"/>\n' \
sTop += ' <label for="%s">Data series: </label>\n' \
' <input type="text" name="%s" id="%s" value="%s" class="graphwiz-maxpergraph-input" title="%s"/>\n' \
'Max data series per graph.' );
#
# The end of the page selection.
#
sEnd = ' <div id="graphwiz-end-selection">\n';
#
# Testbox selection
#
sEnd += ' <div id="graphwiz-testboxes" class="graphwiz-end-selection-group">\n' \
' <h3>TestBox Selection:</h3>\n' \
' <ol class="tmgraph-testboxes">\n';
# Get a list of eligible testboxes from the DB.
except: sChecked = '';
else: sChecked = ' checked';
sEnd += ' <li><input type="checkbox" name="%s" value="%s" id="gw-tb-%u"%s/>' \
'<label for="gw-tb-%u">%s</label></li>\n' \
# List testboxes that have been checked in a different period or something.
for idTestBox in aidTestBoxes:
sEnd += ' <li><input type="checkbox" name="%s" value="%s" id="gw-tb-%u" checked/>' \
'<label for="gw-tb-%u">%s</label></li>\n' \
sEnd += ' </ol>\n' \
' </div>\n';
#
# Build category selection.
#
sEnd += ' <div id="graphwiz-buildcategories" class="graphwiz-end-selection-group">\n' \
' <h3>Build Category Selection:</h3>\n' \
' <ol class="tmgraph-buildcategories">\n';
except: sChecked = '';
else: sChecked = ' checked';
sEnd += ' <li><input type="checkbox" name="%s" value="%s" id="gw-bc-%u" %s/>' \
'<label for="gw-bc-%u">%s / %s / %s / %s</label></li>\n' \
% ( WuiMain.ksParamGraphWizBuildCatIds, oBuildCat.idBuildCategory, oBuildCat.idBuildCategory, sChecked,
sEnd += ' </ol>\n' \
' </div>\n';
#
# Testcase variations.
#
sEnd += ' <div id="graphwiz-testcase-variations" class="graphwiz-end-selection-group">\n' \
' <h3>Miscellaneous:</h3>\n' \
' <ol>';
sEnd += ' <li>\n' \
' <input type="checkbox" id="%s" name="%s" value="1"%s/>\n' \
' <label for="%s">Separate by testcase variation.</label>\n' \
' </li>\n' \
sEnd += ' <li>\n' \
' <lable for="%s">Test case ID:</label>\n' \
' <input type="text" id="%s" name="%s" value="%s" readonly/>\n' \
' </li>\n' \
sEnd += ' </ol>\n' \
' </div>\n';
#sEnd += ' <h3> </h3>\n';
#
# Finish up the form.
#
sEnd += ' </div>\n' \
'</form>\n';
# Quick mockup.
sHtml = '';
sHtml += '<h2>Incomplete code - no complaints yet, thank you!!</h2>\n';
#
# Create a form for altering the data we're working with.
#
if fInteractive:
sHtml += sTopOfForm;
del sTopOfForm;
#
# Emit the graphs. At least one per sample source.
#
sHtml += ' <div id="graphwiz-graphs">\n';
iGraph = 0;
# Name the graph and add a checkbox for removing it.
if fInteractive:
sHtml += ' <div class="graphwiz-src-select">\n' \
' <input type="checkbox" name="%s" id="%s" value="%s:%s%s" checked class="graphwiz-src-input">\n' \
' <label for="%s">%s</label>\n' \
' </div>\n' \
#
# Split the series into sub-graphs as needed and produce SVGs.
#
# Gather the data for this graph. (Most big stuff is passed by
# reference, so there shouldn't be any large memory penalty for
# repacking the data here.)
sYUnit = None;
asHtmlTooltips = None;
asHtmlTooltips = [];
sPlusMinus = '';
sPlusMinus = ' (+%s/-%s; %u samples)' \
sTooltip = '<table class=\'graphwiz-tt\'><tr><td>%s:</td><td>%s %s %s</td></tr>'\
'<tr><td>Rev:</td><td>r%s</td></tr>' \
% ( sSeriesName,
oSeries.aiRevisions[i],
);
#if sMsg.find('\n') >= 0:
# sMsg = sMsg[:sMsg.find('\n')].strip();
sTooltip += '<tr><td>Author:</td><td>%s</td></tr>' \
'<tr><td>Date:</td><td>%s</td><tr>' \
'<tr><td>Message:</td><td>%s%s</td></tr>' \
sTooltip += '</table>';
# Render the data into a graph.
sHtml += '\n </div>\n';
iGraph += 1;
#
# Emit raw tabular data if requested.
#
sHtml += ' <div class="graphwiz-tab-div" id="graphwiz-tab-%u">\n' \
' <table class="tmtable graphwiz-tab">\n' \
% (iCollection, );
else:
sHtml += '<thead class="tmheader">\n' \
' <tr class="graphwiz-tab graphwiz-tab-new-series-row">\n' \
' <th colspan="5"><span style="background-color:%s;"> </span> %s</th>\n' \
' </tr>\n' \
' <tr class="graphwiz-tab graphwiz-tab-col-hdr-row">\n' \
' <th>Revision</th><th>Value (%s)</th><th>Δmax</th><th>Δmin</th>' \
'<th>Samples</th>\n' \
' </tr>\n' \
'</thead>\n' \
% ( sColor,
sUnit );
sHtml += ' <tr class="%s"><td>r%s</td><td>%s</td><td>+%s</td><td>-%s</td><td>%s</td></tr>\n' \
% ( 'tmodd' if i & 1 else 'tmeven',
sHtml += ' </table>\n' \
' </div>\n';
else:
sHtml += '<i>No results.</i>\n';
sHtml += ' </div>\n'
sHtml += ' </div>\n';
#
# Finish the form.
#
if fInteractive:
sHtml += sEndOfForm;
return sHtml;