diff --git a/mozilla/webtools/testopia/.bzrrev b/mozilla/webtools/testopia/.bzrrev index 8a2602231b5..6e1d38407b4 100644 --- a/mozilla/webtools/testopia/.bzrrev +++ b/mozilla/webtools/testopia/.bzrrev @@ -1 +1 @@ -686 \ No newline at end of file +687 \ No newline at end of file diff --git a/mozilla/webtools/testopia/.gitrev b/mozilla/webtools/testopia/.gitrev index 54ffcef318b..5fc89009bc6 100644 --- a/mozilla/webtools/testopia/.gitrev +++ b/mozilla/webtools/testopia/.gitrev @@ -1 +1 @@ -f1c2c3a9c4b0518f3b14eacea0abdfb84dddbdad \ No newline at end of file +99bbb3f4da35fd72b08573e956f3eddff4cab32e \ No newline at end of file diff --git a/mozilla/webtools/testopia/extensions/Testopia/Extension.pm b/mozilla/webtools/testopia/extensions/Testopia/Extension.pm index 665a229c401..b7183fb1300 100644 --- a/mozilla/webtools/testopia/extensions/Testopia/Extension.pm +++ b/mozilla/webtools/testopia/extensions/Testopia/Extension.pm @@ -347,6 +347,10 @@ sub page_before_template { require Bugzilla::Extension::Testopia::Admin; Bugzilla::Extension::Testopia::Admin::report($vars); } + elsif ($page eq 'tr_case_reports.html') { + require Bugzilla::Extension::Testopia::Reports::Case; + Bugzilla::Extension::Testopia::Reports::Case::report($vars); + } } sub post_bug_after_creation { diff --git a/mozilla/webtools/testopia/extensions/Testopia/contrib/drivers/php/.xmlrpc.inc.php b/mozilla/webtools/testopia/extensions/Testopia/contrib/drivers/php/.xmlrpc.inc.php index f8e9f3d9c74..99b80b98cd7 100644 --- a/mozilla/webtools/testopia/extensions/Testopia/contrib/drivers/php/.xmlrpc.inc.php +++ b/mozilla/webtools/testopia/extensions/Testopia/contrib/drivers/php/.xmlrpc.inc.php @@ -1,7 +1,7 @@ -// $Id: .xmlrpc.inc.php,v 1.49 2015-03-15 14:30:16 bzrmirror%bugzilla.org Exp $ +// $Id: .xmlrpc.inc.php,v 1.50 2015-03-15 15:00:19 bzrmirror%bugzilla.org Exp $ // Copyright (c) 1999,2000,2002 Edd Dumbill. // All rights reserved. diff --git a/mozilla/webtools/testopia/extensions/Testopia/js/search.js b/mozilla/webtools/testopia/extensions/Testopia/js/search.js index ae2b8355eb3..3e2ec0f19a5 100644 --- a/mozilla/webtools/testopia/extensions/Testopia/js/search.js +++ b/mozilla/webtools/testopia/extensions/Testopia/js/search.js @@ -341,6 +341,7 @@ Testopia.Search.CasesForm = function(params){ } catch(err){} if (params.report){ + values.id = 'tr_case_reports.html'; Ext.getCmp('object_panel').add(new Ext.Panel({ id: 'case_search' + searchnum, closable: true, @@ -348,7 +349,7 @@ Testopia.Search.CasesForm = function(params){ autoScroll: true, listeners: { 'render': function(){ this.load({ - url: 'tr_case_reports.cgi', + url: 'page.cgi', params: values }); }}, diff --git a/mozilla/webtools/testopia/extensions/Testopia/lib/Report.pm b/mozilla/webtools/testopia/extensions/Testopia/lib/Report.pm index a9b866dbf57..4fa671d76ac 100644 --- a/mozilla/webtools/testopia/extensions/Testopia/lib/Report.pm +++ b/mozilla/webtools/testopia/extensions/Testopia/lib/Report.pm @@ -310,7 +310,7 @@ sub init { $self->{'data'} = \%data; $self->{'image_data'} = \@image_data; - $self->{'report_loc'} = "tr_" . $type . "_reports.cgi"; + $self->{'report_loc'} = "page.cgi?id=tr_" . $type . "_reports.html"; if ($cgi->param('debug')) { print $cgi->header; require Data::Dumper; diff --git a/mozilla/webtools/testopia/extensions/Testopia/lib/Reports/Case.pm b/mozilla/webtools/testopia/extensions/Testopia/lib/Reports/Case.pm new file mode 100644 index 00000000000..bead483fecf --- /dev/null +++ b/mozilla/webtools/testopia/extensions/Testopia/lib/Reports/Case.pm @@ -0,0 +1,127 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +package Bugzilla::Extension::Testopia::Reports::Case; + +use strict; +use warnings; + +use Bugzilla::Constants; +use Bugzilla::Error; +use Bugzilla::Util; + +use Bugzilla::Extension::Testopia::Report; +use Bugzilla::Extension::Testopia::TestCase; +use Bugzilla::Extension::Testopia::TestCaseRun; + +sub report { + my ($vars) = @_; + my $input = Bugzilla->input_params; + my $template = Bugzilla->template; + my $cgi = Bugzilla->cgi; + + Bugzilla->login(LOGIN_REQUIRED); + + my $type = $input->{'type'} || ''; + + if ($type eq 'status-breakdown') { + my $case_id = trim($input->{'case_id'} || ''); + + unless ($case_id) { + print $cgi->header; + $vars->{'form_action'} = 'page.cgi?id=tr_case_reports.html'; + $template->process("testopia/case/choose.html.tmpl", $vars) + || ThrowTemplateError($template->error()); + exit; + } + validate_test_id($case_id, 'case'); + + my $case = Bugzilla::Extension::Testopia::TestCase->new($case_id); + return unless $case->canview; + + my @data; + my $caserun = Bugzilla::Extension::Testopia::TestCaseRun->new({}); + + my @names; + my @values; + foreach my $status (@{$caserun->get_status_list}) { + push @names, $status->{'name'}; + push @values, $case->get_caserun_count($status->{'id'}); + } + push @data, \@names; + push @data, \@values; + + $vars->{'width'} = 200; + $vars->{'height'} = 150; + $vars->{'data'} = \@data; + $vars->{'chart_title'} = 'Historic Status Breakdown'; + $vars->{'colors'} = (['#858aef', '#56e871', '#ed3f58', '#b8eae1', '#f1d9ab', '#e17a56']); + print $cgi->header; + $template->process("testopia/reports/report-pie.png.tmpl", $vars) + || ThrowTemplateError($template->error()); + } + + else { + $input->{'current_tab'} = 'case'; + $input->{'viewall'} = 1; + ### FIXME - tr_list_cases.cgi must be replaced by new code. + my $report = Bugzilla::Extension::Testopia::Report->new('case', 'tr_list_cases.cgi', $cgi); + $vars->{'report'} = $report; + $vars->{'qname'} = $input->{'qname'}; + + ### From Bugzilla report.cgi by Gervase Markham + my $formatparam = $input->{'format'}; + my $report_action = $input->{'report_action'}; + if ($report_action eq "data") { + # So which template are we using? If action is "wrap", we will be using + # no format (it gets passed through to be the format of the actual data), + # and either report.csv.tmpl (CSV), or report.html.tmpl (everything else). + # report.html.tmpl produces an HTML framework for either tables of HTML + # data, or images generated by calling report.cgi again with action as + # "plot". + $formatparam =~ s/[^a-zA-Z\-]//g; + trick_taint($formatparam); + $vars->{'format'} = $formatparam; + $formatparam = ''; + } + elsif ($report_action eq "plot") { + # If action is "plot", we will be using a format as normal (pie, bar etc.) + # and a ctype as normal (currently only png.) + $vars->{'cumulate'} = $input->{'cumulate'} ? 1 : 0; + $vars->{'x_labels_vertical'} = $input->{'x_labels_vertical'} ? 1 : 0; + $vars->{'data'} = $report->{'image_data'}; + } + else { + ThrowUserError("unknown_action", {action => $input->{'report_action'}}); + } + + my $format = $template->get_format("testopia/reports/report", $formatparam, + scalar($input->{'ctype'})); + + my @time = localtime(time()); + my $date = sprintf "%04d-%02d-%02d", 1900+$time[5],$time[4]+1,$time[3]; + my $filename = "report-" . $date . ".$format->{extension}"; + + my $disp = "inline"; + # We set CSV files to be downloaded, as they are designed for importing + # into other programs. + if ( $format->{'extension'} eq "csv" || $format->{'extension'} eq "xml" ) { + $disp = "attachment"; + } + + print $cgi->header( -type => $format->{'ctype'}, + -content_disposition => "$disp; filename=$filename"); + + $vars->{'time'} = $date; + $template->process("$format->{'template'}", $vars) + || ThrowTemplateError($template->error()); + + exit; + } +} + +1; diff --git a/mozilla/webtools/testopia/extensions/Testopia/template/en/default/pages/tr_case_reports.html.tmpl b/mozilla/webtools/testopia/extensions/Testopia/template/en/default/pages/tr_case_reports.html.tmpl new file mode 100644 index 00000000000..bcb75107df8 --- /dev/null +++ b/mozilla/webtools/testopia/extensions/Testopia/template/en/default/pages/tr_case_reports.html.tmpl @@ -0,0 +1,7 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] diff --git a/mozilla/webtools/testopia/extensions/Testopia/template/en/default/testopia/case/show.print.tmpl b/mozilla/webtools/testopia/extensions/Testopia/template/en/default/testopia/case/show.print.tmpl index 94bd7039757..902fd58cbc1 100644 --- a/mozilla/webtools/testopia/extensions/Testopia/template/en/default/testopia/case/show.print.tmpl +++ b/mozilla/webtools/testopia/extensions/Testopia/template/en/default/testopia/case/show.print.tmpl @@ -21,7 +21,7 @@ Test Case [% case.id FILTER html %] - [% case.summary FILTER html %] - +

Test Case [% case.id FILTER html %] - [% case.summary FILTER html %]

@@ -85,7 +85,7 @@

Statistics

- +

Setup

[% case.text.setup FILTER html_light %] diff --git a/mozilla/webtools/testopia/extensions/Testopia/template/en/default/testopia/reports/report.html.tmpl b/mozilla/webtools/testopia/extensions/Testopia/template/en/default/testopia/reports/report.html.tmpl index 8f7b2882c0f..a64a3384e0d 100644 --- a/mozilla/webtools/testopia/extensions/Testopia/template/en/default/testopia/reports/report.html.tmpl +++ b/mozilla/webtools/testopia/extensions/Testopia/template/en/default/testopia/reports/report.html.tmpl @@ -109,8 +109,8 @@ diff --git a/mozilla/webtools/testopia/extensions/Testopia/template/en/default/testopia/search/case.html.tmpl b/mozilla/webtools/testopia/extensions/Testopia/template/en/default/testopia/search/case.html.tmpl index 875777ba2a1..35e0f443eb5 100644 --- a/mozilla/webtools/testopia/extensions/Testopia/template/en/default/testopia/search/case.html.tmpl +++ b/mozilla/webtools/testopia/extensions/Testopia/template/en/default/testopia/search/case.html.tmpl @@ -20,7 +20,8 @@ [% IF report %] - + + [% PROCESS "testopia/search/report-matrix.html.tmpl" obj = case %]
- [% formaturl = "$report.report_loc?$report.switchbase&width=$width&height=$height" _ - "&report_action=data" %] + [% formaturl = "$report.report_loc&$report.switchbase&width=$width&height=$height" _ + "&report_action=data" %] Export as CSV