|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | + |
| 4 | +using System.Drawing; |
| 5 | +using System.Windows.Forms.ButtonInternal; |
| 6 | + |
| 7 | +namespace System.Windows.Forms.Tests; |
| 8 | + |
| 9 | +public class RadioButtonPopupAdapterTests |
| 10 | +{ |
| 11 | + [WinFormsFact] |
| 12 | + public void PaintUp_AppearanceButton_CallsButtonPopupAdapterPaintUp() |
| 13 | + { |
| 14 | + using RadioButton control = new RadioButton |
| 15 | + { |
| 16 | + Appearance = Appearance.Button, |
| 17 | + Checked = true |
| 18 | + }; |
| 19 | + |
| 20 | + RadioButtonPopupAdapter adapter = new(control); |
| 21 | + using Bitmap bitmap = new Bitmap(1, 1); |
| 22 | + using Graphics graphics = Graphics.FromImage(bitmap); |
| 23 | + PaintEventArgs e = new(graphics, control.ClientRectangle); |
| 24 | + |
| 25 | + adapter.PaintUp(e, CheckState.Checked); |
| 26 | + |
| 27 | + control.Appearance.Should().Be(Appearance.Button); |
| 28 | + control.Checked.Should().BeTrue(); |
| 29 | + } |
| 30 | + |
| 31 | + [WinFormsFact] |
| 32 | + public void PaintUp_AppearanceNormal_PaintsCorrectly() |
| 33 | + { |
| 34 | + using RadioButton control = new RadioButton |
| 35 | + { |
| 36 | + Appearance = Appearance.Normal, |
| 37 | + Checked = true |
| 38 | + }; |
| 39 | + |
| 40 | + RadioButtonPopupAdapter adapter = new(control); |
| 41 | + using Bitmap bitmap = new Bitmap(1, 1); |
| 42 | + using Graphics graphics = Graphics.FromImage(bitmap); |
| 43 | + PaintEventArgs e = new(graphics, control.ClientRectangle); |
| 44 | + |
| 45 | + adapter.PaintUp(e, CheckState.Checked); |
| 46 | + |
| 47 | + control.Appearance.Should().Be(Appearance.Normal); |
| 48 | + control.Checked.Should().BeTrue(); |
| 49 | + } |
| 50 | + |
| 51 | + [WinFormsFact] |
| 52 | + public void PaintOver_AppearanceButton_CallsButtonPopupAdapterPaintOver() |
| 53 | + { |
| 54 | + using RadioButton control = new RadioButton |
| 55 | + { |
| 56 | + Appearance = Appearance.Button, |
| 57 | + Checked = false |
| 58 | + }; |
| 59 | + |
| 60 | + RadioButtonPopupAdapter adapter = new(control); |
| 61 | + using Bitmap bitmap = new Bitmap(1, 1); |
| 62 | + using Graphics graphics = Graphics.FromImage(bitmap); |
| 63 | + PaintEventArgs e = new(graphics, control.ClientRectangle); |
| 64 | + |
| 65 | + adapter.PaintOver(e, CheckState.Unchecked); |
| 66 | + |
| 67 | + control.Appearance.Should().Be(Appearance.Button); |
| 68 | + control.Checked.Should().BeFalse(); |
| 69 | + } |
| 70 | + |
| 71 | + [WinFormsFact] |
| 72 | + public void PaintOver_AppearanceNormal_PaintsCorrectly() |
| 73 | + { |
| 74 | + using RadioButton control = new RadioButton |
| 75 | + { |
| 76 | + Appearance = Appearance.Normal, |
| 77 | + Checked = false |
| 78 | + }; |
| 79 | + |
| 80 | + RadioButtonPopupAdapter adapter = new(control); |
| 81 | + using Bitmap bitmap = new Bitmap(1, 1); |
| 82 | + using Graphics graphics = Graphics.FromImage(bitmap); |
| 83 | + PaintEventArgs e = new(graphics, control.ClientRectangle); |
| 84 | + |
| 85 | + adapter.PaintOver(e, CheckState.Unchecked); |
| 86 | + |
| 87 | + control.Appearance.Should().Be(Appearance.Normal); |
| 88 | + control.Checked.Should().BeFalse(); |
| 89 | + } |
| 90 | + |
| 91 | + [WinFormsFact] |
| 92 | + public void PaintDown_AppearanceButton_CallsButtonPopupAdapterPaintDown() |
| 93 | + { |
| 94 | + using RadioButton control = new RadioButton |
| 95 | + { |
| 96 | + Appearance = Appearance.Button, |
| 97 | + Checked = true |
| 98 | + }; |
| 99 | + |
| 100 | + RadioButtonPopupAdapter adapter = new(control); |
| 101 | + using Bitmap bitmap = new Bitmap(1, 1); |
| 102 | + using Graphics graphics = Graphics.FromImage(bitmap); |
| 103 | + PaintEventArgs e = new(graphics, control.ClientRectangle); |
| 104 | + |
| 105 | + adapter.PaintDown(e, CheckState.Checked); |
| 106 | + |
| 107 | + control.Appearance.Should().Be(Appearance.Button); |
| 108 | + control.Checked.Should().BeTrue(); |
| 109 | + } |
| 110 | + |
| 111 | + [WinFormsFact] |
| 112 | + public void PaintDown_AppearanceNormal_PaintsCorrectly() |
| 113 | + { |
| 114 | + using RadioButton control = new RadioButton |
| 115 | + { |
| 116 | + Appearance = Appearance.Normal, |
| 117 | + Checked = false |
| 118 | + }; |
| 119 | + |
| 120 | + RadioButtonPopupAdapter adapter = new(control); |
| 121 | + using Bitmap bitmap = new Bitmap(1, 1); |
| 122 | + using Graphics graphics = Graphics.FromImage(bitmap); |
| 123 | + PaintEventArgs e = new(graphics, control.ClientRectangle); |
| 124 | + |
| 125 | + adapter.PaintDown(e, CheckState.Unchecked); |
| 126 | + |
| 127 | + control.Appearance.Should().Be(Appearance.Normal); |
| 128 | + control.Checked.Should().BeFalse(); |
| 129 | + } |
| 130 | +} |
0 commit comments