@@ -32,6 +32,8 @@ await Wait.For(async () =>
32
32
Assert . Equal ( "1" , await textBox . GetText ( ) ) ;
33
33
Assert . Equal ( 1 , await numericUpDown . GetValue ( ) ) ;
34
34
} ) ;
35
+
36
+ recorder . Success ( ) ;
35
37
}
36
38
37
39
[ Fact ]
@@ -63,6 +65,8 @@ await Wait.For(async () =>
63
65
} ) ;
64
66
65
67
Assert . True ( await plusButton . GetIsEnabled ( ) ) ;
68
+
69
+ recorder . Success ( ) ;
66
70
}
67
71
68
72
[ Fact ]
@@ -94,6 +98,8 @@ await Wait.For(async () =>
94
98
} ) ;
95
99
96
100
Assert . True ( await minusButton . GetIsEnabled ( ) ) ;
101
+
102
+ recorder . Success ( ) ;
97
103
}
98
104
99
105
[ Fact ]
@@ -116,6 +122,8 @@ public async Task MaxAndMinAssignments_CoerceValueToBeInRange()
116
122
Assert . Equal ( 3 , await numericUpDown . GetValue ( ) ) ;
117
123
Assert . Equal ( 3 , await numericUpDown . GetMinimum ( ) ) ;
118
124
Assert . Equal ( 3 , await numericUpDown . GetMaximum ( ) ) ;
125
+
126
+ recorder . Success ( ) ;
119
127
}
120
128
121
129
[ Fact ]
@@ -147,4 +155,63 @@ public async Task InternalTextBoxIsFocused_WhenGettingKeyboardFocus()
147
155
148
156
recorder . Success ( ) ;
149
157
}
158
+
159
+ [ Fact ]
160
+ [ Description ( "Issue 3781" ) ]
161
+ public async Task IncreaseButtonClickWhenTextIsAboveMaximum_DoesNotIncreaseValue ( )
162
+ {
163
+ await using var recorder = new TestRecorder ( App ) ;
164
+
165
+ var stackPanel = await LoadXaml < StackPanel > ( """
166
+ <StackPanel>
167
+ <materialDesign:DecimalUpDown Minimum="-2.5" Maximum="2.5" Value="2.5" />
168
+ <Button Content="AlternateFocusElement" />
169
+ </StackPanel>
170
+ """ ) ;
171
+ var decimalUpDown = await stackPanel . GetElement < DecimalUpDown > ( ) ;
172
+ var textBox = await decimalUpDown . GetElement < TextBox > ( "PART_TextBox" ) ;
173
+ var plusButton = await decimalUpDown . GetElement < RepeatButton > ( "PART_IncreaseButton" ) ;
174
+
175
+ var button = await stackPanel . GetElement < Button > ( ) ;
176
+
177
+ await textBox . MoveKeyboardFocus ( ) ;
178
+ await textBox . SendKeyboardInput ( $ "{ ModifierKeys . Control } { Key . A } { ModifierKeys . None } 30") ;
179
+ await plusButton . LeftClick ( ) ;
180
+
181
+ //NB: Because the focus has not left the up down control, we don't expect the text to change
182
+ Assert . Equal ( "30" , await textBox . GetText ( ) ) ;
183
+ Assert . Equal ( 2.5m , await decimalUpDown . GetValue ( ) ) ;
184
+
185
+ recorder . Success ( ) ;
186
+ }
187
+
188
+ [ Theory ]
189
+ [ Description ( "Issue 3781" ) ]
190
+ [ InlineData ( "30" ) ]
191
+ [ InlineData ( "abc" ) ]
192
+ [ InlineData ( "2a" ) ]
193
+ public async Task LostFocusWhenTextIsInvalid_RevertsToOriginalValue ( string inputText )
194
+ {
195
+ await using var recorder = new TestRecorder ( App ) ;
196
+
197
+ var stackPanel = await LoadXaml < StackPanel > ( """
198
+ <StackPanel>
199
+ <materialDesign:DecimalUpDown Minimum="-2.5" Maximum="2.5" Value="2.5" />
200
+ <Button Content="AlternateFocusElement" />
201
+ </StackPanel>
202
+ """ ) ;
203
+ var decimalUpDown = await stackPanel . GetElement < DecimalUpDown > ( ) ;
204
+ var textBox = await decimalUpDown . GetElement < TextBox > ( "PART_TextBox" ) ;
205
+
206
+ var button = await stackPanel . GetElement < Button > ( ) ;
207
+
208
+ await textBox . MoveKeyboardFocus ( ) ;
209
+ await textBox . SendKeyboardInput ( $ "{ ModifierKeys . Control } { Key . A } { ModifierKeys . None } { inputText } ") ;
210
+ await button . MoveKeyboardFocus ( ) ;
211
+
212
+ Assert . Equal ( "2.5" , await textBox . GetText ( ) ) ;
213
+ Assert . Equal ( 2.5m , await decimalUpDown . GetValue ( ) ) ;
214
+
215
+ recorder . Success ( ) ;
216
+ }
150
217
}
0 commit comments