Skip to content

Commit a7fcf68

Browse files
committed
Update test cases
1 parent f09e561 commit a7fcf68

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/StatusStrip.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,30 +309,36 @@ internal override Size GetPreferredSizeCore(Size proposedSize)
309309
return base.GetPreferredSizeCore(proposedSize);
310310
}
311311

312+
/// <summary>
313+
/// Returns the client rect of the display area of the control.
314+
/// When SizingGrip is enabled, `DisplayRectangle` excludes the sizing grip width.
315+
/// </summary>
312316
public override Rectangle DisplayRectangle
313317
{
314318
get
315319
{
316-
var baseRectangle = base.DisplayRectangle;
320+
Rectangle rectangle = base.DisplayRectangle;
317321

318322
if (!SizingGrip)
319323
{
320-
return baseRectangle;
324+
return rectangle;
321325
}
322326

323-
int scaleGripWidth = ScaleHelper.ScaleToDpi(GripWidth, DeviceDpi);
324-
325-
if (RightToLeft == RightToLeft.Yes)
327+
Rectangle grip = SizeGripBounds;
328+
int remainingWidth = rectangle.Width - grip.Width;
329+
if (grip.IsEmpty || remainingWidth <= 0)
326330
{
327-
baseRectangle.X += scaleGripWidth;
328-
baseRectangle.Width = Math.Max(0, baseRectangle.Width - scaleGripWidth);
331+
return rectangle;
329332
}
330-
else
333+
334+
if (RightToLeft == RightToLeft.Yes)
331335
{
332-
baseRectangle.Width = Math.Max(0, baseRectangle.Width - scaleGripWidth);
336+
rectangle.X += grip.Width;
333337
}
334338

335-
return baseRectangle;
339+
rectangle.Width = remainingWidth;
340+
341+
return rectangle;
336342
}
337343
}
338344

src/test/unit/System.Windows.Forms/System/Windows/Forms/AccessibleObjects/StatusStrip.StatusStripAccessibleObjectTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ static ToolStripItem CreateStatusStripItem()
933933
return new ToolStripStatusLabel()
934934
{
935935
AutoSize = false,
936-
Size = new Size(50, 25)
936+
Size = new Size(40, 25)
937937
};
938938
}
939939
}

src/test/unit/System.Windows.Forms/System/Windows/Forms/StatusStripTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void StatusStrip_Ctor_Default()
6565
Assert.False(control.DesignMode);
6666
Assert.Empty(control.DisplayedItems);
6767
Assert.Same(control.DisplayedItems, control.DisplayedItems);
68-
Assert.Equal(new Rectangle(1, 0, 185, 22), control.DisplayRectangle);
68+
Assert.Equal(new Rectangle(1, 0, 173, 22), control.DisplayRectangle);
6969
Assert.Equal(DockStyle.Bottom, control.Dock);
7070
Assert.NotNull(control.DockPadding);
7171
Assert.Same(control.DockPadding, control.DockPadding);
@@ -108,7 +108,7 @@ public void StatusStrip_Ctor_Default()
108108
Assert.Equal(Point.Empty, control.Location);
109109
Assert.Equal(Padding.Empty, control.Margin);
110110
Assert.Equal(Size.Empty, control.MaximumSize);
111-
Assert.Equal(new Size(185, 22), control.MaxItemSize);
111+
Assert.Equal(new Size(173, 22), control.MaxItemSize);
112112
Assert.Equal(Size.Empty, control.MinimumSize);
113113
Assert.Equal(Orientation.Horizontal, control.Orientation);
114114
Assert.NotNull(control.OverflowButton);

0 commit comments

Comments
 (0)