| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- //
- // ToolBarTest.cs: Test cases for ToolBar.
- //
- // Author:
- // Ritvik Mayank ([email protected])
- //
- // (C) 2005 Novell, Inc. (http://www.novell.com)
- //
- using System;
- using System.Drawing;
- using System.Globalization;
- using System.Windows.Forms;
- using NUnit.Framework;
- namespace MonoTests.System.Windows.Forms
- {
- [TestFixture]
- public class ToolBarTest
- {
- [Test] // bug #79863
- public void TabStop ()
- {
- ToolBar tb = new ToolBar ();
- Assert.IsFalse (tb.TabStop);
- }
- [Test]
- public void ToolBarPropertyTest ()
- {
- Form myform = new Form ();
- myform.ShowInTaskbar = false;
- ToolBar myToolBar = new ToolBar ();
- ToolBarButton myToolBarButton1 = new ToolBarButton ();
- ToolBarButton myToolBarButton2 = new ToolBarButton ();
- myToolBarButton1.Text = "A";
- myToolBarButton2.Text = "B";
- myToolBar.Buttons.Add (myToolBarButton1);
- myToolBar.Buttons.Add (myToolBarButton2);
- myform.Controls.Add (myToolBar);
-
- // A
- Assert.AreEqual (ToolBarAppearance.Normal, myToolBar.Appearance, "#A1");
- Assert.AreEqual (true, myToolBar.AutoSize, "#A2");
-
- // B
- Assert.AreEqual ("Control", myToolBar.BackColor.Name, "#B1");
- myToolBar.BackgroundImage = Image.FromFile ("M.gif");
- Assert.AreEqual (60, myToolBar.BackgroundImage.Height, "#B3");
- Assert.AreEqual (BorderStyle.None, myToolBar.BorderStyle, "#B4");
- myToolBar.BorderStyle = BorderStyle.Fixed3D;
- Assert.AreEqual (BorderStyle.Fixed3D, myToolBar.BorderStyle, "#B5");
- Assert.AreEqual (2, myToolBar.Buttons.Count, "#B6");
- Assert.AreEqual ("B", myToolBar.Buttons [1].Text, "#B7");
-
- // D
- Assert.AreEqual (DockStyle.Top, myToolBar.Dock, "#D1");
- Assert.AreEqual (true, myToolBar.Divider, "#D2");
- Assert.AreEqual (true, myToolBar.DropDownArrows, "#D3");
- // F
- Assert.AreEqual ("ControlText", myToolBar.ForeColor.Name, "#F2");
-
- // I
- ImageList myImageList = new ImageList ();
- myImageList.Images.Add (Image.FromFile ("M.gif"));
- myToolBar.ImageList = myImageList;
- Assert.AreEqual (1, myToolBar.ImageList.Images.Count, "#I1");
- Assert.AreEqual (16, myToolBar.ImageSize.Height, "#I2");
- Assert.AreEqual (16, myToolBar.ImageSize.Width, "#I3");
- Assert.AreEqual (ImeMode.Disable, myToolBar.ImeMode, "#I4");
-
- // R
- Assert.AreEqual (RightToLeft.No, myToolBar.RightToLeft, "#R1");
- // S
- Assert.AreEqual (true, myToolBar.ShowToolTips, "#S1");
-
- // T
- Assert.AreEqual ("", myToolBar.Text, "#T1");
- myToolBar.Text = "MONO TOOLBAR";
- Assert.AreEqual ("MONO TOOLBAR", myToolBar.Text, "#T2");
- Assert.AreEqual (ToolBarTextAlign.Underneath, myToolBar.TextAlign, "#T3");
- // WXYZ
- Assert.AreEqual (true, myToolBar.Wrappable, "#W1");
- myform.Dispose ();
- }
-
- [Test]
- public void ToStringMethodTest ()
- {
- ToolBar tb = new ToolBar ();
- tb.Text = "New ToolBar";
- Assert.AreEqual ("System.Windows.Forms.ToolBar, Buttons.Count: 0",
- tb.ToString (), "#1");
- ToolBarButton buttonA = new ToolBarButton ("A");
- ToolBarButton buttonB = new ToolBarButton ("B");
- tb.Buttons.Add (buttonA);
- tb.Buttons.Add (buttonB);
- Assert.AreEqual ("System.Windows.Forms.ToolBar, Buttons.Count: 2, " +
- "Buttons[0]: ToolBarButton: A, Style: PushButton",
- tb.ToString (), "#2");
- }
- [Test]
- public void ToolbarButtonRectangleTest ()
- {
- ToolBar myToolBar = new ToolBar ();
- ToolBarButton tbb = new ToolBarButton ("hi");
- Assert.IsTrue (tbb.Rectangle.IsEmpty, "#T0");
- myToolBar.Visible = false;
- myToolBar.Buttons.Add (tbb);
- Assert.IsFalse (tbb.Rectangle.IsEmpty, "#T1");
- myToolBar.Visible = true;
- Assert.IsFalse (tbb.Rectangle.IsEmpty, "#T2");
- tbb.Visible = false;
- Assert.IsTrue (tbb.Rectangle.IsEmpty, "#T3");
- }
- [Test] // bug #80416
- public void DockDefault ()
- {
- Form form = new Form ();
- form.ShowInTaskbar = false;
- ToolBar toolBar = new ToolBar ();
- form.Controls.Add (toolBar);
- form.Show ();
- Assert.AreEqual (DockStyle.Top, toolBar.Dock, "#1");
- Assert.AreEqual (form.ClientSize.Width, toolBar.Width, "#2");
- }
-
- [Test]
- public void ButtonSizeTest ()
- {
- Form form = new Form ();
- form.ShowInTaskbar = false;
- ToolBar toolBar = new ToolBar ();
-
- // Size is fixed when dont have buttons
- Assert.AreEqual (39, toolBar.ButtonSize.Width, "#1");
- Assert.AreEqual (36, toolBar.ButtonSize.Height, "#2");
- toolBar.Buttons.Add (new ToolBarButton (""));
- form.Controls.Add (toolBar);
- form.Show ();
- // We cannot determine exact size as it depends of font size
- //Assert.IsTrue (toolBar.ButtonSize.Width < 39, "#3");
- //Assert.IsTrue (toolBar.ButtonSize.Height < 36, "#4");
-
- toolBar.Buttons.Add (new ToolBarButton ("Teste"));
-
- // We cannot determine exact size as it depends of font size
- //Assert.IsTrue (toolBar.ButtonSize.Width >= 39, "#5");
- //Assert.IsTrue (toolBar.ButtonSize.Height >= 36, "#6");
- }
- }
- // [MonoTODO ("Add test for ButtonClickEvent (Visual Test)"]
- // [MonoTODO ("Add test for ButtonDropDownEvent (Visual Test)"]
- }
|