Merge pull request #325 from adbre/iss5464
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / StatusBarPanelTest.cs
1 //
2 // StatusBarPanelTest.cs: Test cases for StatusBar.
3 //
4 // (C) 2006 Novell, Inc. (http://www.novell.com)
5 //
6
7 using System;
8 using NUnit.Framework;
9 using System.Windows.Forms;
10 using System.Drawing;
11 using System.Runtime.Remoting;
12
13 namespace MonoTests.System.Windows.Forms
14 {
15         [TestFixture]
16         public class StatusBarPanelTest : TestHelper 
17         {
18                 [Test]
19                 public void MinimumWidth1 ()
20                 {
21                         StatusBarPanel p = new StatusBarPanel ();
22                         Assert.AreEqual (10, p.MinWidth, "1");
23                 }
24
25                 [Test]
26                 public void MinimumWidth2 ()
27                 {
28                         StatusBarPanel p = new StatusBarPanel ();
29                         p.Width = 50;
30                         p.MinWidth = 100;
31                         Assert.AreEqual (100, p.Width, "1");
32                 }
33
34                 [Test]
35                 public void MinimumWidth3 ()
36                 {
37                         StatusBarPanel p = new StatusBarPanel ();
38                         p.Width = 50;
39                         p.MinWidth = 200;
40                         p.MinWidth = 25;
41                         Assert.AreEqual (200, p.Width, "#1");
42                         
43                         p = new StatusBarPanel ();
44                         p.Width = 50;
45                         p.MinWidth = 25;
46                         Assert.AreEqual (50, p.Width, "#2");
47                         
48                         p = new StatusBarPanel ();
49                         p.Width = 50;
50                         p.MinWidth = 100;
51                         Assert.AreEqual (100, p.Width, "#3");
52                         
53                         p = new StatusBarPanel ();
54                         p.MinWidth = 200;
55                         Assert.AreEqual (200, p.Width, "#4");
56                 }
57                 
58                 [Test]
59 #if NET_2_0
60                 [ExpectedException (typeof (ArgumentOutOfRangeException))]
61 #else
62                 [ExpectedException(typeof(ArgumentException))]
63 #endif
64                 public void MinimumWidth4 ()
65                 {
66                         StatusBarPanel p = new StatusBarPanel ();
67                         p.MinWidth = -50;
68                 }
69
70                 [Test]
71                 public void MinWidth_AutoSize_None ()
72                 {
73                         StatusBarPanel p = new StatusBarPanel ();
74                         p.Width = 50;
75                         Assert.AreEqual (10, p.MinWidth, "#1");
76                 }
77                 
78                 [Test]
79                 public void ToStringTest ()
80                 {
81                         StatusBarPanel p = new StatusBarPanel ();
82                         Assert.AreEqual ("StatusBarPanel: {}", p.ToString(), "1");
83
84                         p.Text = "Hello";
85                         Assert.AreEqual ("StatusBarPanel: {Hello}", p.ToString(), "2");
86
87                         p.Text = "}";
88                         Assert.AreEqual ("StatusBarPanel: {}}", p.ToString(), "3");
89                 }
90                 
91                 [Test]
92                 public void DefaultPropertiesTest ()
93                 {
94                         StatusBarPanel p = new StatusBarPanel ();
95                         Assert.AreEqual (100, p.Width, "#1");
96                         Assert.AreEqual (10, p.MinWidth, "#2");
97                         Assert.AreEqual (String.Empty, p.Text, "#3");
98                         Assert.AreEqual (HorizontalAlignment.Left, p.Alignment, "#4");
99                         Assert.AreEqual (StatusBarPanelAutoSize.None, p.AutoSize, "#5");
100                         Assert.AreEqual (StatusBarPanelBorderStyle.Sunken, p.BorderStyle, "#6");
101                         Assert.AreEqual (StatusBarPanelStyle.Text, p.Style, "#7");
102                         Assert.AreEqual (String.Empty, p.ToolTipText, "#8");
103                         
104                 }
105                 
106                 [Test] // bug 82487
107                 public void IconWidth ()
108                 {
109                         using (Form f = new Form ()) {
110                                 StatusBar _statusBar;
111                                 StatusBarPanel _myComputerPanel;
112                                 
113                                 _statusBar = new StatusBar ();
114                                 _statusBar.ShowPanels = true;
115                                 //Controls.Add (_statusBar);
116                                 
117                                 _myComputerPanel = new StatusBarPanel ();
118                                 _myComputerPanel.AutoSize = StatusBarPanelAutoSize.Contents;
119                                 _myComputerPanel.Text = "My Computer";
120                                 _statusBar.Panels.Add (_myComputerPanel);
121
122                                 int width = _myComputerPanel.Width;
123                                 
124                                 _myComputerPanel.Icon = f.Icon;
125                                 
126                                 Assert.AreEqual (width + 21, _myComputerPanel.Width, "#01");
127                         }
128                 }
129 #if NET_2_0
130                 [Test]
131                 public void TagTest ()
132                 {
133                         StatusBarPanel p = new StatusBarPanel ();
134                         
135                         Assert.AreEqual (null, p.Tag, "#1");
136                         p.Tag = "a";
137                         Assert.AreEqual ("a", p.Tag, "#2");
138                         p.Tag = null;
139                         Assert.AreEqual (null, p.Tag, "#3");
140                 }
141                 
142                 [Test]
143                 public void NameTest ()
144                 {
145                         StatusBarPanel p = new StatusBarPanel ();
146                         Assert.AreEqual ("", p.Name, "#1");
147                         p.Name = "a";
148                         Assert.AreEqual ("a", p.Name, "#2");
149                         p.Name = null;
150                         Assert.AreEqual ("", p.Name, "#3");
151                 }
152 #endif 
153                 
154         }
155 }