Skip to content

Commit 7470e84

Browse files
committed
Address FeedBacks
1 parent 4993530 commit 7470e84

File tree

1 file changed

+45
-20
lines changed

1 file changed

+45
-20
lines changed

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

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,53 +32,78 @@ public void IsSupported_Matches_VisualStyleRenderer_IsSupported() =>
3232
[WinFormsFact]
3333
public void DrawTabItem_Basic_ChangesTabStateSuccessfully()
3434
{
35-
using Bitmap bmp = new(100, 30);
36-
using Graphics g = Graphics.FromImage(bmp);
37-
Rectangle bounds = new(0, 0, 100, 30);
38-
Color before = bmp.GetPixel(10, 10);
35+
Color colorBeforeDraw = _bmp.GetPixel(10, 10);
3936

4037
foreach (TabItemState state in Enum.GetValues<TabItemState>())
4138
{
42-
TabRenderer.DrawTabItem(g, bounds, state);
43-
TabRenderer.DrawTabItem(g, bounds, focused: true, state);
39+
TabRenderer.DrawTabItem(_g, _bounds, state);
40+
TabRenderer.DrawTabItem(_g, _bounds, focused: true, state);
4441
}
4542

46-
Color after = bmp.GetPixel(10, 10);
47-
after.Should().NotBe(before);
43+
Color colorAfterDraw = _bmp.GetPixel(10, 10);
44+
colorAfterDraw.Should().NotBe(colorBeforeDraw);
4845
}
4946

5047
[WinFormsFact]
5148
public void DrawTabItem_WithText_ChangesTabStateSuccessfully()
5249
{
5350
using Font font = new("Arial", 8);
54-
Color before = _bmp.GetPixel(10, 10);
51+
Color colorBeforeDraw = _bmp.GetPixel(10, 10);
5552

5653
foreach (TabItemState state in Enum.GetValues<TabItemState>())
5754
{
5855
TabRenderer.DrawTabItem(_g, _bounds, "TabText", font, state);
56+
}
57+
58+
Color colorAfterDraw = _bmp.GetPixel(10, 10);
59+
colorAfterDraw.Should().NotBe(colorBeforeDraw);
60+
}
61+
62+
[WinFormsFact]
63+
public void DrawTabItem_WithText_Focused_ChangesTabStateSuccessfully()
64+
{
65+
using Font font = new("Arial", 8);
66+
Color colorBeforeDraw = _bmp.GetPixel(10, 10);
67+
68+
foreach (TabItemState state in Enum.GetValues<TabItemState>())
69+
{
5970
TabRenderer.DrawTabItem(_g, _bounds, "TabText", font, focused: true, state);
71+
}
72+
73+
Color colorAfterDraw = _bmp.GetPixel(10, 10);
74+
colorAfterDraw.Should().NotBe(colorBeforeDraw);
75+
}
76+
77+
[WinFormsFact]
78+
public void DrawTabItem_WithText_TextFormatFlags_Focused_ChangesTabStateSuccessfully()
79+
{
80+
using Font font = new("Arial", 8);
81+
Color colorBeforeDraw = _bmp.GetPixel(10, 10);
82+
83+
foreach (TabItemState state in Enum.GetValues<TabItemState>())
84+
{
6085
TabRenderer.DrawTabItem(_g, _bounds, "TabText", font, TextFormatFlags.Default, focused: true, state);
6186
}
6287

63-
Color after = _bmp.GetPixel(10, 10);
64-
after.Should().NotBe(before);
88+
Color colorAfterDraw = _bmp.GetPixel(10, 10);
89+
colorAfterDraw.Should().NotBe(colorBeforeDraw);
6590
}
6691

6792
[WinFormsFact]
6893
public void DrawTabItem_WithImage_ChangesTabStateSuccessfully()
6994
{
7095
using Bitmap image = new(16, 16);
7196
Rectangle imageRect = new(5, 5, 16, 16);
72-
Color before = _bmp.GetPixel(10, 10);
97+
Color colorBeforeDraw = _bmp.GetPixel(10, 10);
7398

7499
foreach (TabItemState state in Enum.GetValues<TabItemState>())
75100
{
76101
TabRenderer.DrawTabItem(_g, _bounds, image, imageRect, focused: false, state);
77102
TabRenderer.DrawTabItem(_g, _bounds, image, imageRect, focused: true, state);
78103
}
79104

80-
Color after = _bmp.GetPixel(10, 10);
81-
after.Should().NotBe(before);
105+
Color colorAfterDraw = _bmp.GetPixel(10, 10);
106+
colorAfterDraw.Should().NotBe(colorBeforeDraw);
82107
}
83108

84109
[WinFormsFact]
@@ -87,16 +112,16 @@ public void DrawTabItem_WithTextAndImage_ChangesTabStateSuccessfully()
87112
using Font font = new("Arial", 8);
88113
using Bitmap image = new(16, 16);
89114
Rectangle imageRect = new(5, 5, 16, 16);
90-
Color before = _bmp.GetPixel(10, 10);
115+
Color colorBeforeDraw = _bmp.GetPixel(10, 10);
91116

92117
foreach (TabItemState state in Enum.GetValues<TabItemState>())
93118
{
94119
TabRenderer.DrawTabItem(_g, _bounds, "TabText", font, image, imageRect, focused: false, state);
95120
TabRenderer.DrawTabItem(_g, _bounds, "TabText", font, TextFormatFlags.Default, image, imageRect, focused: true, state);
96121
}
97122

98-
Color after = _bmp.GetPixel(10, 10);
99-
after.Should().NotBe(before);
123+
Color colorAfterDraw = _bmp.GetPixel(10, 10);
124+
colorAfterDraw.Should().NotBe(colorBeforeDraw);
100125
}
101126

102127
[WinFormsFact]
@@ -105,11 +130,11 @@ public void DrawTabPage_ChangesTabPageStateSuccessfully()
105130
using Bitmap bmp = new(100, 100);
106131
using Graphics g = Graphics.FromImage(bmp);
107132
Rectangle bounds = new(0, 0, 100, 100);
108-
Color before = bmp.GetPixel(10, 10);
133+
Color colorBeforeDraw = bmp.GetPixel(10, 10);
109134

110135
TabRenderer.DrawTabPage(g, bounds);
111136

112-
Color after = bmp.GetPixel(10, 10);
113-
after.Should().NotBe(before);
137+
Color colorAfterDraw = bmp.GetPixel(10, 10);
138+
colorAfterDraw.Should().NotBe(colorBeforeDraw);
114139
}
115140
}

0 commit comments

Comments
 (0)