Просмотр исходного кода

Added test cases for PictureBox

svn path=/trunk/mcs/; revision=50287
Ritvik Mayank 20 лет назад
Родитель
Сommit
ef27ed3bbd

+ 4 - 0
mcs/class/Managed.Windows.Forms/ChangeLog

@@ -1,3 +1,7 @@
+2005-09-20  Ritvik Mayank  <[email protected]>
+
+        * System.Windows.Forms_test.dll.sources : Added pictureBoxTest.cs
+
 2005-09-09 Jonathan Chambers  <[email protected]>
 
 	* System.Windows.Forms.dll.sources: Added IRootGridEntry.cs and PropertyGridCommands.cs

+ 1 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources

@@ -21,6 +21,7 @@ System.Windows.Forms/ListViewEventTest.cs
 System.Windows.Forms/ListViewTest.cs
 System.Windows.Forms/MenuTest.cs
 System.Windows.Forms/MonthCalendarTest.cs
+System.Windows.Forms/PictureBoxTest.cs
 System.Windows.Forms/ProgressBarTest.cs
 System.Windows.Forms/RadioButtonTest.cs
 System.Windows.Forms/ScrollBarTest.cs

+ 4 - 0
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog

@@ -1,3 +1,7 @@
+2005-09-20  Ritvik Mayank  <[email protected]>
+
+	* PictureBoxTest.cs : Test case for PictureBox
+
 2005-09-08  Ritvik Mayank  <[email protected]>
 
 	* MonthCalendarTest.cs : Test case for MonthCalendar

+ 82 - 0
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/PictureBoxTest.cs

@@ -0,0 +1,82 @@
+//
+// PictureBoxTest.cs: Test cases for PictureBox.
+//
+// Author:
+//   Ritvik Mayank ([email protected])
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+using System.Threading;
+
+namespace MonoTests.System.Windows.Forms
+{
+	[TestFixture]
+	public class PictureBoxTest
+	{
+		[Test]
+		public void PictureBoxPropertyTest ()
+		{
+			Form myForm = new Form ();
+			PictureBox myPicBox = new PictureBox ();
+			myForm.Controls.Add (myPicBox);
+			
+			// B 
+			Assert.AreEqual (BorderStyle.None, myPicBox.BorderStyle, "#B1");
+			myPicBox.BorderStyle = BorderStyle.Fixed3D;
+			Assert.AreEqual (BorderStyle.Fixed3D, myPicBox.BorderStyle, "#B2");
+
+			// I 
+			Assert.AreEqual (null, myPicBox.Image, "#I1");
+			Image myImage =	Image.FromFile("M.gif");
+			myPicBox.Image = myImage;
+			Assert.AreEqual (60, myPicBox.Image.Height, "#I2");
+			Assert.AreEqual (150, myPicBox.Image.Width, "#I3");
+			
+			// P 
+			Assert.AreEqual (PictureBoxSizeMode.Normal, myPicBox.SizeMode, "#P1");
+			myPicBox.SizeMode = PictureBoxSizeMode.AutoSize;
+			Assert.AreEqual (PictureBoxSizeMode.AutoSize, myPicBox.SizeMode, "#P2");
+		}
+			
+		
+		[Test]
+		public void ToStringMethodTest () 
+		{
+			PictureBox myPicBox = new PictureBox ();
+			Assert.AreEqual ("System.Windows.Forms.PictureBox, SizeMode: Normal", myPicBox.ToString (), "#T1");
+		}
+		
+		[TestFixture]
+		public class PictureBoxSizeModeEventClass
+		{
+			static bool eventhandled = false;
+			public static void SizeMode_EventHandler (object sender, EventArgs e)
+			{
+				eventhandled = true;
+			}
+
+			[Test]
+			public void PictureBoxEvenTest ()
+			{
+				Form myForm = new Form ();
+				PictureBox myPicBox = new PictureBox ();
+				myForm.Controls.Add (myPicBox);
+				myPicBox.SizeModeChanged += new EventHandler (SizeMode_EventHandler);
+				myPicBox.SizeMode = PictureBoxSizeMode.AutoSize;				
+				Assert.AreEqual (true, eventhandled, "#SM1");
+				eventhandled = false;
+				myPicBox.SizeMode = PictureBoxSizeMode.CenterImage;
+				Assert.AreEqual (true, eventhandled, "#SM2");
+				eventhandled = false;
+				myPicBox.SizeMode = PictureBoxSizeMode.StretchImage;
+				Assert.AreEqual (true, eventhandled, "#SM3");	
+			}
+		}
+	}
+}