@@ -873,5 +873,57 @@ public void CheckBox_ProcessMnemonic_ValidCases(bool useMnemonic, char charCode,
873
873
checkBox . CheckState . Should ( ) . Be ( CheckState . Checked ) ;
874
874
}
875
875
876
+ [ WinFormsTheory ]
877
+ [ InlineData ( Appearance . Button , FlatStyle . Standard , "Test" , 12 , 8 , 100 , 20 ) ]
878
+ [ InlineData ( Appearance . Normal , FlatStyle . System , "Test" , 12 , 8 , 100 , 20 ) ]
879
+ [ InlineData ( Appearance . Normal , FlatStyle . Flat , "Test" , 12 , 8 , 100 , 20 ) ]
880
+ [ InlineData ( Appearance . Normal , FlatStyle . Standard , "Test" , 12 , 8 , 100 , 20 ) ]
881
+ public void CheckBox_GetPreferredSizeCore_VariousStyles_ReturnsExpected (
882
+ Appearance appearance , FlatStyle flatStyle , string text , int fontSize , int padding , int width , int height )
883
+ {
884
+ using SubCheckBox control = ( SubCheckBox ) CreateButton ( ) ;
885
+ control . Appearance = appearance ;
886
+ control . FlatStyle = flatStyle ;
887
+ control . Text = text ;
888
+ control . Font = new Font ( FontFamily . GenericSansSerif , fontSize ) ;
889
+ control . Padding = new Padding ( padding ) ;
890
+
891
+ Size proposed = new ( width , height ) ;
892
+
893
+ if ( appearance == Appearance . Button )
894
+ {
895
+ Size size = control . GetPreferredSizeCore ( proposed ) ;
896
+ size . Width . Should ( ) . BeGreaterThan ( 0 ) ;
897
+ size . Height . Should ( ) . BeGreaterThan ( 0 ) ;
898
+ }
899
+ else if ( flatStyle == FlatStyle . System )
900
+ {
901
+ Size size = control . GetPreferredSizeCore ( proposed ) ;
902
+ size . Width . Should ( ) . BeGreaterThan ( 0 ) ;
903
+ size . Height . Should ( ) . BeGreaterThan ( 0 ) ;
904
+ }
905
+ else
906
+ {
907
+ Size size = control . GetPreferredSizeCore ( proposed ) ;
908
+ size . Width . Should ( ) . BeGreaterThan ( 0 ) ;
909
+ size . Height . Should ( ) . BeGreaterThan ( 0 ) ;
910
+ }
911
+ }
912
+
913
+ [ WinFormsFact ]
914
+ public void CheckBox_GetPreferredSizeCore_EnsuresMinimumHeight ( )
915
+ {
916
+ using SubCheckBox control = ( SubCheckBox ) CreateButton ( ) ;
917
+ control . FlatStyle = FlatStyle . System ;
918
+ control . Text = "A" ;
919
+ control . Font = new Font ( FontFamily . GenericSansSerif , 1 ) ;
920
+ control . Padding = Padding . Empty ;
921
+
922
+ Size proposed = new ( 1 , 1 ) ;
923
+ Size result = control . GetPreferredSizeCore ( proposed ) ;
924
+
925
+ result . Height . Should ( ) . BeGreaterThanOrEqualTo ( 13 ) ;
926
+ }
927
+
876
928
protected override ButtonBase CreateButton ( ) => new SubCheckBox ( ) ;
877
929
}
0 commit comments