diff --git a/src/TestCentric/testcentric.gui/Elements/MultiCheckedToolStripButtonGroupWithDefaultButton.cs b/src/TestCentric/testcentric.gui/Elements/MultiCheckedToolStripButtonGroupWithDefaultButton.cs deleted file mode 100644 index 195748fb8..000000000 --- a/src/TestCentric/testcentric.gui/Elements/MultiCheckedToolStripButtonGroupWithDefaultButton.cs +++ /dev/null @@ -1,66 +0,0 @@ -// *********************************************************************** -// Copyright (c) Charlie Poole and TestCentric contributors. -// Licensed under the MIT License. See LICENSE file in root directory. -// *********************************************************************** - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Windows.Forms; - -namespace TestCentric.Gui.Elements -{ - /// - /// This class is a specialized class of class MultiCheckedToolStripButtonGroup - /// Therefore this class supports also the selection of multiple buttons. - /// But additionally there is one special default button that resets all other buttons when it is clicked. - /// - internal class MultiCheckedToolStripButtonGroupWithDefaultButton : MultiCheckedToolStripButtonGroup - { - public MultiCheckedToolStripButtonGroupWithDefaultButton(params ToolStripButton[] buttons) : base(buttons) - { - // By convention the default button is the first one in the list - DefaultButton = buttons.First(); - IndividualButtons = buttons.Skip(1); - - foreach (ToolStripButton button in ToolStripButtons) - button.CheckedChanged += OnButtonCheckedChanged; - - DefaultButton.Checked = true; - } - - private ToolStripButton DefaultButton { get; } - - private IEnumerable IndividualButtons { get; } - - protected override void OnButtonClicked(object sender, EventArgs e) - { - ToolStripButton clickedButton = sender as ToolStripButton; - if (clickedButton == DefaultButton) - DefaultButtonClicked(sender, e); - else - IndividualButtonClicked(sender, e); - - base.OnButtonClicked(sender, e); - } - - private void DefaultButtonClicked(object sender, EventArgs e) - { - foreach (ToolStripButton button in IndividualButtons) - button.Checked = false; - } - - private void IndividualButtonClicked(object sender, EventArgs e) - { - DefaultButton.Checked = false; - } - - private void OnButtonCheckedChanged(object sender, EventArgs e) - { - ToolStripButton button = sender as ToolStripButton; - var style = button.Checked ? FontStyle.Bold : FontStyle.Regular; - button.Font = new Font(button.Font, style); - } - } -} diff --git a/src/TestCentric/testcentric.gui/Images/FilterAllOutcomes.png b/src/TestCentric/testcentric.gui/Images/FilterAllOutcomes.png deleted file mode 100644 index 720aad93f..000000000 Binary files a/src/TestCentric/testcentric.gui/Images/FilterAllOutcomes.png and /dev/null differ diff --git a/src/TestCentric/testcentric.gui/Views/TestTreeView.Designer.cs b/src/TestCentric/testcentric.gui/Views/TestTreeView.Designer.cs index fba2ec38d..b09203f71 100644 --- a/src/TestCentric/testcentric.gui/Views/TestTreeView.Designer.cs +++ b/src/TestCentric/testcentric.gui/Views/TestTreeView.Designer.cs @@ -33,9 +33,9 @@ private void InitializeComponent() this.treeView = new System.Windows.Forms.TreeView(); this.filterToolStrip = new System.Windows.Forms.ToolStrip(); this.filterOutcomeLabel = new System.Windows.Forms.ToolStripLabel(); - this.filterOutcomeAllButton = new System.Windows.Forms.ToolStripButton(); this.filterOutcomePassedButton = new System.Windows.Forms.ToolStripButton(); this.filterOutcomeFailedButton = new System.Windows.Forms.ToolStripButton(); + this.filterOutcomeWarningButton = new System.Windows.Forms.ToolStripButton(); this.filterOutcomeNotRunButton = new System.Windows.Forms.ToolStripButton(); this.testTreeContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.runMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -73,17 +73,6 @@ private void InitializeComponent() this.filterOutcomeLabel.Size = new System.Drawing.Size(54, 29); this.filterOutcomeLabel.Text = "Filter:"; // - // filterOutcomeAllButton - // - this.filterOutcomeAllButton.Name = "filterOutcomeAllButton"; - this.filterOutcomeAllButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText; - this.filterOutcomeAllButton.Image = ((System.Drawing.Image)(resources.GetObject("FilterAllOutcomes.Image"))); - this.filterOutcomeAllButton.Size = new System.Drawing.Size(70, 29); - this.filterOutcomeAllButton.Text = "All"; - this.filterOutcomeAllButton.Tag = "All"; - this.filterOutcomeAllButton.ToolTipText = "Show tests with all outcomes"; - this.filterOutcomeAllButton.CheckOnClick = true; - // // filterOutcomePassedButton // this.filterOutcomePassedButton.Name = "filterOutcomePassedButton"; @@ -102,6 +91,15 @@ private void InitializeComponent() this.filterOutcomeFailedButton.ToolTipText = "Show all failed tests"; this.filterOutcomeFailedButton.CheckOnClick = true; // + // filterOutcomeWarningButton + // + this.filterOutcomeWarningButton.Name = "filterOutcomeWarningButton"; + this.filterOutcomeWarningButton.Size = new System.Drawing.Size(70, 29); + this.filterOutcomeWarningButton.Text = "Warning"; + this.filterOutcomeWarningButton.Tag = "Warning"; + this.filterOutcomeWarningButton.ToolTipText = "Show all inconclusive, skipped or ignored tests"; + this.filterOutcomeWarningButton.CheckOnClick = true; + // // filterOutcomeNotRunButton // this.filterOutcomeNotRunButton.Name = "filterOutcomeNotRunButton"; @@ -115,9 +113,9 @@ private void InitializeComponent() // this.filterToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.filterOutcomeLabel, - this.filterOutcomeAllButton, this.filterOutcomePassedButton, this.filterOutcomeFailedButton, + this.filterOutcomeWarningButton, this.filterOutcomeNotRunButton, }); this.filterToolStrip.Location = new System.Drawing.Point(0, 0); @@ -244,9 +242,9 @@ private void InitializeComponent() private System.Windows.Forms.ContextMenuStrip testTreeContextMenu; private System.Windows.Forms.ToolStrip filterToolStrip; private System.Windows.Forms.ToolStripLabel filterOutcomeLabel; - private System.Windows.Forms.ToolStripButton filterOutcomeAllButton; private System.Windows.Forms.ToolStripButton filterOutcomePassedButton; private System.Windows.Forms.ToolStripButton filterOutcomeFailedButton; + private System.Windows.Forms.ToolStripButton filterOutcomeWarningButton; private System.Windows.Forms.ToolStripButton filterOutcomeNotRunButton; private System.Windows.Forms.ToolStripMenuItem runMenuItem; private System.Windows.Forms.ToolStripMenuItem expandAllMenuItem; diff --git a/src/TestCentric/testcentric.gui/Views/TestTreeView.cs b/src/TestCentric/testcentric.gui/Views/TestTreeView.cs index 071a6174a..ceeb1d273 100644 --- a/src/TestCentric/testcentric.gui/Views/TestTreeView.cs +++ b/src/TestCentric/testcentric.gui/Views/TestTreeView.cs @@ -48,7 +48,7 @@ public TestTreeView() CollapseToFixturesCommand = new CommandMenuElement(collapseToFixturesMenuItem); TestPropertiesCommand = new CommandMenuElement(testPropertiesMenuItem); ViewAsXmlCommand = new CommandMenuElement(viewAsXmlMenuItem); - OutcomeFilter = new MultiCheckedToolStripButtonGroupWithDefaultButton(new[] { filterOutcomeAllButton, filterOutcomePassedButton, filterOutcomeFailedButton, filterOutcomeNotRunButton }); + OutcomeFilter = new MultiCheckedToolStripButtonGroup(new[] { filterOutcomePassedButton, filterOutcomeFailedButton, filterOutcomeWarningButton, filterOutcomeNotRunButton }); TreeView = treeView; LoadOutcomeFilterImages(); @@ -234,6 +234,7 @@ private void LoadOutcomeFilterImages() filterOutcomeFailedButton.Image = LoadAlternateImage("Failure", imageDir); filterOutcomePassedButton.Image = LoadAlternateImage("Success", imageDir); + filterOutcomeWarningButton.Image = LoadAlternateImage("Ignored", imageDir); filterOutcomeNotRunButton.Image = LoadAlternateImage("Skipped", imageDir); } diff --git a/src/TestCentric/testcentric.gui/Views/TestTreeView.resx b/src/TestCentric/testcentric.gui/Views/TestTreeView.resx index 00891befc..0aa245e42 100644 --- a/src/TestCentric/testcentric.gui/Views/TestTreeView.resx +++ b/src/TestCentric/testcentric.gui/Views/TestTreeView.resx @@ -129,7 +129,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAB+ - DQAAAk1TRnQBSQFMAgEBBQEAAVABBQFUAQUBEAEAARABAAT/AQkBEAj/AUIBTQE2AQQGAAE2AQQCAAEo + DQAAAk1TRnQBSQFMAgEBBQEAAVABBQFYAQUBEAEAARABAAT/AQkBEAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA @@ -189,8 +189,4 @@ AeABAQIAAfABDwHwAQ8B8AEBAgAB+AEfAfgBHwH4ARsCAAb/GAAL - - - ..\Images\FilterAllOutcomes.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - \ No newline at end of file diff --git a/src/TestModel/model/Filter/OutcomeFilter.cs b/src/TestModel/model/Filter/OutcomeFilter.cs index a27eee7f5..b25fc46ad 100644 --- a/src/TestModel/model/Filter/OutcomeFilter.cs +++ b/src/TestModel/model/Filter/OutcomeFilter.cs @@ -16,7 +16,7 @@ public class OutcomeFilter : ITestFilter public const string AllOutcome = "All"; public const string NotRunOutcome = "Not Run"; - private List _condition = new List() { AllOutcome }; + private List _condition = new List(); internal OutcomeFilter(ITestModel model) { @@ -36,7 +36,7 @@ public IEnumerable Condition public bool IsMatching(TestNode testNode) { // All kind of outcomes should be displayed (no outcome filtering) - if (_condition.Contains(AllOutcome)) + if (_condition.Contains(AllOutcome) || !_condition.Any()) return true; string outcome = NotRunOutcome; @@ -48,11 +48,11 @@ public bool IsMatching(TestNode testNode) { case TestStatus.Failed: case TestStatus.Passed: - case TestStatus.Inconclusive: outcome = result.Outcome.Status.ToString(); break; + case TestStatus.Inconclusive: case TestStatus.Skipped: - outcome = result.Outcome.Label == "Ignored" ? "Ignored" : "Skipped"; + outcome = "Warning"; break; } } @@ -62,12 +62,12 @@ public bool IsMatching(TestNode testNode) public void Reset() { - _condition = new List() { AllOutcome }; + _condition = new List(); } public void Init() { - _condition = new List() { AllOutcome }; + _condition = new List(); } } } diff --git a/src/TestModel/tests/TestCentricTestFilterTests.cs b/src/TestModel/tests/TestCentricTestFilterTests.cs index f44db2ca0..adcda6e1c 100644 --- a/src/TestModel/tests/TestCentricTestFilterTests.cs +++ b/src/TestModel/tests/TestCentricTestFilterTests.cs @@ -132,22 +132,23 @@ public void ClearFilter_AllFiltersAreReset() Assert.That(allCategories, Contains.Item(CategoryFilter.NoCategory)); var outcomeFilter = testFilter.OutcomeFilter; - Assert.That(outcomeFilter.Count, Is.EqualTo(1)); - Assert.That(outcomeFilter, Contains.Item(OutcomeFilter.AllOutcome)); + Assert.That(outcomeFilter.Count, Is.EqualTo(0)); Assert.That(testFilter.TextFilter, Is.Empty); } private static object[] FilterByOutcomeTestCases = - { + { new object[] { new List() { "Passed" }, new List() { "3-1000", "3-1001", "3-1010", "3-1011", "3-1012", "3-1020", "3-1022" } }, new object[] { new List() { "Failed" }, new List() { "3-1000", "3-1001", "3-1020", "3-1021" } }, new object[] { new List() { OutcomeFilter.NotRunOutcome }, new List() { "3-1000", "3-1001", "3-1030", "3-1031", "3-1032" } }, new object[] { new List() { "Passed", OutcomeFilter.NotRunOutcome }, new List() { "3-1000", "3-1001", "3-1010", "3-1011", "3-1012", "3-1020", "3-1022", "3-1030", "3-1031", "3-1032" } }, new object[] { new List() { "Passed", "Failed" }, new List() { "3-1000", "3-1001", "3-1010", "3-1011", "3-1012", "3-1020", "3-1022", "3-1020", "3-1021" } }, new object[] { new List() { OutcomeFilter.NotRunOutcome, "Failed" }, new List() { "3-1000", "3-1001", "3-1030", "3-1031", "3-1032", "3-1020", "3-1021" } }, - new object[] { new List() { OutcomeFilter.AllOutcome }, new List() { "3-1000", "3-1001", "3-1010", "3-1011", "3-1012", "3-1020", "3-1021", "3-1022", "3-1030", "3-1031", "3-1032" } }, - }; + new object[] { new List() { "Warning"}, new List() { "3-1000", "3-1001", "3-1040", "3-1042"} }, + new object[] { new List() { OutcomeFilter.AllOutcome }, new List() { "3-1000", "3-1001", "3-1010", "3-1011", "3-1012", "3-1020", "3-1021", "3-1022", "3-1030", "3-1031", "3-1032", "3-1040", "3-1041", "3-1042" } }, + new object[] { new List(), new List() { "3-1000", "3-1001", "3-1010", "3-1011", "3-1012", "3-1020", "3-1021", "3-1022", "3-1030", "3-1031", "3-1032", "3-1040", "3-1041", "3-1042" } }, + }; [Test] [TestCaseSource(nameof(FilterByOutcomeTestCases))] @@ -165,7 +166,10 @@ public void FilterByOutcome_TestNodesAreVisible(IList outcomeFilter, ILi CreateTestcaseXml("3-1022", "TestB", "Passed")) + CreateTestFixtureXml("3-1030", "Fixture_3", "", CreateTestcaseXml("3-1031", "TestA", ""), - CreateTestcaseXml("3-1032", "TestB", ""))))); + CreateTestcaseXml("3-1032", "TestB", "")) + + CreateTestFixtureXml("3-1040", "Fixture_4", "", + CreateTestcaseXml("3-1041", "TestA", ""), + CreateTestcaseXml("3-1042", "TestB", "Skipped"))))); _model.LoadedTests.Returns(testNode); // Act