New test for ListView.Dispose firing extra Layout events.
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / ToolBarButtonTest.cs
1 //
2 // ToolBarButtonTest.cs: Test cases for ToolBarButton.
3 //
4 // Author:
5 //   Chris Toshok (toshok@ximian.com)
6 //
7 // (C) 2006 Novell, Inc. (http://www.novell.com)
8 //
9
10 using System;
11 using NUnit.Framework;
12 using System.Windows.Forms;
13 using System.Drawing;
14 using System.Runtime.Remoting;
15
16 namespace MonoTests.System.Windows.Forms
17 {
18         [TestFixture]
19         public class ToolBarButtonTest : TestHelper 
20         {
21                 [Test]
22                 public void CtorTest1 ()
23                 {
24                         ToolBarButton tbb = new ToolBarButton ();
25                         Assert.IsNull (tbb.DropDownMenu, "A3");
26                         Assert.IsTrue (tbb.Enabled, "A4");
27                         Assert.AreEqual (-1, tbb.ImageIndex, "A5");
28                         Assert.IsFalse (tbb.PartialPush, "A6");
29                         Assert.IsFalse (tbb.Pushed, "A7");
30                         Assert.AreEqual (Rectangle.Empty, tbb.Rectangle, "A8");
31                         Assert.AreEqual (ToolBarButtonStyle.PushButton, tbb.Style, "A8");
32                         Assert.IsNull (tbb.Tag, "A9");
33                         Assert.AreEqual ("", tbb.Text, "A10");
34                         Assert.AreEqual ("", tbb.ToolTipText, "A11");
35                         Assert.IsTrue (tbb.Visible, "A12");
36                 }
37
38                 [Test]
39                 public void CtorTest2 ()
40                 {
41                         ToolBarButton tbb = new ToolBarButton ("hi there");
42                         Assert.IsNull (tbb.DropDownMenu, "A3");
43                         Assert.IsTrue (tbb.Enabled, "A4");
44                         Assert.AreEqual (-1, tbb.ImageIndex, "A5");
45                         Assert.IsFalse (tbb.PartialPush, "A6");
46                         Assert.IsFalse (tbb.Pushed, "A7");
47                         Assert.AreEqual (Rectangle.Empty, tbb.Rectangle, "A8");
48                         Assert.AreEqual (ToolBarButtonStyle.PushButton, tbb.Style, "A8");
49                         Assert.IsNull (tbb.Tag, "A9");
50                         Assert.AreEqual ("hi there", tbb.Text, "A10");
51                         Assert.AreEqual ("", tbb.ToolTipText, "A11");
52                         Assert.IsTrue (tbb.Visible, "A12");
53                 }
54
55                 [Test]
56                 public void ToolTipText ()
57                 {
58                         ToolBarButton tbb = new ToolBarButton ();
59                         Assert.AreEqual ("", tbb.ToolTipText, "A1");
60
61                         tbb.ToolTipText = "hi there";
62                         Assert.AreEqual ("hi there", tbb.ToolTipText, "A2");
63
64                         tbb.ToolTipText = null;
65                         Assert.AreEqual ("", tbb.ToolTipText, "A3");
66                 }
67
68                 [Test]
69                 public void Text ()
70                 {
71                         ToolBarButton tbb = new ToolBarButton ();
72                         Assert.AreEqual ("", tbb.Text, "A1");
73
74                         tbb.Text = "hi there";
75                         Assert.AreEqual ("hi there", tbb.Text, "A2");
76
77                         tbb.Text = null;
78                         Assert.AreEqual ("", tbb.Text, "A3");
79                 }
80                 
81 #if NET_2_0
82                 [Test]
83                 public void Name ()
84                 {
85                         ToolBarButton tbb = new ToolBarButton ();
86                         Assert.AreEqual ("", tbb.Name, "A1");
87                         tbb.Name = "abc";
88                         Assert.AreEqual ("abc", tbb.Name, "A2");
89                         tbb.Name = "";
90                         Assert.AreEqual ("", tbb.Name, "A3");
91                         tbb.Name = null;
92                         Assert.AreEqual ("", tbb.Name, "A4");
93                 }
94                 
95                 [Test]
96                 public void BehaviorImageIndexAndKey ()
97                 {
98                         // Basically, this shows that whichever of [ImageIndex|ImageKey]
99                         // is set last resets the other to the default state
100                         ToolBarButton b = new ToolBarButton ();
101
102                         Assert.AreEqual (-1, b.ImageIndex, "D1");
103                         Assert.AreEqual (string.Empty, b.ImageKey, "D2");
104
105                         b.ImageIndex = 6;
106                         Assert.AreEqual (6, b.ImageIndex, "D3");
107                         Assert.AreEqual (string.Empty, b.ImageKey, "D4");
108                         
109                         b.ImageKey = "test";
110                         Assert.AreEqual (-1, b.ImageIndex, "D5");
111                         Assert.AreEqual ("test", b.ImageKey, "D6");
112                 }
113 #endif
114         }
115
116 }