Skip to content

Commit 341f33a

Browse files
committed
test(detailcontrols): expand Wave 4 offscreen/layout coverage and record gains
- add IDataTreePainter seam and offscreen paint test harness (RecordingPainter, OffscreenGraphicsContext) - add DataTree Wave 4 tests for OnPaint/paint branches and HandleLayout1 branch paths - add Slice branch tests for IsObjectNode, LabelIndent, and GetBranchHeight - fix Slice IsObjectNode test setup to avoid NRE by setting DataTree root directly - update OpenSpec coverage matrix with 2026-02-26 checkpoint (DataTree 67.51/52.02, Slice 34.5/22.4)
1 parent 2ec4fef commit 341f33a

File tree

11 files changed

+2521
-9
lines changed

11 files changed

+2521
-9
lines changed

Src/Common/Controls/DetailControls/DataTree.cs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace SIL.FieldWorks.Common.Framework.DetailControls
5454
/// System.Windows.Forms.Panel
5555
/// System.Windows.Forms.ContainerControl
5656
/// System.Windows.Forms.UserControl
57-
public class DataTree : UserControl, IVwNotifyChange, IxCoreColleague, IRefreshableRoot
57+
public class DataTree : UserControl, IVwNotifyChange, IxCoreColleague, IRefreshableRoot, IDataTreePainter
5858
{
5959
/// <summary>
6060
/// Part refs that don't represent actual data slices
@@ -161,6 +161,14 @@ public class DataTree : UserControl, IVwNotifyChange, IxCoreColleague, IRefresha
161161

162162
public List<Slice> Slices { get; private set; }
163163

164+
/// <summary>
165+
/// The painter used to draw separator lines between slices.
166+
/// Defaults to <c>this</c> (DataTree's own implementation).
167+
/// Tests can substitute a recording implementation to verify
168+
/// rendering without a visible window.
169+
/// </summary>
170+
public IDataTreePainter Painter { get; set; }
171+
164172
#endregion Data members
165173

166174
#region constants
@@ -474,6 +482,7 @@ public DataTree()
474482
// string objName = ToString() + GetHashCode().ToString();
475483
// Debug.WriteLine("Creating object:" + objName);
476484
Slices = new List<Slice>();
485+
Painter = this;
477486
m_autoCustomFieldNodesDocument = new XmlDocument();
478487
m_autoCustomFieldNodesDocRoot = m_autoCustomFieldNodesDocument.CreateElement("root");
479488
m_autoCustomFieldNodesDocument.AppendChild(m_autoCustomFieldNodesDocRoot);
@@ -1627,15 +1636,15 @@ public virtual bool RefreshDisplay()
16271636
/// Answer true if the two slices are displaying fields of the same object.
16281637
/// Review: should we require more strictly, that the full path of objects in their keys are the same?
16291638
/// </summary>
1630-
private static bool SameSourceObject(Slice first, Slice second)
1639+
internal static bool SameSourceObject(Slice first, Slice second)
16311640
{
16321641
return first.Object.Hvo == second.Object.Hvo;
16331642
}
16341643

16351644
/// <summary>
16361645
/// Answer true if the second slice is a 'child' of the first (common key)
16371646
/// </summary>
1638-
private static bool IsChildSlice(Slice first, Slice second)
1647+
internal static bool IsChildSlice(Slice first, Slice second)
16391648
{
16401649
if (second.Key == null || second.Key.Length <= first.Key.Length)
16411650
return false;
@@ -1655,12 +1664,16 @@ private static bool IsChildSlice(Slice first, Slice second)
16551664
/// This actually handles Paint for the contained control that has the slice controls in it.
16561665
/// </summary>
16571666
/// <param name="pea">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
1658-
void HandlePaintLinesBetweenSlices(PaintEventArgs pea)
1667+
internal void HandlePaintLinesBetweenSlices(PaintEventArgs pea)
1668+
{
1669+
PaintLinesBetweenSlices(pea.Graphics, Width);
1670+
}
1671+
1672+
/// <summary>
1673+
/// IDataTreePainter implementation: draw separator lines between slices.
1674+
/// </summary>
1675+
public void PaintLinesBetweenSlices(Graphics gr, int width)
16591676
{
1660-
Graphics gr = pea.Graphics;
1661-
UserControl uc = this;
1662-
// Where we're drawing.
1663-
int width = uc.Width;
16641677
using (var thinPen = new Pen(Color.LightGray, 1))
16651678
using (var thickPen = new Pen(Color.LightGray, 1 + HeavyweightRuleThickness))
16661679
{
@@ -3593,7 +3606,7 @@ protected override void OnPaint(PaintEventArgs e)
35933606
else
35943607
{
35953608
base.OnPaint(e);
3596-
HandlePaintLinesBetweenSlices(e);
3609+
Painter.PaintLinesBetweenSlices(e.Graphics, Width);
35973610
}
35983611
}
35993612
finally

0 commit comments

Comments
 (0)