2 // ControlStyleTest.cs (Auto-generated by GenerateControlStyleTest.cs).
5 // Peter Dennis Bartok (pbartok@novell.com)
7 // (C) 2005 Novell, Inc. (http://www.novell.com)
10 using System.Windows.Forms;
12 using System.Reflection;
13 using NUnit.Framework;
15 namespace MonoTests.System.Windows.Forms {
17 public class TestControlStyle {
19 static Array style_values = Enum.GetValues(typeof(ControlStyles));
20 static string[] style_names = Enum.GetNames(typeof(ControlStyles));
22 public void AssertAreEqual(string[] want, string[] got, string name) {
23 if (want.Length == got.Length) {
24 for (int i=0; i < want.Length; i++) {
25 if (want[i] != got[i]) {
26 Console.WriteLine("{0}: Expected {1}, got {2}", name, want[i], got[i]);
30 Assert.AreEqual(want, got, name);
33 public static string[] GetStyles(Control control) {
36 result = new string[style_names.Length];
38 for (int i = 0; i < style_values.Length; i++) {
39 result[i] = style_names[i] + "=" + control.GetType().GetMethod("GetStyle", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(control, new object[1] {(ControlStyles)style_values.GetValue(i)});
46 public void ControlStyleTest ()
48 string[] Control_want = {
49 "ContainerControl=False",
58 "SupportsTransparentBackColor=False",
59 "StandardDoubleClick=True",
60 "AllPaintingInWmPaint=True",
62 "EnableNotifyMessage=False",
66 Assert.AreEqual(Control_want, GetStyles(new Control()), "ControlStyles");
71 public void ButtonStyleTest ()
73 string[] Button_want = {
74 "ContainerControl=False",
80 "StandardClick=False",
83 "SupportsTransparentBackColor=True",
84 "StandardDoubleClick=False",
85 "AllPaintingInWmPaint=True",
87 "EnableNotifyMessage=False",
91 Assert.AreEqual(Button_want, GetStyles(new Button()), "ButtonStyles");
96 public void CheckBoxStyleTest ()
98 string[] CheckBox_want = {
99 "ContainerControl=False",
105 "StandardClick=False",
108 "SupportsTransparentBackColor=True",
109 "StandardDoubleClick=False",
110 "AllPaintingInWmPaint=True",
112 "EnableNotifyMessage=False",
116 Assert.AreEqual(CheckBox_want, GetStyles(new CheckBox()), "CheckBoxStyles");
121 public void RadioButtonStyleTest ()
123 string[] RadioButton_want = {
124 "ContainerControl=False",
130 "StandardClick=False",
133 "SupportsTransparentBackColor=True",
134 "StandardDoubleClick=True",
135 "AllPaintingInWmPaint=True",
137 "EnableNotifyMessage=False",
141 Assert.AreEqual(RadioButton_want, GetStyles(new RadioButton()), "RadioButtonStyles");
146 public void DataGridStyleTest ()
148 string[] DataGrid_want = {
149 "ContainerControl=False",
152 "ResizeRedraw=False",
155 "StandardClick=True",
158 "SupportsTransparentBackColor=False",
159 "StandardDoubleClick=True",
160 "AllPaintingInWmPaint=True",
162 "EnableNotifyMessage=False",
166 Assert.AreEqual(DataGrid_want, GetStyles(new DataGrid()), "DataGridStyles");
171 public void DateTimePickerStyleTest ()
173 string[] DateTimePicker_want = {
174 "ContainerControl=False",
177 "ResizeRedraw=False",
180 "StandardClick=False",
183 "SupportsTransparentBackColor=False",
184 "StandardDoubleClick=True",
185 "AllPaintingInWmPaint=True",
187 "EnableNotifyMessage=False",
191 Assert.AreEqual(DateTimePicker_want, GetStyles(new DateTimePicker()), "DateTimePickerStyles");
196 public void GroupBoxStyleTest ()
198 string[] GroupBox_want = {
199 "ContainerControl=True",
205 "StandardClick=True",
208 "SupportsTransparentBackColor=True",
209 "StandardDoubleClick=True",
210 "AllPaintingInWmPaint=True",
212 "EnableNotifyMessage=False",
216 Assert.AreEqual(GroupBox_want, GetStyles(new GroupBox()), "GroupBoxStyles");
221 public void LabelStyleTest ()
223 string[] Label_want = {
224 "ContainerControl=False",
230 "StandardClick=True",
233 "SupportsTransparentBackColor=True",
234 "StandardDoubleClick=True",
235 "AllPaintingInWmPaint=True",
237 "EnableNotifyMessage=False",
241 Assert.AreEqual(Label_want, GetStyles(new Label()), "LabelStyles");
246 public void LinkLabelStyleTest ()
248 string[] LinkLabel_want = {
249 "ContainerControl=False",
255 "StandardClick=True",
258 "SupportsTransparentBackColor=True",
259 "StandardDoubleClick=True",
260 "AllPaintingInWmPaint=True",
262 "EnableNotifyMessage=False",
266 string[] LinkLabel_link_want = {
267 "ContainerControl=False",
273 "StandardClick=True",
276 "SupportsTransparentBackColor=True",
277 "StandardDoubleClick=True",
278 "AllPaintingInWmPaint=True",
280 "EnableNotifyMessage=False",
285 Assert.AreEqual(LinkLabel_want, GetStyles(new LinkLabel()), "LinkLabelStyles");
287 // Test LinkLabel with a link
288 LinkLabel link = new LinkLabel();
289 link.Text = "Users need not fear making the switch to Linux";
290 link.Links.Add (6,9, "http://link1");
291 Assert.AreEqual(LinkLabel_link_want, GetStyles(link), "LinkLabelStyles2");
297 public void ComboBoxStyleTest ()
299 string[] ComboBox_want = {
300 "ContainerControl=False",
303 "ResizeRedraw=False",
306 "StandardClick=False",
309 "SupportsTransparentBackColor=False",
310 "StandardDoubleClick=True",
311 "AllPaintingInWmPaint=True",
313 "EnableNotifyMessage=False",
317 Assert.AreEqual(ComboBox_want, GetStyles(new ComboBox()), "ComboBoxStyles");
322 public void ListBoxStyleTest ()
324 string[] ListBox_want = {
325 "ContainerControl=False",
328 "ResizeRedraw=False",
331 "StandardClick=False",
334 "SupportsTransparentBackColor=False",
335 "StandardDoubleClick=True",
336 "AllPaintingInWmPaint=True",
338 "EnableNotifyMessage=False",
342 Assert.AreEqual(ListBox_want, GetStyles(new ListBox()), "ListBoxStyles");
347 public void CheckedListBoxStyleTest ()
349 string[] CheckedListBox_want = {
350 "ContainerControl=False",
356 "StandardClick=False",
359 "SupportsTransparentBackColor=False",
360 "StandardDoubleClick=True",
361 "AllPaintingInWmPaint=True",
363 "EnableNotifyMessage=False",
367 Assert.AreEqual(CheckedListBox_want, GetStyles(new CheckedListBox()), "CheckedListBoxStyles");
372 public void ListViewStyleTest ()
374 string[] ListView_want = {
375 "ContainerControl=False",
378 "ResizeRedraw=False",
381 "StandardClick=False",
384 "SupportsTransparentBackColor=False",
385 "StandardDoubleClick=True",
386 "AllPaintingInWmPaint=True",
388 "EnableNotifyMessage=False",
392 Assert.AreEqual(ListView_want, GetStyles(new ListView()), "ListViewStyles");
397 public void MdiClientStyleTest ()
399 string[] MdiClient_want = {
400 "ContainerControl=False",
403 "ResizeRedraw=False",
406 "StandardClick=True",
409 "SupportsTransparentBackColor=False",
410 "StandardDoubleClick=True",
411 "AllPaintingInWmPaint=True",
413 "EnableNotifyMessage=False",
417 Assert.AreEqual(MdiClient_want, GetStyles(new MdiClient()), "MdiClientStyles");
422 public void MonthCalendarStyleTest ()
424 string[] MonthCalendar_want = {
425 "ContainerControl=False",
428 "ResizeRedraw=False",
431 "StandardClick=False",
434 "SupportsTransparentBackColor=False",
435 "StandardDoubleClick=True",
436 "AllPaintingInWmPaint=True",
438 "EnableNotifyMessage=False",
442 Assert.AreEqual(MonthCalendar_want, GetStyles(new MonthCalendar()), "MonthCalendarStyles");
447 public void PictureBoxStyleTest ()
449 string[] PictureBox_want = {
450 "ContainerControl=False",
453 "ResizeRedraw=False",
456 "StandardClick=True",
459 "SupportsTransparentBackColor=True",
460 "StandardDoubleClick=True",
461 "AllPaintingInWmPaint=True",
463 "EnableNotifyMessage=False",
467 Assert.AreEqual(PictureBox_want, GetStyles(new PictureBox()), "PictureBoxStyles");
472 public void ProgressBarStyleTest ()
474 string[] ProgressBar_want = {
475 "ContainerControl=False",
478 "ResizeRedraw=False",
481 "StandardClick=True",
484 "SupportsTransparentBackColor=False",
485 "StandardDoubleClick=True",
486 "AllPaintingInWmPaint=True",
488 "EnableNotifyMessage=False",
492 Assert.AreEqual(ProgressBar_want, GetStyles(new ProgressBar()), "ProgressBarStyles");
497 public void ScrollableControlStyleTest ()
499 string[] ScrollableControl_want = {
500 "ContainerControl=True",
503 "ResizeRedraw=False",
506 "StandardClick=True",
509 "SupportsTransparentBackColor=False",
510 "StandardDoubleClick=True",
511 "AllPaintingInWmPaint=False",
513 "EnableNotifyMessage=False",
517 Assert.AreEqual(ScrollableControl_want, GetStyles(new ScrollableControl()), "ScrollableControlStyles");
522 public void ContainerControlStyleTest ()
524 string[] ContainerControl_want = {
525 "ContainerControl=True",
528 "ResizeRedraw=False",
531 "StandardClick=True",
534 "SupportsTransparentBackColor=False",
535 "StandardDoubleClick=True",
536 "AllPaintingInWmPaint=False",
538 "EnableNotifyMessage=False",
542 Assert.AreEqual(ContainerControl_want, GetStyles(new ContainerControl()), "ContainerControlStyles");
547 public void FormStyleTest ()
549 string[] Form_want = {
550 "ContainerControl=True",
553 "ResizeRedraw=False",
556 "StandardClick=True",
559 "SupportsTransparentBackColor=False",
560 "StandardDoubleClick=True",
561 "AllPaintingInWmPaint=False",
563 "EnableNotifyMessage=False",
567 Assert.AreEqual(Form_want, GetStyles(new Form()), "FormStyles");
572 public void PropertyGridStyleTest ()
574 string[] PropertyGrid_want = {
575 "ContainerControl=True",
578 "ResizeRedraw=False",
581 "StandardClick=True",
584 "SupportsTransparentBackColor=False",
585 "StandardDoubleClick=True",
586 "AllPaintingInWmPaint=False",
588 "EnableNotifyMessage=False",
592 Assert.AreEqual(PropertyGrid_want, GetStyles(new PropertyGrid()), "PropertyGridStyles");
597 public void DomainUpDownStyleTest ()
599 string[] DomainUpDown_want = {
600 "ContainerControl=True",
603 "ResizeRedraw=False",
606 "StandardClick=True",
609 "SupportsTransparentBackColor=False",
610 "StandardDoubleClick=True",
611 "AllPaintingInWmPaint=False",
613 "EnableNotifyMessage=False",
617 Assert.AreEqual(DomainUpDown_want, GetStyles(new DomainUpDown()), "DomainUpDownStyles");
622 public void NumericUpDownStyleTest ()
624 string[] NumericUpDown_want = {
625 "ContainerControl=True",
628 "ResizeRedraw=False",
631 "StandardClick=True",
634 "SupportsTransparentBackColor=False",
635 "StandardDoubleClick=True",
636 "AllPaintingInWmPaint=False",
638 "EnableNotifyMessage=False",
642 Assert.AreEqual(NumericUpDown_want, GetStyles(new NumericUpDown()), "NumericUpDownStyles");
647 public void UserControlStyleTest ()
649 string[] UserControl_want = {
650 "ContainerControl=True",
653 "ResizeRedraw=False",
656 "StandardClick=True",
659 "SupportsTransparentBackColor=False",
660 "StandardDoubleClick=True",
661 "AllPaintingInWmPaint=False",
663 "EnableNotifyMessage=False",
667 Assert.AreEqual(UserControl_want, GetStyles(new UserControl()), "UserControlStyles");
672 public void PanelStyleTest ()
674 string[] Panel_want = {
675 "ContainerControl=True",
678 "ResizeRedraw=False",
681 "StandardClick=True",
684 "SupportsTransparentBackColor=True",
685 "StandardDoubleClick=True",
686 "AllPaintingInWmPaint=False",
688 "EnableNotifyMessage=False",
692 Assert.AreEqual(Panel_want, GetStyles(new Panel()), "PanelStyles");
697 public void TabPageStyleTest ()
699 string[] TabPage_want = {
700 "ContainerControl=True",
703 "ResizeRedraw=False",
706 "StandardClick=True",
709 "SupportsTransparentBackColor=True",
710 "StandardDoubleClick=True",
711 "AllPaintingInWmPaint=False",
713 "EnableNotifyMessage=False",
717 Assert.AreEqual(TabPage_want, GetStyles(new TabPage()), "TabPageStyles");
722 public void HScrollBarStyleTest ()
724 string[] HScrollBar_want = {
725 "ContainerControl=False",
728 "ResizeRedraw=False",
731 "StandardClick=False",
734 "SupportsTransparentBackColor=False",
735 "StandardDoubleClick=True",
736 "AllPaintingInWmPaint=True",
738 "EnableNotifyMessage=False",
742 Assert.AreEqual(HScrollBar_want, GetStyles(new HScrollBar()), "HScrollBarStyles");
747 public void VScrollBarStyleTest ()
749 string[] VScrollBar_want = {
750 "ContainerControl=False",
753 "ResizeRedraw=False",
756 "StandardClick=False",
759 "SupportsTransparentBackColor=False",
760 "StandardDoubleClick=True",
761 "AllPaintingInWmPaint=True",
763 "EnableNotifyMessage=False",
767 Assert.AreEqual(VScrollBar_want, GetStyles(new VScrollBar()), "VScrollBarStyles");
772 public void SplitterStyleTest ()
774 string[] Splitter_want = {
775 "ContainerControl=False",
778 "ResizeRedraw=False",
781 "StandardClick=True",
784 "SupportsTransparentBackColor=False",
785 "StandardDoubleClick=True",
786 "AllPaintingInWmPaint=True",
788 "EnableNotifyMessage=False",
792 Assert.AreEqual(Splitter_want, GetStyles(new Splitter()), "SplitterStyles");
797 public void StatusBarStyleTest ()
799 string[] StatusBar_want = {
800 "ContainerControl=False",
803 "ResizeRedraw=False",
806 "StandardClick=True",
809 "SupportsTransparentBackColor=False",
810 "StandardDoubleClick=True",
811 "AllPaintingInWmPaint=True",
813 "EnableNotifyMessage=False",
817 Assert.AreEqual(StatusBar_want, GetStyles(new StatusBar()), "StatusBarStyles");
822 public void TabControlStyleTest ()
824 string[] TabControl_want = {
825 "ContainerControl=False",
828 "ResizeRedraw=False",
831 "StandardClick=True",
834 "SupportsTransparentBackColor=False",
835 "StandardDoubleClick=True",
836 "AllPaintingInWmPaint=True",
838 "EnableNotifyMessage=False",
842 Assert.AreEqual(TabControl_want, GetStyles(new TabControl()), "TabControlStyles");
847 public void RichTextBoxStyleTest ()
849 string[] RichTextBox_want = {
850 "ContainerControl=False",
853 "ResizeRedraw=False",
856 "StandardClick=False",
859 "SupportsTransparentBackColor=False",
860 "StandardDoubleClick=True",
861 "AllPaintingInWmPaint=True",
863 "EnableNotifyMessage=False",
867 Assert.AreEqual(RichTextBox_want, GetStyles(new RichTextBox()), "RichTextBoxStyles");
872 public void TextBoxStyleTest ()
874 string[] TextBox_want = {
875 "ContainerControl=False",
878 "ResizeRedraw=False",
881 "StandardClick=False",
884 "SupportsTransparentBackColor=False",
885 "StandardDoubleClick=False",
886 "AllPaintingInWmPaint=True",
888 "EnableNotifyMessage=False",
892 Assert.AreEqual(TextBox_want, GetStyles(new TextBox()), "TextBoxStyles");
897 public void DataGridTextBoxStyleTest ()
899 string[] DataGridTextBox_want = {
900 "ContainerControl=False",
903 "ResizeRedraw=False",
906 "StandardClick=False",
909 "SupportsTransparentBackColor=False",
910 "StandardDoubleClick=False",
911 "AllPaintingInWmPaint=True",
913 "EnableNotifyMessage=False",
917 Assert.AreEqual(DataGridTextBox_want, GetStyles(new DataGridTextBox()), "DataGridTextBoxStyles");
922 public void ToolBarStyleTest ()
924 string[] ToolBar_want = {
925 "ContainerControl=False",
928 "ResizeRedraw=False",
931 "StandardClick=True",
934 "SupportsTransparentBackColor=False",
935 "StandardDoubleClick=True",
936 "AllPaintingInWmPaint=True",
938 "EnableNotifyMessage=False",
942 Assert.AreEqual(ToolBar_want, GetStyles(new ToolBar()), "ToolBarStyles");
947 public void TrackBarStyleTest ()
949 string[] TrackBar_want = {
950 "ContainerControl=False",
953 "ResizeRedraw=False",
956 "StandardClick=True",
959 "SupportsTransparentBackColor=False",
960 "StandardDoubleClick=True",
961 "AllPaintingInWmPaint=True",
963 "EnableNotifyMessage=False",
967 Assert.AreEqual(TrackBar_want, GetStyles(new TrackBar()), "TrackBarStyles");
972 public void TreeViewStyleTest ()
974 string[] TreeView_want = {
975 "ContainerControl=False",
978 "ResizeRedraw=False",
981 "StandardClick=False",
984 "SupportsTransparentBackColor=False",
985 "StandardDoubleClick=True",
986 "AllPaintingInWmPaint=True",
988 "EnableNotifyMessage=False",
992 Assert.AreEqual(TreeView_want, GetStyles(new TreeView()), "TreeViewStyles");