Skip to content
Browse files

Support for clipboard (context menu within Test panel). (1) Copy: cop…

…y clicked result message into the clipboard, (2) Copy All: copy all messages including summary into the clipboard.
  • Loading branch information...
1 parent 58d0714 commit a9bd7e85b25a5fcf1fcdce60072e96176b1a8a67 @janodvarko janodvarko committed Dec 29, 2008
Showing with 61 additions and 5 deletions.
  1. +56 −3 chrome/content/fireunit/fireunit.js
  2. +5 −2 chrome/locale/en-US/fireunit.properties
View
59 chrome/content/fireunit/fireunit.js
@@ -467,6 +467,14 @@ FireUnitPanel.prototype = extend(Firebug.Panel,
var row = Firebug.FireUnitModule.TestResultRep.resultTag.insertRows(
{results: queueResults}, tbody.lastChild ? tbody.lastChild : tbody)[0];
+ for (var i = 0; i < queueResults.length; ++i)
+ {
+ var result = queueResults[i];
+ row.repObject = result;
+ result.row = row;
+ row = row.nextSibling;
+ }
+
scrollToBottom(this.panelNode);
},
@@ -627,18 +635,32 @@ Firebug.FireUnitModule.TestResultRep = domplate(Firebug.Rep,
{
return testResult;
},
-
+
getContextMenuItems: function(testResult, target, context)
{
// xxxHonza: The "copy" command shouldn't be there for now.
var popup = $("fbContextMenu");
FBL.eraseNode(popup);
var items = [];
-
+
if (testResult.stack)
{
items.push({
+ label: $FU_STR("fireunit.item.Copy"),
+ nol10n: true,
+ command: bindFixed(this.onCopy, this, testResult)
+ });
+
+ items.push({
+ label: $FU_STR("fireunit.item.Copy_All"),
+ nol10n: true,
+ command: bindFixed(this.onCopyAll, this, testResult)
+ });
+
+ items.push("-");
+
+ items.push({
label: $FU_STR("fireunit.item.View_Source"),
nol10n: true,
command: bindFixed(this.onViewSource, this, testResult)
@@ -647,14 +669,45 @@ Firebug.FireUnitModule.TestResultRep = domplate(Firebug.Rep,
return items;
},
-
+
// Context menu commands
onViewSource: function(testResult)
{
var stackFrame = testResult.stack[0];
FirebugContext.chrome.select(new SourceLink(stackFrame.fileName,
stackFrame.lineNumber, "js"));
},
+
+ onCopy: function(testResult)
+ {
+ copyToClipboard(testResult.msg);
+ },
+
+ onCopyAll: function(testResult)
+ {
+ var row = testResult.row;
+ var tbody = getAncestorByClass(testResult.row, "testTable").firstChild;
+ var passLabel = $FU_STR("fireunit.label.Pass");
+ var failLabel = $FU_STR("fireunit.label.Fail");
+
+ var text = "";
+ for (var row = tbody.firstChild; row; row = row.nextSibling) {
+ if (hasClass(row, "testResultRow") && row.repObject) {
+ text += (hasClass(row, "testError") ? failLabel : passLabel);
+ text += ": " + row.repObject.msg;
+ text += ", " + row.repObject.fileName + "\n";
+ }
+ }
+
+ var summary = getElementByClass(tbody, "testResultSummaryRow");
+ if (summary) {
+ summary = summary.firstChild;
+ text += summary.childNodes[0].textContent + ", " +
+ summary.childNodes[1].textContent;
+ }
+
+ copyToClipboard(text);
+ },
});
//-----------------------------------------------------------------------------
View
7 chrome/locale/en-US/fireunit.properties
@@ -1,6 +1,5 @@
fireunit.panel.Test=Test
fireunit.tab.Stack=Test Location
-fireunit.test.line=Line
fireunit.tab.Compare=Compare
fireunit.title.Expected=Expected Result
fireunit.title.Result=Actual Result
@@ -10,4 +9,8 @@ fireunit.switch.pretty_print=pretty print
fireunit.option.Passing_Tests=Passing Tests
fireunit.option.Failing_Tests=Failing Tests
fireunit.item.View_Source=View Source
-fireunit.test.Line=Line
+fireunit.item.Copy=Copy
+fireunit.item.Copy_All=Copy All
+fireunit.test.Line=Line
+fireunit.label.Pass=Pass
+fireunit.label.Fail=Fail

0 comments on commit a9bd7e8

Please sign in to comment.
Something went wrong with that request. Please try again.