Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWade Berrier <wade@mono-cvs.ximian.com>2006-02-28 23:08:50 +0300
committerWade Berrier <wade@mono-cvs.ximian.com>2006-02-28 23:08:50 +0300
commit933491861325258994290ac573f66db398b2151c (patch)
tree5717dd3ac39bc7b233e373c160e2c4662f4f9f43 /mcs/class/Managed.Windows.Forms/Test
parent195be47f2f0c0d6a78e398b80f7916d53110919b (diff)
parent543a824b06d71ae56e982ead9d213eba6207cad7 (diff)
pull in changes from trunkmono-1-1-13-3
svn path=/branches/mono-1-1-13/mcs/; revision=57423
Diffstat (limited to 'mcs/class/Managed.Windows.Forms/Test')
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Resources/ChangeLog8
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Resources/CompatTest.cs51
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Resources/CultureTest.cs59
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Resources/WriterTest.cs60
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_1_1.resx81
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_2_0.resx102
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ButtonTest.cs104
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog258
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxEventTest.cs65
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxTest.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxEventTest.cs42
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxTest.cs133
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs326
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/Common.cs251
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlEventTest.cs300
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlPaintTest.cs150
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlStyleTest.cs961
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs790
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CursorTest.cs29
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridCellTest.cs56
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTableStyleTest.cs270
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs314
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTextBoxColumnTest.cs105
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewAdvancedBorderStyleTest.cs149
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewBandTest.cs73
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellStyleTest.cs125
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellTest.cs74
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewElementTest.cs57
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewRowTest.cs64
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewTest.cs282
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ErrorProviderTest.cs98
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormEventTest.cs237
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs175
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GenerateControlStyleTest.cs129
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridColumnStylesCollectionTest.cs199
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridTableStylesCollectionTest.cs193
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GroupBoxTest.cs40
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageListTest.cs94
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelPropertyTest.cs138
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelTest.cs970
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxEventTest.cs65
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxTest.cs351
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewCollectionsTest.cs243
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewEventTest.cs208
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewItemTest.cs88
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewTest.cs136
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuItemTest.cs170
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuTest.cs86
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MonthCalendarTest.cs166
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/PictureBoxTest.cs82
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ProgressBarTest.cs84
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RadioButtonTest.cs104
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RichTextBoxTest.cs187
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ScrollBarTest.cs1453
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/StatusBarTest.cs75
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TabControlTest.cs87
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TestImageIndexConverter.cs157
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs191
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolBarTest.cs97
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolTipTest.cs71
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TrackBarTest.cs79
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeNodeTest.cs162
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeViewTest.cs34
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/bitmaps/a.pngbin0 -> 651 bytes
-rwxr-xr-xmcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/tests-ms.sh28
-rwxr-xr-xmcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/tests.sh29
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/resources/a.curbin0 -> 766 bytes
67 files changed, 12085 insertions, 0 deletions
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/ChangeLog b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ChangeLog
new file mode 100644
index 00000000000..ae72a33c991
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/ChangeLog
@@ -0,0 +1,8 @@
+2005-12-01 Robert Jordan <robertj@gmx.net>
+
+ * CompatTest.cs, compat*.resx: Compatibility unit tests.
+ * WriterTest.cs: Unit tests for ResXResourceWriter.
+
+2005-11-30 Robert Jordan <robertj@gmx.net>
+
+ * CultureTest.cs: Unit tests for the culture-invariance.
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/CompatTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/CompatTest.cs
new file mode 100644
index 00000000000..453d5ba6774
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/CompatTest.cs
@@ -0,0 +1,51 @@
+//
+// CompatTest.cs: Compatibility unit tests for ResXResourceReader.
+//
+// Authors:
+// Robert Jordan <robertj@gmx.net>
+//
+
+using System;
+using System.Collections;
+using System.Drawing;
+using System.IO;
+using System.Resources;
+using NUnit.Framework;
+
+namespace MonoTests.System.Resources
+{
+ [TestFixture]
+ public class CompatTest
+ {
+ class Helper
+ {
+ public static void TestReader (string fileName)
+ {
+ ResXResourceReader r = new ResXResourceReader (fileName);
+ Hashtable h = new Hashtable();
+ foreach (DictionaryEntry e in r) {
+ h.Add (e.Key, e.Value);
+ }
+ r.Close ();
+
+ Assert.AreEqual ("hola", (string) h["String"], fileName + "#1");
+ Assert.AreEqual ("hello", (string) h["String2"], fileName + "#2");
+ Assert.AreEqual (42, (int) h["Int"], fileName + "#3");
+ Assert.AreEqual (PlatformID.Win32NT, (PlatformID) h["Enum"], fileName + "#4");
+ Assert.AreEqual (43, ((Point) h["Convertible"]).X, fileName + "#5");
+ Assert.AreEqual (2, (byte) ((ArrayList) h["Serializable"])[1], fileName + "#6");
+ Assert.AreEqual (13, ((byte[]) h["ByteArray"])[1], fileName + "#7");
+ Assert.AreEqual (16, ((byte[]) h["ByteArray2"])[1], fileName + "#8");
+ Assert.AreEqual (1013, ((int[]) h["IntArray"])[1], fileName + "#9");
+ Assert.AreEqual ("world", ((string[]) h["StringArray"])[1], fileName + "#10");
+ }
+ }
+
+ [Test]
+ public void TestReader ()
+ {
+ Helper.TestReader ("Test/System.Resources/compat_1_1.resx");
+ Helper.TestReader ("Test/System.Resources/compat_2_0.resx");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/CultureTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/CultureTest.cs
new file mode 100644
index 00000000000..1c9e65114ce
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/CultureTest.cs
@@ -0,0 +1,59 @@
+//
+// CultureTest.cs: Test cases for culture-invariant string convertions
+//
+// Authors:
+// Robert Jordan <robertj@gmx.net>
+//
+
+using System;
+using System.Collections;
+using System.Globalization;
+using System.Drawing;
+using System.IO;
+using System.Resources;
+using System.Threading;
+using NUnit.Framework;
+
+namespace MonoTests.System.Resources
+{
+ [TestFixture]
+ public class CultureTest
+ {
+ string fileName = Path.GetTempFileName ();
+
+ [Test]
+ public void TestWriter ()
+ {
+ Thread.CurrentThread.CurrentCulture =
+ Thread.CurrentThread.CurrentUICulture = new CultureInfo ("de-DE");
+
+ ResXResourceWriter w = new ResXResourceWriter (fileName);
+ w.AddResource ("point", new Point (42, 43));
+ w.Generate ();
+ w.Close ();
+ }
+
+ [Test]
+ public void TestReader ()
+ {
+ Thread.CurrentThread.CurrentCulture =
+ Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
+
+ int count = 0;
+ ResXResourceReader r = new ResXResourceReader (fileName);
+ IDictionaryEnumerator e = r.GetEnumerator ();
+ while (e.MoveNext ()) {
+ if ((string)e.Key == "point") {
+ Assert.AreEqual (typeof (Point), e.Value.GetType (), "#1");
+ Point p = (Point) e.Value;
+ Assert.AreEqual (42, p.X, "#2");
+ Assert.AreEqual (43, p.Y, "#3");
+ count++;
+ }
+ }
+ r.Close ();
+ File.Delete (fileName);
+ Assert.AreEqual (1, count, "#100");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/WriterTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Resources/WriterTest.cs
new file mode 100644
index 00000000000..a5f20d556b5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/WriterTest.cs
@@ -0,0 +1,60 @@
+//
+// WriterTest.cs: Unit Tests for ResXResourceWriter.
+//
+// Authors:
+// Robert Jordan <robertj@gmx.net>
+//
+
+using System;
+using System.Collections;
+using System.Drawing;
+using System.IO;
+using System.Resources;
+using NUnit.Framework;
+
+namespace MonoTests.System.Resources
+{
+ [TestFixture]
+ public class WriterTest
+ {
+ string fileName = Path.GetTempFileName ();
+
+ [Test]
+ public void TestWriter ()
+ {
+ ResXResourceWriter w = new ResXResourceWriter (fileName);
+ w.AddResource ("String", "hola");
+ w.AddResource ("String2", (object) "hello");
+ w.AddResource ("Int", 42);
+ w.AddResource ("Enum", PlatformID.Win32NT);
+ w.AddResource ("Convertible", new Point (43, 45));
+ w.AddResource ("Serializable", new ArrayList(new byte[] {1, 2, 3, 4}));
+ w.AddResource ("ByteArray", new byte[] {12, 13, 14});
+ w.AddResource ("ByteArray2", (object) new byte[] {15, 16, 17});
+ w.AddResource ("IntArray", new int[] {1012, 1013, 1014});
+ w.AddResource ("StringArray", new string[] {"hello", "world"});
+ w.Generate ();
+ w.Close ();
+
+ ResXResourceReader r = new ResXResourceReader (fileName);
+ Hashtable h = new Hashtable();
+ foreach (DictionaryEntry e in r) {
+ h.Add (e.Key, e.Value);
+ }
+ r.Close ();
+
+ Assert.AreEqual ("hola", (string) h["String"], "#1");
+ Assert.AreEqual ("hello", (string) h["String2"], "#2");
+ Assert.AreEqual (42, (int) h["Int"], "#3");
+ Assert.AreEqual (PlatformID.Win32NT, (PlatformID) h["Enum"], "#4");
+ Assert.AreEqual (43, ((Point) h["Convertible"]).X, "#5");
+ Assert.AreEqual (2, (byte) ((ArrayList) h["Serializable"])[1], "#6");
+ Assert.AreEqual (13, ((byte[]) h["ByteArray"])[1], "#7");
+ Assert.AreEqual (16, ((byte[]) h["ByteArray2"])[1], "#8");
+ Assert.AreEqual (1013, ((int[]) h["IntArray"])[1], "#9");
+ Assert.AreEqual ("world", ((string[]) h["StringArray"])[1], "#10");
+
+ File.Delete (fileName);
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_1_1.resx b/mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_1_1.resx
new file mode 100644
index 00000000000..bbf08ef6e1a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_1_1.resx
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 1.3 (NET_1_1)
+
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>1.3</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="String">
+ <value>hola</value>
+ </data>
+ <data name="String2">
+ <value>hello</value>
+ </data>
+ <data name="Int" type="System.Int32, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>42</value>
+ </data>
+ <data name="Enum" type="System.PlatformID, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>Win32NT</value>
+ </data>
+ <data name="Convertible" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>43, 45</value>
+ </data>
+ <data name="Serializable" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>
+ AAEAAAD/////AQAAAAAAAAAEAQAAABxTeXN0ZW0uQ29sbGVjdGlvbnMuQXJyYXlMaXN0AwAAAAZfaXRl
+ bXMFX3NpemUIX3ZlcnNpb24FAAAICAkCAAAABAAAAAEAAAAQAgAAAAQAAAAIAgEIAgIIAgMIAgQL
+</value>
+ </data>
+ <data name="ByteArray" type="System.Byte[], mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>DA0O</value>
+ </data>
+ <data name="ByteArray2" type="System.Byte[], mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>DxAR</value>
+ </data>
+ <data name="IntArray" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>AAEAAAD/////AQAAAAAAAAAPAQAAAAMAAAAI9AMAAPUDAAD2AwAACw==</value>
+ </data>
+ <data name="StringArray" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>AAEAAAD/////AQAAAAAAAAARAQAAAAIAAAAGAgAAAAVoZWxsbwYDAAAABXdvcmxkCw==</value>
+ </data>
+</root>
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_2_0.resx b/mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_2_0.resx
new file mode 100644
index 00000000000..ca1fb642744
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Resources/compat_2_0.resx
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0 (NET_2_0)
+
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="String" xml:space="preserve">
+ <value>hola</value>
+ </data>
+ <data name="String2" xml:space="preserve">
+ <value>hello</value>
+ </data>
+ <assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <data name="Int" type="System.Int32, mscorlib">
+ <value>42</value>
+ </data>
+ <data name="Enum" type="System.PlatformID, mscorlib">
+ <value>Win32NT</value>
+ </data>
+ <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <data name="Convertible" type="System.Drawing.Point, System.Drawing">
+ <value>43, 45</value>
+ </data>
+ <data name="Serializable" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>
+ AAEAAAD/////AQAAAAAAAAAEAQAAABxTeXN0ZW0uQ29sbGVjdGlvbnMuQXJyYXlMaXN0AwAAAAZfaXRl
+ bXMFX3NpemUIX3ZlcnNpb24FAAAICAkCAAAABAAAAAEAAAAQAgAAAAQAAAAIAgEIAgIIAgMIAgQL
+</value>
+ </data>
+ <data name="ByteArray" type="System.Byte[], mscorlib">
+ <value>DA0O</value>
+ </data>
+ <data name="ByteArray2" type="System.Byte[], mscorlib">
+ <value>DxAR</value>
+ </data>
+ <data name="IntArray" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>AAEAAAD/////AQAAAAAAAAAPAQAAAAMAAAAI9AMAAPUDAAD2AwAACw==</value>
+ </data>
+ <data name="StringArray" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>AAEAAAD/////AQAAAAAAAAARAQAAAAIAAAAGAgAAAAVoZWxsbwYDAAAABXdvcmxkCw==</value>
+ </data>
+</root>
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ButtonTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ButtonTest.cs
new file mode 100644
index 00000000000..f792e8de509
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ButtonTest.cs
@@ -0,0 +1,104 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ButtonTest
+ {
+ [Test]
+ public void FlatStyleTest ()
+ {
+ Button B1 = new Button ();
+ Assert.AreEqual (FlatStyle.Standard, B1.FlatStyle, "#1");
+ }
+
+ [Test]
+ public void ImageTest ()
+ {
+ Button B1 = new Button ();
+ B1.Visible = true;
+ B1.Image = Image.FromFile ("M.gif");
+ Assert.AreEqual (ContentAlignment.MiddleCenter, B1.ImageAlign, "#2");
+ }
+
+ [Test]
+ public void ImageListTest ()
+ {
+ Button B1 = new Button ();
+ B1.Image = Image.FromFile ("M.gif");
+ Assert.AreEqual (null, B1.ImageList, "#3a");
+ ImageList ImageList1 = new ImageList ();
+ ImageList1.Images.Add(Image.FromFile ("M.gif"));
+ B1.ImageList = ImageList1;
+ Assert.AreEqual (-1, B1.ImageIndex, "#3b");
+ B1.ImageIndex = 0;
+ Assert.AreEqual (1, B1.ImageList.Images.Count, "#3c");
+ Assert.AreEqual (16, B1.ImageList.ImageSize.Height, "#3d");
+ Assert.AreEqual (16, B1.ImageList.ImageSize.Width, "#3e");
+ }
+
+ [Test]
+ public void IMeModeTest ()
+ {
+ Button B1 = new Button ();
+ Assert.AreEqual (ImeMode.Disable, B1.ImeMode, "#4");
+ }
+
+ [Test]
+ public void TextAlignTest ()
+ {
+ Button B1 = new Button ();
+ Assert.AreEqual (ContentAlignment.MiddleCenter, B1.TextAlign, "#5");
+ }
+
+ [Test]
+ public void DialogResultTest ()
+ {
+ Form f = new Form ();
+ Button B1 = new Button ();
+ B1.Text = "DialogResult";
+ B1.DialogResult = DialogResult.No;
+ B1.TextAlign = ContentAlignment.BottomRight;
+ B1.Visible = true;
+ f.Controls.Add (B1);
+ Assert.AreEqual (DialogResult.No, B1.DialogResult, "#6");
+ }
+
+ [Test]
+ public void PerformClickTest ()
+ {
+ Form f = new Form ();
+ Button B1 = new Button ();
+ B1.Text = "DialogResult";
+ B1.Visible = true;
+ f.Controls.Add (B1);
+ B1.PerformClick ();
+ Assert.AreEqual (DialogResult.None, B1.DialogResult, "#7");
+ }
+
+ [Test]
+ public void NotifyDefaultTest ()
+ {
+ Button B1 = new Button ();
+ Assert.AreEqual ("System.Windows.Forms.Button, Text: ", B1.ToString (), "#8");
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ Button B1 = new Button ();
+ Assert.AreEqual ("System.Windows.Forms.Button, Text: " , B1.ToString (), "#9");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
new file mode 100644
index 00000000000..5daae3c1c9d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
@@ -0,0 +1,258 @@
+2006-02-02 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ControlTest.cs: Added test for layout nesting
+ * MonthCalendarTest.cs: Fixed typo in class name
+
+2005-12-01 Jackson Harper <jackson@ximian.com>
+
+ * TreeNodeTest.cs: TreeNodeTest.cs : Added namespace +
+ SingleNodeIndexTest.
+ - Fixed warning CS0219. Patches by Dieter Bremes
+
+2005-11-12 Pedro Martínez Juliá <pedromj@gmail.com>
+
+ * DataGridViewElementTest.cs DataGridViewBandTest.cs
+ DataGridViewCellTest.cs DataGridViewAdvancedBorderStyleTest.cs
+ DataGridViewCellStyleTest.cs DataGridViewRowTest.cs DataGridViewTest.cs:
+
+ Add some DataGridView tests.
+
+2005-11-11 Ankit Jain <jankit@novell.com>
+
+ * RichTextBoxTest.cs: Fix typos.
+
+2005-11-09 Peter Dennis Bartok <pbartok@novell.com>
+
+ * RichTextBoxTest.cs: Added Find() tests
+
+2005-11-05 Kornél Pál <kornelpal@hotmail.com>
+
+ * LabelPropertyTest.cs: Updated product version to 1.1.4322.2032 (1.1 SP1).
+
+2005-10-18 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListViewCollectionsTest.cs: Add tests for the ListView Collections
+
+2005-10-17 Ritvik Mayank <mritvik@novell.com>
+
+ * TabControlTest.cs : Added test case for TabControl
+
+2005-10-16 Ritvik Mayank <mritvik@novell.com>
+
+ * TrackBarTest.cs : Added test case for TrackBar
+
+2005-10-16 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridBoolColumn.cs: fixes warning
+
+2005-10-10 Peter Dennis Bartok <pbartok@novell.com>
+
+ * GenerateControlStyleTest.cs, ControlStyleTest.cs: Flipped
+ order for want and actual to avoid misleading errors
+
+2005-10-07 Peter Dennis Bartok <pbartok@novell.com>
+
+ * GenerateControlStyleTest.cs: Code to auto-generate the
+ source file ControlStyleTest.cs
+ * ControlStyleTest.cs: Tests for testing ControlStyles
+
+2005-09-28 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * Common.cs : Add common things here.
+ * LabelTest.cs : Remove common declarations to Common.cs
+ * ScrollBarTest.cs : Remove common declarations to Common.cs
+ Add more propery range / exception tests
+ Add more event order tests
+ Fix Mouse tests.
+ Add event arg tests.
+
+2005-09-27 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * LabelTest.cs : Added more event tests (external handlers)
+ Added event arg checks
+ Fixed OnPaint tests.
+ Seperated invalidation tests.
+
+2005-09-26 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * ScrollBarTest.cs : Add more tests for event firing order
+ Messages to simulate mouse events
+
+2005-09-23 Ritvik Mayank <mritvik@novell.com>
+
+ * ErrorProviderTest.cs : Added test case for ErrorProvider
+
+2005-09-23 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * LabelTest.cs : Added messages to simulate Key* events.
+ Key* events have tests now.
+
+2005-09-22 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * LabelTest.cs : Implement event firing order tests.
+ * ScrollBarTest.cs : Implement event firing order tests.
+
+2005-09-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * MenuTest.cs: Fixes some tests
+ * MenuItemTest.cs: New unit test
+
+2005-09-21 Hisham Mardam Bey <hisham.mardambey@gmail.com>
+
+ * LabelTest.cs : Several new tests.
+ * ScrollBarTest.cs : Several new tests.
+ * bitmaps : added dir containing images for tests.
+
+2005-09-21 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ListViewItemTest.cs: New unit test
+
+2005-09-20 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ButtonTest.cs, LabelTest.cs, ControlEventTest.cs, ScrollBarTest.cs,
+ LabelPropertyTest.cs, ProgressBarTest.cs, StatusBarTest.cs,
+ ImageListTest.cs, MonthCalendarTest.cs, ControlTest.cs,
+ ListBoxEventTest.cs, TreeViewTest.cs, TestImageIndexConverter.cs,
+ ToolBarTest.cs, MenuTest.cs
+
+ Remove all the tests that are giving errors. All of them should
+ be reviewed. Right now having this text throwing 40 errors do not
+ help at all to do regression testing. Peter has already assigned
+ a group of controls to every developer that will be tested and
+ reviewed.
+
+2005-09-20 Ritvik Mayank <mritvik@novell.com>
+
+ * PictureBoxTest.cs : Test case for PictureBox
+
+2005-09-08 Ritvik Mayank <mritvik@novell.com>
+
+ * MonthCalendarTest.cs : Test case for MonthCalendar
+
+2005-08-29 Ritvik Mayank <mritvik@novell.com>
+
+ * ProgressBarTest.cs : Test case for ProgressBar
+ * ToolBarTest.cs : Test case for ToolBar
+ * ToolTipTest.cs : Test case for ToolTip
+ * RichTextBoxTest.cs : Test case for RichTextBox
+
+2005-08-16 Martin Baulig <martin@ximian.com>
+
+ * ControlTest.cs: Renamed namespace `MWF.Test' -> `MWF.MonoTest'
+ to make it compile.
+
+2005-08-16 Ritvik Mayank <mritvik@novell.com>
+
+ * ScrollBarTest.cs, ImageListTest.cs, CheckedListBoxTest.cs, CheckedListBoxEventTest.cs, MenuTest.cs,
+ ListViewTest.cs: enhancement and cleanup
+
+2005-08-16 Ritvik Mayank <mritvik@novell.com>
+
+ * ImageListTest.cs : Test case for ImageList
+ * RadioButtonTest.cs : Test case for RadioButton
+ * ScrollBarTest.cs : Test case for ScrollBar
+ * StatusBatTest.cs : Test case for StatusBar
+
+2005-08-10 Ritvik Mayank <mritvik@novell.com>
+
+ * ControlTest.cs : Commented out test for GetChildAtPointSkip (feature not
+ yet implemented)
+
+2005-08-08 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ComboBoxTest.cs: new tests for properties, exceptions, and colletions
+ * ListBoxTest.cs: new tests for properties, exceptions, and colletionss
+
+2005-08-06 Ritvik Mayank <mritvik@novell.com>
+
+ * ComboBoxTest.cs, ListBoxTest.cs : Cleanup, added few more tests
+
+2005-08-05 Ritvik Mayank <mritvik@novell.com>
+
+ * ButtonTest.cs, ImageListTest.cs, ControlEventTest.cs,
+ LabelPropertyTest.cs, CheckBoxTest.cs, ListBoxEventTest.cs,
+ CheckBoxEventTest.cs, CheckedListBoxTest.cs, TextBoxTest.cs,
+ CheckedListBoxEventTest.cs, FormTest.cs, MenuTest.cs,
+ FormEventTest.cs, GroupBoxTest.cs, ListViewTest.cs,
+ ListViewEventTest.cs :
+ Cleanup, Ignored tests which need manual intervention,
+ work still in progress.
+
+2005-08-05 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumnTest.cs: test fixes and enhancements
+ * GridTableStylesCollectionTest.cs: test fixes and enhancements
+ * DataGridTest.cs: test fixes and enhancements
+ * DataGridCellTest.cs: New unit test
+ * GridColumnStylesCollectionTest.cs: test fixes and enhancements
+ * DataGridTableStyleTest.cs: test fixes and enhancements
+
+2005-08-04 Peter Dennis Bartok <pbartok@novell.com>
+
+ * ControlTest.cs: Cleanup, fixed commented out tests with syntax
+ errors, streamlined a few tests, added full tab order test, still
+ work in progress
+
+2005-08-02 Ritvik Mayank <mritvik@novell.com>
+
+ * FormTest.cs : Test case for Form
+ * GropBoxTest : Test case for GroupBox
+ * MenuTest.cs : Test case for Menu
+ * ImageListTest.cs : Test case for ImageList
+
+2005-07-26 Ritvik Mayank <mritvik@novell.com>
+
+ * ListViewTest.cs : Test case for ListView
+ * ListViewEventTest.cs : Test case for ListView events
+ * ComboBoxTest.cs : Test case for ComboBox
+ * FormEventTest.cs : Test case for Form events
+
+2005-07-12 Ritvik Mayank <mritvik@novell.com>
+
+ * CheckBoxTest.cs : Test case for CheckBox
+ * CheckBoxEventTest.cs : Test case for CheckBox events
+ * CheckedListBoxTest.cs : Test case for CheckedListBox
+ * CheckedListBoxEventTest.cs : Test case for CheckedListBox events
+
+2005-07-05 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * DataGridTextBoxColumnTest.cs: Test case
+ * GridTableStylesCollectionTest.cs: Test case
+ * DataGridTest.cs: Test case
+ * GridColumnStylesCollectionTest.cs: Test case
+ * DataGridTableStyleTest.cs: Test case
+
+
+2005-07-04 Ritvik Mayank <mritvik@novell.com>
+
+ * ListBoxTest.cs : Test Cases for ListBox Properties and Methods
+ * ListBoxEventTest.cs : Test Cases for ListBox Events
+
+2005-06-13 Ritvik Mayank <mritvik@novell.com>
+
+ * TextBoxTest.cs : Test Cases for TextBox
+ * BUttonTest.cs : Test Cases for Buttons
+
+2005-05-11 Ritvik Mayank <mritvik@novell.com>
+
+ * ControlEventTest.cs : Test Cases for Events
+
+2005-05-02 Ritvik Mayank <mritvik@novell.com>
+
+ * ControlTest.cs : Minor modifications
+
+2005-05-02 Ritvik Mayank <mritvik@novell.com>
+
+ * ControlTest.cs : Test for Control
+
+2005-04-25 Ritvik Mayank <mritvik@novell.com>
+ * LabelPropertyTest.cs : Test for Label
+
+2004-11-29 Marek Safar <marek.safar@seznam.cz>
+ * TreeViewTest.cs : Test for TreeView
+ * TreeNodeTest.cs : Test for TreeNode
+
+2004-11-29 Ravindra <rkumar@novell.com>
+ * ImageIndexConverter.cs : Test for ImageIndexConversion.
+
+
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxEventTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxEventTest.cs
new file mode 100644
index 00000000000..a81d3764894
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxEventTest.cs
@@ -0,0 +1,65 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class CheckBoxEventTest
+ {
+ static bool eventhandled = false;
+ public void CheckBox_EventHandler (object sender,EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void ApperanceEventTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ CheckBox chkbox = new CheckBox ();
+ chkbox.Visible = true;
+ myform.Controls.Add (chkbox);
+ chkbox.AppearanceChanged += new EventHandler (CheckBox_EventHandler);
+ chkbox.Appearance = Appearance.Button;
+ Assert.AreEqual (true, eventhandled, "#A1");
+ }
+
+ [Test]
+ public void CheckedChangedEventTest ()
+ {
+ eventhandled = false;
+ Form myform = new Form ();
+ myform.Visible = true;
+ CheckBox chkbox = new CheckBox ();
+ chkbox.Visible = true;
+ myform.Controls.Add (chkbox);
+ chkbox.CheckedChanged += new EventHandler (CheckBox_EventHandler);
+ chkbox.CheckState = CheckState.Indeterminate;
+ Assert.AreEqual (true, eventhandled, "#A2");
+ }
+
+ [Test]
+ public void CheckStateChangedEventTest ()
+ {
+ eventhandled = false;
+ Form myform = new Form ();
+ myform.Visible = true;
+ CheckBox chkbox = new CheckBox ();
+ chkbox.Visible = true;
+ myform.Controls.Add (chkbox);
+ chkbox.CheckStateChanged += new EventHandler (CheckBox_EventHandler);
+ chkbox.CheckState = CheckState.Checked;
+ Assert.AreEqual (true, eventhandled, "#A3");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxTest.cs
new file mode 100644
index 00000000000..2fd428da8fb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckBoxTest.cs
@@ -0,0 +1,40 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using System.Collections;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+using System.Threading;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class CheckBoxTest
+ {
+ [Test]
+ public void CheckBoxPropertyTest ()
+ {
+ Form myform = new Form ();
+ CheckBox mychkbox = new CheckBox();
+ myform.Controls.Add (mychkbox);
+ Assert.AreEqual (Appearance.Normal, mychkbox.Appearance, "#1");
+ mychkbox.Appearance = Appearance.Button;
+ Assert.AreEqual (Appearance.Button, mychkbox.Appearance, "#2");
+ Assert.AreEqual (true, mychkbox.AutoCheck, "#3");
+ mychkbox.AutoCheck = false;
+ Assert.AreEqual (false, mychkbox.AutoCheck, "#4");
+ Assert.AreEqual (false, mychkbox.Checked, "#5");
+ Assert.AreEqual (CheckState.Unchecked, mychkbox.CheckState, "#6");
+ Assert.AreEqual (ContentAlignment.MiddleLeft, mychkbox.CheckAlign, "#7");
+ Assert.AreEqual (ContentAlignment.MiddleLeft, mychkbox.TextAlign, "#8");
+ Assert.AreEqual (false, mychkbox.ThreeState, "#9");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxEventTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxEventTest.cs
new file mode 100644
index 00000000000..8bd1fe0b0dc
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxEventTest.cs
@@ -0,0 +1,42 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class CheckedListBoxItemCheckEvent
+ {
+ static bool eventhandled = false;
+ public void ItemCheck_EventHandler (object sender,ItemCheckEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void ItemCheckTest ()
+ {
+ Form myform = new Form ();
+ CheckedListBox mychklstbox = new CheckedListBox ();
+ mychklstbox.Items.Add ("test1");
+ mychklstbox.Items.Add ("test2");
+ //Test ItemCheck Event
+ mychklstbox.ItemCheck += new ItemCheckEventHandler (ItemCheck_EventHandler);
+ mychklstbox.Items.Add ("test1",CheckState.Checked);
+ myform.Controls.Add (mychklstbox);
+ myform.Show ();
+ Assert.AreEqual (true, eventhandled, "#A1");
+ eventhandled = false;
+ mychklstbox.SetItemChecked (1,true);
+ Assert.AreEqual (true, eventhandled, "#A2");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxTest.cs
new file mode 100644
index 00000000000..f88b583d5ef
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CheckedListBoxTest.cs
@@ -0,0 +1,133 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using System.Collections;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class CheckedListBoxTest
+ {
+ [Test]
+ public void CheckedListBoxPropertyTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ CheckedListBox mychklistbox = new CheckedListBox ();
+ ArrayList checked_items = new ArrayList (2);
+ ArrayList checked_pos = new ArrayList (2);
+ mychklistbox.Items.Add ("test1", true);
+ checked_items.Add ("test1"); checked_pos.Add (0);
+ mychklistbox.Items.Add ("test2");
+ mychklistbox.Items.Add ("test3", true);
+ checked_items.Add ("test3"); checked_pos.Add (2);
+ mychklistbox.Visible = true;
+ myform.Controls.Add (mychklistbox);
+ Assert.AreEqual (checked_items.Count, mychklistbox.CheckedIndices.Count, "#1");
+ Assert.AreEqual (checked_items.Count, mychklistbox.CheckedItems.Count, "#2");
+ foreach (object o in mychklistbox.CheckedItems)
+ {
+ Assert.IsTrue (checked_items.Contains (o),"#3");
+ checked_items.Remove (o);
+ }
+
+ Assert.AreEqual (0, checked_items.Count);
+ for (int i = 0; i < mychklistbox.Items.Count; ++i)
+ {
+ if (checked_pos.Contains (i))
+ Assert.AreEqual (CheckState.Checked, mychklistbox.GetItemCheckState (i),"#4");
+ else
+ Assert.IsFalse (CheckState.Checked == mychklistbox.GetItemCheckState (i),"#5");
+ }
+ Assert.AreEqual (false, mychklistbox.CheckOnClick, "#6");
+ Assert.AreEqual (3, mychklistbox.Items.Count, "#7");
+ Assert.AreEqual (SelectionMode.One, mychklistbox.SelectionMode, "#8");
+ Assert.AreEqual (false , mychklistbox.ThreeDCheckBoxes, "#9");
+ }
+
+ [Test]
+ public void GetItemCheckedTest ()
+ {
+ Form f = new Form ();
+ f.Visible = true;
+ CheckedListBox mychklistbox = new CheckedListBox ();
+ mychklistbox.Items.Add ("test1",true);
+ mychklistbox.Items.Add ("test2",CheckState.Indeterminate);
+ mychklistbox.Items.Add ("test3");
+ mychklistbox.Visible = true;
+ f.Controls.Add (mychklistbox);
+ Assert.AreEqual (true, mychklistbox.GetItemChecked (0), "#10");
+ Assert.AreEqual (true, mychklistbox.GetItemChecked (1), "#11");
+ Assert.AreEqual (false, mychklistbox.GetItemChecked (2), "#12");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException) )]
+ public void GetItemCheckedExceptionTest ()
+ {
+ CheckedListBox mychklistbox = new CheckedListBox ();
+ mychklistbox.Items.Add ("test1",true);
+ Assert.AreEqual (true, mychklistbox.GetItemChecked (1), "#13");
+ }
+
+ [Test]
+ public void GetItemCheckStateTest ()
+ {
+ Form f = new Form ();
+ f.Visible = true;
+ CheckedListBox mychklistbox = new CheckedListBox ();
+ mychklistbox.Items.Add ("test1",true);
+ mychklistbox.Items.Add ("test2",CheckState.Indeterminate);
+ mychklistbox.Items.Add ("test3");
+ mychklistbox.Visible = true;
+ f.Controls.Add (mychklistbox);
+ Assert.AreEqual (CheckState.Checked, mychklistbox.GetItemCheckState (0), "#14");
+ Assert.AreEqual (CheckState.Indeterminate, mychklistbox.GetItemCheckState (1), "#15");
+ Assert.AreEqual (CheckState.Unchecked, mychklistbox.GetItemCheckState (2), "#16");
+ }
+
+ [Test]
+ public void SetItemCheckedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ CheckedListBox mychklistbox = new CheckedListBox ();
+ mychklistbox.Items.Add ("test1");
+ mychklistbox.Items.Add ("test2");
+ mychklistbox.Visible = true;
+ myform.Controls.Add (mychklistbox);
+ mychklistbox.SetItemChecked (0,true);
+ mychklistbox.SetItemChecked (1,false);
+ Assert.AreEqual (CheckState.Checked, mychklistbox.GetItemCheckState (0), "#17");
+ Assert.AreEqual (CheckState.Unchecked, mychklistbox.GetItemCheckState (1), "#18");
+ }
+
+ [Test]
+ public void SetItemCheckStateTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ CheckedListBox mychklistbox = new CheckedListBox ();
+ mychklistbox.Items.Add ("test1");
+ mychklistbox.Items.Add ("test2");
+ mychklistbox.Items.Add ("test3");
+ mychklistbox.Visible = true;
+ myform.Controls.Add (mychklistbox);
+ mychklistbox.SetItemCheckState (0,CheckState.Checked);
+ mychklistbox.SetItemCheckState (1,CheckState.Indeterminate);
+ mychklistbox.SetItemCheckState (2,CheckState.Unchecked);
+ Assert.AreEqual (CheckState.Checked, mychklistbox.GetItemCheckState (0), "#19");
+ Assert.AreEqual (CheckState.Indeterminate, mychklistbox.GetItemCheckState (1), "#20");
+ Assert.AreEqual (CheckState.Unchecked, mychklistbox.GetItemCheckState (2), "#21");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs
new file mode 100644
index 00000000000..67765f281d6
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs
@@ -0,0 +1,326 @@
+//
+// ComboBoxTest.cs: Test cases for ComboBox.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Ritvik Mayank <mritvik@novell.com>
+// Jordi Mas i Hernandez <jordi@ximian.com>
+
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+using System.Collections;
+using System.ComponentModel;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class ComboBoxTest
+ {
+ [Test]
+ public void ComboBoxPropertyTest ()
+ {
+ ComboBox mycmbbox = new ComboBox ();
+ Assert.AreEqual (DrawMode.Normal, mycmbbox.DrawMode, "#1");
+ Assert.AreEqual (ComboBoxStyle.DropDown, mycmbbox.DropDownStyle, "#2");
+ Assert.AreEqual (121, mycmbbox.DropDownWidth, "#3");
+ Assert.AreEqual (false, mycmbbox.DroppedDown, "#4");
+ Assert.AreEqual (true, mycmbbox.IntegralHeight, "#5");
+ Assert.AreEqual (0, mycmbbox.Items.Count, "#6");
+ //Assert.AreEqual (15, mycmbbox.ItemHeight, "#7"); // Note: Item height depends on the current font.
+ Assert.AreEqual (8, mycmbbox.MaxDropDownItems, "#8");
+ Assert.AreEqual (0, mycmbbox.MaxLength, "#9");
+ Assert.AreEqual (20, mycmbbox.PreferredHeight, "#10");
+ Assert.AreEqual (-1, mycmbbox.SelectedIndex, "#11");
+ Assert.AreEqual (null, mycmbbox.SelectedItem, "#12");
+ Assert.AreEqual ("", mycmbbox.SelectedText, "#13");
+ Assert.AreEqual (0, mycmbbox.SelectionLength, "#14");
+ Assert.AreEqual (0, mycmbbox.SelectionStart, "#15");
+ Assert.AreEqual (false, mycmbbox.Sorted, "#16");
+ Assert.AreEqual ("", mycmbbox.Text, "#17");
+ }
+
+ [Test]
+ public void BeginEndUpdateTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.Items.Add ("A");
+ cmbbox.Visible = true;
+ myform.Controls.Add (cmbbox);
+ cmbbox.BeginUpdate ();
+ for (int x = 1 ; x < 5000 ; x++) {
+ cmbbox.Items.Add ("Item " + x.ToString ());
+ }
+ cmbbox.EndUpdate ();
+ }
+
+ [Test]
+ public void FindStringTest ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.FindString ("Hola", -5); // No exception, it's empty
+ int x = cmbbox.FindString ("Hello");
+ Assert.AreEqual (-1, x, "#19");
+ cmbbox.Items.AddRange(new object[] {"ACBD", "ABDC", "ACBD", "ABCD"});
+ String myString = "ABC";
+ x = cmbbox.FindString (myString);
+ Assert.AreEqual (3, x, "#191");
+ x = cmbbox.FindString (string.Empty);
+ Assert.AreEqual (0, x, "#192");
+ x = cmbbox.FindString ("NonExistant");
+ Assert.AreEqual (-1, x, "#193");
+ }
+
+ [Test]
+ public void FindStringExactTest ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.FindStringExact ("Hola", -5); // No exception, it's empty
+ int x = cmbbox.FindStringExact ("Hello");
+ Assert.AreEqual (-1, x, "#20");
+ cmbbox.Items.AddRange (new object[] {"ABCD","ABC","ABDC"});
+ String myString = "ABC";
+ x = cmbbox.FindStringExact (myString);
+ Assert.AreEqual (1, x, "#201");
+ x = cmbbox.FindStringExact (string.Empty);
+ Assert.AreEqual (-1, x, "#202");
+ x = cmbbox.FindStringExact ("NonExistant");
+ Assert.AreEqual (-1, x, "#203");
+ }
+
+ [Test]
+ public void GetItemHeightTest ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.Items.Add ("ABC");
+ cmbbox.Items.Add ("BCD");
+ cmbbox.Items.Add ("DEF");
+ int x = -1;
+ x = cmbbox.GetItemHeight (x);
+ Assert.IsTrue (cmbbox.ItemHeight > 0, "#21");
+ }
+
+
+ //
+ // Exceptions
+ //
+
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void DropDownStyleException ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.DropDownStyle = (ComboBoxStyle) 10;
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void DrawModeException ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.DrawMode = (DrawMode) 10;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void DropDownWidthException ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.DropDownWidth = 0;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ItemHeightException ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.ItemHeight = -1;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void SelectedIndexException ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.SelectedIndex = -2;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void FindStringExactMinException ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.Items.AddRange(new object[] {"ACBD", "ABDC", "ACBD", "ABCD"});
+ cmbbox.FindStringExact ("Hola", -2);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void FindStringExactMaxException ()
+ {
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.Items.AddRange(new object[] {"ACBD", "ABDC", "ACBD", "ABCD"});
+ cmbbox.FindStringExact ("Hola", 3);
+ }
+
+ //
+ // Events
+ //
+ private bool eventFired;
+ private DrawItemEventArgs drawItemsArgs;
+ private void DrawItemEventH (object sender, DrawItemEventArgs e)
+ {
+ eventFired = true;
+ drawItemsArgs = e;
+ }
+
+ private void GenericHandler (object sender, EventArgs e)
+ {
+ eventFired = true;
+ }
+
+ [Ignore ("Bugs in X11 prevent this test to run properly")]
+ public void DrawItemEventTest ()
+ {
+ eventFired = false;
+ drawItemsArgs = null;
+ Form myform = new Form ();
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.DropDownStyle = ComboBoxStyle.Simple;
+ cmbbox.DrawMode = DrawMode.OwnerDrawFixed;
+ cmbbox.DrawItem += new DrawItemEventHandler (DrawItemEventH);
+
+ myform.Controls.Add (cmbbox);
+ cmbbox.Items.AddRange(new object[] {"Item1"});
+
+ myform.Visible = true;
+ cmbbox.Visible = true;
+ cmbbox.Refresh ();
+
+ Assert.AreEqual (true, eventFired, "DW1");
+ Assert.AreEqual (0, drawItemsArgs.Index, "DW2");
+ }
+
+ [Test]
+ public void DropDownStyleEventTest ()
+ {
+ eventFired = false;
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.DropDownStyleChanged += new EventHandler (GenericHandler);
+ cmbbox.DropDownStyle = ComboBoxStyle.Simple;
+
+ Assert.AreEqual (true, eventFired, "DI1");
+ }
+
+ [Test]
+ public void SelectedIndextTest ()
+ {
+ eventFired = false;
+ ComboBox cmbbox = new ComboBox ();
+ cmbbox.Items.AddRange(new object[] {"Item1", "Item2"});
+ cmbbox.SelectedIndexChanged += new EventHandler (GenericHandler);
+ cmbbox.SelectedIndex = 1;
+ Assert.AreEqual (true, eventFired, "SI1");
+ }
+
+ }
+
+ [TestFixture]
+ public class ComboBoxObjectCollectionTest
+ {
+ [Test]
+ public void ComboBoxObjectCollectionPropertyTest ()
+ {
+ ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+ Assert.AreEqual (false, col.IsReadOnly, "#B1");
+ Assert.AreEqual (false, ((ICollection)col).IsSynchronized, "#B2");
+ Assert.AreEqual (col, ((ICollection)col).SyncRoot, "#B3");
+ Assert.AreEqual (false, ((IList)col).IsFixedSize, "#B4");
+ }
+
+ [Test]
+ public void AddTest ()
+ {
+ ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ Assert.AreEqual (2, col.Count, "#C1");
+ }
+
+ [Test]
+ public void ClearTest ()
+ {
+ ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ col.Clear ();
+ Assert.AreEqual (0, col.Count, "#D1");
+ }
+
+ [Test]
+ public void ContainsTest ()
+ {
+ ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+ object obj = "Item1";
+ col.Add (obj);
+ Assert.AreEqual (true, col.Contains ("Item1"), "#E1");
+ Assert.AreEqual (false, col.Contains ("Item2"), "#E2");
+ }
+
+ [Test]
+ public void IndexOfTest ()
+ {
+ ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ Assert.AreEqual (1, col.IndexOf ("Item2"), "#F1");
+ }
+
+ [Test]
+ public void RemoveTest ()
+ {
+ ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ col.Remove ("Item1");
+ Assert.AreEqual (1, col.Count, "#G1");
+ }
+
+ [Test]
+ public void RemoveAtTest ()
+ {
+ ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ col.RemoveAt (0);
+ Assert.AreEqual (1, col.Count, "#H1");
+ Assert.AreEqual (true, col.Contains ("Item2"), "#H1");
+ }
+ }
+
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/Common.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/Common.cs
new file mode 100644
index 00000000000..d02e9424b36
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/Common.cs
@@ -0,0 +1,251 @@
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms
+{
+ internal enum WndMsg {
+ WM_NULL = 0x0000,
+ WM_CREATE = 0x0001,
+ WM_DESTROY = 0x0002,
+ WM_MOVE = 0x0003,
+ WM_SIZE = 0x0005,
+ WM_ACTIVATE = 0x0006,
+ WM_SETFOCUS = 0x0007,
+ WM_KILLFOCUS = 0x0008,
+ //public const uint WM_SETVISIBLE = 0x0009;
+ WM_ENABLE = 0x000A,
+ WM_SETREDRAW = 0x000B,
+ WM_SETTEXT = 0x000C,
+ WM_GETTEXT = 0x000D,
+ WM_GETTEXTLENGTH = 0x000E,
+ WM_PAINT = 0x000F,
+ WM_CLOSE = 0x0010,
+ WM_QUERYENDSESSION = 0x0011,
+ WM_QUIT = 0x0012,
+ WM_QUERYOPEN = 0x0013,
+ WM_ERASEBKGND = 0x0014,
+ WM_SYSCOLORCHANGE = 0x0015,
+ WM_ENDSESSION = 0x0016,
+ //public const uint WM_SYSTEMERROR = 0x0017;
+ WM_SHOWWINDOW = 0x0018,
+ WM_CTLCOLOR = 0x0019,
+ WM_WININICHANGE = 0x001A,
+ WM_SETTINGCHANGE = 0x001A,
+ WM_DEVMODECHANGE = 0x001B,
+ WM_ACTIVATEAPP = 0x001C,
+ WM_FONTCHANGE = 0x001D,
+ WM_TIMECHANGE = 0x001E,
+ WM_CANCELMODE = 0x001F,
+ WM_SETCURSOR = 0x0020,
+ WM_MOUSEACTIVATE = 0x0021,
+ WM_CHILDACTIVATE = 0x0022,
+ WM_QUEUESYNC = 0x0023,
+ WM_GETMINMAXINFO = 0x0024,
+ WM_PAINTICON = 0x0026,
+ WM_ICONERASEBKGND = 0x0027,
+ WM_NEXTDLGCTL = 0x0028,
+ //public const uint WM_ALTTABACTIVE = 0x0029;
+ WM_SPOOLERSTATUS = 0x002A,
+ WM_DRAWITEM = 0x002B,
+ WM_MEASUREITEM = 0x002C,
+ WM_DELETEITEM = 0x002D,
+ WM_VKEYTOITEM = 0x002E,
+ WM_CHARTOITEM = 0x002F,
+ WM_SETFONT = 0x0030,
+ WM_GETFONT = 0x0031,
+ WM_SETHOTKEY = 0x0032,
+ WM_GETHOTKEY = 0x0033,
+ //public const uint WM_FILESYSCHANGE = 0x0034;
+ //public const uint WM_ISACTIVEICON = 0x0035;
+ //public const uint WM_QUERYPARKICON = 0x0036;
+ WM_QUERYDRAGICON = 0x0037,
+ WM_COMPAREITEM = 0x0039,
+ //public const uint WM_TESTING = 0x003a;
+ //public const uint WM_OTHERWINDOWCREATED = 0x003c;
+ WM_GETOBJECT = 0x003D,
+ //public const uint WM_ACTIVATESHELLWINDOW = 0x003e;
+ WM_COMPACTING = 0x0041,
+ WM_COMMNOTIFY = 0x0044 ,
+ WM_WINDOWPOSCHANGING = 0x0046,
+ WM_WINDOWPOSCHANGED = 0x0047,
+ WM_POWER = 0x0048,
+ WM_COPYDATA = 0x004A,
+ WM_CANCELJOURNAL = 0x004B,
+ WM_NOTIFY = 0x004E,
+ WM_INPUTLANGCHANGEREQUEST = 0x0050,
+ WM_INPUTLANGCHANGE = 0x0051,
+ WM_TCARD = 0x0052,
+ WM_HELP = 0x0053,
+ WM_USERCHANGED = 0x0054,
+ WM_NOTIFYFORMAT = 0x0055,
+ WM_CONTEXTMENU = 0x007B,
+ WM_STYLECHANGING = 0x007C,
+ WM_STYLECHANGED = 0x007D,
+ WM_DISPLAYCHANGE = 0x007E,
+ WM_GETICON = 0x007F,
+
+ // Non-Client messages
+ WM_SETICON = 0x0080,
+ WM_NCCREATE = 0x0081,
+ WM_NCDESTROY = 0x0082,
+ WM_NCCALCSIZE = 0x0083,
+ WM_NCHITTEST = 0x0084,
+ WM_NCPAINT = 0x0085,
+ WM_NCACTIVATE = 0x0086,
+ WM_GETDLGCODE = 0x0087,
+ WM_SYNCPAINT = 0x0088,
+ //public const uint WM_SYNCTASK = 0x0089;
+ WM_NCMOUSEMOVE = 0x00A0,
+ WM_NCLBUTTONDOWN = 0x00A1,
+ WM_NCLBUTTONUP = 0x00A2,
+ WM_NCLBUTTONDBLCLK = 0x00A3,
+ WM_NCRBUTTONDOWN = 0x00A4,
+ WM_NCRBUTTONUP = 0x00A5,
+ WM_NCRBUTTONDBLCLK = 0x00A6,
+ WM_NCMBUTTONDOWN = 0x00A7,
+ WM_NCMBUTTONUP = 0x00A8,
+ WM_NCMBUTTONDBLCLK = 0x00A9,
+ //public const uint WM_NCXBUTTONDOWN = 0x00ab;
+ //public const uint WM_NCXBUTTONUP = 0x00ac;
+ //public const uint WM_NCXBUTTONDBLCLK = 0x00ad;
+ WM_KEYDOWN = 0x0100,
+ WM_KEYFIRST = 0x0100,
+ WM_KEYUP = 0x0101,
+ WM_CHAR = 0x0102,
+ WM_DEADCHAR = 0x0103,
+ WM_SYSKEYDOWN = 0x0104,
+ WM_SYSKEYUP = 0x0105,
+ WM_SYSCHAR = 0x0106,
+ WM_SYSDEADCHAR = 0x0107,
+ WM_KEYLAST = 0x0108,
+ WM_IME_STARTCOMPOSITION = 0x010D,
+ WM_IME_ENDCOMPOSITION = 0x010E,
+ WM_IME_COMPOSITION = 0x010F,
+ WM_IME_KEYLAST = 0x010F,
+ WM_INITDIALOG = 0x0110,
+ WM_COMMAND = 0x0111,
+ WM_SYSCOMMAND = 0x0112,
+ WM_TIMER = 0x0113,
+ WM_HSCROLL = 0x0114,
+ WM_VSCROLL = 0x0115,
+ WM_INITMENU = 0x0116,
+ WM_INITMENUPOPUP = 0x0117,
+ //public const uint WM_SYSTIMER = 0x0118;
+ WM_MENUSELECT = 0x011F,
+ WM_MENUCHAR = 0x0120,
+ WM_ENTERIDLE = 0x0121,
+ WM_MENURBUTTONUP = 0x0122,
+ WM_MENUDRAG = 0x0123,
+ WM_MENUGETOBJECT = 0x0124,
+ WM_UNINITMENUPOPUP = 0x0125,
+ WM_MENUCOMMAND = 0x0126,
+ //public const uint WM_CHANGEUISTATE = 0x0127;
+ //public const uint WM_UPDATEUISTATE = 0x0128;
+ //public const uint WM_QUERYUISTATE = 0x0129;
+ //
+ //public const uint WM_LBTRACKPOINT = 0x0131;
+ WM_CTLCOLORMSGBOX = 0x0132,
+ WM_CTLCOLOREDIT = 0x0133,
+ WM_CTLCOLORLISTBOX = 0x0134,
+ WM_CTLCOLORBTN = 0x0135,
+ WM_CTLCOLORDLG = 0x0136,
+ WM_CTLCOLORSCROLLBAR = 0x0137,
+ WM_CTLCOLORSTATIC = 0x0138,
+ WM_MOUSEMOVE = 0x0200,
+ WM_MOUSEFIRST = 0x0200,
+ WM_LBUTTONDOWN = 0x0201,
+ WM_LBUTTONUP = 0x0202,
+ WM_LBUTTONDBLCLK = 0x0203,
+ WM_RBUTTONDOWN = 0x0204,
+ WM_RBUTTONUP = 0x0205,
+ WM_RBUTTONDBLCLK = 0x0206,
+ WM_MBUTTONDOWN = 0x0207,
+ WM_MBUTTONUP = 0x0208,
+ WM_MBUTTONDBLCLK = 0x0209,
+ WM_MOUSEWHEEL = 0x020A,
+ WM_MOUSELAST = 0x020D,
+ //public const uint WM_XBUTTONDOWN = 0x020B;
+ //public const uint WM_XBUTTONUP = 0x020C;
+ //public const uint WM_XBUTTONDBLCLK = 0x020D;
+ WM_PARENTNOTIFY = 0x0210,
+ WM_ENTERMENULOOP = 0x0211,
+ WM_EXITMENULOOP = 0x0212,
+ WM_NEXTMENU = 0x0213,
+ WM_SIZING = 0x0214,
+ WM_CAPTURECHANGED = 0x0215,
+ WM_MOVING = 0x0216,
+ //public const uint WM_POWERBROADCAST = 0x0218;
+ WM_DEVICECHANGE = 0x0219,
+ WM_MDICREATE = 0x0220,
+ WM_MDIDESTROY = 0x0221,
+ WM_MDIACTIVATE = 0x0222,
+ WM_MDIRESTORE = 0x0223,
+ WM_MDINEXT = 0x0224,
+ WM_MDIMAXIMIZE = 0x0225,
+ WM_MDITILE = 0x0226,
+ WM_MDICASCADE = 0x0227,
+ WM_MDIICONARRANGE = 0x0228,
+ WM_MDIGETACTIVE = 0x0229,
+ /* D&D messages */
+ //public const uint WM_DROPOBJECT = 0x022A;
+ //public const uint WM_QUERYDROPOBJECT = 0x022B;
+ //public const uint WM_BEGINDRAG = 0x022C;
+ //public const uint WM_DRAGLOOP = 0x022D;
+ //public const uint WM_DRAGSELECT = 0x022E;
+ //public const uint WM_DRAGMOVE = 0x022F;
+ WM_MDISETMENU = 0x0230,
+ WM_ENTERSIZEMOVE = 0x0231,
+ WM_EXITSIZEMOVE = 0x0232,
+ WM_DROPFILES = 0x0233,
+ WM_MDIREFRESHMENU = 0x0234,
+ WM_IME_SETCONTEXT = 0x0281,
+ WM_IME_NOTIFY = 0x0282,
+ WM_IME_CONTROL = 0x0283,
+ WM_IME_COMPOSITIONFULL = 0x0284,
+ WM_IME_SELECT = 0x0285,
+ WM_IME_CHAR = 0x0286,
+ WM_IME_REQUEST = 0x0288,
+ WM_IME_KEYDOWN = 0x0290,
+ WM_IME_KEYUP = 0x0291,
+ WM_MOUSEHOVER = 0x02A1,
+ WM_MOUSELEAVE = 0x02A3,
+ WM_CUT = 0x0300,
+ WM_COPY = 0x0301,
+ WM_PASTE = 0x0302,
+ WM_CLEAR = 0x0303,
+ WM_UNDO = 0x0304,
+ WM_RENDERFORMAT = 0x0305,
+ WM_RENDERALLFORMATS = 0x0306,
+ WM_DESTROYCLIPBOARD = 0x0307,
+ WM_DRAWCLIPBOARD = 0x0308,
+ WM_PAINTCLIPBOARD = 0x0309,
+ WM_VSCROLLCLIPBOARD = 0x030A,
+ WM_SIZECLIPBOARD = 0x030B,
+ WM_ASKCBFORMATNAME = 0x030C,
+ WM_CHANGECBCHAIN = 0x030D,
+ WM_HSCROLLCLIPBOARD = 0x030E,
+ WM_QUERYNEWPALETTE = 0x030F,
+ WM_PALETTEISCHANGING = 0x0310,
+ WM_PALETTECHANGED = 0x0311,
+ WM_HOTKEY = 0x0312,
+ WM_PRINT = 0x0317,
+ WM_PRINTCLIENT = 0x0318,
+ WM_HANDHELDFIRST = 0x0358,
+ WM_HANDHELDLAST = 0x035F,
+ WM_AFXFIRST = 0x0360,
+ WM_AFXLAST = 0x037F,
+ WM_PENWINFIRST = 0x0380,
+ WM_PENWINLAST = 0x038F,
+ WM_APP = 0x8000,
+ WM_USER = 0x0400,
+
+ // Our "private" ones
+ WM_MOUSE_ENTER = 0x0401,
+ WM_MOUSE_LEAVE = 0x0402,
+ WM_ASYNC_MESSAGE = 0x0403,
+ WM_REFLECT = WM_USER + 0x1c00
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlEventTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlEventTest.cs
new file mode 100644
index 00000000000..e44734c03d3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlEventTest.cs
@@ -0,0 +1,300 @@
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Threading;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class EventClass
+ {
+ static bool eventhandled = false;
+ public static void Event_Handler1 (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void BackColorChangedTest ()
+ {
+ Control c = new Control ();
+ // Test BackColorChanged Event
+ c.BackColorChanged += new EventHandler (Event_Handler1);
+ c.BackColor = Color.Black;
+ Assert.AreEqual (true, eventhandled, "#A1");
+
+ }
+
+ [Test]
+ public void BgrndImageChangedTest ()
+ {
+ Control c = new Control ();
+ // Test BackgroundImageChanged Event
+ c.BackgroundImageChanged += new EventHandler (Event_Handler1);
+ string abc = "M.gif";
+ eventhandled = false;
+ c.BackgroundImage = Image.FromFile (abc);
+ Assert.AreEqual (true, eventhandled, "#A2");
+ }
+
+ [Test]
+ public void BindingContextChangedTest ()
+ {
+ Control c = new Control ();
+ // Test BindingContextChanged Event
+ c.BindingContextChanged += new EventHandler (Event_Handler1);
+ BindingContext bcG1 = new BindingContext ();
+ eventhandled = false;
+ c.BindingContext = bcG1;
+ Assert.AreEqual (true, eventhandled, "#A3");
+
+ }
+
+ [Test]
+ public void CausesValidationChangedTest ()
+ {
+ Control c = new Control ();
+ // Test CausesValidationChanged Event
+ c.CausesValidationChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.CausesValidation = false;
+ Assert.AreEqual (true, eventhandled, "#A4");
+
+ }
+
+ [Test]
+ public void CursorChangedTest ()
+ {
+ Control c = new Control ();
+ // Test CursorChanged Event
+ c.CursorChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Cursor = Cursors.Hand;
+ Assert.AreEqual (true, eventhandled, "#A6");
+ }
+
+ [Test]
+ public void DisposedTest ()
+ {
+ Control c = new Control ();
+ // Test Disposed Event
+ c.Disposed += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Dispose ();
+ Assert.AreEqual (true, eventhandled, "#A7");
+ }
+
+ [Test]
+ public void DockChangedTest ()
+ {
+ Control c = new Control ();
+ // Test DockChanged Event
+ c.DockChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Dock = DockStyle.Bottom;
+ Assert.AreEqual (true, eventhandled, "#A8");
+ }
+
+ [Test]
+ public void EnabledChangedTest ()
+ {
+ Control c = new Control ();
+ // Test EnabledChanged Event
+ c.EnabledChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Enabled = false;
+ Assert.AreEqual (true, eventhandled, "#A9");
+ }
+
+ [Test]
+ public void FontChangedTest ()
+ {
+ Control c = new Control ();
+ // Test FontChanged Event
+ c.FontChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Font = new Font (c.Font, FontStyle.Bold);
+ Assert.AreEqual (true, eventhandled, "#A11");
+ }
+
+ [Test]
+ public void ForeColorChangedTest ()
+ {
+ Control c = new Control ();
+ // Test ForeColorChanged Event
+ c.ForeColorChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.ForeColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "#A12");
+ }
+
+ [Test]
+ public void HandleCreatedTest ()
+ {
+ Control c = new Control ();
+ // Test HandleCreated Event
+ c.HandleCreated += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Handle.GetType ();
+ Assert.AreEqual (true, eventhandled, "#A15");
+ }
+
+ [Test]
+ public void ImeModeChangedTest ()
+ {
+ Control c = new Control ();
+ // Test ImeModeChanged Event
+ c.ImeModeChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.ImeMode = ImeMode.Off;
+ Assert.AreEqual (true, eventhandled, "#A19");
+ }
+
+ [Test]
+ public void LocationChangedTest ()
+ {
+ Control c = new Control ();
+ // Test LocationChanged Event
+ c.LocationChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Left = 20;
+ Assert.AreEqual (true, eventhandled, "#A20");
+ }
+
+ [Test]
+ public void ResizeTest ()
+ {
+ Control c = new Control ();
+ // Test Resize Event
+ c.Resize += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Height = 20;
+ Assert.AreEqual (true, eventhandled, "#A22");
+ }
+
+ [Test]
+ public void RightToLeftChangedTest ()
+ {
+ Control c = new Control ();
+ // Test RightToLeftChanged Event
+ c.RightToLeftChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.RightToLeft = RightToLeft.Yes;
+ Assert.AreEqual (true, eventhandled, "#A23");
+ }
+
+ [Test]
+ public void SizeChangedTest ()
+ {
+ Control c = new Control ();
+ // Test SizeChanged Event
+ c.SizeChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Height = 80;
+ Assert.AreEqual (true, eventhandled, "#A24");
+ }
+
+ [Test]
+ public void TabIndexChangedTest ()
+ {
+ Control c = new Control ();
+ // Test TabIndexChanged Event
+ c.TabIndexChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.TabIndex = 1;
+ Assert.AreEqual (true, eventhandled, "#A27");
+ }
+
+ [Test]
+ public void TabStopChangedTest ()
+ {
+ Control c = new Control ();
+ // Test TabStopChanged Event
+ c.TabStopChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.TabStop = false;
+ Assert.AreEqual (true, eventhandled, "#A28");
+ }
+
+ [Test]
+ public void TextChangedTest ()
+ {
+ Control c = new Control ();
+ // Test TextChanged Event
+ c.TextChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Text = "some Text";
+ Assert.AreEqual (true, eventhandled, "#A29");
+ }
+
+ [Test]
+ public void VisibleChangedTest ()
+ {
+ Control c = new Control ();
+ // Test VisibleChanged Event
+ c.VisibleChanged += new EventHandler (Event_Handler1);
+ eventhandled = false;
+ c.Visible = false;
+ Assert.AreEqual (true, eventhandled, "#A30");
+ }
+ }
+
+
+ [TestFixture]
+ public class LayoutEventClass
+ {
+ static bool eventhandled = false;
+ public static void LayoutEvent (object sender, LayoutEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void LayoutTest ()
+ {
+ Control c = new Control ();
+ c.Layout += new LayoutEventHandler (LayoutEvent);
+ eventhandled = false;
+ c.Visible = true;
+ c.Height = 100;
+ Assert.AreEqual (true, eventhandled, "#D1");
+
+ }
+ }
+
+ [TestFixture]
+ public class ControlAddRemoveEventClass
+ {
+ static bool eventhandled = false;
+ public static void ControlEvent (object sender, ControlEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void ControlAddedTest ()
+ {
+ Control c = new Control ();
+ c.ControlAdded += new ControlEventHandler (ControlEvent);
+ TextBox TB = new TextBox ();
+ eventhandled = false;
+ c.Controls.Add (TB);
+ Assert.AreEqual (true, eventhandled, "#F1");
+ }
+
+ [Test]
+ public void ControlRemovedTest ()
+ {
+ Control c = new Control ();
+ c.ControlRemoved += new ControlEventHandler (ControlEvent);
+ TextBox TB = new TextBox ();
+ c.Controls.Add (TB);
+ eventhandled = false;
+ c.Controls.Remove (TB);
+ Assert.AreEqual (true, eventhandled, "#F2");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlPaintTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlPaintTest.cs
new file mode 100644
index 00000000000..f1bca95c8f7
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlPaintTest.cs
@@ -0,0 +1,150 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+
+ [TestFixture]
+ class ControlPaintTest
+ {
+ [Test]
+ public void DarkTest ()
+ {
+ Color color;
+
+ // Non control colours
+ color = Color.FromArgb (255, 100, 0, 50);
+ color = ControlPaint.Dark (color);
+ Assert.AreEqual (255, color.A, "testdark#1A");
+ Assert.AreEqual (34, color.R, "testdark#1R");
+ Assert.AreEqual (0, color.G, "testdark#1G");
+ Assert.AreEqual (17, color.B, "testdark#1B");
+
+ color = Color.FromArgb (255, 40, 50, 60);
+ color = ControlPaint.Dark (color);
+ Assert.AreEqual (255, color.A, "testdark#2A");
+ Assert.AreEqual (14, color.R, "testdark#2R");
+ Assert.AreEqual (17, color.G, "testdark#2G");
+ Assert.AreEqual (20, color.B, "testdark#2B");
+
+ // Non-control colours using a specific percentage
+ color = Color.FromArgb (255, 20, 50, 40);
+ color = ControlPaint.Dark (color, 0.8f);
+ Assert.AreEqual (255, color.A, "testdark#3A");
+ Assert.AreEqual (3, color.R, "testdark#3R");
+ Assert.AreEqual (7, color.G, "testdark#3G");
+ Assert.AreEqual (6, color.B, "testdark#3B");
+
+ color = Color.FromArgb (255, 100, 0, 50);
+ color = ControlPaint.Dark (color, 0.6f);
+ Assert.AreEqual (255, color.A, "testdark#4A");
+ Assert.AreEqual (28, color.R, "testdark#4R");
+ Assert.AreEqual (0, color.G, "testdark#4G");
+ Assert.AreEqual (14, color.B, "testdark#4B");
+
+ // Fixed Control colours
+ color = Color.FromKnownColor (KnownColor.Control);
+ color = ControlPaint.Dark (color, 1f);
+ Assert.AreEqual (Color.FromKnownColor (KnownColor.ControlDarkDark), color, "testdark#5");
+
+ color = Color.FromKnownColor (KnownColor.Control);
+ color = ControlPaint.Dark (color, 0f);
+ Assert.AreEqual (Color.FromKnownColor (KnownColor.ControlDark), color, "testdark#6");
+
+ // Calculated non control fixed colour
+ color = Color.FromKnownColor (KnownColor.Control);
+ color = ControlPaint.Dark (color, 0.5f);
+
+ int r_sub, g_sub, b_sub;
+ Color new_color;
+ float per = 0.5f;
+
+ r_sub = Color.FromKnownColor (KnownColor.ControlDarkDark).R -
+ Color.FromKnownColor (KnownColor.ControlDark).R;
+ g_sub = Color.FromKnownColor (KnownColor.ControlDarkDark).G -
+ Color.FromKnownColor (KnownColor.ControlDark).G;
+ b_sub = Color.FromKnownColor (KnownColor.ControlDarkDark).B -
+ Color.FromKnownColor (KnownColor.ControlDark).B;
+
+ new_color = Color.FromArgb (Color.FromKnownColor (KnownColor.ControlDark).A,
+ (int) (Color.FromKnownColor (KnownColor.ControlDark).R + (r_sub * per)),
+ (int) (Color.FromKnownColor (KnownColor.ControlDark).G + (g_sub * per)),
+ (int) (Color.FromKnownColor (KnownColor.ControlDark).B + (b_sub * per)));
+
+ Assert.AreEqual (new_color, color, "testdark#7");
+ }
+
+ [Test]
+ public void LightTest ()
+ {
+ Color color;
+
+ // Non control colours
+
+ // Non-control colours using a specific percentage
+
+ // Fixed Control colours
+ color = Color.FromKnownColor (KnownColor.Control);
+ color = ControlPaint.Light (color, 1f);
+ Assert.AreEqual (Color.FromKnownColor (KnownColor.ControlLightLight), color, "testlight#5");
+
+ color = Color.FromKnownColor (KnownColor.Control);
+ color = ControlPaint.Light (color, 0f);
+ Assert.AreEqual (Color.FromKnownColor (KnownColor.ControlLight), color, "testlight#6");
+
+ // Calculated non control fixed colour
+ color = Color.FromKnownColor (KnownColor.Control);
+ color = ControlPaint.Light (color, 0.5f);
+
+ int r_sub, g_sub, b_sub;
+ Color new_color;
+ float per = 0.5f;
+
+ r_sub = Color.FromKnownColor (KnownColor.ControlLightLight).R -
+ Color.FromKnownColor (KnownColor.ControlLight).R;
+ g_sub = Color.FromKnownColor (KnownColor.ControlLightLight).G -
+ Color.FromKnownColor (KnownColor.ControlLight).G;
+ b_sub = Color.FromKnownColor (KnownColor.ControlLightLight).B -
+ Color.FromKnownColor (KnownColor.ControlLight).B;
+
+ new_color = Color.FromArgb (Color.FromKnownColor (KnownColor.ControlLight).A,
+ (int) (Color.FromKnownColor (KnownColor.ControlLight).R + (r_sub * per)),
+ (int) (Color.FromKnownColor (KnownColor.ControlLight).G + (g_sub * per)),
+ (int) (Color.FromKnownColor (KnownColor.ControlLight).B + (b_sub * per)));
+
+ Assert.AreEqual (new_color, color, "testlight#7");
+
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlStyleTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlStyleTest.cs
new file mode 100644
index 00000000000..77568afb8d8
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlStyleTest.cs
@@ -0,0 +1,961 @@
+//
+// ControlStyleTest.cs (Auto-generated by GenerateControlStyleTest.cs).
+//
+// Author:
+// Peter Dennis Bartok (pbartok@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms {
+ [TestFixture]
+ public class TestControlStyle {
+
+ static Array style_values = Enum.GetValues(typeof(ControlStyles));
+ static string[] style_names = Enum.GetNames(typeof(ControlStyles));
+
+ public static string[] GetStyles(Control control) {
+ string[] result;
+
+ result = new string[style_names.Length];
+
+ for (int i = 0; i < style_values.Length; i++) {
+ result[i] = style_names[i] + "=" + control.GetType().GetMethod("GetStyle", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(control, new object[1] {(ControlStyles)style_values.GetValue(i)});
+ }
+
+ return result;
+ }
+
+ [Test]
+ public void ControlStyleTest ()
+ {
+ string[] Control_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(Control_want, GetStyles(new Control()), "ControlStyles");
+ }
+
+
+ [Test]
+ public void ButtonStyleTest ()
+ {
+ string[] Button_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=True",
+ "ResizeRedraw=True",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=True",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=False",
+ "AllPaintingInWmPaint=True",
+ "CacheText=True",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=True"
+ };
+
+ Assert.AreEqual(Button_want, GetStyles(new Button()), "ButtonStyles");
+ }
+
+
+ [Test]
+ public void CheckBoxStyleTest ()
+ {
+ string[] CheckBox_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=True",
+ "ResizeRedraw=True",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=True",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=False",
+ "AllPaintingInWmPaint=True",
+ "CacheText=True",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=True"
+ };
+
+ Assert.AreEqual(CheckBox_want, GetStyles(new CheckBox()), "CheckBoxStyles");
+ }
+
+
+ [Test]
+ public void RadioButtonStyleTest ()
+ {
+ string[] RadioButton_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=True",
+ "ResizeRedraw=True",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=True",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=True",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=True"
+ };
+
+ Assert.AreEqual(RadioButton_want, GetStyles(new RadioButton()), "RadioButtonStyles");
+ }
+
+
+ [Test]
+ public void DataGridStyleTest ()
+ {
+ string[] DataGrid_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=True",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(DataGrid_want, GetStyles(new DataGrid()), "DataGridStyles");
+ }
+
+
+ [Test]
+ public void DateTimePickerStyleTest ()
+ {
+ string[] DateTimePicker_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=True",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(DateTimePicker_want, GetStyles(new DateTimePicker()), "DateTimePickerStyles");
+ }
+
+
+ [Test]
+ public void GroupBoxStyleTest ()
+ {
+ string[] GroupBox_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=True",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(GroupBox_want, GetStyles(new GroupBox()), "GroupBoxStyles");
+ }
+
+
+ [Test]
+ public void LabelStyleTest ()
+ {
+ string[] Label_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=True",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=True"
+ };
+
+ Assert.AreEqual(Label_want, GetStyles(new Label()), "LabelStyles");
+ }
+
+
+ [Test]
+ public void LinkLabelStyleTest ()
+ {
+ string[] LinkLabel_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=True",
+ "ResizeRedraw=True",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=True"
+ };
+
+ Assert.AreEqual(LinkLabel_want, GetStyles(new LinkLabel()), "LinkLabelStyles");
+ }
+
+
+ [Test]
+ public void ComboBoxStyleTest ()
+ {
+ string[] ComboBox_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(ComboBox_want, GetStyles(new ComboBox()), "ComboBoxStyles");
+ }
+
+
+ [Test]
+ public void ListBoxStyleTest ()
+ {
+ string[] ListBox_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(ListBox_want, GetStyles(new ListBox()), "ListBoxStyles");
+ }
+
+
+ [Test]
+ public void CheckedListBoxStyleTest ()
+ {
+ string[] CheckedListBox_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=True",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(CheckedListBox_want, GetStyles(new CheckedListBox()), "CheckedListBoxStyles");
+ }
+
+
+ [Test]
+ public void ListViewStyleTest ()
+ {
+ string[] ListView_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(ListView_want, GetStyles(new ListView()), "ListViewStyles");
+ }
+
+
+ [Test]
+ public void MdiClientStyleTest ()
+ {
+ string[] MdiClient_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(MdiClient_want, GetStyles(new MdiClient()), "MdiClientStyles");
+ }
+
+
+ [Test]
+ public void MonthCalendarStyleTest ()
+ {
+ string[] MonthCalendar_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(MonthCalendar_want, GetStyles(new MonthCalendar()), "MonthCalendarStyles");
+ }
+
+
+ [Test]
+ public void PictureBoxStyleTest ()
+ {
+ string[] PictureBox_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=True"
+ };
+
+ Assert.AreEqual(PictureBox_want, GetStyles(new PictureBox()), "PictureBoxStyles");
+ }
+
+
+ [Test]
+ public void ProgressBarStyleTest ()
+ {
+ string[] ProgressBar_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(ProgressBar_want, GetStyles(new ProgressBar()), "ProgressBarStyles");
+ }
+
+
+ [Test]
+ public void ScrollableControlStyleTest ()
+ {
+ string[] ScrollableControl_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(ScrollableControl_want, GetStyles(new ScrollableControl()), "ScrollableControlStyles");
+ }
+
+
+ [Test]
+ public void ContainerControlStyleTest ()
+ {
+ string[] ContainerControl_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(ContainerControl_want, GetStyles(new ContainerControl()), "ContainerControlStyles");
+ }
+
+
+ [Test]
+ public void FormStyleTest ()
+ {
+ string[] Form_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(Form_want, GetStyles(new Form()), "FormStyles");
+ }
+
+
+ [Test]
+ public void PropertyGridStyleTest ()
+ {
+ string[] PropertyGrid_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(PropertyGrid_want, GetStyles(new PropertyGrid()), "PropertyGridStyles");
+ }
+
+
+ [Test]
+ public void DomainUpDownStyleTest ()
+ {
+ string[] DomainUpDown_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=True",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(DomainUpDown_want, GetStyles(new DomainUpDown()), "DomainUpDownStyles");
+ }
+
+
+ [Test]
+ public void NumericUpDownStyleTest ()
+ {
+ string[] NumericUpDown_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=True",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(NumericUpDown_want, GetStyles(new NumericUpDown()), "NumericUpDownStyles");
+ }
+
+
+ [Test]
+ public void UserControlStyleTest ()
+ {
+ string[] UserControl_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(UserControl_want, GetStyles(new UserControl()), "UserControlStyles");
+ }
+
+
+ [Test]
+ public void PanelStyleTest ()
+ {
+ string[] Panel_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(Panel_want, GetStyles(new Panel()), "PanelStyles");
+ }
+
+
+ [Test]
+ public void TabPageStyleTest ()
+ {
+ string[] TabPage_want = {
+ "ContainerControl=True",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=True",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=False",
+ "CacheText=True",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(TabPage_want, GetStyles(new TabPage()), "TabPageStyles");
+ }
+
+
+ [Test]
+ public void HScrollBarStyleTest ()
+ {
+ string[] HScrollBar_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(HScrollBar_want, GetStyles(new HScrollBar()), "HScrollBarStyles");
+ }
+
+
+ [Test]
+ public void VScrollBarStyleTest ()
+ {
+ string[] VScrollBar_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(VScrollBar_want, GetStyles(new VScrollBar()), "VScrollBarStyles");
+ }
+
+
+ [Test]
+ public void SplitterStyleTest ()
+ {
+ string[] Splitter_want = {
+ "ContainerControl=False",
+ "UserPaint=True",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(Splitter_want, GetStyles(new Splitter()), "SplitterStyles");
+ }
+
+
+ [Test]
+ public void StatusBarStyleTest ()
+ {
+ string[] StatusBar_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=False",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(StatusBar_want, GetStyles(new StatusBar()), "StatusBarStyles");
+ }
+
+
+ [Test]
+ public void TabControlStyleTest ()
+ {
+ string[] TabControl_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(TabControl_want, GetStyles(new TabControl()), "TabControlStyles");
+ }
+
+
+ [Test]
+ public void RichTextBoxStyleTest ()
+ {
+ string[] RichTextBox_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(RichTextBox_want, GetStyles(new RichTextBox()), "RichTextBoxStyles");
+ }
+
+
+ [Test]
+ public void TextBoxStyleTest ()
+ {
+ string[] TextBox_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=True",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=False",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(TextBox_want, GetStyles(new TextBox()), "TextBoxStyles");
+ }
+
+
+ [Test]
+ public void DataGridTextBoxStyleTest ()
+ {
+ string[] DataGridTextBox_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=True",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=False",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(DataGridTextBox_want, GetStyles(new DataGridTextBox()), "DataGridTextBoxStyles");
+ }
+
+
+ [Test]
+ public void ToolBarStyleTest ()
+ {
+ string[] ToolBar_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=True",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(ToolBar_want, GetStyles(new ToolBar()), "ToolBarStyles");
+ }
+
+
+ [Test]
+ public void TrackBarStyleTest ()
+ {
+ string[] TrackBar_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=True",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(TrackBar_want, GetStyles(new TrackBar()), "TrackBarStyles");
+ }
+
+
+ [Test]
+ public void TreeViewStyleTest ()
+ {
+ string[] TreeView_want = {
+ "ContainerControl=False",
+ "UserPaint=False",
+ "Opaque=False",
+ "ResizeRedraw=False",
+ "FixedWidth=False",
+ "FixedHeight=False",
+ "StandardClick=False",
+ "Selectable=True",
+ "UserMouse=False",
+ "SupportsTransparentBackColor=False",
+ "StandardDoubleClick=True",
+ "AllPaintingInWmPaint=True",
+ "CacheText=False",
+ "EnableNotifyMessage=False",
+ "DoubleBuffer=False"
+ };
+
+ Assert.AreEqual(TreeView_want, GetStyles(new TreeView()), "TreeViewStyles");
+ }
+
+
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs
new file mode 100644
index 00000000000..de8055f36af
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs
@@ -0,0 +1,790 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Threading;
+using System.Reflection;
+using System.Runtime.Remoting;
+
+using NUnit.Framework;
+
+namespace MWF.MonoTest
+{
+ [TestFixture]
+ public class ControlTest
+ {
+ internal static void TestAccessibility(Control c, string Default, string Description, string Name, AccessibleRole Role) {
+ Assert.AreEqual(false, c.AccessibilityObject == null, "Acc1");
+ Assert.AreEqual(Default, c.AccessibleDefaultActionDescription, "Acc2");
+ Assert.AreEqual(Description, c.AccessibleDescription, "Acc3");
+ Assert.AreEqual(Name, c.AccessibleName, "Acc4");
+ Assert.AreEqual(Role, c.AccessibleRole, "Acc5");
+ }
+
+ [Test]
+ public void PubPropTest()
+ {
+ Control c = new Control();
+
+ TestAccessibility(c, null, null, null, AccessibleRole.Default);
+
+ // A
+ Assert.AreEqual(false, c.AllowDrop , "A1");
+ Assert.AreEqual(AnchorStyles.Top | AnchorStyles.Left, c.Anchor, "A2");
+
+ // B
+ Assert.AreEqual("Control", c.BackColor.Name , "B1");
+ Assert.AreEqual(null, c.BackgroundImage, "B2");
+ Assert.AreEqual(null, c.BindingContext, "B3");
+ Assert.AreEqual(0, c.Bottom, "B4");
+ Assert.AreEqual (new Rectangle (0,0, 0, 0) , c.Bounds , "B5");
+
+ // C
+ Assert.AreEqual(false, c.CanFocus, "C1");
+ Assert.AreEqual(true, c.CanSelect, "C2");
+ Assert.AreEqual(false, c.Capture, "C3");
+ Assert.AreEqual(true, c.CausesValidation, "C4");
+ Assert.AreEqual (new Rectangle(0, 0, 0, 0) , c.ClientRectangle , "C5");
+ Assert.AreEqual (new Size(0, 0), c.ClientSize , "C6");
+
+ string name = c.CompanyName;
+ if (!name.Equals("Mono Project, Novell, Inc.") && !name.Equals("Microsoft Corporation")) {
+ Assert.Fail("CompanyName property does not match any accepted value - C7");
+ }
+ Assert.AreEqual(null, c.Container, "C8");
+ Assert.AreEqual(false, c.ContainsFocus, "C9");
+ Assert.AreEqual(null, c.ContextMenu, "C10");
+ Assert.AreEqual(0, c.Controls.Count, "C11");
+ Assert.AreEqual(true, c.Created, "C12");
+ Assert.AreEqual(Cursors.Default, c.Cursor, "C13");
+
+ // D
+ Assert.AreEqual(false, c.DataBindings == null, "D1");
+ Assert.AreEqual("Control", Control.DefaultBackColor.Name, "D2");
+ Assert.AreEqual("ControlText", Control.DefaultForeColor.Name, "D3");
+ Assert.AreEqual(FontStyle.Regular, Control.DefaultFont.Style, "D4");
+ Assert.AreEqual (new Rectangle(0, 0, 0, 0), c.DisplayRectangle , "D5");
+ Assert.AreEqual(false, c.Disposing, "D6");
+ Assert.AreEqual(DockStyle.None, c.Dock, "D7");
+
+ // E
+ Assert.AreEqual(true, c.Enabled, "E1");
+
+ // F
+ Assert.AreEqual(false, c.Focused, "F1");
+ Assert.AreEqual(FontStyle.Regular, c.Font.Style, "F2");
+ Assert.AreEqual(SystemColors.ControlText, c.ForeColor, "F3");
+
+ // G
+
+ // H
+ Assert.AreEqual (((IWin32Window)c).Handle, c.Handle, "H1");
+ Assert.AreEqual(false, c.HasChildren, "H2");
+ Assert.AreEqual(0, c.Height, "H3");
+
+ // I
+ Assert.AreEqual (ImeMode.NoControl, c.ImeMode, "I1");
+ Assert.AreEqual(false, c.InvokeRequired, "I2");
+ Assert.AreEqual(false, c.IsAccessible, "I3");
+ Assert.AreEqual(false, c.IsDisposed, "I4");
+ Assert.AreEqual(true, c.IsHandleCreated, "I5");
+
+ // J
+
+ // K
+
+ // L
+ Assert.AreEqual(0, c.Left, "L1");
+ Assert.AreEqual(Point.Empty, c.Location, "L2");
+
+ // M
+ Assert.AreEqual(Keys.None, Control.ModifierKeys, "M1");
+ Assert.AreEqual(false, Control.MousePosition.IsEmpty, "M2");
+ Assert.AreEqual(MouseButtons.None, Control.MouseButtons, "M3");
+
+ // N
+ Assert.AreEqual("", c.Name, "N1");
+
+ // O
+
+ // P
+ Assert.AreEqual(null, c.Parent, "P1");
+ name = c.ProductName;
+ if (!name.Equals("Novell Mono MWF") && !name.Equals("Microsoft (R) .NET Framework"))
+ Assert.Fail("ProductName property does not match any accepted value - P2");
+
+ name = c.ProductVersion;
+ if (!name.Equals("1.1.4322.2032")) {
+ Assert.Fail("This test is being run against the wrong framework version.\nExpected is Net 1.1sp1. - P3");
+ }
+
+ // R
+ Assert.AreEqual(false, c.RecreatingHandle, "R1");
+ Assert.AreEqual(null, c.Region, "R2");
+ Assert.AreEqual(0, c.Right, "R3");
+ Assert.AreEqual(RightToLeft.No, c.RightToLeft, "R4");
+
+ // S
+ Assert.AreEqual(null, c.Site, "S1");
+ Assert.AreEqual (new Size(0, 0), c.Size, "S2");
+
+ // T
+ Assert.AreEqual(0, c.TabIndex , "T1");
+ Assert.AreEqual(true, c.TabStop, "T2");
+ Assert.AreEqual(null, c.Tag, "T3");
+ Assert.AreEqual("", c.Text, "T4");
+ Assert.AreEqual(0, c.Top, "T5");
+ Assert.AreEqual(null, c.TopLevelControl, "T6");
+
+ // U
+
+ // V
+ Assert.AreEqual(true, c.Visible, "V1");
+
+ // W
+ Assert.AreEqual(0, c.Width, "W1");
+
+ // XYZ
+ }
+
+ [Test]
+ public void RelationTest() {
+ Control c1;
+ Control c2;
+
+ c1 = new Control();
+ c2 = new Control();
+
+ Assert.AreEqual(true , c1.Visible , "Rel1");
+ Assert.AreEqual(false, c1.Contains(c2) , "Rel2");
+ Assert.AreEqual("System.Windows.Forms.Control", c1.ToString() , "Rel3");
+
+ c1.Controls.Add(c2);
+ Assert.AreEqual(true , c2.Visible , "Rel4");
+ Assert.AreEqual(true, c1.Contains(c2) , "Rel5");
+
+ c1.Anchor = AnchorStyles.Top;
+ c1.SuspendLayout ();
+ c1.Anchor = AnchorStyles.Left ;
+ c1.ResumeLayout ();
+ Assert.AreEqual(AnchorStyles.Left , c1.Anchor, "Rel6");
+
+ c1.SetBounds(10, 20, 30, 40) ;
+ Assert.AreEqual(new Rectangle(10, 20, 30, 40), c1.Bounds, "Rel7");
+
+ Assert.AreEqual(c1, c2.Parent, "Rel8");
+ }
+
+ private string TestControl(Control container, Control start, bool forward) {
+ Control ctl;
+
+ ctl = container.GetNextControl(start, forward);
+
+ if (ctl == null) {
+ return null;
+ }
+
+ return ctl.Text;
+ }
+
+ [Test]
+ public void TabOrder() {
+ Form form;
+ Control active;
+
+ Label label1 = new Label(); // To test non-tabstop items as well
+ Label label2 = new Label();
+
+ GroupBox group1 = new GroupBox();
+ GroupBox group2 = new GroupBox();
+ GroupBox group3 = new GroupBox();
+
+ TextBox text1 = new TextBox();
+
+ RadioButton radio11 = new RadioButton();
+ RadioButton radio12 = new RadioButton();
+ RadioButton radio13 = new RadioButton();
+ RadioButton radio14 = new RadioButton();
+ RadioButton radio21 = new RadioButton();
+ RadioButton radio22 = new RadioButton();
+ RadioButton radio23 = new RadioButton();
+ RadioButton radio24 = new RadioButton();
+ RadioButton radio31 = new RadioButton();
+ RadioButton radio32 = new RadioButton();
+ RadioButton radio33 = new RadioButton();
+ RadioButton radio34 = new RadioButton();
+
+ form = new Form();
+
+ form.ClientSize = new System.Drawing.Size (520, 520);
+ Assert.AreEqual(new Size(520, 520), form.ClientSize, "Tab1");
+
+ form.Text = "SWF Taborder Test App Form";
+ Assert.AreEqual("SWF Taborder Test App Form", form.Text, "Tab2");
+
+ label1.Location = new Point(10, 10);
+ Assert.AreEqual(new Point(10, 10), label1.Location, "Tab3");
+ label1.Text = "Label1";
+ form.Controls.Add(label1);
+
+ label2.Location = new Point(200, 10);
+ label2.Text = "Label2";
+ form.Controls.Add(label2);
+
+ group1.Text = "Group1";
+ group2.Text = "Group2";
+ group3.Text = "Group3";
+
+ group1.Size = new Size(200, 400);
+ group2.Size = new Size(200, 400);
+ group3.Size = new Size(180, 180);
+ Assert.AreEqual(new Size(180, 180), group3.Size, "Tab4");
+
+ group1.Location = new Point(10, 40);
+ group2.Location = new Point(220, 40);
+ group3.Location = new Point(10, 210);
+
+ group1.TabIndex = 30;
+ Assert.AreEqual(30, group1.TabIndex, "Tab5");
+ group1.TabStop = true;
+
+ // Don't assign, test automatic assignment
+ //group2.TabIndex = 0;
+ group2.TabStop = true;
+ Assert.AreEqual(0, group2.TabIndex, "Tab6");
+
+ group3.TabIndex = 35;
+ group3.TabStop = true;
+
+ // Test default tab index
+ Assert.AreEqual(0, radio11.TabIndex, "Tab7");
+
+ text1.Text = "Edit Control";
+
+ radio11.Text = "Radio 1-1 [Tab1]";
+ radio12.Text = "Radio 1-2 [Tab2]";
+ radio13.Text = "Radio 1-3 [Tab3]";
+ radio14.Text = "Radio 1-4 [Tab4]";
+
+ radio21.Text = "Radio 2-1 [Tab4]";
+ radio22.Text = "Radio 2-2 [Tab3]";
+ radio23.Text = "Radio 2-3 [Tab2]";
+ radio24.Text = "Radio 2-4 [Tab1]";
+
+ radio31.Text = "Radio 3-1 [Tab1]";
+ radio32.Text = "Radio 3-2 [Tab3]";
+ radio33.Text = "Radio 3-3 [Tab2]";
+ radio34.Text = "Radio 3-4 [Tab4]";
+
+ // We don't assign TabIndex for radio1X; test automatic assignment
+ text1.TabStop = true;
+ radio11.TabStop = true;
+
+ radio21.TabIndex = 4;
+ radio22.TabIndex = 3;
+ radio23.TabIndex = 2;
+ radio24.TabIndex = 1;
+ radio24.TabStop = true;
+
+ radio31.TabIndex = 11;
+ radio31.TabStop = true;
+ radio32.TabIndex = 13;
+ radio33.TabIndex = 12;
+ radio34.TabIndex = 14;
+
+ text1.Location = new Point(10, 100);
+
+ radio11.Location = new Point(10, 20);
+ radio12.Location = new Point(10, 40);
+ radio13.Location = new Point(10, 60);
+ radio14.Location = new Point(10, 80);
+
+ radio21.Location = new Point(10, 20);
+ radio22.Location = new Point(10, 40);
+ radio23.Location = new Point(10, 60);
+ radio24.Location = new Point(10, 80);
+
+ radio31.Location = new Point(10, 20);
+ radio32.Location = new Point(10, 40);
+ radio33.Location = new Point(10, 60);
+ radio34.Location = new Point(10, 80);
+
+ text1.Size = new Size(150, text1.PreferredHeight);
+
+ radio11.Size = new Size(150, 20);
+ radio12.Size = new Size(150, 20);
+ radio13.Size = new Size(150, 20);
+ radio14.Size = new Size(150, 20);
+
+ radio21.Size = new Size(150, 20);
+ radio22.Size = new Size(150, 20);
+ radio23.Size = new Size(150, 20);
+ radio24.Size = new Size(150, 20);
+
+ radio31.Size = new Size(150, 20);
+ radio32.Size = new Size(150, 20);
+ radio33.Size = new Size(150, 20);
+ radio34.Size = new Size(150, 20);
+
+ group1.Controls.Add(text1);
+
+ group1.Controls.Add(radio11);
+ group1.Controls.Add(radio12);
+ group1.Controls.Add(radio13);
+ group1.Controls.Add(radio14);
+
+ group2.Controls.Add(radio21);
+ group2.Controls.Add(radio22);
+ group2.Controls.Add(radio23);
+ group2.Controls.Add(radio24);
+
+ group3.Controls.Add(radio31);
+ group3.Controls.Add(radio32);
+ group3.Controls.Add(radio33);
+ group3.Controls.Add(radio34);
+
+ form.Controls.Add(group1);
+ form.Controls.Add(group2);
+ group2.Controls.Add(group3);
+
+ // Perform some tests, the TabIndex stuff below will alter the outcome
+ Assert.AreEqual(null, TestControl(group2, radio34, true), "Tab8");
+ Assert.AreEqual(31, group2.TabIndex, "Tab9");
+
+ // Does the taborder of containers and non-selectable things change behaviour?
+ label1.TabIndex = 5;
+ label2.TabIndex = 4;
+ group1.TabIndex = 3;
+ group2.TabIndex = 1;
+
+ // Start verification
+ Assert.AreEqual(null, TestControl(group2, radio34, true), "Tab10");
+ Assert.AreEqual(radio24.Text, TestControl(group2, group2, true), "Tab11");
+ Assert.AreEqual(radio31.Text, TestControl(group2, group3, true), "Tab12");
+ Assert.AreEqual(null, TestControl(group1, radio14, true), "Tab13");
+ Assert.AreEqual(radio23.Text, TestControl(group2, radio24, true), "Tab14");
+ Assert.AreEqual(group3.Text, TestControl(group2, radio21, true), "Tab15");
+ Assert.AreEqual(radio13.Text, TestControl(form, radio12, true), "Tab16");
+ Assert.AreEqual(label2.Text, TestControl(form, radio14, true), "Tab17");
+ Assert.AreEqual(group1.Text, TestControl(form, radio34, true), "Tab18");
+ Assert.AreEqual(radio23.Text, TestControl(group2, radio24, true), "Tab19");
+
+ // Sanity checks
+ Assert.AreEqual(null, TestControl(radio11, radio21, true), "Tab20");
+ Assert.AreEqual(text1.Text, TestControl(group1, radio21, true), "Tab21");
+
+ Assert.AreEqual(radio14.Text, TestControl(form, label2, false), "Tab22");
+ Assert.AreEqual(radio21.Text, TestControl(group2, group3, false), "Tab23");
+
+ Assert.AreEqual(4, radio21.TabIndex, "Tab24");
+ Assert.AreEqual(1, radio11.TabIndex, "Tab25");
+ Assert.AreEqual(3, radio13.TabIndex, "Tab26");
+ Assert.AreEqual(35, group3.TabIndex, "Tab27");
+ Assert.AreEqual(1, group2.TabIndex, "Tab28");
+
+ Assert.AreEqual(label1.Text, TestControl(form, form, false), "Tab29");
+ Assert.AreEqual(radio14.Text, TestControl(group1, group1, false), "Tab30");
+ Assert.AreEqual(radio34.Text, TestControl(group3, group3, false), "Tab31");
+
+ Assert.AreEqual(null, TestControl(label1, label1, false), "Tab31");
+ Assert.AreEqual(null, TestControl(radio11, radio21, false), "Tab32");
+ }
+
+ [Test]
+ public void ScaleTest()
+ {
+ Control r1 = new Control();
+
+ r1.Width = 40;
+ r1.Height = 20;
+ r1.Scale(2);
+ Assert.AreEqual(80, r1.Width, "Scale1");
+ Assert.AreEqual(40, r1.Height, "Scale2");
+ }
+
+ [Test]
+ public void TextTest()
+ {
+ Control r1 = new Control();
+ r1.Text = "Hi" ;
+ Assert.AreEqual("Hi" , r1.Text , "Text1");
+
+ r1.ResetText();
+ Assert.AreEqual("" , r1.Text , "Text2");
+ }
+
+ [Test]
+ public void PubMethodTest7()
+ {
+ Control r1 = new Control();
+ r1.RightToLeft = RightToLeft.Yes ;
+ r1.ResetRightToLeft() ;
+ Assert.AreEqual(RightToLeft.No , r1.RightToLeft , "#81");
+ r1.ImeMode = ImeMode.Off ;
+ r1.ResetImeMode () ;
+ Assert.AreEqual(ImeMode.NoControl , r1.ImeMode , "#82");
+ r1.ForeColor= SystemColors.GrayText ;
+ r1.ResetForeColor() ;
+ Assert.AreEqual(SystemColors.ControlText , r1.ForeColor , "#83");
+ //r1.Font = Font.FromHdc();
+ r1.ResetFont () ;
+ //Assert.AreEqual(FontFamily.GenericSansSerif , r1.Font , "#83");
+ r1.Cursor = Cursors.Hand ;
+ r1.ResetCursor () ;
+ Assert.AreEqual(Cursors.Default , r1.Cursor , "#83");
+ //r1.DataBindings = System.Windows.Forms.Binding ;
+ //r1.ResetBindings() ;
+ //Assert.AreEqual(ControlBindingsCollection , r1.DataBindings , "#83");
+ r1.BackColor = System.Drawing.Color.Black ;
+ r1.ResetBackColor() ;
+ Assert.AreEqual( SystemColors.Control , r1.BackColor , "#84");
+ r1.BackColor = System.Drawing.Color.Black ;
+ r1.Refresh() ;
+ Assert.AreEqual( null , r1.Region , "#85");
+ Rectangle M = new Rectangle(10, 20, 30 ,40);
+ r1.RectangleToScreen(M) ;
+ Assert.AreEqual( null , r1.Region , "#86");
+
+ }
+
+ [Test]
+ public void ScreenClientCoords()
+ {
+ Label l;
+ Point p1;
+ Point p2;
+ Point p3;
+
+ l = new Label();
+ l.Left = 10;
+ l.Top = 12;
+ l.Visible = true;
+ p1 = new Point (10,10);
+ p2 = l.PointToScreen(p1);
+ p3 = l.PointToClient(p2);
+
+ Assert.AreEqual (p1, p3, "SC1");
+ }
+
+ [Test]
+ public void ContainsTest ()
+ {
+ Control t = new Control ();
+ Control s = new Control ();
+
+ t.Controls.Add (s);
+
+ Assert.AreEqual (true, t.Contains (s), "Con1");
+ Assert.AreEqual (false, s.Contains (t), "Con2");
+ Assert.AreEqual (false, s.Contains (null), "Con3");
+ Assert.AreEqual (false, t.Contains (new Control ()), "Con4");
+ }
+
+ [Test]
+ public void CreateHandleTest ()
+ {
+ Control parent;
+ Control child;
+
+ parent = null;
+ child = null;
+
+ try {
+ parent = new Control ();
+ child = new Control ();
+
+ parent.Visible = true;
+ parent.Controls.Add (child);
+
+ Assert.IsFalse (parent.IsHandleCreated, "CH1");
+ Assert.IsFalse (child.IsHandleCreated, "CH2");
+
+ parent.CreateControl ();
+ Assert.IsNotNull (parent.Handle, "CH3");
+ Assert.IsNotNull (child.Handle, "CH4");
+ Assert.IsTrue (parent.IsHandleCreated, "CH5");
+ Assert.IsTrue (child.IsHandleCreated, "CH6");
+ } finally {
+ if (parent != null)
+ parent.Dispose ();
+ if (child != null)
+ child.Dispose ();
+ }
+
+ // Accessing Handle Property creates the handle
+ try {
+ parent = new Control ();
+ parent.Visible = true;
+ child = new Control ();
+ parent.Controls.Add (child);
+ Assert.IsFalse (parent.IsHandleCreated, "CH7");
+ Assert.IsFalse (child.IsHandleCreated, "CH8");
+ Assert.IsNotNull (parent.Handle, "CH9");
+ Assert.IsTrue (parent.IsHandleCreated, "CH10");
+ Assert.IsTrue (child.IsHandleCreated, "CH11");
+ } finally {
+ if (parent != null)
+ parent.Dispose ();
+ if (child != null)
+ child.Dispose ();
+ }
+ }
+
+ [Test]
+ public void CreateGraphicsTest ()
+ {
+ Graphics g = null;
+ Pen p = null;
+
+ try {
+ Control c = new Control ();
+ c.SetBounds (0,0, 20, 20);
+ g = c.CreateGraphics ();
+ Assert.IsNotNull (g, "Graph1");
+ } finally {
+ if (p != null)
+ p.Dispose ();
+ if (g != null)
+ g.Dispose ();
+ }
+ }
+
+ bool delegateCalled = false;
+ public delegate void TestDelegate ();
+
+ [Test]
+ [ExpectedException(typeof(System.InvalidOperationException))]
+ public void InvokeException1 () {
+ Control c = new Control ();
+ IAsyncResult result;
+
+ result = c.BeginInvoke (new TestDelegate (delegate_call));
+ c.EndInvoke (result);
+ }
+
+ [Test]
+ public void InvokeTest () {
+ Control c = null;
+
+ try {
+ c = new Control ();
+ IAsyncResult result;
+
+ c.CreateControl ();
+ result = c.BeginInvoke (new TestDelegate (delegate_call));
+ c.EndInvoke (result);
+ Assert.AreEqual (true, delegateCalled, "Invoke1");
+ } finally {
+ if (c != null)
+ c.Dispose ();
+ }
+ }
+
+ public void delegate_call () {
+ delegateCalled = true;
+ }
+
+ [Test]
+ public void FindFormTest () {
+ Form f = new Form ();
+
+ f.Name = "form";
+ Control c = null;
+
+ try {
+ f.Controls.Add (c = new Control ());
+ Assert.AreEqual (f.Name, c.FindForm ().Name, "Find1");
+
+ f.Controls.Remove (c);
+
+ GroupBox g = new GroupBox ();
+ g.Name = "box";
+ f.Controls.Add (g);
+ g.Controls.Add (c);
+
+ Assert.AreEqual (f.Name, f.FindForm ().Name, "Find2");
+
+ g.Controls.Remove (c);
+ Assert.IsNull(c.FindForm (), "Find3");
+
+ } finally {
+ if (c != null)
+ c.Dispose ();
+ if (f != null)
+ f.Dispose ();
+ }
+ }
+
+ [Test]
+ public void FocusTest ()
+ {
+ Form f = null;
+ Button c = null, d = null;
+
+ try {
+ f = new Form ();
+ f.Visible = true;
+ c = new Button ();
+ c.Visible = true;
+ f.Controls.Add (c);
+
+ d = new Button ();
+ d.Visible = false;
+ f.Controls.Add (d);
+
+ Assert.IsTrue (c.CanFocus, "Focus1");
+ Assert.IsFalse (c.Focused, "Focus2");
+ c.Focus ();
+ Assert.IsTrue (c.Focused, "Focus3");
+ d.Focus ();
+ Assert.IsFalse (d.Focused, "Focus4");
+
+ d.Visible = true;
+ d.Focus ();
+ Assert.IsTrue (d.Focused, "Focus5");
+ Assert.IsFalse (c.Focused, "Focus6");
+
+ c.Enabled = false;
+ Assert.IsFalse (c.Focused, "Focus7");
+ } finally {
+ if (f != null)
+ f.Dispose ();
+ if (c != null)
+ c.Dispose ();
+ if (d != null)
+ d.Dispose ();
+ }
+ }
+
+ [Test]
+ public void FromHandleTest ()
+ {
+ Control c1 = null;
+ Control c2 = null;
+
+ try {
+ c1 = new Control ();
+ c2 = new Control ();
+
+ c1.Name = "parent";
+ c2.Name = "child";
+ c1.Controls.Add(c2);
+
+ // Handle
+ Assert.AreEqual (c1.Name, Control.FromHandle (c1.Handle).Name, "Handle1");
+ Assert.IsNull (Control.FromHandle (IntPtr.Zero), "Handle2");
+
+ // ChildHandle
+ Assert.AreEqual (c1.Name, Control.FromChildHandle (c1.Handle).Name, "Handle3");
+ Assert.IsNull (Control.FromChildHandle (IntPtr.Zero), "Handle4");
+
+
+ } finally {
+ if (c1 != null)
+ c1.Dispose ();
+
+ if (c2 != null)
+ c2.Dispose ();
+ }
+ }
+
+ [Test]
+ public void GetChildAtPointTest ()
+ {
+ Control c = null, d = null, e = null;
+
+ try {
+ c = new Control ();
+ c.Name = "c1";
+ c.SetBounds (0, 0, 100, 100);
+
+ d = new Control ();
+ d.Name = "d1";
+ d.SetBounds (10, 10, 40, 40);
+ c.Controls.Add (d);
+
+ e = new Control ();
+ e.Name = "e1";
+ e.SetBounds (55, 55, 10, 10);
+
+ Control l = c.GetChildAtPoint (new Point (15, 15));
+ Assert.AreEqual (d.Name, l.Name, "Child1");
+ Assert.IsFalse (e.Name == l.Name, "Child2");
+
+ l = c.GetChildAtPoint (new Point (57, 57));
+ Assert.IsNull (l, "Child3");
+
+ l = c.GetChildAtPoint (new Point (10, 10));
+ Assert.AreEqual (d.Name, l.Name, "Child4");
+
+ // GetChildAtPointSkip is not implemented and the following test is breaking for Net_2_0 profile
+// #if NET_2_0
+// c.Controls.Add (e);
+// e.Visible = false;
+// l = c.GetChildAtPoint (new Point (57, 57), GetChildAtPointSkip.Invisible);
+// Assert.IsNull (l, "Child5");
+
+// e.Visible = true;
+// l = c.GetChildAtPoint (new Point (57, 57), GetChildAtPointSkip.Invisible);
+// Assert.AreSame (e.Name, l.Name, "Child6");
+// #endif // NET_2_0
+ } finally {
+ if (c != null)
+ c.Dispose ();
+ if (d != null)
+ d.Dispose ();
+ }
+ }
+
+
+ public class LayoutTestControl : Control {
+ public int LayoutCount;
+
+ public LayoutTestControl () : base() {
+ LayoutCount = 0;
+ }
+
+ protected override void OnLayout(LayoutEventArgs levent) {
+ LayoutCount++;
+ base.OnLayout (levent);
+ }
+ }
+
+ [Test]
+ public void LayoutTest() {
+ LayoutTestControl c;
+
+ c = new LayoutTestControl();
+
+ c.SuspendLayout();
+ c.SuspendLayout();
+ c.SuspendLayout();
+ c.SuspendLayout();
+
+ c.ResumeLayout(true);
+ c.PerformLayout();
+ c.ResumeLayout(true);
+ c.PerformLayout();
+ c.ResumeLayout(true);
+ c.PerformLayout();
+ c.ResumeLayout(true);
+ c.PerformLayout();
+ c.ResumeLayout(true);
+ c.PerformLayout();
+ c.ResumeLayout(true);
+ c.PerformLayout();
+ c.ResumeLayout(true);
+ c.PerformLayout();
+ c.SuspendLayout();
+ c.PerformLayout();
+
+ Assert.AreEqual(5, c.LayoutCount, "Layout Suspend/Resume locking does not bottom out at 0");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CursorTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CursorTest.cs
new file mode 100644
index 00000000000..e7123e1891d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/CursorTest.cs
@@ -0,0 +1,29 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Miguel de Icaza
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class CursorTest
+ {
+ [Test]
+ public void LoadCursorKind2 ()
+ {
+ //
+ // This test tries to load a cursor with type 1
+ // this contains an and mask, it used to crash
+ //
+
+ new Cursor (typeof (CursorTest).Assembly.GetManifestResourceStream ("a.cur"));
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridCellTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridCellTest.cs
new file mode 100644
index 00000000000..5213c36003a
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridCellTest.cs
@@ -0,0 +1,56 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.ComponentModel;
+using System.Windows.Forms;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class DataGridCellTest
+ {
+ private bool eventhandled;
+
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGridCell cell = new DataGridCell (5, 10);
+
+ Assert.AreEqual (5, cell.RowNumber, "A1 RowNumber");
+ Assert.AreEqual (10, cell.ColumnNumber, "A2 ColumnNumber");
+
+ cell.ColumnNumber = 20;
+ cell.RowNumber = 30;
+
+ Assert.AreEqual (30, cell.RowNumber, "A3 RowNumber");
+ Assert.AreEqual (20, cell.ColumnNumber, "A4 ColumnNumber");
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTableStyleTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTableStyleTest.cs
new file mode 100644
index 00000000000..97cbda27cb3
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTableStyleTest.cs
@@ -0,0 +1,270 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class DataGridTableStyleTest
+ {
+ private bool eventhandled;
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady ()
+ {
+ }
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+
+ Assert.AreEqual (true, dg.AllowSorting, "AllowSorting property");
+ Assert.AreEqual (true, dg.ColumnHeadersVisible, "ColumnHeadersVisible property");
+ Assert.AreEqual (DataGridLineStyle.Solid, dg.GridLineStyle, "GridLineStyle property");
+ Assert.AreEqual (75, dg.PreferredColumnWidth, "PreferredColumnWidth property");
+ Assert.AreEqual (16, dg.PreferredRowHeight, "PreferredRowHeight property");
+ Assert.AreEqual (false, dg.ReadOnly, "ReadOnly property");
+ Assert.AreEqual (true, dg.RowHeadersVisible, "RowHeadersVisible property");
+ Assert.AreEqual (35, dg.RowHeaderWidth, "RowHeaderWidth property");
+ }
+
+ [Test]
+ public void TestAllowSortingChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.AllowSortingChanged += new EventHandler (OnEventHandler);
+ dg.AllowSorting = !dg.AllowSorting;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestAlternatingBackColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.AlternatingBackColorChanged += new EventHandler (OnEventHandler);
+ dg.AlternatingBackColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Ignore ("Microsoft lunches ForeColor event instead of BackColor")]
+ public void TestBackColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.BackColorChanged += new EventHandler (OnEventHandler);
+ dg.BackColor = Color.Yellow;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestColumnHeadersVisibleChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.ColumnHeadersVisibleChanged += new EventHandler (OnEventHandler);
+ dg.ColumnHeadersVisible = !dg.ColumnHeadersVisible;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Ignore ("Microsoft lunches BackColor event instead of ForeColor")]
+ public void TestForeColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.ForeColorChanged += new EventHandler (OnEventHandler);
+ dg.ForeColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestGridLineColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.GridLineColorChanged += new EventHandler (OnEventHandler);
+ dg.GridLineColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestGridLineStyleChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.GridLineStyleChanged += new EventHandler (OnEventHandler);
+ dg.GridLineStyle = DataGridLineStyle.None;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestHeaderBackColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.HeaderBackColorChanged += new EventHandler (OnEventHandler);
+ dg.HeaderBackColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestHeaderFontChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.HeaderFontChanged += new EventHandler (OnEventHandler);
+ dg.HeaderFont = new Font ("Arial", 20);
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestHeaderForeColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.HeaderForeColorChanged += new EventHandler (OnEventHandler);
+ dg.HeaderForeColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestLinkColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.LinkColorChanged += new EventHandler (OnEventHandler);
+ dg.LinkColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+
+ [Ignore ("Microsoft is not firing any event")]
+ public void TestLinkHoverColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.LinkHoverColorChanged += new EventHandler (OnEventHandler);
+ dg.LinkHoverColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestMappingNameChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.MappingNameChanged += new EventHandler (OnEventHandler);
+ dg.MappingName = "name1";
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestPreferredColumnWidthChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.PreferredColumnWidthChanged += new EventHandler (OnEventHandler);
+ dg.PreferredColumnWidth = dg.PreferredColumnWidth++;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestPreferredRowHeightChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.PreferredRowHeightChanged += new EventHandler (OnEventHandler);
+ dg.PreferredRowHeight = dg.PreferredRowHeight++;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+ [Test]
+ public void TestReadOnlyChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.ReadOnlyChanged += new EventHandler (OnEventHandler);
+ dg.ReadOnly = !dg.ReadOnly;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestRowHeadersVisibleChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.RowHeadersVisibleChanged += new EventHandler (OnEventHandler);
+ dg.RowHeadersVisible = !dg.RowHeadersVisible;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestRowHeaderWidthChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.RowHeaderWidthChanged += new EventHandler (OnEventHandler);
+ dg.RowHeaderWidth = dg.RowHeaderWidth++;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestSelectionBackColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.SelectionBackColorChanged += new EventHandler (OnEventHandler);
+ dg.SelectionBackColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestSelectionForeColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.SelectionForeColorChanged += new EventHandler (OnEventHandler);
+ dg.SelectionForeColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ public void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs
new file mode 100644
index 00000000000..77b061906a1
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs
@@ -0,0 +1,314 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ // Helper classes
+
+ class TestDataGrid : DataGrid
+ {
+ public TestDataGrid ()
+ {
+
+ }
+
+ public CurrencyManager Manager {
+ get {
+ return ListManager;
+ }
+ }
+ }
+
+ [TestFixture]
+ class DataGridTest
+ {
+ private bool eventhandled;
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady ()
+ {
+ }
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGrid dg = new DataGrid ();
+
+ Assert.AreEqual (true, dg.AllowNavigation, "AllowNavigation property");
+ Assert.AreEqual (true, dg.AllowSorting, "AllowSorting property");
+ Assert.AreEqual (BorderStyle.Fixed3D, dg.BorderStyle, "BorderStyle property");
+ Assert.AreEqual (string.Empty, dg.CaptionText, "CaptionText property");
+ Assert.AreEqual (true, dg.CaptionVisible, "CaptionVisible property");
+ Assert.AreEqual (true, dg.ColumnHeadersVisible, "ColumnHeadersVisible property");
+ Assert.AreEqual (new DataGridCell (), dg.CurrentCell, "CurrentCell property");
+ Assert.AreEqual (-1, dg.CurrentRowIndex, "CurrentRowIndex property");
+ Assert.AreEqual (string.Empty, dg.DataMember, "DataMember property");
+ Assert.AreEqual (null, dg.DataSource, "DataSource property");
+ Assert.AreEqual (0, dg.FirstVisibleColumn, "FirstVisibleColumn property");
+ Assert.AreEqual (false, dg.FlatMode, "FlatMode property");
+ Assert.AreEqual (DataGridLineStyle.Solid, dg.GridLineStyle, "GridLineStyle property");
+ Assert.AreEqual (DataGridParentRowsLabelStyle.Both, dg.ParentRowsLabelStyle, "ParentRowsLabelStyle property");
+ Assert.AreEqual (true, dg.ParentRowsVisible, "ParentRowsVisible property");
+ Assert.AreEqual (75, dg.PreferredColumnWidth, "PreferredColumnWidth property");
+ //Assert.AreEqual (16, dg.PreferredRowHeight, "PreferredRowHeight property");
+ Assert.AreEqual (false, dg.ReadOnly, "ReadOnly property");
+ Assert.AreEqual (true, dg.RowHeadersVisible, "RowHeadersVisible property");
+ Assert.AreEqual (35, dg.RowHeaderWidth, "RowHeaderWidth property");
+ Assert.AreEqual (null, dg.Site, "Site property");
+ Assert.AreEqual (string.Empty, dg.Text, "Text property");
+ Assert.AreEqual (0, dg.VisibleColumnCount, "VisibleColumnCount property");
+ }
+
+ [Test]
+ public void TestAllowNavigationChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.AllowNavigationChanged += new EventHandler (OnEventHandler);
+ dg.AllowNavigation = !dg.AllowNavigation;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestBackgroundColorChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.BackgroundColorChanged += new EventHandler (OnEventHandler);
+ dg.BackgroundColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestBorderStyleChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.BorderStyleChanged += new EventHandler (OnEventHandler);
+ dg.BorderStyle = BorderStyle.None;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestCaptionVisibleChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.CaptionVisibleChanged += new EventHandler (OnEventHandler);
+ dg.CaptionVisible = !dg.CaptionVisible;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestFlatModeChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.FlatModeChanged += new EventHandler (OnEventHandler);
+ dg.FlatMode = !dg.FlatMode;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestParentRowsLabelStyleChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.ParentRowsLabelStyleChanged += new EventHandler (OnEventHandler);
+ dg.ParentRowsLabelStyle = DataGridParentRowsLabelStyle.None;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestParentRowsVisibleChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.ParentRowsVisibleChanged += new EventHandler (OnEventHandler);
+ dg.ParentRowsVisible = !dg.ParentRowsVisible;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestReadOnlyChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.ReadOnlyChanged += new EventHandler (OnEventHandler);
+ dg.ReadOnly = !dg.ReadOnly;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ public void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ // Property exceptions
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void GridLineColorException ()
+ {
+ DataGrid dg = new DataGrid ();
+ dg.GridLineColor = Color.Empty;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void HeaderBackColorException ()
+ {
+ DataGrid dg = new DataGrid ();
+ dg.HeaderBackColor = Color.Empty;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void PreferredColumnWidthException ()
+ {
+ DataGrid dg = new DataGrid ();
+ dg.PreferredColumnWidth = -1;
+ }
+
+ [Test]
+ public void ResetAlternatingBackColor ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.AlternatingBackColor = Color.Red;
+ dg2.ResetAlternatingBackColor ();
+ Assert.AreEqual (dg.AlternatingBackColor, dg2.AlternatingBackColor, "A1");
+ }
+
+ // Test reset colour methods
+ [Test]
+ public void ResetBackColorMethod ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.BackColor = Color.Red;
+ dg2.ResetBackColor ();
+ Assert.AreEqual (dg.BackColor, dg2.BackColor, "A1");
+ }
+
+ [Test]
+ public void ResetForeColorMethod ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.ForeColor = Color.Red;
+ dg2.ResetForeColor ();
+ Assert.AreEqual (dg.ForeColor, dg2.ForeColor, "A1");
+ }
+
+ [Test]
+ public void ResetGridLineColorMethod ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.GridLineColor = Color.Red;
+ dg2.ResetGridLineColor ();
+ Assert.AreEqual (dg.GridLineColor, dg2.GridLineColor, "A1");
+ }
+
+ [Test]
+ public void ResetHeaderBackColorMethod ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.HeaderBackColor = Color.Red;
+ dg2.ResetHeaderBackColor ();
+ Assert.AreEqual (dg.HeaderBackColor, dg2.HeaderBackColor, "A1");
+ }
+
+ [Test]
+ public void ResetHeaderFontMethod ()
+ {
+ }
+
+ [Test]
+ public void ResetHeaderForeColorMethod ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.HeaderForeColor = Color.Red;
+ dg2.ResetHeaderForeColor ();
+ Assert.AreEqual (dg.HeaderForeColor, dg2.HeaderForeColor, "A1");
+ }
+
+ [Test]
+ public void ResetLinkColorMethod ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.LinkColor = Color.Red;
+ dg2.ResetLinkColor ();
+ Assert.AreEqual (dg.LinkColor, dg2.LinkColor, "A1");
+ }
+
+ [Test]
+ public void ResetLinkHoverColor ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.LinkHoverColor = Color.Red;
+ dg2.ResetLinkHoverColor ();
+ Assert.AreEqual (dg.LinkHoverColor, dg2.LinkHoverColor, "A1");
+ }
+
+ [Test]
+ public void ResetSelectionBackColor ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.SelectionBackColor = Color.Red;
+ dg2.ResetSelectionBackColor ();
+ Assert.AreEqual (dg.SelectionBackColor, dg2.SelectionBackColor, "A1");
+ }
+
+ [Test]
+ public void ResetSelectionForeColor ()
+ {
+ DataGrid dg = new DataGrid ();
+ DataGrid dg2 = new DataGrid ();
+ dg2.SelectionForeColor = Color.Red;
+ dg2.ResetSelectionForeColor ();
+ Assert.AreEqual (dg.SelectionForeColor, dg2.SelectionForeColor, "A1");
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTextBoxColumnTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTextBoxColumnTest.cs
new file mode 100644
index 00000000000..601faae3cfd
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTextBoxColumnTest.cs
@@ -0,0 +1,105 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class DataGridTextBoxColumnTest
+ {
+ private bool eventhandled;
+ private object Element;
+ private CollectionChangeAction Action;
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn ();
+
+ Assert.AreEqual (HorizontalAlignment.Left, col.Alignment, "HorizontalAlignment property");
+ Assert.AreEqual ("", col.HeaderText, "HeaderText property");
+ Assert.AreEqual ("", col.MappingName, "MappingName property");
+ Assert.AreEqual ("(null)", col.NullText, "NullText property");
+ Assert.AreEqual (false, col.ReadOnly, "ReadOnly property");
+ Assert.AreEqual (-1, col.Width, "Width property");
+ Assert.AreEqual ("", col.Format, "Format property");
+ Assert.AreEqual (null, col.FormatInfo, "FormatInfo property");
+ }
+
+ [Test]
+ public void TestMappingNameChangedEvent ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn ();
+ eventhandled = false;
+ col.MappingNameChanged += new EventHandler (OnEventHandler);
+ col.MappingName = "name1";
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestAlignmentChangedEvent ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn ();
+ eventhandled = false;
+ col.AlignmentChanged += new EventHandler (OnEventHandler);
+ col.Alignment = HorizontalAlignment.Center;
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestHeaderTextChangedEvent ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn ();
+ eventhandled = false;
+ col.HeaderTextChanged += new EventHandler (OnEventHandler);
+ col.HeaderText = "Header";
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+ [Test]
+ public void TestNullTextChangedEvent ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn ();
+ eventhandled = false;
+ col.NullTextChanged += new EventHandler (OnEventHandler);
+ col.NullText = "Null";
+ Assert.AreEqual (true, eventhandled, "A1");
+ }
+
+
+ private void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewAdvancedBorderStyleTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewAdvancedBorderStyleTest.cs
new file mode 100644
index 00000000000..7d125797913
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewAdvancedBorderStyleTest.cs
@@ -0,0 +1,149 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms {
+
+ [TestFixture]
+ public class DataGridViewAdvancedBorderStyleTest : Assertion {
+
+ private DataGridViewAdvancedBorderStyle style;
+
+ [SetUp]
+ public void GetReady() {
+ style = new DataGridViewAdvancedBorderStyle();
+ }
+
+ [TearDown]
+ public void Clean() {
+ }
+
+ [Test]
+ public void TestDefaultValues () {
+ AssertEquals("All property before any change", DataGridViewAdvancedCellBorderStyle.None, style.All);
+ style.Left = DataGridViewAdvancedCellBorderStyle.Single;
+ AssertEquals("All property after changes", DataGridViewAdvancedCellBorderStyle.NotSet, style.All);
+ style.All = DataGridViewAdvancedCellBorderStyle.Single;
+ AssertEquals("All property after changes", DataGridViewAdvancedCellBorderStyle.Single, style.All);
+ AssertEquals("Left property after changes", DataGridViewAdvancedCellBorderStyle.Single, style.Left);
+ AssertEquals("Right property after changes", DataGridViewAdvancedCellBorderStyle.Single, style.Right);
+ AssertEquals("Top property after changes", DataGridViewAdvancedCellBorderStyle.Single, style.Top);
+ AssertEquals("Bottom property after changes", DataGridViewAdvancedCellBorderStyle.Single, style.Bottom);
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestLeftInvalidEnumArgumentException () {
+ style.Left = (DataGridViewAdvancedCellBorderStyle) 8;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestLeftArgumentException1 () {
+ style.Left = DataGridViewAdvancedCellBorderStyle.NotSet;
+ }
+
+ /*
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestLeftArgumentException2 () {
+ Control.RightToLeft = true;
+ style.Left = DataGridViewAdvancedCellBorderStyle.InsetDouble;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestLeftArgumentException3 () {
+ Control.RightToLeft = true;
+ style.Left = DataGridViewAdvancedCellBorderStyle.OutsetDouble;
+ }
+ */
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestRightInvalidEnumArgumentException () {
+ style.Right = (DataGridViewAdvancedCellBorderStyle) 8;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestRightArgumentException1 () {
+ style.Right = DataGridViewAdvancedCellBorderStyle.NotSet;
+ }
+
+ /*
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestRightArgumentException2 () {
+ Control.RightToLeft = false;
+ style.Right = DataGridViewAdvancedCellBorderStyle.InsetDouble;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestRightArgumentException3 () {
+ Control.RightToLeft = false;
+ style.Right = DataGridViewAdvancedCellBorderStyle.OutsetDouble;
+ }
+ */
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestTopInvalidEnumArgumentException () {
+ style.Top = (DataGridViewAdvancedCellBorderStyle) 8;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestTopArgumentException () {
+ style.Top = DataGridViewAdvancedCellBorderStyle.NotSet;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestBottomInvalidEnumArgumentException () {
+ style.Bottom = (DataGridViewAdvancedCellBorderStyle) 8;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestBottomArgumentException () {
+ style.Bottom = DataGridViewAdvancedCellBorderStyle.NotSet;
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewBandTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewBandTest.cs
new file mode 100644
index 00000000000..475237c7d14
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewBandTest.cs
@@ -0,0 +1,73 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms {
+
+ [TestFixture]
+ public class DataGridViewBandTest : Assertion {
+
+ [SetUp]
+ public void GetReady() {}
+
+ [TearDown]
+ public void Clean() {}
+
+ [Test]
+ public void TestDefaultValues () {
+ DataGridViewBand band = new DataGridViewBand();
+ // AssertEquals("ContextMenuStrip property", null, band.ContextMenuStrip);
+ AssertEquals("Frozen", false, band.Frozen);
+ AssertEquals("HasDefaultCellStyle property", false, band.HasDefaultCellStyle);
+ AssertEquals("Index property", -1, band.Index);
+ AssertEquals("InheritedStyle property", null, band.InheritedStyle);
+ AssertEquals("ReadOnly property", false, band.ReadOnly);
+ AssertEquals("Resizable property", DataGridViewTriState.True, band.Resizable);
+ AssertEquals("Selected property", false, band.Selected);
+ AssertEquals("Tag property", null, band.Tag);
+ AssertEquals("Visible property", true, band.Visible);
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestSelectedInvalidOperationException () {
+ DataGridViewBand band = new DataGridViewBand();
+ band.Selected = true;
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellStyleTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellStyleTest.cs
new file mode 100644
index 00000000000..269ab9fb9fb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellStyleTest.cs
@@ -0,0 +1,125 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Collections;
+using System.Globalization;
+
+namespace MonoTests.System.Windows.Forms {
+
+ [TestFixture]
+ public class DataGridViewCellStyleTest : Assertion {
+
+ DataGridViewCellStyle style;
+
+ [SetUp]
+ public void GetReady() {
+ style = new DataGridViewCellStyle();
+ }
+
+ [TearDown]
+ public void Clean() {
+ style = new DataGridViewCellStyle();
+ }
+
+ [Test]
+ public void TestDefaultValues () {
+ AssertEquals("Alignment property", DataGridViewContentAlignment.NotSet, style.Alignment);
+ AssertEquals("BackColor property", Color.Empty, style.BackColor);
+ AssertEquals("Font property", null, style.Font);
+ AssertEquals("ForeColor property", Color.Empty, style.ForeColor);
+ AssertEquals("Format property", String.Empty, style.Format);
+ AssertEquals("FormatProvider property", CultureInfo.CurrentUICulture, style.FormatProvider);
+ AssertEquals("IsFormatProviderDefault property", true, style.IsFormatProviderDefault);
+ AssertEquals("IsNullValueDefault property", true, style.IsNullValueDefault);
+ AssertEquals("NullValue property", "(null)", style.NullValue);
+ AssertEquals("SelectionBackColor property", Color.Empty, style.SelectionBackColor);
+ AssertEquals("SelectionForeColor property", Color.Empty, style.SelectionForeColor);
+ AssertEquals("Tag property", null, style.Tag);
+ AssertEquals("WrapMode property", DataGridViewTriState.NotSet, style.WrapMode);
+ }
+
+ [Test]
+ public void TestApplyStyle () {
+ DataGridViewCellStyle style_aux = new DataGridViewCellStyle();
+ style.ApplyStyle(style_aux);
+ AssertEquals("ApplyStyle method", style_aux, style);
+ }
+
+ [Test]
+ public void TestClone () {
+ DataGridViewCellStyle style_aux = (DataGridViewCellStyle) style.Clone();
+ AssertEquals("Clone method", style_aux, style);
+ }
+
+ [Test]
+ public void TestEquals () {
+ DataGridViewCellStyle style_aux = (DataGridViewCellStyle) style.Clone();
+ AssertEquals("Equals method", true, (style_aux.Equals(style)));
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestAlignmentInvalidEnumArgumentException () {
+ style.Alignment = DataGridViewContentAlignment.BottomCenter | DataGridViewContentAlignment.BottomRight;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestSelectionBackColorArgumentException () {
+ style.SelectionBackColor = Color.FromArgb(100, Color.Red);
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestWrapModeInvalidEnumArgumentException () {
+ style.WrapMode = (DataGridViewTriState) 3;
+ }
+
+ /*
+ [Test]
+ [ExpectedException(typeof(Exception))]
+ public void TestException () {
+ ConcreteCollection myCollection;
+ myCollection = new ConcreteCollection();
+ ....
+ AssertEquals ("#UniqueID", expected, actual);
+ ....
+ Fail ("Message");
+ }
+ */
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellTest.cs
new file mode 100644
index 00000000000..4b133b16760
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellTest.cs
@@ -0,0 +1,74 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms {
+
+ [TestFixture]
+ public class DataGridViewCellTest : Assertion {
+
+ [SetUp]
+ public void GetReady() {}
+
+ [TearDown]
+ public void Clean() {}
+
+ [Test]
+ public void TestDefaultValues () {
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestException () {
+ throw new InvalidEnumArgumentException();
+ }
+
+ /*
+ [Test]
+ [ExpectedException(typeof(Exception))]
+ public void TestException () {
+ ConcreteCollection myCollection;
+ myCollection = new ConcreteCollection();
+ ....
+ AssertEquals ("#UniqueID", expected, actual);
+ ....
+ Fail ("Message");
+ }
+ */
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewElementTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewElementTest.cs
new file mode 100644
index 00000000000..36d9306dda2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewElementTest.cs
@@ -0,0 +1,57 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms {
+
+ [TestFixture]
+ public class DataGridViewElementTest : Assertion {
+
+ [SetUp]
+ public void GetReady() {}
+
+ [TearDown]
+ public void Clean() {}
+
+ [Test]
+ public void TestDefaultValues () {
+ DataGridViewElement element = new DataGridViewElement();
+ AssertEquals("DataGridView property", null, element.DataGridView);
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewRowTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewRowTest.cs
new file mode 100644
index 00000000000..41cfde87aa0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewRowTest.cs
@@ -0,0 +1,64 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms {
+
+ [TestFixture]
+ public class DataGridViewRowTest : Assertion {
+
+ [SetUp]
+ public void GetReady() {}
+
+ [TearDown]
+ public void Clean() {}
+
+ [Test]
+ public void TestDefaultValues () {
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestVisibleInvalidOperationException () {
+ DataGridView grid = new DataGridView();
+ DataGridViewRow row = new DataGridViewRow();
+ grid.Rows.Add(row);
+ row.Visible = false;
+ }
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewTest.cs
new file mode 100644
index 00000000000..a0dd21e9ce0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewTest.cs
@@ -0,0 +1,282 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Pedro Martínez Juliá <pedromj@gmail.com>
+//
+
+
+#if NET_2_0
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms {
+
+ [TestFixture]
+ public class DataGridViewTest : Assertion {
+
+ [SetUp]
+ public void GetReady() {}
+
+ [TearDown]
+ public void Clean() {}
+
+ [Test]
+ public void TestDefaultValues () {
+ DataGridView grid = new DataGridView();
+ AssertEquals("AllowUserToAddRows property", true, grid.AllowUserToAddRows);
+ AssertEquals("AllowUserToDeleteRows property", true, grid.AllowUserToDeleteRows);
+ AssertEquals("AllowUserToOrderColumns property", false, grid.AllowUserToOrderColumns);
+ AssertEquals("AllowUserToResizeColumns property", true, grid.AllowUserToResizeColumns);
+ AssertEquals("AllowUserToResizeRows property", true, grid.AllowUserToResizeRows);
+ AssertEquals("AlternatingRowsDefaultCellStyle property", new DataGridViewCellStyle(), grid.AlternatingRowsDefaultCellStyle);
+ AssertEquals("AutoGenerateColumns property", true, grid.AutoGenerateColumns);
+ AssertEquals("AutoSizeRowsMode property", DataGridViewAutoSizeRowsMode.None, grid.AutoSizeRowsMode);
+ AssertEquals("BackColor property", Control.DefaultBackColor, grid.BackColor);
+ AssertEquals("BackgroundColor property", SystemColors.AppWorkspace, grid.BackgroundColor);
+ AssertEquals("BorderStyle property", BorderStyle.FixedSingle, grid.BorderStyle);
+ AssertEquals("ClipboardCopyMode property", DataGridViewClipboardCopyMode.EnableWithAutoHeaderText, grid.ClipboardCopyMode);
+ AssertEquals("ColumnHeadersDefaultCellStyle.BackColor property", SystemColors.Control, grid.ColumnHeadersDefaultCellStyle.BackColor);
+ AssertEquals("ColumnHeadersDefaultCellStyle.ForeColor property", SystemColors.WindowText, grid.ColumnHeadersDefaultCellStyle.ForeColor);
+ AssertEquals("ColumnHeadersDefaultCellStyle.SelectionBackColor property", SystemColors.Highlight, grid.ColumnHeadersDefaultCellStyle.SelectionBackColor);
+ AssertEquals("ColumnHeadersDefaultCellStyle.SelectionForeColor property", SystemColors.HighlightText, grid.ColumnHeadersDefaultCellStyle.SelectionForeColor);
+ AssertEquals("ColumnHeadersDefaultCellStyle.Font property", grid.Font, grid.ColumnHeadersDefaultCellStyle.Font);
+ AssertEquals("ColumnHeadersDefaultCellStyle.Alignment property", DataGridViewContentAlignment.MiddleLeft, grid.ColumnHeadersDefaultCellStyle.Alignment);
+ AssertEquals("ColumnHeadersDefaultCellStyle.WrapMode property", DataGridViewTriState.True, grid.ColumnHeadersDefaultCellStyle.WrapMode);
+ AssertEquals("ColumnHeadersHeight property", 23, grid.ColumnHeadersHeight);
+ AssertEquals("ColumnHeadersHeightSizeMode property", DataGridViewColumnHeadersHeightSizeMode.EnableResizing, grid.ColumnHeadersHeightSizeMode);
+ AssertEquals("ColumnHeadersVisible property", true, grid.ColumnHeadersVisible);
+ AssertEquals("DataMember property", String.Empty, grid.DataMember);
+ AssertEquals("DefaultCellStyle.BackColor property", SystemColors.Control, grid.DefaultCellStyle.BackColor);
+ AssertEquals("DefaultCellStyle.ForeColor property", SystemColors.WindowText, grid.DefaultCellStyle.ForeColor);
+ AssertEquals("DefaultCellStyle.SelectionBackColor property", SystemColors.Highlight, grid.DefaultCellStyle.SelectionBackColor);
+ AssertEquals("DefaultCellStyle.SelectionForeColor property", SystemColors.HighlightText, grid.DefaultCellStyle.SelectionForeColor);
+ AssertEquals("DefaultCellStyle.Font property", grid.Font, grid.DefaultCellStyle.Font);
+ AssertEquals("DefaultCellStyle.Alignment property", DataGridViewContentAlignment.MiddleLeft, grid.DefaultCellStyle.Alignment);
+ AssertEquals("DefaultCellStyle.WrapMode property", DataGridViewTriState.True, grid.DefaultCellStyle.WrapMode);
+ AssertEquals("EditMode property", DataGridViewEditMode.EditOnKeystrokeOrF2, grid.EditMode);
+ AssertEquals("Font property", Control.DefaultFont, grid.Font);
+ AssertEquals("ForeColor property", Control.DefaultForeColor, grid.ForeColor);
+ AssertEquals("GridColor property", Color.FromKnownColor(KnownColor.ControlDarkDark), grid.GridColor);
+ AssertEquals("MultiSelect property", true, grid.MultiSelect);
+ AssertEquals("NewRowIndex property", grid.Rows.Count - 1, grid.NewRowIndex);
+ AssertEquals("Padding property", Padding.Empty, grid.Padding);
+ AssertEquals("ReadOnly property", false, grid.ReadOnly);
+ AssertEquals("RowHeadersVisible property", true, grid.RowHeadersVisible);
+ AssertEquals("RowHeadersWidth property", 43, grid.RowHeadersWidth);
+ AssertEquals("SelectionMode property", DataGridViewSelectionMode.RowHeaderSelect, grid.SelectionMode);
+ AssertEquals("ShowCellErrors property", true, grid.ShowCellErrors);
+ AssertEquals("ShowEditingIcon property", true, grid.ShowEditingIcon);
+ AssertEquals("UserSetCursor property", Cursor.Current, grid.UserSetCursor);
+ AssertEquals("VirtualMode property", false, grid.VirtualMode);
+ }
+
+ #region AutoSizeColumnsModeExceptions
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestAutoSizeColumnsModeInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill | DataGridViewAutoSizeColumnsMode.None;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestAutoSizeColumnsModeInvalidOperationException1 () {
+ DataGridView grid = new DataGridView();
+ grid.ColumnHeadersVisible = false;
+ DataGridViewColumn col = new DataGridViewColumn();
+ col.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
+ grid.Columns.Add(col);
+ grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestAutoSizeColumnsModeInvalidOperationException2 () {
+ DataGridView grid = new DataGridView();
+ DataGridViewColumn col = new DataGridViewColumn();
+ col.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
+ col.Frozen = true;
+ grid.Columns.Add(col);
+ grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ }
+
+ #endregion
+
+ #region AutoSizeRowsModeExceptions
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestAutoSizeRowsModeInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.AutoSizeRowsMode = (DataGridViewAutoSizeRowsMode) 4;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestAutoSizeRowsModeInvalidOperationException1 () {
+ DataGridView grid = new DataGridView();
+ grid.RowHeadersVisible = false;
+ grid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllHeaders;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestAutoSizeRowsModeInvalidOperationException2 () {
+ DataGridView grid = new DataGridView();
+ grid.RowHeadersVisible = false;
+ grid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedHeaders;
+ }
+
+ #endregion
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestBackgroundColorArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.BackgroundColor = Color.Empty;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestBorderStyleInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.BorderStyle = BorderStyle.FixedSingle | BorderStyle.Fixed3D;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestColumnCountArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.ColumnCount = -1;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestColumnCountInvalidOperationException () {
+ DataGridView grid = new DataGridView();
+ grid.DataSource = new ArrayList();
+ grid.ColumnCount = 0;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestColumnHeadersHeightArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.ColumnHeadersHeight = 3;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestColumnHeadersHeightSizeModeInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.ColumnHeadersHeightSizeMode = (DataGridViewColumnHeadersHeightSizeMode) 3;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestCurrentCellArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.CurrentCell = new DataGridViewTextBoxCell();
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestRowHeadersWidthArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.RowHeadersWidth = 3;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestDataGridViewRowHeadersWidthSizeModeInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.RowHeadersWidthSizeMode = (DataGridViewRowHeadersWidthSizeMode) 5;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestScrollBarsInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.ScrollBars = (ScrollBars) 4;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestSelectionModeInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.SelectionMode = (DataGridViewSelectionMode) 5;
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidEnumArgumentException))]
+ public void TestAutoResizeRowsInvalidEnumArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.AutoResizeRows((DataGridViewAutoSizeRowsMode) 4);
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestAutoResizeRowsInvalidOperationException1 () {
+ DataGridView grid = new DataGridView();
+ grid.RowHeadersVisible = false;
+ grid.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllHeaders);
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidOperationException))]
+ public void TestAutoResizeRowsInvalidOperationException2 () {
+ DataGridView grid = new DataGridView();
+ grid.RowHeadersVisible = false;
+ grid.AutoResizeRows(DataGridViewAutoSizeRowsMode.DisplayedHeaders);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void TestAutoResizeRowsArgumentException () {
+ DataGridView grid = new DataGridView();
+ grid.AutoResizeRows(DataGridViewAutoSizeRowsMode.None);
+ }
+
+ /*
+ [Test]
+ [ExpectedException(typeof(Exception))]
+ public void TestException () {
+ ConcreteCollection myCollection;
+ myCollection = new ConcreteCollection();
+ ....
+ AssertEquals ("#UniqueID", expected, actual);
+ ....
+ Fail ("Message");
+ }
+ */
+
+ }
+
+}
+
+#endif
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ErrorProviderTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ErrorProviderTest.cs
new file mode 100644
index 00000000000..182b9a0673d
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ErrorProviderTest.cs
@@ -0,0 +1,98 @@
+//
+// ErrorProviderTest.cs: Test cases for ErrorProvider.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Data;
+using System.Runtime.Remoting;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class ErrorProviderTest
+ {
+
+ [Test]
+ public void ErrorProviderPropertyTest ()
+ {
+ ErrorProvider myErrorProvider = new ErrorProvider ();
+
+ // B
+ Assert.AreEqual (250, myErrorProvider.BlinkRate, "#B1");
+ Assert.AreEqual (ErrorBlinkStyle.BlinkIfDifferentError, myErrorProvider.BlinkStyle, "#B2");
+
+ // C
+ Assert.AreEqual (null, myErrorProvider.ContainerControl, "#C1");
+
+ // D
+ Assert.AreEqual (null, myErrorProvider.DataMember, "#D1");
+ Assert.AreEqual (null, myErrorProvider.DataSource, "#D2");
+
+ // I
+ Assert.AreEqual (16, myErrorProvider.Icon.Height, "#I1");
+ Assert.AreEqual (16, myErrorProvider.Icon.Width, "#I2");
+
+ // S
+ Assert.AreEqual (null, myErrorProvider.Site, "#S1");
+ }
+
+ [Test]
+ public void BindToDateAndErrorsTest ()
+ {
+ ErrorProvider myErrorProvider = new ErrorProvider ();
+ DataSet myDataSet= new DataSet();
+ myErrorProvider.DataSource = myDataSet;
+ myErrorProvider.DataMember = "Customers";
+ Assert.AreEqual (myDataSet, myErrorProvider.DataSource, "#Bind1");
+ Assert.AreEqual ("Customers", myErrorProvider.DataMember, "#Bind2");
+ }
+
+ [Test]
+ public void CanExtendTest ()
+ {
+ Control myControl = new Control ();
+ Form myForm = new Form ();
+ ToolBar myToolBar = new ToolBar ();
+ ErrorProvider myErrorProvider = new ErrorProvider ();
+ Assert.AreEqual (myErrorProvider.CanExtend (myControl), true, "#ext1");
+ Assert.AreEqual (myErrorProvider.CanExtend (myToolBar), false, "#ext2");
+ Assert.AreEqual (myErrorProvider.CanExtend (myForm), false, "#ext3");
+ }
+
+ [Test]
+ public void GetandSetErrorTest ()
+ {
+ Form myForm = new Form ();
+ Label myLabel = new Label ();
+ ErrorProvider myErrorProvider = new ErrorProvider ();
+ myErrorProvider.SetError(myLabel, "New Error msg for Label");
+ Assert.AreEqual ("New Error msg for Label", myErrorProvider.GetError (myLabel), "#getset1");
+ }
+
+ [Test]
+ public void GetandSetIconAlignmentTest ()
+ {
+ TextBox myTextBox = new TextBox ();
+ ErrorProvider myErrorProvider = new ErrorProvider ();
+ myErrorProvider.SetIconAlignment (myTextBox, ErrorIconAlignment.MiddleRight);
+ Assert.AreEqual (ErrorIconAlignment.MiddleRight, myErrorProvider.GetIconAlignment (myTextBox), "#getset2");
+ }
+
+ [Test]
+ public void GetandSetIconPaddingTest ()
+ {
+ Form myForm = new Form ();
+ ErrorProvider myErrorProvider = new ErrorProvider ();
+ myErrorProvider.SetIconPadding (myForm, 2);
+ Assert.AreEqual (2, myErrorProvider.GetIconPadding (myForm), "#getset3");
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormEventTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormEventTest.cs
new file mode 100644
index 00000000000..e396aa1ea51
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormEventTest.cs
@@ -0,0 +1,237 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Threading;
+using System.Globalization;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class FormEvent
+ {
+ static bool eventhandled = false;
+ public void New_EventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test, Ignore ("Manual Intervention")]
+ public void ActivatedTest ()
+ {
+ Form myform = new Form ();
+ myform.Activated += new EventHandler (New_EventHandler);
+ myform.Activate ();
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A1");
+ }
+
+ [Test, Ignore ("Manual Intervention")]
+ public void ClosedTest ()
+ {
+ Form myform = new Form ();
+ myform.Closed += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ myform.Close ();
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A2");
+ }
+
+ [Test, Ignore ("Manual Intervention")]
+ public void DeactivateTest ()
+ {
+ Form myform = new Form ();
+ myform.Deactivate += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ myform.Close ();
+ myform.Activate ();
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A3");
+ }
+
+ [Test, Ignore ("Manual Intervention")]
+ public void LoadTest ()
+ {
+ Form myform = new Form ();
+ myform.Load += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A4");
+ myform.Dispose ();
+ }
+
+ class MyForm : Form
+ {
+ public void MaximizeBoundsTest ()
+ {
+ this.MaximizedBounds = new Rectangle (10,10,100,100);
+ }
+ }
+
+ [Test]
+ public void MaximizedBoundsChangedTest ()
+ {
+ MyForm myform = new MyForm ();
+ myform.MaximizedBoundsChanged += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ myform.MaximizeBoundsTest ();
+ Assert.AreEqual (true, eventhandled, "#A5");
+ myform.Dispose ();
+ }
+
+ [Test]
+ public void MaximumSizeChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.MaximumSizeChanged += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ myform.MaximumSize = new Size (500, 500);
+ Assert.AreEqual (true, eventhandled, "#A6");
+ myform.Dispose ();
+ }
+
+ [Test, Ignore ("Manual Intervention")]
+ public void MdiChildActivateTest ()
+ {
+ Form parent = new Form ();
+ Form child = new Form ();
+ parent.IsMdiContainer = true;
+ child.IsMdiContainer = false;
+ child.MdiParent = parent;
+ parent.MdiChildActivate += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ using (parent)
+ {
+ child.Visible = true;
+ parent.Show ();
+ Assert.AreEqual (true, eventhandled, "#A7");
+ eventhandled = false;
+ child.Close ();
+ Assert.AreEqual (true, eventhandled, "#A8");
+ }
+ }
+
+ [Test]
+ public void MinimumSizeChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.MinimumSizeChanged += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ myform.MinimumSize = new Size(100, 100);
+ Assert.AreEqual (true, eventhandled, "#A10");
+ myform.Dispose ();
+ }
+ }
+
+ [TestFixture]
+ public class ClosingEvent
+ {
+ bool cancel = true;
+ CancelEventArgs args = null;
+ public void Closing_Handler (object sender, CancelEventArgs e)
+ {
+ e.Cancel = cancel;
+ args = e;
+ }
+
+ [Test, Ignore ("visual test")]
+ public void ClosingEventTest ()
+ {
+ Form myform = new Form ();
+ myform.Closing += new CancelEventHandler (Closing_Handler);
+ myform.Show ();
+ args = null;
+ myform.Close ();
+ Assert.AreEqual (true, args != null, "#A11");
+ Assert.AreEqual (true, myform.Visible, "#A12");
+ cancel = false;
+ args = null;
+ myform.Close ();
+ Assert.AreEqual (true, args != null, "#A13");
+ Assert.AreEqual (false, myform.Visible, "#A14");
+ }
+ }
+
+ [TestFixture,Ignore ("Test Breaks")]
+ public class InputLanguageChangedEvent
+ {
+ static bool eventhandled = false;
+ public void InputLanguage_Handler (object sender,InputLanguageChangedEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void InputLanguageChangedEventTest ()
+ {
+ Form myform = new Form ();
+ CultureInfo oldci = Thread.CurrentThread.CurrentCulture;
+ CultureInfo oldcui = Thread.CurrentThread.CurrentUICulture;
+ InputLanguage oldil = InputLanguage.CurrentInputLanguage;
+ try
+ {
+ if (InputLanguage.InstalledInputLanguages.Count > 1)
+ {
+ InputLanguage.CurrentInputLanguage = InputLanguage.InstalledInputLanguages[0];
+ myform.InputLanguageChanged += new InputLanguageChangedEventHandler (InputLanguage_Handler);
+ Thread.CurrentThread.CurrentCulture = new CultureInfo ("ta-IN");
+ Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
+ InputLanguage.CurrentInputLanguage = InputLanguage.InstalledInputLanguages[1];
+ Assert.AreEqual (true, eventhandled, "#A15");
+ }
+ }
+ finally
+ {
+ Thread.CurrentThread.CurrentCulture = oldci;
+ Thread.CurrentThread.CurrentUICulture = oldcui;
+ InputLanguage.CurrentInputLanguage = oldil;
+ }
+ }
+ }
+
+ [TestFixture,Ignore ("Test Breaks")]
+ public class InputLanguageChangingdEvent
+ {
+ static bool eventhandled = false;
+ public void InputLangChanging_Handler(object sender,InputLanguageChangingEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void InputLanguageChangingEventTest ()
+ {
+ Form myform = new Form ();
+ CultureInfo oldci = Thread.CurrentThread.CurrentCulture;
+ CultureInfo oldcui = Thread.CurrentThread.CurrentUICulture;
+ InputLanguage oldil = InputLanguage.CurrentInputLanguage;
+ try
+ {
+ if (InputLanguage.InstalledInputLanguages.Count > 1)
+ {
+ InputLanguage.CurrentInputLanguage = InputLanguage.InstalledInputLanguages[0];
+ myform.InputLanguageChanging += new InputLanguageChangingEventHandler (InputLangChanging_Handler);
+ Thread.CurrentThread.CurrentCulture = new CultureInfo ("ta-IN");
+ Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
+ InputLanguage.CurrentInputLanguage = InputLanguage.InstalledInputLanguages[1];
+ Assert.AreEqual (true, eventhandled, "#A16");
+ }
+ }
+ finally
+ {
+ Thread.CurrentThread.CurrentCulture = oldci;
+ Thread.CurrentThread.CurrentUICulture = oldcui;
+ InputLanguage.CurrentInputLanguage = oldil;
+ }
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs
new file mode 100644
index 00000000000..c83c72fefd5
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs
@@ -0,0 +1,175 @@
+//
+// FormTest.cs: Test cases for Form.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class FormTest
+ {
+ [Test]
+ public void FormPropertyTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ myform.Text = "NewForm";
+ myform.Name = "FormTest";
+ Assert.AreEqual (null, myform.AcceptButton, "#1");
+ //Assert.AreEqual (null, myform.ActiveMdiChild, "#2");
+ //System.NotImplementedException for ActiveMdiChild. Feature not implemented.
+ Assert.AreEqual (false, myform.AutoScale, "#3");
+ Assert.AreEqual (13, myform.AutoScaleBaseSize.Height, "#4");
+ Assert.AreEqual (5, myform.AutoScaleBaseSize.Width, "#5");
+ Assert.AreEqual (null, myform.CancelButton, "#6");
+ Assert.AreEqual (273, myform.ClientSize.Height, "#7");
+ Assert.AreEqual (292, myform.ClientSize.Width, "#8");
+ Assert.AreEqual (true, myform.ControlBox, "#9");
+ Assert.IsTrue (myform.DesktopBounds.X > 0, "#10a");
+ Assert.IsTrue (myform.DesktopBounds.Y > 0, "#10b");
+ Assert.AreEqual (300, myform.DesktopBounds.Height, "#10c");
+ Assert.AreEqual (300, myform.DesktopBounds.Width, "#10d");
+ Assert.IsTrue (myform.DesktopLocation.X > 0, "#11a");
+ Assert.IsTrue (myform.DesktopLocation.Y > 0, "#11b");
+ Assert.AreEqual (DialogResult.None, myform.DialogResult, "#12");
+ Assert.AreEqual (FormBorderStyle.Sizable, myform.FormBorderStyle, "#13");
+ Assert.AreEqual (false, myform.HelpButton, "#14");
+ Assert.AreEqual ("System.Drawing.Icon", myform.Icon.GetType ().ToString (), "#15");
+ Assert.AreEqual (false, myform.IsMdiChild, "#16");
+ Assert.AreEqual (false, myform.IsMdiContainer, "#17");
+ Assert.AreEqual (false, myform.KeyPreview, "#18");
+ Assert.AreEqual (true, myform.MaximizeBox, "#19");
+ Assert.AreEqual (0, myform.MaximumSize.Height, "#20a");
+ Assert.AreEqual (0, myform.MaximumSize.Width, "#20b");
+ Assert.AreEqual (0, myform.MdiChildren.Length, "#21a");
+ Assert.AreEqual (1, myform.MdiChildren.Rank, "#21b");
+ Assert.AreEqual (false, myform.MdiChildren.IsSynchronized, "#21c");
+ Assert.AreEqual (null, myform.MdiParent, "#22");
+ Assert.AreEqual (null, myform.Menu, "#23");
+ //Assert.AreEqual (null, myform.MergedMenu, "#24");
+ //System.NotImplementedException for MergedMenu. Feature not implemented.
+ Assert.AreEqual (true, myform.MinimizeBox, "#25");
+ Assert.AreEqual (0, myform.MinimumSize.Height, "#26a");
+ Assert.AreEqual (0, myform.MinimumSize.Width, "#26b");
+ Assert.AreEqual (true, myform.MinimumSize.IsEmpty, "#26c");
+ Assert.AreEqual (false, myform.Modal, "#27");
+ //Assert.AreEqual (1, myform.Opacity, "#28");
+ //System.NotImplementedException for Opacity. Feature not implemented.
+ Assert.AreEqual (0, myform.OwnedForms.Length, "#29a");
+ Assert.AreEqual (1, myform.OwnedForms.Rank, "#29b");
+ Assert.AreEqual (null, myform.Owner, "#30");
+ Assert.AreEqual (true, myform.ShowInTaskbar, "#31");
+ Assert.AreEqual (300, myform.Size.Height, "#32a");
+ Assert.AreEqual (300, myform.Size.Width, "#32b");
+ Assert.AreEqual (SizeGripStyle.Auto, myform.SizeGripStyle, "#33");
+ Assert.AreEqual (FormStartPosition.WindowsDefaultLocation, myform.StartPosition, "#34");
+ Assert.AreEqual (true, myform.TopLevel, "#35");
+ Assert.AreEqual (false, myform.TopMost, "#36");
+ Assert.AreEqual (Color.Empty, myform.TransparencyKey, "#37");
+ Assert.AreEqual (FormWindowState.Normal, myform.WindowState, "#38");
+ }
+
+ [Test]
+ public void ActivateTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ myform.Text = "NewForm";
+ myform.Name = "FormTest";
+ myform.Activate ();
+ Assert.AreEqual (true, myform.Focus (), "#40");
+ }
+
+ [Test]
+ public void AddOwnedFormTest ()
+ {
+ Form parent = new Form ();
+ parent.Text = "NewParent";
+ Form ownedForm = new Form ();
+ ownedForm.Text = "Owned Form";
+ parent.AddOwnedForm (ownedForm);
+ ownedForm.Show ();
+ Assert.AreEqual ("NewParent", ownedForm.Owner.Text, "#41");
+ }
+
+ [Test]
+ public void CloseTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ myform.Text = "NewForm";
+ myform.Name = "FormTest";
+ myform.Close ();
+ Assert.IsTrue (myform.Size.Height > 0, "#42");
+ }
+
+ [Test]
+ [Ignore ("System.NotImplementedException. LayoutMdi not implemented")]
+ public void LayoutMdiTest ()
+ {
+ Form parent = new Form ();
+ Form child = new Form ();
+ parent.IsMdiContainer = true;
+ child.IsMdiContainer = false;
+ child.MdiParent = parent;
+ parent.LayoutMdi (MdiLayout.TileHorizontal);
+ child.Visible = true;
+ parent.Show ();
+ }
+
+ [Test]
+ public void RemoveOwnedFormTest ()
+ {
+ Form myform = new Form ();
+ myform.Text = "NewForm";
+ myform.Name = "FormTest";
+ myform.RemoveOwnedForm (myform);
+ myform.Show ();
+ Assert.AreEqual (null, myform.Owner, "#44");
+ }
+
+ [Test]
+ public void SetDesktopBoundsTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ myform.Text = "NewForm";
+ myform.Name = "FormTest";
+ myform.SetDesktopBounds (10, 10, 200 , 200);
+ Assert.AreEqual (200, myform.DesktopBounds.Height, "#45");
+ }
+
+ [Test]
+ public void SetDesktopLocationTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ myform.Text = "NewForm";
+ myform.Name = "FormTest";
+ myform.SetDesktopLocation (10, 10);
+ Assert.AreEqual (10, myform.DesktopLocation.X, "#46");
+ }
+
+ [Test, Ignore ("Needs Manual Intervention")]
+ public void ShowDialogTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = false;
+ myform.Text = "NewForm";
+ myform.Name = "FormTest";
+ myform.ShowDialog ();
+ Assert.AreEqual (DialogResult.Cancel, myform.DialogResult, "#47");
+ myform.Dispose ();
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GenerateControlStyleTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GenerateControlStyleTest.cs
new file mode 100644
index 00000000000..9e030762a49
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GenerateControlStyleTest.cs
@@ -0,0 +1,129 @@
+//
+// This code generates the ControlStylesTest.cs test
+//
+// Author: Peter Dennis Bartok (pbartok@novell.com)
+//
+
+
+using System.Windows.Forms;
+using System.Drawing;
+using System;
+using System.Reflection;
+using System.IO;
+using System.Text;
+
+namespace TestApp {
+ class MainForm {
+ static Array style_values = Enum.GetValues(typeof(ControlStyles));
+ static string[] style_names = Enum.GetNames(typeof(ControlStyles));
+ static string TestHeader = "//\n" +
+ "// ControlStyleTest.cs (Auto-generated by GenerateControlStyleTest.cs).\n" +
+ "//\n" +
+ "// Author: \n" +
+ "// Peter Dennis Bartok (pbartok@novell.com)\n" +
+ "//\n" +
+ "// (C) 2005 Novell, Inc. (http://www.novell.com)\n" +
+ "//\n" +
+ "using System;\n" +
+ "using System.Windows.Forms;\n" +
+ "using System.Drawing;\n" +
+ "using System.Reflection;\n" +
+ "using NUnit.Framework;\n\n" +
+ "namespace MonoTests.System.Windows.Forms {\n" +
+ "\t[TestFixture]\n" +
+ "\tpublic class TestControlStyle {\n\n" +
+ "\t\tstatic Array style_values = Enum.GetValues(typeof(ControlStyles));\n" +
+ "\t\tstatic string[] style_names = Enum.GetNames(typeof(ControlStyles));\n\n" +
+ " public static string[] GetStyles(Control control) {\n" +
+ " string[] result;\n\n" +
+ " result = new string[style_names.Length];\n\n" +
+ " for (int i = 0; i < style_values.Length; i++) {\n" +
+ " result[i] = style_names[i] + \"=\" + control.GetType().GetMethod(\"GetStyle\", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(control, new object[1] {(ControlStyles)style_values.GetValue(i)});\n" +
+ " }\n\n" +
+ " return result;\n" +
+ " }\n";
+ static string TestFooter = "\t}\n}\n";
+
+ public static string[] GetStyles(Control control) {
+ string[] result;
+
+ result = new string[style_names.Length];
+
+ for (int i = 0; i < style_values.Length; i++) {
+ result[i] = style_names[i] + "=" + control.GetType().GetMethod("GetStyle", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(control, new object[1] {(ControlStyles)style_values.GetValue(i)});
+ }
+
+ return result;
+ }
+
+ public static void TestStyles(StreamWriter file, Control control, string name) {
+ string[] results;
+
+ results = GetStyles(control);
+
+ file.WriteLine("\t\t[Test]");
+ file.WriteLine("\t\tpublic void {0}StyleTest ()", name);
+ file.WriteLine("\t\t{");
+
+ file.WriteLine("\t\t\tstring[] {0}_want = {{", name);
+ for (int i=0; i < results.Length; i++) {
+ if ((i+1) != results.Length) {
+ file.WriteLine("\t\t\t\t\"{0}\",", results[i]);
+ } else {
+ file.WriteLine("\t\t\t\t\"{0}\"", results[i]);
+ }
+ }
+ file.WriteLine("\t\t\t};\n");
+ file.WriteLine("\t\t\tAssert.AreEqual({0}_want, GetStyles(new {0}()), \"{0}Styles\");", name);
+ file.WriteLine("\t\t}\n\n");
+ }
+
+ public static void Main(string[] args) {
+ using (StreamWriter file = new StreamWriter("c:\\ControlStyleTest.cs", false, Encoding.ASCII, 1024)) {
+ file.WriteLine(TestHeader);
+ TestStyles(file, new Control(), "Control");
+ TestStyles(file, new Button(), "Button");
+ TestStyles(file, new CheckBox(), "CheckBox");
+ TestStyles(file, new RadioButton(), "RadioButton");
+ TestStyles(file, new DataGrid(), "DataGrid");
+ TestStyles(file, new DateTimePicker(), "DateTimePicker");
+ TestStyles(file, new GroupBox(), "GroupBox");
+ TestStyles(file, new Label(), "Label");
+ TestStyles(file, new LinkLabel(), "LinkLabel");
+ TestStyles(file, new ComboBox(), "ComboBox");
+ TestStyles(file, new ListBox(), "ListBox");
+ TestStyles(file, new CheckedListBox(), "CheckedListBox");
+ TestStyles(file, new ListView(), "ListView");
+ TestStyles(file, new MdiClient(), "MdiClient");
+ TestStyles(file, new MonthCalendar(), "MonthCalendar");
+ TestStyles(file, new PictureBox(), "PictureBox");
+ // Mono doesn't support yet
+ //TestStyles(file, new PrintPreviewControl(), "PrintPreviewControl");
+ TestStyles(file, new ProgressBar(), "ProgressBar");
+ TestStyles(file, new ScrollableControl(), "ScrollableControl");
+ TestStyles(file, new ContainerControl(), "ContainerControl");
+ TestStyles(file, new Form(), "Form");
+ TestStyles(file, new PropertyGrid(), "PropertyGrid");
+ TestStyles(file, new DomainUpDown(), "DomainUpDown");
+ TestStyles(file, new NumericUpDown(), "NumericUpDown");
+ TestStyles(file, new UserControl(), "UserControl");
+ TestStyles(file, new Panel(), "Panel");
+ TestStyles(file, new TabPage(), "TabPage");
+ TestStyles(file, new HScrollBar(), "HScrollBar");
+ TestStyles(file, new VScrollBar(), "VScrollBar");
+ TestStyles(file, new Splitter(), "Splitter");
+ TestStyles(file, new StatusBar(), "StatusBar");
+ TestStyles(file, new TabControl(), "TabControl");
+ TestStyles(file, new RichTextBox(), "RichTextBox");
+ TestStyles(file, new TextBox(), "TextBox");
+ TestStyles(file, new DataGridTextBox(), "DataGridTextBox");
+ TestStyles(file, new ToolBar(), "ToolBar");
+ TestStyles(file, new TrackBar(), "TrackBar");
+ TestStyles(file, new TreeView(), "TreeView");
+ file.WriteLine(TestFooter);
+ }
+ }
+ }
+
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridColumnStylesCollectionTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridColumnStylesCollectionTest.cs
new file mode 100644
index 00000000000..ee12067c62e
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridColumnStylesCollectionTest.cs
@@ -0,0 +1,199 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class GridColumnStylesCollectionTest
+ {
+ private bool eventhandled;
+ private object Element;
+ private CollectionChangeAction Action;
+ private int times;
+
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ GridColumnStylesCollection sc = ts.GridColumnStyles;
+
+ Assert.AreEqual (false, sc.IsSynchronized, "IsSynchronized property");
+ Assert.AreEqual (0, sc.Count, "Count");
+ Assert.AreEqual (sc, sc.SyncRoot, "SyncRoot property");
+ Assert.AreEqual (false, ((IList)sc).IsFixedSize, "IsFixedSize property");
+ Assert.AreEqual (false, sc.IsReadOnly, "IsReadOnly property");
+ }
+
+ [Test]
+ public void TestAdd ()
+ {
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ GridColumnStylesCollection sc = ts.GridColumnStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ ResetEventData ();
+ DataGridTextBoxColumn col1 = new DataGridTextBoxColumn ();
+ col1.MappingName = "Column1";
+ sc.Add (col1);
+ Assert.AreEqual (true, eventhandled);
+ Assert.AreEqual (col1, Element);
+ Assert.AreEqual (CollectionChangeAction.Add, Action);
+
+ // Add multiple
+ ResetEventData ();
+ DataGridTextBoxColumn elem1 = new DataGridTextBoxColumn ();
+ DataGridTextBoxColumn elem2 = new DataGridTextBoxColumn ();
+ sc.AddRange (new DataGridTextBoxColumn [] {elem1, elem2});
+ Assert.AreEqual (true, eventhandled, "A1");
+ Assert.AreEqual (CollectionChangeAction.Add, Action, "A2");
+ Assert.AreEqual (elem2, Element, "A3");
+
+ }
+
+ [Test]
+ public void TestAddRange ()
+ {
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ GridColumnStylesCollection sc = ts.GridColumnStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ ResetEventData ();
+ DataGridTextBoxColumn col1 = new DataGridTextBoxColumn ();
+ col1.MappingName = "Column1";
+
+ DataGridTextBoxColumn col2 = new DataGridTextBoxColumn ();
+ col2.MappingName = "Column2";
+ sc.AddRange (new DataGridColumnStyle[] {col1, col2});
+
+ Assert.AreEqual (true, eventhandled, "A1");
+ Assert.AreEqual (col2, Element, "A2");
+ Assert.AreEqual (CollectionChangeAction.Add, Action, "A3");
+ Assert.AreEqual (2, times, "A4");
+ }
+
+ [Test]
+ public void TestRemove ()
+ {
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ GridColumnStylesCollection sc = ts.GridColumnStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ DataGridTextBoxColumn col1 = new DataGridTextBoxColumn ();
+ col1.MappingName = "Column1";
+ sc.Add (col1);
+
+ DataGridTextBoxColumn col2 = new DataGridTextBoxColumn ();
+ col2.MappingName = "Column2";
+ sc.Add (col2);
+
+ DataGridTextBoxColumn col3 = new DataGridTextBoxColumn ();
+ col3.MappingName = "Column3";
+ sc.Add (col3);
+
+ ResetEventData ();
+ sc.Remove (col2);
+ Assert.AreEqual (true, eventhandled, "A1");
+ Assert.AreEqual (col2, Element, "A2");
+ Assert.AreEqual (CollectionChangeAction.Remove, Action, "A3");
+ Assert.AreEqual (2, sc.Count, "A4");
+
+ ResetEventData ();
+ sc.RemoveAt (0);
+ Assert.AreEqual (true, eventhandled, "A5");
+ Assert.AreEqual (col1, Element, "A6");
+ Assert.AreEqual (CollectionChangeAction.Remove, Action, "A6");
+ Assert.AreEqual (1, sc.Count, "A7");
+
+ ResetEventData ();
+ sc.Clear ();
+ Assert.AreEqual (null, Element, "A8");
+ Assert.AreEqual (CollectionChangeAction.Refresh, Action, "A9");
+
+ }
+
+ [Test]
+ public void TestIndexContains ()
+ {
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ GridColumnStylesCollection sc = ts.GridColumnStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ DataGridTextBoxColumn col1 = new DataGridTextBoxColumn ();
+ col1.MappingName = "Column1";
+ sc.Add (col1);
+
+ DataGridTextBoxColumn col2 = new DataGridTextBoxColumn ();
+ col2.MappingName = "Column2";
+ sc.Add (col2);
+
+ DataGridTextBoxColumn col3 = new DataGridTextBoxColumn ();
+ col3.MappingName = "Column3";
+ sc.Add (col3);
+
+ ResetEventData ();
+ IList ilist = (IList) sc;
+ Assert.AreEqual (1, ilist.IndexOf (col2), "A1");
+ Assert.AreEqual (false, sc.Contains ("nothing"), "A2");
+ Assert.AreEqual (true, sc.Contains (col3), "A3");
+ }
+
+ private void ResetEventData ()
+ {
+ times = 0;
+ eventhandled = false;
+ Element = null;
+ Action = (CollectionChangeAction) 0;
+ }
+
+ private void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ private void OnCollectionEventHandler (object sender, CollectionChangeEventArgs e)
+ {
+ eventhandled = true;
+ Element = e.Element;
+ Action = e.Action;
+ times++;
+ }
+
+
+ }
+
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridTableStylesCollectionTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridTableStylesCollectionTest.cs
new file mode 100644
index 00000000000..708f284587b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridTableStylesCollectionTest.cs
@@ -0,0 +1,193 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class GridTableStylesCollectionTest
+ {
+ private bool eventhandled;
+ private object Element;
+ private CollectionChangeAction Action;
+ private int times;
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGrid grid = new DataGrid ();
+ GridTableStylesCollection sc = grid.TableStyles;
+
+ Assert.AreEqual (false, sc.IsSynchronized, "IsSynchronized property");
+ Assert.AreEqual (0, sc.Count, "Count");
+ Assert.AreEqual (sc, sc.SyncRoot, "SyncRoot property");
+ Assert.AreEqual (false, ((IList)sc).IsFixedSize, "IsFixedSize property");
+ Assert.AreEqual (false, sc.IsReadOnly, "IsReadOnly property");
+ }
+
+ [Test]
+ public void TestAdd ()
+ {
+ DataGrid grid = new DataGrid ();
+ GridTableStylesCollection sc = grid.TableStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ ResetEventData ();
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ ts.MappingName = "Table1";
+ sc.Add (ts);
+ Assert.AreEqual (true, eventhandled, "A1");
+ Assert.AreEqual (ts, Element, "A2");
+ Assert.AreEqual (CollectionChangeAction.Add, Action, "A3");
+
+ // Add multiple
+ ResetEventData ();
+ sc.AddRange (new DataGridTableStyle [] {new DataGridTableStyle (), new DataGridTableStyle ()});
+ Assert.AreEqual (true, eventhandled, "A4");
+ Assert.AreEqual (null, Element, "A5");
+ Assert.AreEqual (CollectionChangeAction.Refresh, Action, "A6");
+ }
+
+ [Test]
+ public void TestAddRange ()
+ {
+ DataGrid grid = new DataGrid ();
+ GridTableStylesCollection sc = grid.TableStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ ResetEventData ();
+ DataGridTableStyle ts1 = new DataGridTableStyle ();
+ ts1.MappingName = "Table1";
+
+ DataGridTableStyle ts2 = new DataGridTableStyle ();
+ ts2.MappingName = "Table2";
+ sc.AddRange (new DataGridTableStyle[] {ts1, ts2});
+
+ Assert.AreEqual (true, eventhandled, "A1");
+ Assert.AreEqual (null, Element, "A2");
+ Assert.AreEqual (CollectionChangeAction.Refresh, Action, "A3");
+ Assert.AreEqual (1, times, "A4");
+ }
+
+ [Test]
+ public void TestRemove ()
+ {
+ DataGrid grid = new DataGrid ();
+ GridTableStylesCollection sc = grid.TableStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ DataGridTableStyle ts1 = new DataGridTableStyle ();
+ ts1.MappingName = "Table1";
+ sc.Add (ts1);
+
+ DataGridTableStyle ts2 = new DataGridTableStyle ();
+ ts2.MappingName = "Table2";
+ sc.Add (ts2);
+
+ DataGridTableStyle ts3 = new DataGridTableStyle ();
+ ts3.MappingName = "Table3";
+ sc.Add (ts3);
+
+ ResetEventData ();
+ sc.Remove (ts2);
+ Assert.AreEqual (true, eventhandled, "A1");
+ Assert.AreEqual (ts2, Element, "A2");
+ Assert.AreEqual (CollectionChangeAction.Remove, Action, "A3");
+ Assert.AreEqual (2, sc.Count, "A4");
+
+ ResetEventData ();
+ sc.RemoveAt (0);
+ Assert.AreEqual (true, eventhandled, "A5");
+ Assert.AreEqual (ts1, Element, "A6");
+ Assert.AreEqual (CollectionChangeAction.Remove, Action, "A7");
+ Assert.AreEqual (1, sc.Count, "A8");
+
+ ResetEventData ();
+ sc.Clear ();
+ Assert.AreEqual (null, Element, "A9");
+ Assert.AreEqual (CollectionChangeAction.Refresh, Action, "A10");
+
+ }
+
+ [Test]
+ public void TestIndexContains ()
+ {
+ DataGrid grid = new DataGrid ();
+ GridTableStylesCollection sc = grid.TableStyles;
+ sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ DataGridTableStyle ts1 = new DataGridTableStyle ();
+ ts1.MappingName = "Table1";
+ sc.Add (ts1);
+
+ DataGridTableStyle ts2 = new DataGridTableStyle ();
+ ts2.MappingName = "Table2";
+ sc.Add (ts2);
+
+ DataGridTableStyle ts3 = new DataGridTableStyle ();
+ ts3.MappingName = "Table3";
+ sc.Add (ts3);
+
+ ResetEventData ();
+ IList ilist = (IList) sc;
+ Assert.AreEqual (1, ilist.IndexOf (ts2), "A1");
+ Assert.AreEqual (false, sc.Contains ("nothing"), "A2");
+ Assert.AreEqual (true, sc.Contains (ts3), "A3");
+ }
+
+ private void ResetEventData ()
+ {
+ times = 0;
+ eventhandled = false;
+ Element = null;
+ Action = (CollectionChangeAction) 0;
+ }
+
+ private void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ private void OnCollectionEventHandler (object sender, CollectionChangeEventArgs e)
+ {
+ times++;
+ eventhandled = true;
+ Element = e.Element;
+ Action = e.Action;
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GroupBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GroupBoxTest.cs
new file mode 100644
index 00000000000..9d9ed081e09
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GroupBoxTest.cs
@@ -0,0 +1,40 @@
+//
+// GroupBoxTest.cs: Test cases for GroupBox.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class GroupBoxTest
+ {
+ [Test]
+ public void GroupBoxPropertyTest ()
+ {
+ Form myform = new Form ();
+ GroupBox mygrpbox = new GroupBox ();
+ RadioButton myradiobutton1 = new RadioButton ();
+ RadioButton myradiobutton2 = new RadioButton ();
+ mygrpbox.Controls.Add (myradiobutton1);
+ mygrpbox.Controls.Add (myradiobutton2);
+ myform.Show ();
+ Assert.AreEqual (FlatStyle.Standard, mygrpbox.FlatStyle, "#1");
+ mygrpbox.FlatStyle = FlatStyle.Popup;
+ Assert.AreEqual (FlatStyle.Popup, mygrpbox.FlatStyle, "#2");
+ mygrpbox.FlatStyle = FlatStyle.Flat;
+ Assert.AreEqual (FlatStyle.Flat, mygrpbox.FlatStyle, "#3");
+ mygrpbox.FlatStyle = FlatStyle.System;
+ Assert.AreEqual (FlatStyle.System, mygrpbox.FlatStyle, "#4");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageListTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageListTest.cs
new file mode 100644
index 00000000000..f2cf0200890
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageListTest.cs
@@ -0,0 +1,94 @@
+//
+// ImageImageListTest.cs: Test cases for ImageImageList.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (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]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ImageListTest
+ {
+ [Test]
+ public void ImageListPropertyTest ()
+ {
+ ImageList myimagelist = new ImageList ();
+
+ // C
+ Assert.AreEqual (ColorDepth.Depth8Bit, myimagelist.ColorDepth, "#C1");
+ myimagelist.ColorDepth = ColorDepth.Depth32Bit;
+ Assert.AreEqual (ColorDepth.Depth32Bit, myimagelist.ColorDepth, "#C2");
+ Assert.AreEqual (0, myimagelist.Images.Count, "#C3");
+ // H
+ Assert.AreEqual (false, myimagelist.HandleCreated, "#H1");
+ myimagelist.Handle.ToInt32 ();
+ Assert.AreEqual (true, myimagelist.HandleCreated, "#H2");
+ Assert.AreEqual ("System.IntPtr", myimagelist.Handle.GetType ().FullName, "#H3");
+
+ // I
+ Image myImage = Image.FromFile("M.gif");
+ myimagelist.Images.Add (myImage);
+ Assert.AreEqual (1, myimagelist.Images.Count, "#I1");
+ Assert.AreEqual (16, myimagelist.ImageSize.Height, "#I2");
+ Assert.AreEqual (16, myimagelist.ImageSize.Width, "#I3");
+ // [MonoTODO ("Add test for ImageStream")]
+ // [MonoTODO ("Test for Draw Method (visual test)")]
+
+ // T
+ Assert.AreEqual (Color.Transparent, myimagelist.TransparentColor, "#T1");
+ }
+
+ [Test]
+ public void ToStringMethodTest ()
+ {
+ ImageList myimagelist = new ImageList ();
+ Assert.AreEqual ("System.Windows.Forms.ImageList Images.Count: 0, ImageSize: {Width=16, Height=16}", myimagelist.ToString (), "#T3");
+ }
+
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ImageListRecreateHandleEventClass
+ {
+ static bool eventhandled = false;
+ public static void RecreateHandle_EventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void RecreateHandleEvenTest ()
+ {
+ Form myform = new Form ();
+ Graphics mygraphics = null;
+ ImageList myimagelist = new ImageList ();
+ Image myImage = Image.FromFile("M.gif");
+ myimagelist.Images.Add (myImage);
+ myimagelist.ColorDepth = ColorDepth.Depth8Bit;
+ myimagelist.ImageSize = new Size (50,50);
+ myimagelist.RecreateHandle += new EventHandler (RecreateHandle_EventHandler);
+ mygraphics = Graphics.FromHwnd(myform.Handle);
+ myimagelist.Draw(mygraphics, new Point(5, 5), 0);
+ myimagelist.ImageSize = new Size (100,100);
+ Assert.AreEqual (true, eventhandled, "#1");
+ eventhandled = false;
+ myimagelist.Images.Add (myImage);
+ myimagelist.ColorDepth = ColorDepth.Depth32Bit;
+ Assert.AreEqual (true, eventhandled, "#2");
+ }
+
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelPropertyTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelPropertyTest.cs
new file mode 100644
index 00000000000..6b284f50240
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelPropertyTest.cs
@@ -0,0 +1,138 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// $Log: LabelPropertyTest.cs,v $
+// Adding tests for Label
+//
+
+
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Runtime.Remoting;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class LabelTest {
+
+ [Test]
+ public void PubPropTest ()
+ {
+ Label l = new Label ();
+
+ Assert.AreEqual (false, l.AllowDrop , "#1");
+ Assert.AreEqual (false, l.AccessibilityObject == null, "#2");
+ Assert.AreEqual (false , l.AutoSize , "#3");
+ Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, l.Anchor, "#4");
+ Assert.AreEqual (false, l.AutoSize, "#5");
+
+ Assert.AreEqual ("Control", l.BackColor.Name , "#6");
+ Assert.AreEqual (null, l.BindingContext, "#7");
+ Assert.AreEqual (null, l.BackgroundImage, "#8");
+ Assert.AreEqual (BorderStyle.None , l.BorderStyle, "#9");
+ Assert.AreEqual (23, l.Bottom, "#10");
+ Assert.AreEqual (new Rectangle (0,0,100,23), l.Bounds, "#11");
+
+ Assert.AreEqual (false, l.CanFocus, "#12");
+ Assert.AreEqual (false, l.CanSelect, "#13");
+ Assert.AreEqual (false, l.Capture, "#14");
+ Assert.AreEqual (true, l.CausesValidation, "#15");
+ Assert.AreEqual (new Rectangle (0,0,100,23), l.ClientRectangle, "#16");
+ Assert.AreEqual (23, l.ClientSize.Height, "#17a");
+ Assert.AreEqual (100, l.ClientSize.Width, "#17b");
+ Assert.AreEqual ("Mono Project, Novell, Inc.", l.CompanyName, "#18");
+ Assert.AreEqual (null, l.Container, "#19");
+ Assert.AreEqual (false, l.ContainsFocus, "#20");
+ Assert.AreEqual (null, l.ContextMenu, "#21");
+ Assert.AreEqual (true, l.Created, "#23");
+ Assert.AreEqual (Cursors.Default , l.Cursor, "#24");
+
+ Assert.AreEqual (false, l.DataBindings == null , "#25");
+ Assert.AreEqual (false, l.Disposing , "#27");
+ Assert.AreEqual (DockStyle.None, l.Dock, "#28");
+
+ Assert.AreEqual (true, l.Enabled, "#29");
+
+ Assert.AreEqual (FlatStyle.Standard, l.FlatStyle, "#30");
+ Assert.AreEqual (false, l.Focused, "#31");
+ Assert.AreEqual (FontFamily.GenericSansSerif, l.Font.FontFamily, "#32");
+ Assert.AreEqual (SystemColors.ControlText, l.ForeColor, "#33");
+
+ Assert.AreEqual (((IWin32Window)l).Handle, l.Handle, "#34");
+ Assert.AreEqual (false, l.HasChildren, "#35");
+ Assert.AreEqual (23, l.Height, "#36");
+
+ Assert.AreEqual (null, l.Image, "#37");
+ Assert.AreEqual (ContentAlignment.MiddleCenter, l.ImageAlign, "#38");
+ Assert.AreEqual (-1, l.ImageIndex, "#39");
+ Assert.AreEqual (null, l.ImageList, "#40");
+ Assert.AreEqual (false, l.InvokeRequired, "#42");
+ Assert.AreEqual (false, l.IsAccessible, "#43");
+ Assert.AreEqual (false, l.IsDisposed, "#44");
+ Assert.AreEqual (true, l.IsHandleCreated, "#45");
+
+ Assert.AreEqual (0, l.Left, "#46");
+ Assert.AreEqual (Point.Empty, l.Location, "#47");
+
+ Assert.AreEqual ("", l.Name, "#48a");
+ l.Name = "New Label";
+ Assert.AreEqual ("New Label", l.Name, "#48b");
+
+ Assert.AreEqual (null, l.Parent, "#49");
+ Assert.AreEqual (16, l.PreferredHeight, "#50");
+ Assert.AreEqual (0, l.PreferredWidth, "#51");
+ Assert.AreEqual ("Novell Mono MWF", l.ProductName, "#52");
+ Assert.AreEqual ("1.1.4322.2032", l.ProductVersion, "#53");
+
+ Assert.AreEqual (false, l.RecreatingHandle, "#54");
+ Assert.AreEqual (null, l.Region, "#55");
+ Assert.AreEqual (100, l.Right, "#56");
+ Assert.AreEqual (RightToLeft.No, l.RightToLeft, "#57");
+
+ Assert.AreEqual (null, l.Site, "#58");
+ Assert.AreEqual (23, l.Size.Height, "#59a");
+ Assert.AreEqual (100, l.Size.Width, "#59b");
+
+ Assert.AreEqual (0, l.TabIndex, "#60");
+ Assert.AreEqual (null, l.Tag, "#61");
+ Assert.AreEqual ("", l.Text, "#62");
+ Assert.AreEqual (ContentAlignment.TopLeft, l.TextAlign, "#63");
+ Assert.AreEqual (0, l.Top, "#64");
+ Assert.AreEqual (null, l.TopLevelControl, "#65");
+
+ Assert.AreEqual (true, l.UseMnemonic, "#66");
+
+ Assert.AreEqual (true, l.Visible, "#67");
+
+ Assert.AreEqual (100, l.Width, "#68");
+ }
+
+ [Test]
+ public void LabelEqualsTest () {
+ Label s1 = new Label ();
+ Label s2 = new Label ();
+ s1.Text = "abc";
+ s2.Text = "abc";
+ Assert.AreEqual (false, s1.Equals (s2), "#69");
+ Assert.AreEqual (true, s1.Equals (s1), "#70");
+ }
+
+ [Test]
+ public void LabelScaleTest () {
+ Label r1 = new Label ();
+ r1.Width = 40;
+ r1.Height = 20 ;
+ r1.Scale (2);
+ Assert.AreEqual (80, r1.Width, "#71");
+ Assert.AreEqual (40, r1.Height, "#72");
+
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelTest.cs
new file mode 100644
index 00000000000..236ee26e3b0
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/LabelTest.cs
@@ -0,0 +1,970 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+
+ public class LabelTest2
+ {
+
+ [Test]
+ public void PubPropTest ()
+ {
+ Label l = new Label ();
+
+ // A
+ Assert.AreEqual (false, l.AutoSize, "A1");
+ l.AutoSize = true;
+ Assert.AreEqual (true, l.AutoSize, "A2");
+ l.AutoSize = false;
+ Assert.AreEqual (false, l.AutoSize, "A3");
+
+ // B
+ Assert.AreEqual (null, l.BackgroundImage, "B1");
+ l.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+ Assert.IsNotNull (l.BackgroundImage, "B2");
+ Bitmap bmp = (Bitmap)l.BackgroundImage;
+ Assert.IsNotNull (bmp.GetPixel (0, 0), "B3");
+
+ Assert.AreEqual (BorderStyle.None, l.BorderStyle, "B4");
+ l.BorderStyle = BorderStyle.FixedSingle;
+ Assert.AreEqual (BorderStyle.FixedSingle, l.BorderStyle, "B5");
+ l.BorderStyle = BorderStyle.Fixed3D;
+ Assert.AreEqual (BorderStyle.Fixed3D, l.BorderStyle, "B6");
+ l.BorderStyle = BorderStyle.None;
+ Assert.AreEqual (BorderStyle.None, l.BorderStyle, "B7");
+
+ // C
+ string name = l.CompanyName;
+ if (!name.Equals("Mono Project, Novell, Inc.") && !name.Equals("Microsoft Corporation")) {
+ Assert.Fail("CompanyName property does not match any accepted value - C1");
+ }
+
+ // F
+ Assert.AreEqual (FlatStyle.Standard, l.FlatStyle, "F1");
+ l.FlatStyle = FlatStyle.Flat;
+ Assert.AreEqual (FlatStyle.Flat, l.FlatStyle, "F1");
+ l.FlatStyle = FlatStyle.Popup;
+ Assert.AreEqual (FlatStyle.Popup, l.FlatStyle, "F2");
+ l.FlatStyle = FlatStyle.Standard;
+ Assert.AreEqual (FlatStyle.Standard, l.FlatStyle, "F3");
+ l.FlatStyle = FlatStyle.System;
+ Assert.AreEqual (FlatStyle.System, l.FlatStyle, "F4");
+
+ // I
+ Assert.AreEqual (ContentAlignment.MiddleCenter, l.ImageAlign, "I1");
+ l.ImageAlign = ContentAlignment.TopLeft;
+ Assert.AreEqual (ContentAlignment.TopLeft, l.ImageAlign, "I2");
+ l.ImageAlign = ContentAlignment.TopCenter;
+ Assert.AreEqual (ContentAlignment.TopCenter, l.ImageAlign, "I3");
+ l.ImageAlign = ContentAlignment.TopRight;
+ Assert.AreEqual (ContentAlignment.TopRight, l.ImageAlign, "I4");
+ l.ImageAlign = ContentAlignment.MiddleLeft;
+ Assert.AreEqual (ContentAlignment.MiddleLeft, l.ImageAlign, "I5");
+ l.ImageAlign = ContentAlignment.MiddleCenter;
+ Assert.AreEqual (ContentAlignment.MiddleCenter, l.ImageAlign, "I6");
+ l.ImageAlign = ContentAlignment.MiddleRight;
+ Assert.AreEqual (ContentAlignment.MiddleRight, l.ImageAlign, "I7");
+ l.ImageAlign = ContentAlignment.BottomLeft;
+ Assert.AreEqual (ContentAlignment.BottomLeft, l.ImageAlign, "I8");
+ l.ImageAlign = ContentAlignment.BottomCenter;
+ Assert.AreEqual (ContentAlignment.BottomCenter, l.ImageAlign, "I9");
+ l.ImageAlign = ContentAlignment.BottomRight;
+ Assert.AreEqual (ContentAlignment.BottomRight, l.ImageAlign, "I10");
+ Assert.AreEqual (-1, l.ImageIndex, "I11");
+ Assert.AreEqual (null, l.ImageList, "I12");
+ Assert.AreEqual (null, l.Image, "I13");
+ l.Image = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+ Assert.IsNotNull (l.Image, "I14");
+ bmp = (Bitmap)l.Image;
+ Assert.IsNotNull (bmp.GetPixel (0, 0), "I15");
+
+ ImageList il = new ImageList ();
+ il.ColorDepth = ColorDepth.Depth32Bit;
+ il.ImageSize = new Size (15, 15);
+ il.Images.Add (Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png"));
+ l.ImageList = il;
+ l.ImageIndex = 0;
+
+ Assert.AreEqual (0, l.ImageIndex, "I16");
+ Assert.IsNotNull (l.ImageList, "I17");
+
+ // PreferredHeight
+ // PregerredWidth
+ // RenderTransparent
+ //
+ // T
+ // Assert.AreEqual (false, l.TabStop, "T1");
+ Assert.AreEqual (ContentAlignment.TopLeft, l.TextAlign, "T2");
+
+ // U
+ Assert.AreEqual (true, l.UseMnemonic, "U1");
+ l.UseMnemonic = false;
+ Assert.AreEqual (false, l.UseMnemonic, "U2");
+ }
+
+ [Test]
+ public void LabelEqualsTest ()
+ {
+ Label s1 = new Label ();
+ Label s2 = new Label ();
+ s1.Text = "abc";
+ s2.Text = "abc";
+ Assert.AreEqual (false, s1.Equals (s2), "E1");
+ Assert.AreEqual (true, s1.Equals (s1), "E2");
+ }
+
+ [Test]
+ public void LabelScaleTest ()
+ {
+ Label r1 = new Label ();
+ r1.Width = 40;
+ r1.Height = 20 ;
+ r1.Scale (2);
+ Assert.AreEqual (80, r1.Width, "W1");
+ Assert.AreEqual (40, r1.Height, "H1");
+ }
+
+ [Test]
+ public void PubMethodTest ()
+ {
+ Label l = new Label ();
+
+ l.Text = "My Label";
+
+ Assert.AreEqual ("System.Windows.Forms.Label, Text: My Label", l.ToString (), "T1");
+
+ }
+ }
+
+ [TestFixture]
+ public class LabelEventTest
+ {
+ static bool eventhandled = false;
+ public void Label_EventHandler (object sender,EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ public void Label_KeyDownEventHandler (object sender, KeyEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void AutoSizeChangedChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ Label l = new Label ();
+ l.Visible = true;
+ myform.Controls.Add (l);
+ l.AutoSizeChanged += new EventHandler (Label_EventHandler);
+ l.AutoSize = true;
+ Assert.AreEqual (true, eventhandled, "B4");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void BackgroundImageChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ Label l = new Label ();
+ l.Visible = true;
+ myform.Controls.Add (l);
+ l.BackgroundImageChanged += new EventHandler (Label_EventHandler);
+ l.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+ Assert.AreEqual (true, eventhandled, "B4");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void ImeModeChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ Label l = new Label ();
+ l.Visible = true;
+ myform.Controls.Add (l);
+ l.ImeModeChanged += new EventHandler (Label_EventHandler);
+ l.ImeMode = ImeMode.Katakana;
+ Assert.AreEqual (true, eventhandled, "I16");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void KeyDownTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ l.Visible = true;
+ myform.Controls.Add (l);
+ l.KeyDown += new KeyEventHandler (Label_KeyDownEventHandler);
+ l.KeyPressA ();
+
+ Assert.AreEqual (true, eventhandled, "K1");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void TabStopChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ Label l = new Label ();
+ l.Visible = true;
+ myform.Controls.Add (l);
+ l.TabStopChanged += new EventHandler (Label_EventHandler);
+ l.TabStop = true;
+ Assert.AreEqual (true, eventhandled, "T3");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void TextAlignChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ Label l = new Label ();
+ l.Visible = true;
+ myform.Controls.Add (l);
+ l.TextAlignChanged += new EventHandler (Label_EventHandler);
+ l.TextAlign = ContentAlignment.TopRight;
+ Assert.AreEqual (true, eventhandled, "T4");
+ eventhandled = false;
+ }
+ }
+
+public class MyLabelInvalidate : MyLabel
+ {
+ //protected ArrayList results = new ArrayList ();
+ public MyLabelInvalidate () : base ()
+ {}
+
+ protected override void OnInvalidated (InvalidateEventArgs e)
+ {
+ base.OnInvalidated (e);
+ string res = (string)results [results.Count - 1];
+ results [results.Count - 1 ] = string.Concat (res, "," + e.InvalidRect.ToString ());
+ //results.Add ("OnInvalidate," + e.InvalidRect.ToString ());
+ }
+
+ //public ArrayList Results {
+ // get { return results; }
+ //}
+
+ }
+
+public class MyLabel : Label
+ {
+ protected ArrayList results = new ArrayList ();
+ public MyLabel () : base ()
+ { }
+
+ protected override void OnAutoSizeChanged (EventArgs e)
+ {
+ results.Add ("OnAutoSizeChanged");
+ base.OnAutoSizeChanged (e);
+ }
+
+ protected override void OnBackgroundImageChanged (EventArgs e)
+ {
+ results.Add ("OnBackgroundImageChanged");
+ base.OnBackgroundImageChanged (e);
+ }
+
+ protected override void OnImeModeChanged (EventArgs e)
+ {
+ results.Add ("OnImeModeChanged");
+ base.OnImeModeChanged (e);
+ }
+
+ protected override void OnKeyDown (KeyEventArgs e)
+ {
+ results.Add ("OnKeyDown,"+(char)e.KeyValue);
+ base.OnKeyDown (e);
+ }
+
+ protected override void OnKeyPress (KeyPressEventArgs e)
+ {
+ results.Add ("OnKeyPress,"+e.KeyChar.ToString ());
+ base.OnKeyPress (e);
+ }
+
+ protected override void OnKeyUp (KeyEventArgs e)
+ {
+ results.Add ("OnKeyUp,"+(char)e.KeyValue);
+ base.OnKeyUp (e);
+ }
+
+ protected override void OnHandleCreated (EventArgs e)
+ {
+ results.Add ("OnHandleCreated");
+ base.OnHandleCreated (e);
+ }
+
+ protected override void OnBindingContextChanged (EventArgs e)
+ {
+ results.Add ("OnBindingContextChanged");
+ base.OnBindingContextChanged (e);
+ }
+
+ protected override void OnInvalidated (InvalidateEventArgs e)
+ {
+ results.Add("OnInvalidated");
+ base.OnInvalidated (e);
+ }
+
+ protected override void OnResize (EventArgs e)
+ {
+ results.Add("OnResize");
+ base.OnResize (e);
+ }
+
+ protected override void OnSizeChanged (EventArgs e)
+ {
+ results.Add("OnSizeChanged");
+ base.OnSizeChanged (e);
+ }
+
+ protected override void OnLayout (LayoutEventArgs e)
+ {
+ results.Add("OnLayout");
+ base.OnLayout (e);
+ }
+
+ protected override void OnVisibleChanged (EventArgs e)
+ {
+ results.Add("OnVisibleChanged");
+ base.OnVisibleChanged (e);
+ }
+
+ protected override void OnPaint (PaintEventArgs e)
+ {
+ results.Add("OnPaint");
+ base.OnPaint (e);
+ }
+
+ public void KeyPressA()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_KEYDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_CHAR;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x61;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_KEYUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)unchecked((int)0xC01e0001);
+ this.WndProc(ref m);
+ }
+
+ public void KeyDownA()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_KEYDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_CHAR;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x61;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+ }
+
+ public void KeyUpA()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_KEYUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)unchecked((int)0xC01e0001);
+ this.WndProc(ref m);
+ }
+
+ public ArrayList Results {
+ get { return results; }
+ }
+ }
+
+ [TestFixture]
+ public class LabelTestEventsOrder
+ {
+ public string [] ArrayListToString (ArrayList arrlist)
+ {
+ string [] retval = new string [arrlist.Count];
+ for (int i = 0; i < arrlist.Count; i++)
+ retval[i] = (string)arrlist[i];
+ return retval;
+ }
+
+ [Test]
+ public void CreateEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void SizeChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnSizeChanged",
+ "OnResize",
+ "OnInvalidated",
+ "OnLayout"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.Size = new Size (150, 20);
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void AutoSizeChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnSizeChanged",
+ "OnResize",
+ "OnInvalidated",
+ "OnLayout",
+ "OnAutoSizeChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.AutoSize = true;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void BackgroundImageChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnBackgroundImageChanged",
+ "OnInvalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void ImeModeChangedChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnImeModeChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.ImeMode = ImeMode.Katakana;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void KeyPressEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnKeyDown,A",
+ "OnKeyPress,a",
+ "OnKeyUp,A"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.KeyPressA ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void TabStopChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.TabStop = true;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void TextAlignChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnInvalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.TextAlign = ContentAlignment.TopRight;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void InvalidateEventsOrder ()
+ {
+ Rectangle rect = new Rectangle (new Point (0,0), new Size (2, 2));
+
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabelInvalidate l = new MyLabelInvalidate ();
+ myform.Controls.Add (l);
+ l.TextAlign = ContentAlignment.TopRight;
+
+ string [] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnInvalidated,{X=0,Y=0,Width="+l.Size.Width+",Height="+l.Size.Height+"}",
+ "OnInvalidated," + rect.ToString ()
+ };
+
+ l.Invalidate (rect);
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+
+ }
+
+ [Test]
+ public void PaintEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnInvalidated",
+ "OnInvalidated",
+ "OnPaint"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel l = new MyLabel ();
+ myform.Controls.Add (l);
+ l.TextAlign = ContentAlignment.TopRight;
+ l.Refresh ();
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ }
+
+public class MyLabel2 : Label
+ {
+ protected ArrayList results = new ArrayList ();
+ public MyLabel2 () : base ()
+ {
+ this.AutoSizeChanged += new EventHandler (AutoSizeChanged_Handler);
+ this.HandleCreated += new EventHandler (HandleCreated_Handler);
+ this.BindingContextChanged += new EventHandler (BindingContextChanged_Handler);
+ this.BackgroundImageChanged += new EventHandler (BackgroundImageChanged_Handler);
+ this.ImeModeChanged += new EventHandler (ImeModeChanged_Handler);
+ this.KeyDown += new KeyEventHandler (KeyDown_Handler);
+ this.KeyPress += new KeyPressEventHandler (KeyPress_Handler);
+ this.KeyUp += new KeyEventHandler (KeyUp_Handler);
+ this.Invalidated += new InvalidateEventHandler (Invalidated_Handler);
+ this.Resize += new EventHandler (Resize_Handler);
+ this.SizeChanged += new EventHandler (SizeChanged_Handler);
+ this.Layout += new LayoutEventHandler (Layout_Handler);
+ this.VisibleChanged += new EventHandler (VisibleChanged_Handler);
+ this.Paint += new PaintEventHandler (Paint_Handler);
+ }
+
+ protected void AutoSizeChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("AutoSizeChanged");
+ }
+
+ protected void BackgroundImageChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("BackgroundImageChanged");
+ }
+
+ protected void ImeModeChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("ImeModeChanged");
+ }
+
+ protected void KeyDown_Handler (object sender, KeyEventArgs e)
+ {
+ results.Add ("KeyDown,"+(char)e.KeyValue);
+ }
+
+ protected void KeyPress_Handler (object sender, KeyPressEventArgs e)
+ {
+ results.Add ("KeyPress,"+e.KeyChar.ToString ());
+ }
+
+ protected void KeyUp_Handler (object sender, KeyEventArgs e)
+ {
+ results.Add ("KeyUp,"+(char)e.KeyValue);
+ }
+
+ protected void HandleCreated_Handler (object sender, EventArgs e)
+ {
+ results.Add ("HandleCreated");
+ }
+
+ protected void BindingContextChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("BindingContextChanged");
+ }
+
+ protected void Invalidated_Handler (object sender, InvalidateEventArgs e)
+ {
+ results.Add("Invalidated");
+ }
+
+ protected void Resize_Handler (object sender, EventArgs e)
+ {
+ results.Add("Resize");
+ }
+
+ protected void SizeChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add("SizeChanged");
+ }
+
+ protected void Layout_Handler (object sender, LayoutEventArgs e)
+ {
+ results.Add("Layout");
+ }
+
+ protected void VisibleChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add("VisibleChanged");
+ }
+
+ protected void Paint_Handler (object sender, PaintEventArgs e)
+ {
+ results.Add("Paint");
+ }
+
+ public void KeyPressA()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_KEYDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_CHAR;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x61;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_KEYUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)unchecked((int)0xC01e0001);
+ this.WndProc(ref m);
+ }
+
+ public void KeyDownA()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_KEYDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_CHAR;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x61;
+ m.LParam = (IntPtr)0x1e0001;
+ this.WndProc(ref m);
+ }
+
+ public void KeyUpA()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_KEYUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x41;
+ m.LParam = (IntPtr)unchecked((int)0xC01e0001);
+ this.WndProc(ref m);
+ }
+
+ public ArrayList Results {
+ get { return results; }
+ }
+ }
+
+ [TestFixture]
+ public class LabelTestEventsOrder2
+ {
+ public string [] ArrayListToString (ArrayList arrlist)
+ {
+ string [] retval = new string [arrlist.Count];
+ for (int i = 0; i < arrlist.Count; i++)
+ retval[i] = (string)arrlist[i];
+ return retval;
+ }
+
+ [Test]
+ public void CreateEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void SizeChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated",
+ "Layout",
+ "Resize",
+ "SizeChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.Size = new Size (150, 20);
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void AutoSizeChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated",
+ "Layout",
+ "Resize",
+ "SizeChanged",
+ "AutoSizeChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.AutoSize = true;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void BackgroundImageChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated",
+ "BackgroundImageChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void ImeModeChangedChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "ImeModeChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.ImeMode = ImeMode.Katakana;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void KeyPressEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "KeyDown,A",
+ "KeyPress,a",
+ "KeyUp,A"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.KeyPressA ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void TabStopChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.TabStop = true;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void TextAlignChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.TextAlign = ContentAlignment.TopRight;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ [Test]
+ public void PaintEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated",
+ "Invalidated",
+ "Paint"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyLabel2 l = new MyLabel2 ();
+ myform.Controls.Add (l);
+ l.TextAlign = ContentAlignment.TopRight;
+ l.Refresh ();
+ Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+ }
+
+ }
+
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxEventTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxEventTest.cs
new file mode 100644
index 00000000000..65d35511832
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxEventTest.cs
@@ -0,0 +1,65 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ListBoxDrawItemEvent
+ {
+ static bool eventhandled = false;
+ public void DrawItem_EventHandler (object sender,DrawItemEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void DrawItemTest ()
+ {
+ Form myform = new Form ();
+ ListBox lb1 = new ListBox ();
+ lb1.Items.Add ("A");
+ // Test DrawItem Event
+ lb1.DrawItem += new DrawItemEventHandler (DrawItem_EventHandler);
+ lb1.DrawMode = DrawMode.OwnerDrawFixed;
+ myform.Controls.Add (lb1);
+ myform.Show ();
+ Assert.AreEqual (true, eventhandled, "#A1");
+ }
+
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ListBoxMeasureItemEvent
+ {
+ static bool eventhandled = false;
+ public void MeasureItem_EventHandler (object sender,MeasureItemEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void MeasureItemTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ListBox lb1 = new ListBox ();
+ lb1.Items.Add ("B");
+ lb1.Visible = true;
+ myform.Controls.Add (lb1);
+ // Test MeasureItem Event
+ lb1.MeasureItem += new MeasureItemEventHandler (MeasureItem_EventHandler);
+ lb1.DrawMode = DrawMode.OwnerDrawVariable;
+ Assert.AreEqual (true, eventhandled, "#A2");
+ }
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxTest.cs
new file mode 100644
index 00000000000..d946b7a38fb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxTest.cs
@@ -0,0 +1,351 @@
+//
+// ComboBoxTest.cs: Test cases for ComboBox.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Ritvik Mayank <mritvik@novell.com>
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+using System.Collections;
+using System.ComponentModel;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class ListBoxTest
+ {
+ [Test]
+ public void ListBoxPropertyTest ()
+ {
+ ListBox lb1 = new ListBox ();
+ Assert.AreEqual (0, lb1.ColumnWidth, "#1");
+ Assert.AreEqual (DrawMode.Normal, lb1.DrawMode, "#2");
+ Assert.AreEqual (0, lb1.HorizontalExtent, "#3");
+ Assert.AreEqual (false, lb1.HorizontalScrollbar, "#4");
+ Assert.AreEqual (true, lb1.IntegralHeight, "#5");
+ //Assert.AreEqual (13, lb1.ItemHeight, "#6"); // Note: Item height depends on the current font.
+ lb1.Items.Add ("a");
+ lb1.Items.Add ("b");
+ lb1.Items.Add ("c");
+ Assert.AreEqual (3, lb1.Items.Count, "#7");
+ Assert.AreEqual (false, lb1.MultiColumn, "#8");
+ //Assert.AreEqual (46, lb1.PreferredHeight, "#9"); // Note: Item height depends on the current font.
+ //Assert.AreEqual (RightToLeft.No , lb1.RightToLeft, "#10"); // Depends on Windows version
+ Assert.AreEqual (false, lb1.ScrollAlwaysVisible, "#11");
+ Assert.AreEqual (-1, lb1.SelectedIndex, "#12");
+ lb1.SetSelected (2,true);
+ Assert.AreEqual (2, lb1.SelectedIndices[0], "#13");
+ Assert.AreEqual ("c", lb1.SelectedItem, "#14");
+ Assert.AreEqual ("c", lb1.SelectedItems[0], "#15");
+ Assert.AreEqual (SelectionMode.One, lb1.SelectionMode, "#16");
+ lb1.SetSelected (2,false);
+ Assert.AreEqual (false, lb1.Sorted, "#17");
+ Assert.AreEqual ("", lb1.Text, "#18");
+ Assert.AreEqual (0, lb1.TopIndex, "#19");
+ Assert.AreEqual (true, lb1.UseTabStops, "#20");
+ }
+
+ [Test]
+ public void BeginEndUpdateTest ()
+ {
+ Form f = new Form ();
+ f.Visible = true;
+ ListBox lb1 = new ListBox ();
+ lb1.Items.Add ("A");
+ lb1.Visible = true;
+ f.Controls.Add (lb1);
+ lb1.BeginUpdate ();
+ for (int x = 1; x < 5000; x++)
+ {
+ lb1.Items.Add ("Item " + x.ToString ());
+ }
+ lb1.EndUpdate ();
+ lb1.SetSelected (1, true);
+ lb1.SetSelected (3, true);
+ Assert.AreEqual (true, lb1.SelectedItems.Contains ("Item 3"), "#21");
+ }
+
+ [Test]
+ public void ClearSelectedTest ()
+ {
+ Form f = new Form ();
+ f.Visible = true;
+ ListBox lb1 = new ListBox ();
+ lb1.Items.Add ("A");
+ lb1.Visible = true;
+ f.Controls.Add (lb1);
+ lb1.SetSelected (0, true);
+ Assert.AreEqual ("A", lb1.SelectedItems [0].ToString (),"#22");
+ lb1.ClearSelected ();
+ Assert.AreEqual (0, lb1.SelectedItems.Count,"#23");
+ }
+
+ [Ignore ("It depends on user system settings")]
+ public void GetItemHeightTest ()
+ {
+ Form f = new Form ();
+ ListBox lb1 = new ListBox ();
+ lb1.Visible = true;
+ f.Controls.Add (lb1);
+ lb1.Items.Add ("A");
+ Assert.AreEqual (13, lb1.GetItemHeight (0) , "#28");
+ }
+
+ [Ignore ("It depends on user system settings")]
+ public void GetItemRectangleTest ()
+ {
+ Form f = new Form ();
+ f.Visible = true;
+ ListBox lb1 = new ListBox ();
+ lb1.Visible = true;
+ f.Controls.Add (lb1);
+ lb1.Items.Add ("A");
+ Assert.AreEqual (new Rectangle(0,0,116,13), lb1.GetItemRectangle (0), "#29");
+ }
+
+ [Test]
+ public void GetSelectedTest ()
+ {
+ ListBox lb1 = new ListBox ();
+ lb1.Items.Add ("A");
+ lb1.Items.Add ("B");
+ lb1.Items.Add ("C");
+ lb1.Items.Add ("D");
+ lb1.Sorted = true;
+ lb1.SetSelected (0,true);
+ lb1.SetSelected (2,true);
+ lb1.TopIndex=0;
+ Assert.AreEqual (true, lb1.GetSelected (0), "#30");
+ lb1.SetSelected (2,false);
+ Assert.AreEqual (false, lb1.GetSelected (2), "#31");
+ }
+
+ [Test]
+ public void IndexFromPointTest ()
+ {
+ ListBox lb1 = new ListBox ();
+ lb1.Items.Add ("A");
+ Point pt = new Point (100,100);
+ lb1.IndexFromPoint (pt);
+ Assert.AreEqual (-1, lb1.IndexFromPoint (100,100), "#32");
+ }
+
+ [Test]
+ public void FindStringTest ()
+ {
+ ListBox cmbbox = new ListBox ();
+ cmbbox.FindString ("Hola", -5); // No exception, it's empty
+ int x = cmbbox.FindString ("Hello");
+ Assert.AreEqual (-1, x, "#19");
+ cmbbox.Items.AddRange(new object[] {"ACBD", "ABDC", "ACBD", "ABCD"});
+ String myString = "ABC";
+ x = cmbbox.FindString (myString);
+ Assert.AreEqual (3, x, "#191");
+ x = cmbbox.FindString (string.Empty);
+ Assert.AreEqual (0, x, "#192");
+ x = cmbbox.FindString ("NonExistant");
+ Assert.AreEqual (-1, x, "#193");
+ }
+
+ [Test]
+ public void FindStringExactTest ()
+ {
+ ListBox cmbbox = new ListBox ();
+ cmbbox.FindStringExact ("Hola", -5); // No exception, it's empty
+ int x = cmbbox.FindStringExact ("Hello");
+ Assert.AreEqual (-1, x, "#20");
+ cmbbox.Items.AddRange (new object[] {"ABCD","ABC","ABDC"});
+ String myString = "ABC";
+ x = cmbbox.FindStringExact (myString);
+ Assert.AreEqual (1, x, "#201");
+ x = cmbbox.FindStringExact (string.Empty);
+ Assert.AreEqual (-1, x, "#202");
+ x = cmbbox.FindStringExact ("NonExistant");
+ Assert.AreEqual (-1, x, "#203");
+ }
+
+ //
+ // Exceptions
+ //
+
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void BorderStyleException ()
+ {
+ ListBox lstbox = new ListBox ();
+ lstbox.BorderStyle = (BorderStyle) 10;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ColumnWidthException ()
+ {
+ ListBox lstbox = new ListBox ();
+ lstbox.ColumnWidth = -1;
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void DrawModeException ()
+ {
+ ListBox lstbox = new ListBox ();
+ lstbox.DrawMode = (DrawMode) 10;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void DrawModeAndMultiColumnException ()
+ {
+ ListBox lstbox = new ListBox ();
+ lstbox.MultiColumn = true;
+ lstbox.DrawMode = DrawMode.OwnerDrawVariable;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void ItemHeightException ()
+ {
+ ListBox lstbox = new ListBox ();
+ lstbox.ItemHeight = 256;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void SelectedIndexException ()
+ {
+ ListBox lstbox = new ListBox ();
+ lstbox.SelectedIndex = -2;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void SelectedIndexModeNoneException ()
+ {
+ ListBox lstbox = new ListBox ();
+ lstbox.SelectionMode = SelectionMode.None;
+ lstbox.SelectedIndex = -1;
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void SelectionModeException ()
+ {
+ ListBox lstbox = new ListBox ();
+ lstbox.SelectionMode = (SelectionMode) 10;
+ }
+
+ //
+ // Events
+ //
+ private bool eventFired;
+
+ private void GenericHandler (object sender, EventArgs e)
+ {
+ eventFired = true;
+ }
+
+
+ }
+
+ [TestFixture]
+ public class ListBoxObjectCollectionTest
+ {
+ [Test]
+ public void ComboBoxObjectCollectionPropertyTest ()
+ {
+ ListBox.ObjectCollection col = new ListBox.ObjectCollection (new ListBox ());
+ Assert.AreEqual (false, col.IsReadOnly, "#B1");
+ Assert.AreEqual (false, ((ICollection)col).IsSynchronized, "#B2");
+ Assert.AreEqual (col, ((ICollection)col).SyncRoot, "#B3");
+ Assert.AreEqual (false, ((IList)col).IsFixedSize, "#B4");
+ }
+
+ [Test]
+ public void AddTest ()
+ {
+ ListBox.ObjectCollection col = new ListBox.ObjectCollection (new ListBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ Assert.AreEqual (2, col.Count, "#C1");
+ }
+
+ [Test]
+ public void ClearTest ()
+ {
+ ListBox.ObjectCollection col = new ListBox.ObjectCollection (new ListBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ col.Clear ();
+ Assert.AreEqual (0, col.Count, "#D1");
+ }
+
+ [Test]
+ public void ContainsTest ()
+ {
+ ListBox.ObjectCollection col = new ListBox.ObjectCollection (new ListBox ());
+ object obj = "Item1";
+ col.Add (obj);
+ Assert.AreEqual (true, col.Contains ("Item1"), "#E1");
+ Assert.AreEqual (false, col.Contains ("Item2"), "#E2");
+ }
+
+ [Test]
+ public void IndexOfTest ()
+ {
+ ListBox.ObjectCollection col = new ListBox.ObjectCollection (new ListBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ Assert.AreEqual (1, col.IndexOf ("Item2"), "#F1");
+ }
+
+ [Test]
+ public void RemoveTest ()
+ {
+ ListBox.ObjectCollection col = new ListBox.ObjectCollection (new ListBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ col.Remove ("Item1");
+ Assert.AreEqual (1, col.Count, "#G1");
+ }
+
+ [Test]
+ public void RemoveAtTest ()
+ {
+ ListBox.ObjectCollection col = new ListBox.ObjectCollection (new ListBox ());
+ col.Add ("Item1");
+ col.Add ("Item2");
+ col.RemoveAt (0);
+ Assert.AreEqual (1, col.Count, "#H1");
+ Assert.AreEqual (true, col.Contains ("Item2"), "#H1");
+ }
+
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewCollectionsTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewCollectionsTest.cs
new file mode 100644
index 00000000000..3cde0af7b9f
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewCollectionsTest.cs
@@ -0,0 +1,243 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using System.Collections;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class ListViewCollectionsTest
+ {
+ /*
+ ColumnHeaderCollection
+ */
+ [Test]
+ public void ColumnHeaderCollectionTest_PropertiesTest ()
+ {
+ ListView listview = new ListView ();
+
+ // Properties
+ Assert.AreEqual (false, listview.Columns.IsReadOnly, "ColumnHeaderCollectionTest_PropertiesTest#1");
+ Assert.AreEqual (true, ((ICollection)listview.Columns).IsSynchronized, "ColumnHeaderCollectionTest_PropertiesTest#2");
+ Assert.AreEqual (listview.Columns, ((ICollection)listview.Columns).SyncRoot, "ColumnHeaderCollectionTest_PropertiesTest#3");
+ Assert.AreEqual (false, ((IList)listview.Columns).IsFixedSize, "ColumnHeaderCollectionTest_PropertiesTest#4");
+ Assert.AreEqual (0, listview.Columns.Count, "ColumnHeaderCollectionTest_PropertiesTest#5");
+ }
+
+ [Test]
+ public void ColumnHeaderCollectionTest_AddTest ()
+ {
+ ListView listview = new ListView ();
+
+ // Duplicated elements with same text added
+ listview.Columns.Add (new ColumnHeader ());
+ listview.Columns.Add (new ColumnHeader ());
+ Assert.AreEqual (2, listview.Columns.Count, "ColumnHeaderCollectionTest_AddTest#1");
+ Assert.AreEqual ("ColumnHeader", listview.Columns[0].Text, "ColumnHeaderCollectionTest_AddTest#2");
+ }
+
+ [Test]
+ public void ColumnHeaderCollectionTest_ClearTest ()
+ {
+ ListView listview = new ListView ();
+
+ // Duplicated elements with same text added
+ listview.Columns.Add (new ColumnHeader ());
+ listview.Columns.Clear ();
+ Assert.AreEqual (0, listview.Columns.Count, "ColumnHeaderCollectionTest_ClearTest#1");
+ }
+
+ // Exceptions
+ [Test, ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void ColumnHeaderCollectionTest_GetItem_ExceptionTest ()
+ {
+ // Duplicated elements not added
+ ListView listview = new ListView ();
+ ColumnHeader item = listview.Columns[5];
+ }
+
+ /*
+ CheckedIndexCollection
+ */
+ [Test]
+ public void CheckedIndexCollectionTest_PropertiesTest ()
+ {
+ ListView listview = new ListView ();
+
+ // Properties
+ Assert.AreEqual (true, listview.CheckedIndices.IsReadOnly, "CheckedIndexCollectionTest_PropertiesTest#1");
+ Assert.AreEqual (false, ((ICollection)listview.CheckedIndices).IsSynchronized, "CheckedIndexCollectionTest_PropertiesTest#2");
+ Assert.AreEqual (listview.CheckedIndices, ((ICollection)listview.CheckedIndices).SyncRoot, "CheckedIndexCollectionTest_PropertiesTest#3");
+ Assert.AreEqual (true, ((IList)listview.CheckedIndices).IsFixedSize, "CheckedIndexCollectionTest_PropertiesTest#4");
+ Assert.AreEqual (0, listview.CheckedIndices.Count, "CheckedIndexCollectionTest_PropertiesTest#5");
+ }
+
+
+ // Exceptions
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void CheckedIndexCollectionTest_Add_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.CheckedIndices).Add (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void CheckedIndexCollectionTest_Remove_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.CheckedIndices).Remove (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void CheckedIndexCollectionTest_RemoveAt_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.CheckedIndices).RemoveAt (5);
+ }
+
+ /*
+ CheckedItemCollection
+ */
+ [Test]
+ public void CheckedItemCollectionTest_PropertiesTest ()
+ {
+ ListView listview = new ListView ();
+
+ // Properties
+ Assert.AreEqual (true, listview.CheckedItems.IsReadOnly, "CheckedItemCollectionTest_PropertiesTest#1");
+ Assert.AreEqual (false, ((ICollection)listview.CheckedItems).IsSynchronized, "CheckedItemCollectionTest_PropertiesTest#2");
+ Assert.AreEqual (listview.CheckedItems, ((ICollection)listview.CheckedItems).SyncRoot, "CheckedItemCollectionTest_PropertiesTest#3");
+ Assert.AreEqual (true, ((IList)listview.CheckedItems).IsFixedSize, "CheckedItemCollectionTest_PropertiesTest#4");
+ Assert.AreEqual (0, listview.CheckedItems.Count, "CheckedItemCollectionTest_PropertiesTest#5");
+ }
+
+
+ // Exceptions
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void CheckedItemCollectionTest_PropertiesTest_Add_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.CheckedItems).Add (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void CheckedItemCollectionTest_PropertiesTest_Remove_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.CheckedItems).Remove (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void CheckedItemCollectionTest_PropertiesTest_RemoveAt_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.CheckedItems).RemoveAt (5);
+ }
+
+ /*
+ SelectedIndexCollection
+ */
+ [Test]
+ public void SelectedIndexCollectionTest_PropertiesTest ()
+ {
+ ListView listview = new ListView ();
+
+ // Properties
+ Assert.AreEqual (true, listview.SelectedIndices.IsReadOnly, "SelectedIndexCollectionTest_PropertiesTest#1");
+ Assert.AreEqual (false, ((ICollection)listview.SelectedIndices).IsSynchronized, "SelectedIndexCollectionTest_PropertiesTest#2");
+ Assert.AreEqual (listview.SelectedIndices, ((ICollection)listview.SelectedIndices).SyncRoot, "SelectedIndexCollectionTest_PropertiesTest#3");
+ Assert.AreEqual (true, ((IList)listview.SelectedIndices).IsFixedSize, "SelectedIndexCollectionTest_PropertiesTest#4");
+ Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_PropertiesTest#5");
+ }
+
+
+ // Exceptions
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void SelectedIndexCollectionTest_Add_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.SelectedIndices).Add (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void SelectedIndexCollectionTest_Remove_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.SelectedIndices).Remove (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void SelectedIndexCollectionTest_RemoveAt_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.SelectedIndices).RemoveAt (5);
+ }
+
+ /*
+ SelectedItemCollection
+ */
+ [Test]
+ public void SelectedItemCollectionTest_PropertiesTest ()
+ {
+ ListView listview = new ListView ();
+
+ // Properties
+ Assert.AreEqual (true, listview.SelectedItems.IsReadOnly, "SelectedItemCollectionTest_PropertiesTest#1");
+ Assert.AreEqual (false, ((ICollection)listview.SelectedItems).IsSynchronized, "SelectedItemCollectionTest_PropertiesTest#2");
+ Assert.AreEqual (listview.SelectedItems, ((ICollection)listview.SelectedItems).SyncRoot, "SelectedItemCollectionTest_PropertiesTest#3");
+ Assert.AreEqual (true, ((IList)listview.SelectedItems).IsFixedSize, "SelectedItemCollectionTest_PropertiesTest#4");
+ Assert.AreEqual (0, listview.SelectedItems.Count, "SelectedItemCollectionTest_PropertiesTest#5");
+ }
+
+
+ // Exceptions
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void SelectedItemCollectionTest_PropertiesTest_Add_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.SelectedItems).Add (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void SelectedItemCollectionTest_PropertiesTest_Remove_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.SelectedItems).Remove (5);
+ }
+
+ [Test, ExpectedException (typeof (NotSupportedException))]
+ public void SelectedItemCollectionTest_PropertiesTest_RemoveAt_ExceptionTest ()
+ {
+ ListView listview = new ListView ();
+ ((IList)listview.SelectedItems).RemoveAt (5);
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewEventTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewEventTest.cs
new file mode 100644
index 00000000000..9294bc2a168
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewEventTest.cs
@@ -0,0 +1,208 @@
+//
+// ListViewEventTest.cs: Test cases for ListView events.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture, Ignore ("Needs Manual Intervention")]
+ public class ListViewEvent
+ {
+ static bool eventhandled = false;
+ public void LabelEdit_EventHandler (object sender,LabelEditEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void AfterLabelEditTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+ mylistview.LabelEdit = true ;
+ mylistview.AfterLabelEdit += new LabelEditEventHandler (LabelEdit_EventHandler);
+ mylistview.View = View.Details;
+ mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
+ mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
+ mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ myform.Controls.Add (mylistview);
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A1");
+ }
+
+ [Test]
+ public void BeforeLabelEditTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+ mylistview.LabelEdit = true ;
+ mylistview.BeforeLabelEdit += new LabelEditEventHandler (LabelEdit_EventHandler);
+ eventhandled = false;
+ mylistview.View = View.Details;
+ mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
+ mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
+ mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ myform.Controls.Add (mylistview);
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A2");
+ }
+ }
+
+ [TestFixture, Ignore ("Needs Manual Intervention")]
+
+ public class ColumnClickEvent
+ {
+ static bool eventhandled = false;
+ public void ColumnClickEventHandler (object sender, ColumnClickEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void ColumnClickTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+
+ mylistview.LabelEdit = true ;
+ mylistview.ColumnClick += new ColumnClickEventHandler (ColumnClickEventHandler);
+ mylistview.View = View.Details;
+ mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
+ mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
+ mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ myform.Controls.Add (mylistview);
+ myform.ShowDialog ();
+ mylistview.Sort ();
+ Assert.AreEqual (true, eventhandled, "#A3");
+ }
+ }
+
+ [TestFixture, Ignore ("Needs Manual Intervention")]
+
+ public class MyEvent
+ {
+ static bool eventhandled = false;
+ public void New_EventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void ItemActivateTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+ mylistview.Activation = ItemActivation.OneClick;
+ mylistview.LabelEdit = true ;
+ mylistview.ItemActivate += new EventHandler (New_EventHandler);
+ mylistview.View = View.Details;
+ mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
+ mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
+ mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ myform.Controls.Add (mylistview);
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A4");
+ }
+
+ [Test]
+ public void SelectedIndexChangedTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+ mylistview.LabelEdit = true ;
+ mylistview.SelectedIndexChanged += new EventHandler (New_EventHandler);
+ eventhandled = false;
+ mylistview.View = View.Details;
+ mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
+ mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
+ mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ myform.Controls.Add (mylistview);
+ myform.ShowDialog ();
+ Assert.AreEqual (true, eventhandled, "#A5");
+ }
+ }
+
+ [TestFixture, Ignore ("Needs Manual Intervention")]
+
+ public class ItemCheckEvent
+ {
+ static bool eventhandled = false;
+ public void ItemCheckEventHandler (object sender, ItemCheckEventArgs e)
+
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void ItemCheckTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+ mylistview.CheckBoxes = true;
+ mylistview.LabelEdit = true ;
+ mylistview.ItemCheck += new ItemCheckEventHandler (ItemCheckEventHandler);
+ mylistview.View = View.Details;
+ mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
+ mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
+ mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ myform.Controls.Add (mylistview);
+ myform.ShowDialog ();
+ mylistview.Visible = true;
+ Assert.AreEqual (true, eventhandled, "#A6");
+ }
+ }
+
+
+ [TestFixture, Ignore ("Needs Manual Intervention")]
+
+ public class ItemDragEvent
+ {
+ static bool eventhandled = false;
+ public void ItemDragEventHandler (object sender, ItemDragEventArgs e)
+
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void ItemDragTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+ mylistview.ItemDrag += new ItemDragEventHandler (ItemDragEventHandler);
+ mylistview.View = View.Details;
+ mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
+ mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
+ mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ myform.Controls.Add (mylistview);
+ myform.ShowDialog ();
+ mylistview.Visible = true;
+ mylistview.DoDragDrop (mylistview.SelectedItems, DragDropEffects.Link);
+ Assert.AreEqual (true, eventhandled, "#A7");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewItemTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewItemTest.cs
new file mode 100644
index 00000000000..e16b5023c44
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewItemTest.cs
@@ -0,0 +1,88 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class ListViewItemTest
+ {
+ [Test]
+ public void ListViewItemConstructors ()
+ {
+ Font fnt = new Font ("Arial", 12);
+ ListViewItem item1 = new ListViewItem ("Hello folks");
+ Assert.AreEqual ("Hello folks", item1.Text, "Constructor#1");
+
+ ListViewItem item2 = new ListViewItem (new string [] {"Element1", "Element2"},
+ -1, Color.Blue, Color.Red, fnt);
+
+ Assert.AreEqual (item2.ForeColor, Color.Blue, "Constructor#2");
+ Assert.AreEqual (item2.BackColor, Color.Red, "Constructor#3");
+
+ Assert.AreEqual (2, item2.SubItems.Count,"Constructor#4");
+ Assert.AreEqual (Color.Blue, item2.SubItems[0].ForeColor,"Constructor#5");
+ Assert.AreEqual (Color.Red, item2.SubItems[0].BackColor, "Constructor#6");
+ Assert.AreEqual (fnt, item2.SubItems[0].Font, "Constructor#7");
+ Assert.AreEqual ("Element1", item2.SubItems[0].Text, "Constructor#8");
+ Assert.AreEqual ("Element2", item2.SubItems[1].Text, "Constructor#12");
+ }
+
+ [Test]
+ public void ListViewItemDefaultValues ()
+ {
+ ListViewItem item = new ListViewItem ();
+
+ Assert.AreEqual (false, item.Focused, "DefaultValues#3");
+ Assert.AreEqual (false, item.Checked, "DefaultValues#4");
+ Assert.AreEqual (string.Empty, item.Text, "DefaultValues#5");
+ Assert.AreEqual (true, item.UseItemStyleForSubItems, "DefaultValues#6");
+ }
+
+ [Test]
+ public void ListViewItemTestClone ()
+ {
+ ListViewItem item1 = new ListViewItem ("Hello");
+ item1.ForeColor = Color.Blue;
+ item1.BackColor = Color.Red;
+ item1.Font = new Font ("Arial", 14);
+ item1.SubItems.Add ("Element2");
+
+ ListViewItem item2 = (ListViewItem) item1.Clone ();
+ Assert.AreEqual (item2.ForeColor, Color.Blue, "Clone#1");
+ Assert.AreEqual (item2.BackColor, Color.Red, "Clone#2");
+ Assert.AreEqual (item2.Text, "Hello", "Clone#3");
+ Assert.AreEqual (item2.Font, item1.Font, "Clone#4");
+ Assert.AreEqual (2, item2.SubItems.Count, "Clone#5");
+ Assert.AreEqual (item2.SubItems[1].Text, "Element2", "Clone#6");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewTest.cs
new file mode 100644
index 00000000000..f5f4f0c6f62
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListViewTest.cs
@@ -0,0 +1,136 @@
+//
+// ListViewTest.cs: Test cases for ListView.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class ListViewTest
+ {
+ [Test]
+ public void ListViewPropertyTest ()
+ {
+ ListView mylistview = new ListView ();
+ Assert.AreEqual (ItemActivation.Standard, mylistview.Activation, "#1");
+ Assert.AreEqual (ListViewAlignment.Top, mylistview.Alignment, "#2");
+ Assert.AreEqual (false, mylistview.AllowColumnReorder, "#3");
+ Assert.AreEqual (true, mylistview.AutoArrange, "#4");
+ Assert.AreEqual (BorderStyle.Fixed3D , mylistview.BorderStyle, "#5");
+ Assert.AreEqual (false, mylistview.CheckBoxes, "#6");
+ Assert.AreEqual (0, mylistview.CheckedIndices.Count, "#7");
+ Assert.AreEqual (0, mylistview.CheckedItems.Count, "#8");
+ Assert.AreEqual (0, mylistview.Columns.Count, "#9");
+ Assert.AreEqual (null, mylistview.FocusedItem, "#10");
+ Assert.AreEqual (false, mylistview.FullRowSelect, "#11");
+ Assert.AreEqual (false, mylistview.GridLines, "#12");
+ Assert.AreEqual (ColumnHeaderStyle.Clickable, mylistview.HeaderStyle, "#13");
+ Assert.AreEqual (true, mylistview.HideSelection, "#14");
+ Assert.AreEqual (false, mylistview.HoverSelection, "#15");
+ ListViewItem item1 = new ListViewItem ("A", -1);
+ mylistview.Items.Add (item1);
+ Assert.AreEqual (1, mylistview.Items.Count, "#16");
+ Assert.AreEqual (false, mylistview.LabelEdit, "#17");
+ Assert.AreEqual (true, mylistview.LabelWrap, "#18");
+ Assert.AreEqual (null, mylistview.LargeImageList, "#19");
+ Assert.AreEqual (null, mylistview.ListViewItemSorter, "#20");
+ Assert.AreEqual (true, mylistview.MultiSelect, "#21");
+ Assert.AreEqual (true, mylistview.Scrollable, "#22");
+ Assert.AreEqual (0, mylistview.SelectedIndices.Count, "#23");
+ Assert.AreEqual (0, mylistview.SelectedItems.Count, "#24");
+ Assert.AreEqual (null, mylistview.SmallImageList, "#25");
+ Assert.AreEqual (null, mylistview.LargeImageList, "#26");
+ Assert.AreEqual (SortOrder.None, mylistview.Sorting, "#27");
+ Assert.AreEqual (null, mylistview.StateImageList, "#28");
+ Assert.AreEqual (View.LargeIcon, mylistview.View, "#29");
+ mylistview.View = View.List;
+ Assert.AreEqual (false, mylistview.TopItem.Checked, "#30");
+ }
+
+ [Test]
+ public void ArrangeIconsTest ()
+ {
+ Form myform = new Form ();
+ ListView mylistview = new ListView ();
+ myform.Controls.Add (mylistview);
+ mylistview.Items.Add ("Item 1");
+ mylistview.Items.Add ("Item 2");
+ mylistview.View = View.LargeIcon;
+ mylistview.ArrangeIcons ();
+ }
+
+ [Test]
+ public void BeginEndUpdateTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ListView mylistview = new ListView();
+ mylistview.Items.Add ("A");
+ mylistview.Visible = true;
+ myform.Controls.Add (mylistview);
+ mylistview.BeginUpdate ();
+ for(int x = 1 ; x < 5000 ; x++){
+ mylistview.Items.Add ("Item " + x.ToString());
+ }
+ mylistview.EndUpdate ();
+ }
+
+ [Test]
+ public void ClearTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ListView mylistview = new ListView ();
+ mylistview.Items.Add ("A");
+ mylistview.Columns.Add ("Item Column", -2, HorizontalAlignment.Left);
+ mylistview.Visible = true;
+ myform.Controls.Add (mylistview);
+ Assert.AreEqual (1, mylistview.Columns.Count, "#31");
+ Assert.AreEqual (1, mylistview.Items.Count, "#32");
+ mylistview.Clear ();
+ Assert.AreEqual (0, mylistview.Columns.Count, "#33");
+ Assert.AreEqual (0, mylistview.Items.Count, "#34");
+ }
+
+ [Test]
+ public void EnsureVisibleTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ListView mylistview = new ListView ();
+ mylistview.Items.Add ("A");
+ myform.Controls.Add (mylistview);
+ mylistview.BeginUpdate ();
+ for(int x = 1 ; x < 5000 ; x++) {
+ mylistview.Items.Add ("Item " + x.ToString());
+ }
+ mylistview.EndUpdate ();
+ mylistview.EnsureVisible (4999);
+ }
+
+ [Test]
+ public void GetItemRectTest ()
+ {
+ ListView mylistview = new ListView ();
+ mylistview.Items.Add ("Item 1");
+ mylistview.Items.Add ("Item 2");
+ Rectangle r = mylistview.GetItemRect (1);
+ Assert.AreEqual (0, r.Top, "#35a");
+ Assert.IsTrue (r.Bottom > 0, "#35b");
+ Assert.IsTrue (r.Right > 0, "#35c");
+ Assert.IsTrue (r.Left > 0, "#35d");
+ Assert.IsTrue (r.Height > 0, "#35e");
+ Assert.IsTrue (r.Width > 0, "#35f");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuItemTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuItemTest.cs
new file mode 100644
index 00000000000..aad692b1188
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuItemTest.cs
@@ -0,0 +1,170 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class MenuItemTest
+ {
+ [Test]
+ public void MenuItemDefaultValues ()
+ {
+ MenuItem mi = new MenuItem ();
+
+ Assert.AreEqual (false, mi.BarBreak, "DefaultValues#1");
+ Assert.AreEqual (false, mi.Break, "DefaultValues#2");
+ Assert.AreEqual (false, mi.Checked, "DefaultValues#3");
+ Assert.AreEqual (false, mi.DefaultItem, "DefaultValues#4");
+ Assert.AreEqual (true, mi.Enabled, "DefaultValues#5");
+ Assert.AreEqual (-1, mi.Index, "DefaultValues#6");
+ Assert.AreEqual (false, mi.IsParent, "DefaultValues#7");
+
+ // TODO: MDI is not completed yet
+ //Assert.AreEqual (, mi.MdiList, "DefaultValues#8");
+
+ Assert.AreEqual (0, mi.MergeOrder, "DefaultValues#9");
+ Assert.AreEqual (MenuMerge.Add, mi.MergeType, "DefaultValues#10");
+ Assert.AreEqual ('\0', mi.Mnemonic, "DefaultValues#11");
+
+ Assert.AreEqual (false, mi.OwnerDraw, "DefaultValues#12");
+ Assert.AreEqual (null, mi.Parent, "DefaultValues#13");
+ Assert.AreEqual (false, mi.RadioCheck, "DefaultValues#14");
+ Assert.AreEqual (Shortcut.None, mi.Shortcut, "DefaultValues#15");
+ Assert.AreEqual (true, mi.ShowShortcut, "DefaultValues#16");
+ Assert.AreEqual (string.Empty, mi.Text, "DefaultValues#17");
+ Assert.AreEqual (true, mi.Visible, "DefaultValues#18");
+ }
+
+ [Test]
+ public void MenuItemConstructors ()
+ {
+ MenuItem mi;
+ MenuItem subitem1 = new MenuItem ("SubItem1");
+ MenuItem subitem2 = new MenuItem ("SubItem2");
+ MenuItem subitem3 = new MenuItem ("SubItem3");
+
+ {
+ mi = new MenuItem ("Item1");
+ Assert.AreEqual ("Item1", mi.Text, "Constructor#1");
+ }
+
+ {
+ mi = new MenuItem ("Item2", new MenuItem [] {subitem1,
+ subitem2, subitem3});
+
+ Assert.AreEqual ("Item2", mi.Text, "Constructor#2");
+ Assert.AreEqual (3, mi.MenuItems.Count, "Constructor#3");
+
+ Assert.AreEqual ("SubItem1", mi.MenuItems[0].Text, "Constructor#4");
+ Assert.AreEqual (mi, mi.MenuItems[0].Parent, "Constructor#5");
+
+ Assert.AreEqual ("SubItem2", mi.MenuItems[1].Text, "Constructor#6");
+ Assert.AreEqual (mi, mi.MenuItems[1].Parent, "Constructor#7");
+
+ Assert.AreEqual ("SubItem3", mi.MenuItems[2].Text, "Constructor#8");
+ Assert.AreEqual (mi, mi.MenuItems[2].Parent, "Constructor#9");
+ }
+
+ }
+
+ [Test]
+ public void MenuItemSimpleMerge ()
+ {
+ MainMenu mymainmenu1 = new MainMenu ();
+ MainMenu mymainmenu2 = new MainMenu ();
+ MenuItem mymenuitem1 = new MenuItem ();
+ MenuItem mymenuitem2 = new MenuItem ();
+ mymenuitem1.Text = "A";
+ mymenuitem2.Text = "B";
+ mymainmenu1.MenuItems.Add (mymenuitem1);
+ mymainmenu2.MenuItems.Add (mymenuitem2);
+ mymainmenu1.MergeMenu (mymainmenu2);
+ Assert.AreEqual (2, mymainmenu1.MenuItems.Count, "SimpleMerge#1");
+ }
+
+ [Test]
+ public void MenuItemMerge ()
+ {
+ MenuItem item1 = new MenuItem ("File (0)"); // Position 0
+ MenuItem item2 = new MenuItem ("Print the file (1)"); // Position 1
+ MenuItem item3 = new MenuItem ("Print Preview (2)"); // Position 2
+ MenuItem item4 = new MenuItem ("-"); // Position 3
+ MenuItem item5 = new MenuItem ("Recent files (4)"); // Position 4
+ MenuItem item6 = new MenuItem ("Exit (5)"); // Position 5
+
+ MenuItem item10 = new MenuItem ("Compare... (6)"); // Replace pos 3
+ MenuItem item11 = new MenuItem ("Sort (7)");
+ MenuItem item12 = new MenuItem ("Conversions (8)");
+ MenuItem item13 = new MenuItem ("Specials Functions (9)");
+ MenuItem item14 = new MenuItem ("Another option... (10)");
+
+ MenuItem item20 = new MenuItem ("autors.doc");
+ MenuItem item21 = new MenuItem ("testing.html");
+ MenuItem item22 = new MenuItem ("proves.txt");
+
+ MenuItem[] first_items = new MenuItem[] {item1, item2, item3, item4, item5, item6};
+ MenuItem[] second_items = new MenuItem[] {item10, item11, item12, item13, item14};
+ MenuItem[] third_items = new MenuItem[] {item20, item21, item22};
+
+ item14.MergeType = MenuMerge.Remove;
+ item10.MergeOrder = 40;
+
+ item11.MergeType = MenuMerge.Replace;
+ item11.MergeOrder = 30;
+ item12.MergeOrder = 5;
+ item10.MergeType = MenuMerge.MergeItems;
+
+ ContextMenu first_menu = new ContextMenu (first_items);
+ ContextMenu second_menu = new ContextMenu (second_items);
+ ContextMenu third_menu = new ContextMenu (third_items);
+
+ first_menu.MergeMenu (second_menu);
+ first_menu.MergeMenu (third_menu);
+
+ Assert.AreEqual ("File (0)", first_menu.MenuItems[0].Text, "ItemMerge#1");
+ Assert.AreEqual ("Print the file (1)", first_menu.MenuItems[1].Text, "ItemMerge#2");
+ Assert.AreEqual ("Print Preview (2)", first_menu.MenuItems[2].Text, "ItemMerge#3");
+ Assert.AreEqual ("-", first_menu.MenuItems[3].Text, "ItemMerge#4");
+ Assert.AreEqual ("Recent files (4)", first_menu.MenuItems[4].Text, "ItemMerge#5");
+ Assert.AreEqual ("Exit (5)", first_menu.MenuItems[5].Text, "ItemMerge#6");
+ Assert.AreEqual ("Specials Functions (9)", first_menu.MenuItems[6].Text, "ItemMerge#7");
+ Assert.AreEqual ("autors.doc", first_menu.MenuItems[7].Text, "ItemMerge#8");
+ Assert.AreEqual ("testing.html", first_menu.MenuItems[8].Text, "ItemMerge#9");
+ Assert.AreEqual ("proves.txt", first_menu.MenuItems[9].Text, "ItemMerge#10");
+ Assert.AreEqual ("Conversions (8)", first_menu.MenuItems[10].Text, "ItemMerge#11");
+ Assert.AreEqual ("Sort (7)", first_menu.MenuItems[11].Text, "ItemMerge#11");
+ Assert.AreEqual ("Compare... (6)", first_menu.MenuItems[12].Text, "ItemMerge#11");
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuTest.cs
new file mode 100644
index 00000000000..176e36cba30
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MenuTest.cs
@@ -0,0 +1,86 @@
+//
+// MenuTest.cs: Test cases for Menu, MainMenu
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class MenuTest
+ {
+ [Test]
+ public void MenuPropertyTest ()
+ {
+ Menu mymenu = new MainMenu ();
+ Assert.AreEqual ("System.IntPtr", mymenu.Handle.GetType().FullName, "#1");
+ Assert.AreEqual (false, mymenu.IsParent, "#2");
+ // TODO: MDI is not completed yet
+ //Assert.AreEqual (null, mymenu.MdiListItem, "#3");
+ Assert.AreEqual (0, mymenu.MenuItems.Count,"#4");
+ mymenu.MenuItems.Add ("newmenu1");
+ mymenu.MenuItems.Add ("newmenu2");
+ Assert.AreEqual (2, mymenu.MenuItems.Count,"#5");
+ MainMenu mymainmenu = new MainMenu ();
+ Assert.AreEqual (RightToLeft.Inherit, mymainmenu.RightToLeft,"#6");
+ }
+
+ [Test]
+ public void GetMainMenuTest ()
+ {
+ MainMenu mymainmenu = new MainMenu ();
+ MenuItem mymenuitem = new MenuItem ();
+ mymenuitem.Text = "menu 1";
+ mymainmenu.MenuItems.Add (mymenuitem);
+ Assert.AreEqual (mymainmenu, mymenuitem.GetMainMenu (), "#7");
+ }
+
+ [Test]
+ public void CloneMenuTest ()
+ {
+ MainMenu mymainmenu1 = new MainMenu ();
+ MenuItem menuitem1 = new MenuItem ();
+ MenuItem menuitem2 = new MenuItem ();
+ menuitem1.Text = "item1";
+ menuitem2.Text = "item2";
+ mymainmenu1.MenuItems.Add (menuitem1);
+ mymainmenu1.MenuItems.Add (menuitem2);
+ MainMenu mymainmenu2 = mymainmenu1.CloneMenu ();
+ Assert.AreEqual ("item1", mymainmenu2.MenuItems[0].Text, "#9");
+ }
+
+ [Test]
+ public void GetFormTest ()
+ {
+ Form myform = new Form ();
+ myform.Name = "New Form";
+ MainMenu mymainmenu1 = new MainMenu ();
+ MenuItem menuitem1 = new MenuItem ();
+ menuitem1.Text = "item1";
+ mymainmenu1.MenuItems.Add (menuitem1);
+ myform.Menu = mymainmenu1;
+ Assert.AreEqual ("New Form", mymainmenu1.GetForm().Name, "#10");
+ }
+
+ [Test]
+ public void GetContextMenuTest ()
+ {
+ Form myform = new Form ();
+ ContextMenu mycontextmenu = new ContextMenu ();
+ myform.ContextMenu= mycontextmenu;
+ MenuItem menuItem1 = new MenuItem ();
+ menuItem1.Text = "1";
+ mycontextmenu.MenuItems.Add (menuItem1);
+ Assert.AreEqual (mycontextmenu, menuItem1.GetContextMenu (),"#11");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MonthCalendarTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MonthCalendarTest.cs
new file mode 100644
index 00000000000..b6737b9f565
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MonthCalendarTest.cs
@@ -0,0 +1,166 @@
+//
+// MonthCalendarTest.cs: Test case for MonthCalendar
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class MonthCalendarTest
+ {
+ [Test]
+ public void MonthCalendarPropertyTest ()
+ {
+ Form myfrm = new Form ();
+ MonthCalendar myMonthCal1 = new MonthCalendar ();
+ MonthCalendar myMonthCal2 = new MonthCalendar ();
+ myMonthCal1.Name = "MonthCendar";
+ myMonthCal1.TabIndex = 1;
+ DateTime myDateTime = new DateTime ();
+
+ // A
+ myMonthCal1.AddAnnuallyBoldedDate (new DateTime (2005, 09, 01));
+ Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal1.AnnuallyBoldedDates.GetValue (0), "#A1");
+
+ // B
+ Assert.AreEqual ("Window", myMonthCal1.BackColor.Name, "#B1");
+ myMonthCal1.AddBoldedDate (new DateTime (2005, 09, 01));
+ Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal1.BoldedDates.GetValue (0), "#B2");
+
+ // C
+ Assert.AreEqual (1, myMonthCal1.CalendarDimensions.Height, "#C1");
+ Assert.AreEqual (1, myMonthCal1.CalendarDimensions.Width, "#C2");
+ Assert.AreEqual (false, myMonthCal1.CalendarDimensions.IsEmpty, "#C3");
+
+ // F
+ Assert.AreEqual (Day.Default, myMonthCal1.FirstDayOfWeek, "#F1");
+ myMonthCal1.FirstDayOfWeek = Day.Sunday;
+ Assert.AreEqual (Day.Sunday, myMonthCal1.FirstDayOfWeek, "#F2");
+ Assert.AreEqual ("WindowText", myMonthCal1.ForeColor.Name, "#F3");
+
+ // M
+ Assert.AreEqual (new DateTime (9998,12,31), myMonthCal1.MaxDate, "#M1");
+ Assert.AreEqual (7, myMonthCal1.MaxSelectionCount, "#M2");
+ Assert.AreEqual (new DateTime (1753,1,1), myMonthCal1.MinDate, "#M3");
+ myMonthCal1.AddMonthlyBoldedDate (new DateTime (2005, 09, 01));
+ Assert.AreEqual (new DateTime(2005, 09, 01), myMonthCal1.MonthlyBoldedDates.GetValue (0), "#M4");
+
+ // S
+ Assert.AreEqual (0, myMonthCal1.ScrollChange, "#S1");
+ myMonthCal1.SelectionStart = new DateTime (2005,09,02);
+ myMonthCal1.SelectionEnd = new DateTime (2005,09,03);
+ Assert.AreEqual (new DateTime (2005,09,03), myMonthCal1.SelectionEnd, "#S2");
+ //Assert.AreEqual (new SelectionRange (new DateTime(2005,09,02), new DateTime(2005,09,03)), myMonthCal1.SelectionRange, "#S3");
+ Assert.AreEqual (new DateTime (2005,09,02), myMonthCal1.SelectionStart, "#S4");
+ Assert.AreEqual (true, myMonthCal1.ShowToday, "#S5");
+ Assert.AreEqual (true, myMonthCal1.ShowTodayCircle, "#S6");
+ Assert.AreEqual (false, myMonthCal1.ShowWeekNumbers, "#S7");
+ Assert.AreEqual (153, myMonthCal1.SingleMonthSize.Height, "#S8a");
+ Assert.AreEqual (176, myMonthCal1.SingleMonthSize.Width, "#S8b");
+ Assert.AreEqual (null, myMonthCal1.Site, "#S9");
+ // T
+ Assert.AreEqual ("ActiveCaption", myMonthCal1.TitleBackColor.Name, "#T1");
+ Assert.AreEqual ("ActiveCaptionText", myMonthCal1.TitleForeColor.Name, "#T2");
+ Assert.AreEqual (DateTime.Today, myMonthCal1.TodayDate, "#T3");
+ Assert.AreEqual (false, myMonthCal1.TodayDateSet, "#T4");
+ Assert.AreEqual ("GrayText", myMonthCal1.TrailingForeColor.Name, "#T5");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void MonthCalMaxSelectionCountException ()
+ {
+ MonthCalendar myMonthCal1 = new MonthCalendar ();
+ myMonthCal1.MaxSelectionCount = 0 ; // value is less than 1
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void MonthCalMaxDateException ()
+ {
+ MonthCalendar myMonthCal1 = new MonthCalendar ();
+ myMonthCal1.MaxDate = new DateTime (1752, 1, 1, 0, 0, 0, 0); // value is less than min date (01/01/1753)
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void MonthCalMinDateException ()
+ {
+ MonthCalendar myMonthCal1 = new MonthCalendar ();
+ myMonthCal1.MinDate = new DateTime(1752, 1, 1, 0, 0, 0, 0); // Date earlier than 01/01/1753
+ myMonthCal1.MinDate = new DateTime(9999, 12, 31, 0, 0, 0, 0); // Date greater than max date (01/01/1753)
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void MonthCalSelectRangeException ()
+ {
+ MonthCalendar myMonthCal1 = new MonthCalendar ();
+ myMonthCal1.SelectionRange = new SelectionRange (new DateTime (1752, 01, 01), new DateTime (1752, 01, 02));
+ myMonthCal1.SelectionRange = new SelectionRange (new DateTime (9999, 12, 30), new DateTime (9999, 12, 31));
+ }
+
+ [Test]
+ public void AddAnnuallyBoldedDateTest ()
+ {
+ Form myForm = new Form ();
+ MonthCalendar myMonthCal = new MonthCalendar ();
+ myMonthCal.AddAnnuallyBoldedDate (new DateTime (2005, 09, 01));
+ myForm.Controls.Add (myMonthCal);
+ Assert.AreEqual (new DateTime (2005, 09, 01), myMonthCal.AnnuallyBoldedDates.GetValue (0), "#add1");
+ }
+
+ [Test]
+ public void AddBoldedDateTest ()
+ {
+ Form myForm = new Form ();
+ MonthCalendar myMonthCal = new MonthCalendar ();
+ myMonthCal.AddBoldedDate (new DateTime (2005, 09, 02));
+ myForm.Controls.Add (myMonthCal);
+ Assert.AreEqual (new DateTime (2005, 09, 02), myMonthCal.BoldedDates.GetValue (0), "#add2");
+ }
+
+ [Test]
+ public void AddMonthlyBoldedDateTest ()
+ {
+ Form myForm = new Form ();
+ MonthCalendar myMonthCal = new MonthCalendar ();
+ myMonthCal.AddMonthlyBoldedDate (new DateTime (2005, 09, 03));
+ myForm.Controls.Add (myMonthCal);
+ Assert.AreEqual (new DateTime (2005, 09, 03), myMonthCal.MonthlyBoldedDates.GetValue (0), "#add2");
+ }
+
+ [Test]
+ public void GetDispalyRangeTest ()
+ {
+ Form myForm = new Form ();
+ MonthCalendar myMonthCal = new MonthCalendar ();
+ myForm.Controls.Add (myMonthCal);
+ SelectionRange mySelRange = new SelectionRange ();
+ mySelRange.Start = new DateTime (2005, 09, 01);
+ mySelRange.End = new DateTime (2005, 09, 30);
+ Assert.AreEqual (mySelRange.Start, myMonthCal.GetDisplayRange (true).Start, "#Get1");
+ Assert.AreEqual (mySelRange.End, myMonthCal.GetDisplayRange (true).End, "#Get22");
+ }
+
+ [Test]
+ public void HitTest ()
+ {
+ Form myForm = new Form ();
+ MonthCalendar myMonthCal = new MonthCalendar ();
+ myForm.Controls.Add (myMonthCal);
+ Assert.AreEqual (new DateTime (01, 01, 01), myMonthCal.HitTest(10, 10).Time, "#Hit1");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/PictureBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/PictureBoxTest.cs
new file mode 100644
index 00000000000..3b0151afefb
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/PictureBoxTest.cs
@@ -0,0 +1,82 @@
+//
+// PictureBoxTest.cs: Test cases for PictureBox.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (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, Ignore ("This seems to fail.")]
+ 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");
+ }
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ProgressBarTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ProgressBarTest.cs
new file mode 100644
index 00000000000..0b93e3db00b
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ProgressBarTest.cs
@@ -0,0 +1,84 @@
+//
+// ProgressBarTest.cs: Test cases for ProgressBar.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ProgressBarBaseTest
+ {
+ [Test]
+ public void ProgressBarPropertyTest ()
+ {
+ ProgressBar myProgressBar = new ProgressBar ();
+
+ // A
+ Assert.AreEqual (false, myProgressBar.AllowDrop, "#A1");
+
+ // B
+ Assert.AreEqual ("Control", myProgressBar.BackColor.Name, "#B1");
+ myProgressBar.BackColor = Color.White;
+ Assert.AreEqual (255, myProgressBar.BackColor.R, "#B2");
+ Assert.AreEqual (null, myProgressBar.BackgroundImage, "#B3");
+ string gif = "M.gif";
+ myProgressBar.BackgroundImage = Image.FromFile (gif);
+ // comparing image objects fails on MS .Net so using Size property
+ Assert.AreEqual (Image.FromFile(gif, true).Size, myProgressBar.BackgroundImage.Size, "#B4");
+
+ // F
+ Assert.AreEqual (8.25, myProgressBar.Font.Size, "#F1");
+ Assert.AreEqual (FontStyle.Regular, myProgressBar.Font.Style, "#F2");
+ Assert.AreEqual ("ControlText", myProgressBar.ForeColor.Name, "#F3");
+
+ // M
+ Assert.AreEqual (100, myProgressBar.Maximum, "#M1");
+ Assert.AreEqual (0, myProgressBar.Minimum, "#M2");
+
+ // R
+ Assert.AreEqual (RightToLeft.No, myProgressBar.RightToLeft, "#R1");
+
+ // S
+ Assert.AreEqual (10, myProgressBar.Step, "#S1");
+
+ // T
+ Assert.AreEqual ("", myProgressBar.Text, "#T1");
+ myProgressBar.Text = "New ProgressBar";
+ Assert.AreEqual ("New ProgressBar", myProgressBar.Text, "#T2");
+
+ // V
+ Assert.AreEqual (0, myProgressBar.Value, "#V1");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ValueTest ()
+ {
+ ProgressBar myProgressBar = new ProgressBar ();
+ myProgressBar.Value = -1;
+ myProgressBar.Value = 100;
+ }
+
+ [Test]
+ public void ToStringMethodTest ()
+ {
+ ProgressBar myProgressBar = new ProgressBar ();
+ myProgressBar.Text = "New ProgressBar";
+ Assert.AreEqual ("System.Windows.Forms.ProgressBar, Minimum: 0, Maximum: 100, Value: 0", myProgressBar.ToString (), "#T3");
+ }
+ // [MonoTODO("Add test for method Increment (Visual Test)")]
+ // [MonoTODO("Add test for method PerformStep (Visual Test)")]
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RadioButtonTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RadioButtonTest.cs
new file mode 100644
index 00000000000..b16dcc70427
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RadioButtonTest.cs
@@ -0,0 +1,104 @@
+//
+// RadioRadioButtonTest.cs: Test cases for RadioRadioButton.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class RadioButtonTest
+ {
+ [Test]
+ public void RadioButtonPropertyTest ()
+ {
+ RadioButton rButton1 = new RadioButton ();
+
+ // A
+ Assert.AreEqual (Appearance.Normal, rButton1.Appearance, "#A1");
+ Assert.AreEqual (true, rButton1.AutoCheck, "#A2");
+
+ // C
+ Assert.AreEqual (false, rButton1.Checked, "#C1");
+ Assert.AreEqual (ContentAlignment.MiddleLeft, rButton1.CheckAlign, "#C2");
+
+ // S
+ Assert.AreEqual (null, rButton1.Site, "#S1");
+
+ // T
+ rButton1.Text = "New RadioButton";
+ Assert.AreEqual ("New RadioButton", rButton1.Text, "#T1");
+ Assert.AreEqual (ContentAlignment.MiddleLeft, rButton1.TextAlign, "#T2");
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ RadioButton rButton1 = new RadioButton ();
+ Assert.AreEqual ("System.Windows.Forms.RadioButton, Checked: False" , rButton1.ToString (), "#9");
+ }
+ }
+
+ [TestFixture]
+ public class RadioButtonEventTestClass
+ {
+ static bool eventhandled = false;
+ public static void RadioButton_EventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void PanelClickTest ()
+ {
+ Form myForm = new Form ();
+ RadioButton rButton1 = new RadioButton ();
+ rButton1.Select ();
+ rButton1.Visible = true;
+ myForm.Controls.Add (rButton1);
+ eventhandled = false;
+ rButton1.Click += new EventHandler (RadioButton_EventHandler);
+ myForm.Show ();
+ rButton1.PerformClick ();
+ Assert.AreEqual (true, eventhandled, "#2");
+ }
+
+ [Test]
+ public void ApperanceChangedTest ()
+ {
+ Form myForm = new Form ();
+ RadioButton rButton1 = new RadioButton ();
+ rButton1.Select ();
+ rButton1.Visible = true;
+ myForm.Controls.Add (rButton1);
+ rButton1.Appearance = Appearance.Normal;
+ eventhandled = false;
+ rButton1.AppearanceChanged += new EventHandler (RadioButton_EventHandler);
+ rButton1.Appearance = Appearance.Button;
+ Assert.AreEqual (true, eventhandled, "#2");
+ }
+
+ [Test]
+ public void CheckedChangedTest ()
+ {
+ Form myForm = new Form ();
+ RadioButton rButton1 = new RadioButton ();
+ rButton1.Select ();
+ rButton1.Visible = true;
+ myForm.Controls.Add (rButton1);
+ rButton1.Checked = false;
+ eventhandled = false;
+ rButton1.CheckedChanged += new EventHandler (RadioButton_EventHandler);
+ rButton1.Checked = true;
+ Assert.AreEqual (true, eventhandled, "#3");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RichTextBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RichTextBoxTest.cs
new file mode 100644
index 00000000000..64a74b79077
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RichTextBoxTest.cs
@@ -0,0 +1,187 @@
+//
+// RichTextBoxTest.cs: Test cases for RichTextBox.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class RichTextBoxBaseTest
+ {
+#if not
+ [Test]
+ public void RichTextBoxPropertyTest ()
+ {
+ RichTextBox rTBox = new RichTextBox ();
+
+ // A
+ Assert.AreEqual (false, rTBox.AllowDrop, "#A1");
+ rTBox.Multiline = true;
+ rTBox.AcceptsTab = true;
+ SendKeys.SendWait ("^%");
+ Assert.AreEqual (false, rTBox.AutoSize, "#A2");
+ Assert.AreEqual (false, rTBox.AutoWordSelection, "#A3");
+
+
+ // B
+ rTBox.BackColor = Color.White;
+ Assert.AreEqual (null, rTBox.BackgroundImage, "#B1");
+ string gif = "M.gif";
+ rTBox.BackgroundImage = Image.FromFile (gif);
+ // comparing image objects fails on MS .Net so using Size property
+ Assert.AreEqual (Image.FromFile(gif, true).Size, rTBox.BackgroundImage.Size, "#B2");
+ Assert.AreEqual (0, rTBox.BulletIndent, "#B3");
+
+ // C
+ Assert.AreEqual (false, rTBox.CanRedo, "#C1");
+ rTBox.Paste ();
+ Assert.AreEqual (false, rTBox.CanRedo, "#C2");
+ rTBox.ClearUndo ();
+ Assert.AreEqual (false, rTBox.CanRedo, "#C3");
+
+ // D
+ Assert.AreEqual (true, rTBox.DetectUrls, "#D1");
+
+ // F
+ Assert.AreEqual (FontStyle.Regular, rTBox.Font.Style, "#F1");
+ Assert.AreEqual ("WindowText", rTBox.ForeColor.Name, "#F2");
+
+ //M
+ Assert.AreEqual (2147483647, rTBox.MaxLength, "#M1");
+ Assert.AreEqual (true, rTBox.Multiline, "#M2");
+ rTBox.WordWrap = false;
+ Assert.AreEqual (true, rTBox.Multiline, "#M3");
+
+ // R
+ Assert.AreEqual ("", rTBox.RedoActionName, "#R1");
+ Assert.AreEqual (0, rTBox.RightMargin, "#R2");
+
+ // [MonoTODO ("Assert.AreEqual (false, rTBox.Rtf, "#R3");") ]
+
+ // S
+
+ // [MonoTODO ("Assert.AreEqual (ScrollBars.Both, rTBox.ScrollBars, "#S1");")]
+ Assert.AreEqual (RichTextBoxScrollBars.Both, rTBox.ScrollBars, "#S1");
+ Assert.AreEqual ("", rTBox.SelectedText, "#S3");
+ rTBox.Text = "sample TextBox";
+ Assert.AreEqual (HorizontalAlignment.Left, rTBox.SelectionAlignment, "#S5");
+ Assert.AreEqual (false, rTBox.SelectionBullet, "#S6");
+ Assert.AreEqual (0, rTBox.SelectionCharOffset, "#S7");
+ //Assert.AreEqual (Color.Black, rTBox.SelectionColor, "#S8"); // Random color
+ Assert.AreEqual ("Courier New", rTBox.SelectionFont.Name, "#S9a");
+ Assert.AreEqual (FontStyle.Regular, rTBox.SelectionFont.Style, "#S9b");
+ Assert.AreEqual (0, rTBox.SelectionHangingIndent, "#S10");
+ Assert.AreEqual (0, rTBox.SelectionIndent, "#S11");
+ Assert.AreEqual (0, rTBox.SelectionLength, "#S12");
+ Assert.AreEqual (false, rTBox.SelectionProtected, "#S13");
+ Assert.AreEqual (0, rTBox.SelectionRightIndent, "#S14");
+ Assert.AreEqual (false, rTBox.ShowSelectionMargin, "#S15");
+ // [MonoTODO ("Assert.AreEqual (, rTBox.SelectionTabs, "#S16");")]
+ // [MonoTODO("Assert.AreEqual (TypeCode.Empty, rTBox.SelectionType, "#S17");")]
+
+ // T
+ Assert.AreEqual ("sample TextBox", rTBox.Text, "#T1");
+ Assert.AreEqual (14, rTBox.TextLength, "#T2");
+
+ // UVW
+ Assert.AreEqual ("", rTBox.UndoActionName, "#U1");
+
+ // XYZ
+ Assert.AreEqual (1, rTBox.ZoomFactor, "#Z1");
+
+ }
+
+ [Test]
+ public void CanPasteTest ()
+ {
+ RichTextBox rTextBox = new RichTextBox ();
+ Bitmap myBitmap = new Bitmap ("M.gif");
+ Clipboard.SetDataObject (myBitmap);
+ DataFormats.Format myFormat = DataFormats.GetFormat (DataFormats.Bitmap);
+ Assert.AreEqual (true, rTextBox.CanPaste (myFormat), "#Mtd1");
+ }
+#endif
+
+ [Test]
+ public void FindCharTest ()
+ {
+ RichTextBox rTextBox = new RichTextBox ();
+ rTextBox.Text = "something";
+ Assert.AreEqual (2, rTextBox.Find (new char [] {'m'}), "#Mtd3");
+ Assert.AreEqual (-1, rTextBox.Find (new char [] {'t'},5), "#Mtd3a");
+ Assert.AreEqual (4, rTextBox.Find (new char [] {'t'},4,5), "#Mtd3b");
+ }
+
+ [Test]
+ public void FindStringTest ()
+ {
+ RichTextBox rTextBox = new RichTextBox ();
+ rTextBox.Text = "sample text for richtextbox";
+ int indexToText1 = rTextBox.Find ("for");
+ Assert.AreEqual (12, indexToText1, "#Mtd4");
+ int indexToText2 = rTextBox.Find ("for", 0, 14, RichTextBoxFinds.MatchCase);
+ Assert.AreEqual (-1, indexToText2, "#Mtd5");
+ int indexToText3 = rTextBox.Find ("for", 0, 15, RichTextBoxFinds.MatchCase);
+ Assert.AreEqual (12, indexToText3, "#Mtd6");
+ int indexToText4 = rTextBox.Find ("richtextbox", 0, RichTextBoxFinds.MatchCase);
+ Assert.AreEqual (16, indexToText4, "#Mtd7");
+ int indexToText5 = rTextBox.Find ("text", RichTextBoxFinds.MatchCase);
+ Assert.AreEqual (7, indexToText5, "#Mtd8");
+ }
+
+ [Test]
+ public void FindTest() {
+ RichTextBox t = new RichTextBox();
+
+ t.Text = "Testtext and arglblah may not be what we're looking for\n, but blah Blah is";
+
+ Assert.AreEqual(t.Find(new char[] {'b', 'l', 'a', 'h'}), 9, "Find1");
+ Assert.AreEqual(t.Find(new char[] {'b', 'l', 'a', 'h'}, 20), 20, "Find2");
+ Assert.AreEqual(t.Find(new char[] {'b', 'l', 'a', 'h'}, 25, 30), -1, "Find3");
+ Assert.AreEqual(t.Find("blah"), 17, "Find4");
+ Assert.AreEqual(t.Find("blah", 10, 30, RichTextBoxFinds.None), 17, "Find5");
+ Assert.AreEqual(t.Find("blah", 10, 30, RichTextBoxFinds.WholeWord), -1, "Find6");
+ Assert.AreEqual(t.Find("blah", 10, 30, RichTextBoxFinds.MatchCase), 17, "Find7");
+ Assert.AreEqual(t.Find("blah", 10, 70, RichTextBoxFinds.Reverse), 62, "Find8");
+ Assert.AreEqual(t.Find("blah", 10, 73, RichTextBoxFinds.Reverse), 67, "Find9");
+ Assert.AreEqual(t.Find("blah", 10, 73, RichTextBoxFinds.Reverse | RichTextBoxFinds.MatchCase), 62, "Find10");
+ Assert.AreEqual(t.Find("blah", 10, RichTextBoxFinds.None), 17, "Find11");
+ Assert.AreEqual(t.Find("blah", 10, RichTextBoxFinds.WholeWord), 62, "Find12");
+ Assert.AreEqual(t.Find("blah", 10, RichTextBoxFinds.MatchCase), 17, "Find13");
+ Assert.AreEqual(t.Find("blah", 10, RichTextBoxFinds.Reverse), 67, "Find14");
+ Assert.AreEqual(t.Find("blah", 10, RichTextBoxFinds.Reverse | RichTextBoxFinds.MatchCase), 62, "Find15");
+ Assert.AreEqual(t.Find("blah", RichTextBoxFinds.Reverse), 67, "Find16");
+ Assert.AreEqual(t.Find("blah", RichTextBoxFinds.MatchCase), 17, "Find17");
+ Assert.AreEqual(t.Find("blah", RichTextBoxFinds.WholeWord), 62, "Find18");
+
+ // Special cases
+ Assert.AreEqual(t.Find("blah", 10, 11, RichTextBoxFinds.None), -1, "Find19"); // Range to short to ever match
+ Assert.AreEqual(t.Find("blah", 17, 18, RichTextBoxFinds.None), -1, "Find20"); // Range to short to ever match, but starts matching
+ Assert.AreEqual(t.Find("is", RichTextBoxFinds.WholeWord), 72, "Find21"); // Last word in document
+ Assert.AreEqual(t.Find("for", RichTextBoxFinds.WholeWord), 52, "Find22"); // word followed by \n
+ Assert.AreEqual(t.Find("Testtext", RichTextBoxFinds.WholeWord), 0, "Find23"); // First word in document
+ Assert.AreEqual(t.Find("Testtext", RichTextBoxFinds.WholeWord | RichTextBoxFinds.Reverse), 0, "Find24"); // First word in document, searched in reverse
+ }
+
+ [Test]
+ public void GetCharFromPositionTest ()
+ {
+ Form myForm = new Form ();
+ RichTextBox rTextBox = new RichTextBox ();
+ rTextBox.Text = "sample text for richtextbox";
+ myForm.Controls.Add (rTextBox);
+ Assert.AreEqual ('m', rTextBox.GetCharFromPosition (new Point (10, 10)), "#21");
+ }
+ //[MonoTODO("Add test for method Paste (Visual Test)")]
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ScrollBarTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ScrollBarTest.cs
new file mode 100644
index 00000000000..0c0e2897a70
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ScrollBarTest.cs
@@ -0,0 +1,1453 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// Ritvik Mayank (mritvik@novell.com)
+//
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Collections;
+
+namespace MonoTests.System.Windows.Forms
+{
+
+public class MyScrollBar : HScrollBar
+ {
+ private ArrayList results = new ArrayList ();
+ public MyScrollBar () : base ()
+ {}
+
+ protected override void OnBackColorChanged (EventArgs e)
+ {
+ results.Add ("OnBackColorChanged");
+ base.OnBackColorChanged (e);
+ }
+
+ protected override void OnBackgroundImageChanged (EventArgs e)
+ {
+ results.Add ("OnBackgroundImageChanged");
+ base.OnBackgroundImageChanged (e);
+ }
+
+ protected override void OnClick (EventArgs e)
+ {
+ results.Add ("OnClick");
+ base.OnClick (e);
+ }
+
+ protected override void OnDoubleClick (EventArgs e)
+ {
+ results.Add ("OnDoubleClick");
+ base.OnDoubleClick (e);
+ }
+
+ protected override void OnFontChanged (EventArgs e)
+ {
+ results.Add ("OnFontChanged");
+ base.OnFontChanged (e);
+ }
+
+ protected override void OnForeColorChanged (EventArgs e)
+ {
+ results.Add ("OnForeColorChanged");
+ base.OnForeColorChanged (e);
+ }
+
+ protected override void OnImeModeChanged (EventArgs e)
+ {
+ results.Add ("OnImeModeChanged");
+ base.OnImeModeChanged (e);
+ }
+
+ protected override void OnMouseDown (MouseEventArgs e)
+ {
+ results.Add ("OnMouseDown");
+ base.OnMouseDown (e);
+ }
+
+ protected override void OnMouseMove (MouseEventArgs e)
+ {
+ results.Add ("OnMouseMove");
+ base.OnMouseMove (e);
+ }
+
+ protected override void OnMouseEnter (EventArgs e)
+ {
+ results.Add ("OnMouseEnter");
+ base.OnMouseEnter (e);
+ }
+
+ protected override void OnMouseLeave (EventArgs e)
+ {
+ results.Add ("OnMouseLeave");
+ base.OnMouseLeave (e);
+ }
+
+ protected override void OnMouseHover (EventArgs e)
+ {
+ results.Add ("OnMouseHover");
+ base.OnMouseHover (e);
+ }
+
+ protected override void OnMouseUp (MouseEventArgs e)
+ {
+ results.Add ("OnMouseUp");
+ base.OnMouseUp (e);
+ }
+
+ protected override void OnHandleCreated (EventArgs e)
+ {
+ results.Add ("OnHandleCreated");
+ base.OnHandleCreated (e);
+ }
+
+ protected override void OnBindingContextChanged (EventArgs e)
+ {
+ results.Add ("OnBindingContextChanged");
+ base.OnBindingContextChanged (e);
+ }
+
+ protected override void OnInvalidated (InvalidateEventArgs e)
+ {
+ results.Add("OnInvalidated");
+ base.OnInvalidated (e);
+ }
+
+ protected override void OnResize (EventArgs e)
+ {
+ results.Add("OnResize");
+ base.OnResize (e);
+ }
+
+ protected override void OnSizeChanged (EventArgs e)
+ {
+ results.Add("OnSizeChanged");
+ base.OnSizeChanged (e);
+ }
+
+ protected override void OnLayout (LayoutEventArgs e)
+ {
+ results.Add("OnLayout");
+ base.OnLayout (e);
+ }
+
+ protected override void OnVisibleChanged (EventArgs e)
+ {
+ results.Add("OnVisibleChanged");
+ base.OnVisibleChanged (e);
+ }
+
+ protected override void OnScroll (ScrollEventArgs e)
+ {
+ results.Add("OnScroll");
+ base.OnScroll (e);
+ }
+
+ protected override void OnTextChanged (EventArgs e)
+ {
+ results.Add("OnTextChanged");
+ base.OnTextChanged (e);
+ }
+
+ protected override void OnValueChanged (EventArgs e)
+ {
+ results.Add("OnValueChanged");
+ base.OnValueChanged (e);
+ }
+
+ protected override void OnPaint (PaintEventArgs e)
+ {
+ results.Add("OnPaint");
+ base.OnPaint (e);
+ }
+
+ public ArrayList Results {
+ get { return results; }
+ }
+
+ public void MoveMouse ()
+ {
+ Message m;
+
+ m = new Message ();
+
+ m.Msg = (int)WndMsg.WM_NCHITTEST;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x0;
+ m.LParam = (IntPtr)0x1c604ea;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_SETCURSOR;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x100448;
+ m.LParam = (IntPtr)0x2000001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_MOUSEFIRST;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x0;
+ m.LParam = (IntPtr)0x14000b;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_MOUSEHOVER;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x0;
+ m.LParam = (IntPtr)0x14000b;
+ this.WndProc(ref m);
+ }
+
+ public void MouseClick()
+ {
+
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_LBUTTONDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_LBUTTONUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+ }
+
+ public void MouseDoubleClick ()
+ {
+ MouseClick ();
+ MouseClick ();
+ }
+ public void MouseRightDown()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_RBUTTONDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+ }
+
+ public void MouseRightUp()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_RBUTTONUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+ }
+
+ public void ScrollNow ()
+ {
+ Message m;
+
+ m = new Message ();
+
+ m.Msg = 8468;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x1;
+ m.LParam = (IntPtr)0x1a051a;
+ this.WndProc(ref m);
+
+ m.Msg = 233;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x1;
+ m.LParam = (IntPtr)0x12eb34;
+ this.WndProc(ref m);
+ }
+ }
+ [TestFixture]
+ public class ScrollbarTest
+ {
+ [Test]
+ public void PubPropTest ()
+ {
+ MyScrollBar myscrlbar = new MyScrollBar ();
+
+ // B
+ myscrlbar.BackColor = Color.Red;
+ Assert.AreEqual (255, myscrlbar.BackColor.R, "B2");
+ myscrlbar.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+ Assert.AreEqual (16, myscrlbar.BackgroundImage.Height, "B3");
+
+ // F
+ Assert.AreEqual ("ff000000", myscrlbar.ForeColor.Name, "F1");
+
+ // I
+ //Assert.AreEqual (ImeMode.Disable, myscrlbar.ImeMode, "I1");
+
+ // L
+ Assert.AreEqual (10, myscrlbar.LargeChange, "L1");
+
+ // M
+ Assert.AreEqual (100, myscrlbar.Maximum, "M1");
+ Assert.AreEqual (0, myscrlbar.Minimum, "M2");
+ myscrlbar.Maximum = 300;
+ myscrlbar.Minimum = 100;
+ Assert.AreEqual (300, myscrlbar.Maximum, "M3");
+ Assert.AreEqual (100, myscrlbar.Minimum, "M4");
+
+ // S
+ Assert.AreEqual (null, myscrlbar.Site, "S1");
+ Assert.AreEqual (1, myscrlbar.SmallChange, "S2");
+ myscrlbar.SmallChange = 10;
+ Assert.AreEqual (10, myscrlbar.SmallChange, "S3");
+
+ // T
+ Assert.AreEqual (false, myscrlbar.TabStop, "T1");
+ myscrlbar.TabStop = true;
+ Assert.AreEqual (true, myscrlbar.TabStop, "T2");
+ Assert.AreEqual ("", myscrlbar.Text, "T3");
+ myscrlbar.Text = "MONO SCROLLBAR";
+ Assert.AreEqual ("MONO SCROLLBAR", myscrlbar.Text, "T4");
+
+ // V
+ Assert.AreEqual (100, myscrlbar.Value, "V1");
+ myscrlbar.Value = 150;
+ Assert.AreEqual (150, myscrlbar.Value, "V2");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ExceptionValueTest ()
+ {
+ MyScrollBar myscrlbar = new MyScrollBar ();
+ myscrlbar.Minimum = 10;
+ myscrlbar.Maximum = 20;
+ myscrlbar.Value = 9;
+ myscrlbar.Value = 21;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ExceptionSmallChangeTest ()
+ {
+ MyScrollBar myscrlbar = new MyScrollBar ();
+ myscrlbar.SmallChange = -1;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ExceptionLargeChangeTest ()
+ {
+ MyScrollBar myscrlbar = new MyScrollBar ();
+ myscrlbar.LargeChange = -1;
+ }
+
+ [Test, Ignore ("Look into this")]
+ public void PubMethodTest ()
+ {
+ MyScrollBar myscrlbar = new MyScrollBar ();
+ myscrlbar.Text = "New HScrollBar";
+ Assert.AreEqual ("System.Windows.Forms.HScrollBar, Minimum: 0, Maximum: 100, Value: 0",
+ myscrlbar.ToString (), "T5");
+ }
+ }
+
+ [TestFixture]
+ public class ScrollBarEventTest
+ {
+ static bool eventhandled = false;
+ public void ScrollBar_EventHandler (object sender,EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ public void ScrollBarMouse_EventHandler (object sender,MouseEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ public void ScrollBarScroll_EventHandler (object sender,ScrollEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ public void ScrollBarPaint_EventHandler (object sender,PaintEventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ [Test]
+ public void BackColorChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ScrollBar myHscrlbar = new HScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.BackColorChanged += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.BackColor = Color.Red;
+ Assert.AreEqual (true, eventhandled, "B4");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void BackgroundImageChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ScrollBar myHscrlbar = new HScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.BackgroundImageChanged += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+ Assert.AreEqual (true, eventhandled, "B5");
+ eventhandled = false;
+ }
+
+ [Test, Ignore ("Need to send proper Click / DoubleClick")]
+ public void ClickTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.Click += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.MouseClick ();
+
+ Assert.AreEqual (false, eventhandled, "C1");
+ }
+
+ [Test, Ignore ("Need to send proper Click / DoubleClick")]
+ public void DoubleClickTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.DoubleClick += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.MouseDoubleClick ();
+
+ Assert.AreEqual (false, eventhandled, "D1");
+ }
+
+ [Test]
+ public void FontChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ScrollBar myHscrlbar = new HScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.FontChanged += new EventHandler (ScrollBar_EventHandler);
+ FontDialog myFontDialog = new FontDialog();
+ myHscrlbar.Font = myFontDialog.Font;
+ Assert.AreEqual (true, eventhandled, "F2");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void ForeColorChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ScrollBar myHscrlbar = new HScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.ForeColorChanged += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.ForeColor = Color.Azure;
+ Assert.AreEqual (true, eventhandled, "F3");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void ImeModehangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ ScrollBar myHscrlbar = new HScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.ImeModeChanged += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.ImeMode = ImeMode.Katakana;
+ Assert.AreEqual (true, eventhandled, "I2");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void MouseDownTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.MouseDown += new MouseEventHandler (ScrollBarMouse_EventHandler);
+ myHscrlbar.MouseRightDown ();
+
+ Assert.AreEqual (true, eventhandled, "M5");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void MouseMoveTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.MouseMove += new MouseEventHandler (ScrollBarMouse_EventHandler);
+ myHscrlbar.MoveMouse ();
+
+ Assert.AreEqual (true, eventhandled, "M6");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void MouseUpTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.MouseUp += new MouseEventHandler (ScrollBarMouse_EventHandler);
+ myHscrlbar.MouseRightUp ();
+
+ Assert.AreEqual (true, eventhandled, "M7");
+ eventhandled = false;
+ }
+
+ [Test, Ignore ("How can we force it to pain?")]
+ public void PaintTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.Paint += new PaintEventHandler (ScrollBarPaint_EventHandler);
+
+ myHscrlbar.Refresh ();
+
+ Assert.AreEqual (true, eventhandled, "P1");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void ScrollTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.Scroll += new ScrollEventHandler (ScrollBarScroll_EventHandler);
+ myHscrlbar.ScrollNow ();
+
+ Assert.AreEqual (true, eventhandled, "S4");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void TextChangedTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.TextChanged += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.Text = "foo";
+
+ Assert.AreEqual (true, eventhandled, "T6");
+ eventhandled = false;
+ }
+
+ [Test]
+ public void ValueChangeTest ()
+ {
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar myHscrlbar = new MyScrollBar ();
+ myform.Controls.Add (myHscrlbar);
+ myHscrlbar.Value = 40 ;
+ myHscrlbar.ValueChanged += new EventHandler (ScrollBar_EventHandler);
+ myHscrlbar.Value = 50 ;
+ Assert.AreEqual (true, eventhandled, "V3");
+ eventhandled = false;
+ }
+ }
+
+public class MyHScrollBar : HScrollBar
+ {
+ public MyHScrollBar () : base ()
+ {
+ }
+
+ public Size MyDefaultSize {
+ get { return DefaultSize; }
+ }
+
+ public CreateParams MyCreateParams {
+ get { return CreateParams; }
+ }
+ }
+
+ [TestFixture]
+ public class MyHScrollBarTest
+ {
+ [Test]
+ public void ProtectedTest ()
+ {
+ MyHScrollBar msbar = new MyHScrollBar ();
+
+ Assert.AreEqual (80, msbar.MyDefaultSize.Width, "D1");
+ Assert.AreEqual (21, msbar.MyDefaultSize.Height, "D2");
+ }
+ }
+
+public class MyVScrollBar : VScrollBar
+ {
+ public MyVScrollBar () : base ()
+ {
+ }
+
+ public Size MyDefaultSize {
+ get { return DefaultSize; }
+ }
+
+ public CreateParams MyCreateParams {
+ get { return CreateParams; }
+ }
+ }
+
+ [TestFixture]
+ public class MyVScrollBarTest
+ {
+ [Test]
+ public void PubMethodTest ()
+ {
+ MyVScrollBar msbar = new MyVScrollBar ();
+
+ Assert.AreEqual (RightToLeft.No, msbar.RightToLeft, "R1");
+
+ }
+
+ [Test]
+ public void ProtMethodTest ()
+ {
+ MyVScrollBar msbar = new MyVScrollBar ();
+
+ Assert.AreEqual (21, msbar.MyDefaultSize.Width, "D3");
+ Assert.AreEqual (80, msbar.MyDefaultSize.Height, "D4");
+ }
+ }
+
+ [TestFixture]
+ public class HScrollBarTestEventsOrder
+ {
+ public string [] ArrayListToString (ArrayList arrlist)
+ {
+ string [] retval = new string [arrlist.Count];
+ for (int i = 0; i < arrlist.Count; i++)
+ retval[i] = (string)arrlist[i];
+ return retval;
+ }
+
+ [Test]
+ public void CreateEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void BackColorChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnBackColorChanged",
+ "OnInvalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.BackColor = Color.Aqua;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void BackgroundImageChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnBackgroundImageChanged",
+ "OnInvalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test, Ignore ("Need to send proper Click / DoubleClick")]
+ public void ClickEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.MouseClick ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test, Ignore ("Need to send proper Click / DoubleClick")]
+ public void DoubleClickEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.MouseDoubleClick ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void FontChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ FontDialog myFontDialog = new FontDialog();
+ s.Font = myFontDialog.Font;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ForeColorChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnForeColorChanged",
+ "OnInvalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.ForeColor = Color.Aqua;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ImeModeChangedChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnImeModeChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.ImeMode = ImeMode.Katakana;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void MouseDownEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnMouseDown"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.MouseRightDown ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void MouseMoveEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnMouseMove",
+ "OnMouseHover"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.MoveMouse ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void MouseUpEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnMouseUp"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.MouseRightUp ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void PaintEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnInvalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.Visible = true;
+ s.Refresh ();
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ScrollEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnScroll",
+ "OnValueChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.ScrollNow ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void TextChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnTextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.Text = "foobar";
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ValueChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "OnHandleCreated",
+ "OnBindingContextChanged",
+ "OnBindingContextChanged",
+ "OnValueChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar s = new MyScrollBar ();
+ myform.Controls.Add (s);
+ s.Value = 10;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+ }
+
+public class MyScrollBar2 : HScrollBar
+ {
+ protected ArrayList results = new ArrayList ();
+ public MyScrollBar2 () : base ()
+ {
+ this.HandleCreated += new EventHandler (HandleCreated_Handler);
+ this.BackColorChanged += new EventHandler (BackColorChanged_Handler);
+ this.BackgroundImageChanged += new EventHandler (BackgroundImageChanged_Handler);
+ this.BindingContextChanged += new EventHandler (BindingContextChanged_Handler);
+ this.Click += new EventHandler (Click_Handler);
+ this.DoubleClick += new EventHandler (DoubleClick_Handler);
+ this.FontChanged += new EventHandler (FontChanged_Handler);
+ this.ForeColorChanged += new EventHandler (ForeColorChanged_Handler);
+ this.ImeModeChanged += new EventHandler (ImeModeChanged_Handler);
+ this.MouseDown += new MouseEventHandler (MouseDown_Handler);
+ this.MouseMove += new MouseEventHandler (MouseMove_Handler);
+ this.MouseUp += new MouseEventHandler (MouseUp_Handler);
+ this.Invalidated += new InvalidateEventHandler (Invalidated_Handler);
+ this.Resize += new EventHandler (Resize_Handler);
+ this.SizeChanged += new EventHandler (SizeChanged_Handler);
+ this.Layout += new LayoutEventHandler (Layout_Handler);
+ this.VisibleChanged += new EventHandler (VisibleChanged_Handler);
+ this.Paint += new PaintEventHandler (Paint_Handler);
+ this.Scroll += new ScrollEventHandler (Scroll_Handler);
+ this.TextChanged += new EventHandler (TextChanged_Handler);
+ this.ValueChanged += new EventHandler (ValueChanged_Handler);
+ }
+
+ protected void HandleCreated_Handler (object sender, EventArgs e)
+ {
+ results.Add ("HandleCreated");
+ }
+
+ protected void BackColorChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("BackColorChanged");
+ }
+
+ protected void BackgroundImageChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("BackgroundImageChanged");
+ }
+
+ protected void Click_Handler (object sender, EventArgs e)
+ {
+ results.Add ("Click");
+ }
+
+ protected void DoubleClick_Handler (object sender, EventArgs e)
+ {
+ results.Add ("DoubleClick");
+ }
+
+ protected void FontChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("FontChanged");
+ }
+
+ protected void ForeColorChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("ForeColorChanged");
+ }
+
+ protected void ImeModeChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("ImeModeChanged");
+ }
+
+ protected void MouseDown_Handler (object sender, MouseEventArgs e)
+ {
+ results.Add ("MouseDown");
+ }
+
+ protected void MouseMove_Handler (object sender, MouseEventArgs e)
+ {
+ results.Add ("MouseMove");
+ }
+
+ protected void MouseUp_Handler (object sender, MouseEventArgs e)
+ {
+ results.Add ("MouseUp");
+ }
+
+ protected void BindingContextChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("BindingContextChanged");
+ }
+
+ protected void Invalidated_Handler (object sender, InvalidateEventArgs e)
+ {
+ results.Add("Invalidated");
+ }
+
+ protected void Resize_Handler (object sender, EventArgs e)
+ {
+ results.Add("Resize");
+ }
+
+ protected void SizeChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add("SizeChanged");
+ }
+
+ protected void Layout_Handler (object sender, LayoutEventArgs e)
+ {
+ results.Add("Layout");
+ }
+
+ protected void VisibleChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add("VisibleChanged");
+ }
+
+ protected void Paint_Handler (object sender, PaintEventArgs e)
+ {
+ results.Add("Paint");
+ }
+
+ protected void Scroll_Handler (object sender, ScrollEventArgs e)
+ {
+ results.Add ("Scroll");
+ }
+
+ protected void TextChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("TextChanged");
+ }
+
+ protected void ValueChanged_Handler (object sender, EventArgs e)
+ {
+ results.Add ("ValueChanged");
+ }
+
+ public ArrayList Results {
+ get { return results; }
+ }
+
+ public void MoveMouse ()
+ {
+ Message m;
+
+ m = new Message ();
+
+ m.Msg = (int)WndMsg.WM_NCHITTEST;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x0;
+ m.LParam = (IntPtr)0x1c604ea;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_SETCURSOR;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x100448;
+ m.LParam = (IntPtr)0x2000001;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_MOUSEFIRST;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x0;
+ m.LParam = (IntPtr)0x14000b;
+ this.WndProc(ref m);
+
+ m.Msg = (int)WndMsg.WM_MOUSEHOVER;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x0;
+ m.LParam = (IntPtr)0x14000b;
+ this.WndProc(ref m);
+ }
+
+ public void MouseRightDown()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_RBUTTONDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+ }
+
+ public void MouseClick()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_LBUTTONDOWN;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_LBUTTONUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+ }
+
+ public void MouseDoubleClick ()
+ {
+ MouseClick ();
+ MouseClick ();
+ }
+
+ public void MouseRightUp()
+ {
+ Message m;
+
+ m = new Message();
+
+ m.Msg = (int)WndMsg.WM_RBUTTONUP;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x01;
+ m.LParam = (IntPtr)0x9004f;
+ this.WndProc(ref m);
+ }
+
+ public void ScrollNow ()
+ {
+ Message m;
+
+ m = new Message ();
+
+ m.Msg = 8468;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x1;
+ m.LParam = (IntPtr)0x1a051a;
+ this.WndProc(ref m);
+
+ m.Msg = 233;
+ m.HWnd = this.Handle;
+ m.WParam = (IntPtr)0x1;
+ m.LParam = (IntPtr)0x12eb34;
+ this.WndProc(ref m);
+ }
+ }
+
+ [TestFixture]
+ public class HScrollBarTestEventsOrder2
+ {
+ public string [] ArrayListToString (ArrayList arrlist)
+ {
+ string [] retval = new string [arrlist.Count];
+ for (int i = 0; i < arrlist.Count; i++)
+ retval[i] = (string)arrlist[i];
+ return retval;
+ }
+
+ [Test]
+ public void CreateEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void BackColorChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated",
+ "BackColorChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.BackColor = Color.Aqua;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void BackgroundImageChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated",
+ "BackgroundImageChanged"
+
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test, Ignore ("Need to send proper Click / DoubleClick")]
+ public void ClickEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.MouseClick ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test, Ignore ("Need to send proper Click / DoubleClick")]
+ public void DoubleClickEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.MouseDoubleClick ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void FontChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ FontDialog myFontDialog = new FontDialog();
+ s.Font = myFontDialog.Font;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ForeColorChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated",
+ "ForeColorChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.ForeColor = Color.Aqua;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ImeModeChangedChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "ImeModeChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.ImeMode = ImeMode.Katakana;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void MouseDownEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "MouseDown"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.MouseRightDown ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void MouseMoveEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "MouseMove"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.MoveMouse ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void MouseUpEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "MouseUp"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.MouseRightUp ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void PaintEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Invalidated"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.Visible = true;
+ s.Refresh ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ScrollEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "Scroll",
+ "ValueChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.ScrollNow ();
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void TextChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "TextChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.Text = "foobar";
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+
+ [Test]
+ public void ValueChangedEventsOrder ()
+ {
+ string[] EventsWanted = {
+ "HandleCreated",
+ "BindingContextChanged",
+ "BindingContextChanged",
+ "ValueChanged"
+ };
+ Form myform = new Form ();
+ myform.Visible = true;
+ MyScrollBar2 s = new MyScrollBar2 ();
+ myform.Controls.Add (s);
+ s.Value = 10;
+
+ Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
+ }
+ }
+
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/StatusBarTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/StatusBarTest.cs
new file mode 100644
index 00000000000..a2bfe319124
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/StatusBarTest.cs
@@ -0,0 +1,75 @@
+//
+// StatusBarTest.cs: Test cases for StatusBar.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Runtime.Remoting;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class StatusBarTest
+ {
+
+ [Test]
+ public void StatusBarPropertyTest ()
+ {
+ Form myform = new Form ();
+ StatusBar mysbar = new StatusBar ();
+ StatusBarPanel sbarpanel1 = new StatusBarPanel ();
+ StatusBarPanel sbarpanel2 = new StatusBarPanel ();
+ sbarpanel1.Text = "Status Quo";
+ sbarpanel2.Text = "State 2";
+ mysbar.Panels.Add (sbarpanel1);
+ mysbar.Panels.Add (sbarpanel2);
+ myform.Controls.Add (mysbar);
+
+ // B
+ Assert.AreEqual ("Control", mysbar.BackColor.Name, "#B1");
+ mysbar.BackColor = Color.Red;
+ Assert.AreEqual (212, mysbar.BackColor.R, "#B2");
+ mysbar.BackgroundImage = Image.FromFile ("M.gif");
+ Assert.AreEqual (60, mysbar.BackgroundImage.Height, "#B3");
+
+ // D
+ Assert.AreEqual (DockStyle.Bottom, mysbar.Dock, "#D1");
+
+ // F
+ Assert.AreEqual (8.25, mysbar.Font.Size, "#F1");
+ Assert.AreEqual ("ControlText", mysbar.ForeColor.Name, "#F2");
+
+ // P
+ Assert.AreEqual (sbarpanel1.Text, mysbar.Panels [0].Text , "#P1");
+
+ // S
+ Assert.AreEqual (false, mysbar.ShowPanels, "#S1");
+ Assert.AreEqual (true, mysbar.SizingGrip, "#S2");
+ Assert.AreEqual (null, mysbar.Site, "#S3");
+
+ // T
+ Assert.AreEqual ("", mysbar.Text, "#T1");
+ mysbar.Text = "MONO STATUSBAR";
+ Assert.AreEqual ("MONO STATUSBAR", mysbar.Text, "#T2");
+
+ }
+
+ [Test]
+ public void ToStringMethodTest ()
+ {
+ StatusBar mysbar = new StatusBar ();
+ mysbar.Text = "New StatusBar";
+ Assert.AreEqual ("System.Windows.Forms.StatusBar, Panels.Count: 0", mysbar.ToString (), "#T3");
+ }
+ //[MonoTODO ("Test case for DrawItem")]
+ //[MonoTODO ("Test case for PanelClick")]
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TabControlTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TabControlTest.cs
new file mode 100644
index 00000000000..ede33a91594
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TabControlTest.cs
@@ -0,0 +1,87 @@
+//
+// TabControlTest.cs: Test cases for TabControl.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+[TestFixture]
+public class TabControlTest
+{
+ [Test]
+ public void TabControlPropertyTest ()
+ {
+ Form myForm = new Form ();
+ TabControl myTabControl = new TabControl ();
+ myTabControl.Visible = true;
+ myTabControl.Name = "Mono TabControl";
+
+ // A
+ Assert.AreEqual (TabAlignment.Top, myTabControl.Alignment, "A1");
+ Assert.AreEqual (TabAppearance.Normal, myTabControl.Appearance, "#A2");
+
+ // D
+ Assert.AreEqual (4, myTabControl.DisplayRectangle.X, "#D1");
+ Assert.AreEqual (4, myTabControl.DisplayRectangle.Y, "#D2");
+ Assert.AreEqual (192, myTabControl.DisplayRectangle.Width, "#D3");
+ Assert.AreEqual (92, myTabControl.DisplayRectangle.Height, "#D4");
+ Assert.AreEqual (TabDrawMode.Normal, myTabControl.DrawMode, "#D5");
+
+ // H
+ Assert.AreEqual (false, myTabControl.HotTrack, "#H1");
+
+ // I
+ Assert.AreEqual (null, myTabControl.ImageList, "#I1");
+ Assert.AreEqual (18, myTabControl.ItemSize.Height, "#I2");
+ Assert.AreEqual (0, myTabControl.ItemSize.Width, "#I3");
+
+ // M
+ Assert.AreEqual (false, myTabControl.Multiline, "#M1");
+
+ // P
+ Assert.AreEqual (6, myTabControl.Padding.X, "#P1");
+ Assert.AreEqual (3, myTabControl.Padding.Y, "#P1");
+
+ // R
+ Assert.AreEqual (0, myTabControl.RowCount, "#R1");
+
+ // S
+ Assert.AreEqual (-1, myTabControl.SelectedIndex, "#S1");
+ Assert.AreEqual (null, myTabControl.SelectedTab, "#S2");
+ Assert.AreEqual (false, myTabControl.ShowToolTips, "#S3");
+ Assert.AreEqual (TabSizeMode.Normal, myTabControl.SizeMode, "#S4");
+
+ // T
+ Assert.AreEqual (0, myTabControl.TabCount, "#T1");
+ Assert.AreEqual (0, myTabControl.TabPages.Count, "#T2");
+ }
+
+ [Test]
+ public void GetTabRectTest ()
+ {
+ TabControl myTabControl = new TabControl ();
+ TabPage myTabPage = new TabPage();
+ myTabControl.Controls.Add(myTabPage);
+ myTabPage.TabIndex = 0;
+ Rectangle myTabRect = new Rectangle ();
+ Assert.AreEqual (2, myTabControl.GetTabRect (0).X, "#GetT1");
+ Assert.AreEqual (2, myTabControl.GetTabRect (0).Y, "#GetT2");
+ Assert.AreEqual (42, myTabControl.GetTabRect (0).Width, "#GetT3");
+ Assert.AreEqual (18, myTabControl.GetTabRect (0).Height, "#GetT4");
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ TabControl myTabControl = new TabControl ();
+ Assert.AreEqual ("System.Windows.Forms.TabControl, TabPages.Count: 0", myTabControl.ToString(), "#Str1");
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TestImageIndexConverter.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TestImageIndexConverter.cs
new file mode 100644
index 00000000000..679dcef4ea2
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TestImageIndexConverter.cs
@@ -0,0 +1,157 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2004 Novell, Inc.
+//
+// Authors:
+// Ravindra (rkumar@novell.com)
+//
+//
+
+using NUnit.Framework;
+using System;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Globalization;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ImageIndexConverterTest
+ {
+ ToolBarButton button;
+ PropertyDescriptorCollection pdc;
+ ImageIndexConverter ic;
+
+ public ImageIndexConverterTest ()
+ {
+ button = new ToolBarButton ();
+ pdc = TypeDescriptor.GetProperties (button);
+ ic = (ImageIndexConverter) pdc.Find ("ImageIndex", true).Converter;
+ }
+
+ [TearDown]
+ public void TearDown () { }
+
+ [SetUp]
+ public void SetUp () { }
+
+ [Test]
+ public void TestCanConvertFrom ()
+ {
+ Assert.IsFalse (ic.CanConvertFrom (typeof (byte)), "CanConvertFromByte must be false.");
+ Assert.IsFalse (ic.CanConvertFrom (typeof (char)), "CanConvertFromChar must be false.");
+ Assert.IsFalse (ic.CanConvertFrom (typeof (int)), "CanConvertFromInt must be false.");
+ Assert.IsFalse (ic.CanConvertFrom (typeof (float)), "CanConvertFromFloat must be false.");
+ Assert.IsFalse (ic.CanConvertFrom (typeof (long)), "CanConvertFromLong must be false.");
+ Assert.IsFalse (ic.CanConvertFrom (typeof (double)), "CanConvertFromDouble must be false.");
+ Assert.IsTrue (ic.CanConvertFrom (typeof (string)), "CanConvertFromString must be true.");
+ Assert.IsFalse (ic.CanConvertFrom (typeof (object)), "CanConvertFromObject must be false.");
+ }
+
+ [Test]
+ public void TestCanConvertTo ()
+ {
+ Assert.IsTrue (ic.CanConvertTo (typeof (byte)), "CanConvertToByte must be true.");
+ Assert.IsTrue (ic.CanConvertTo (typeof (char)), "CanConvertToChar must be true.");
+ Assert.IsTrue (ic.CanConvertTo (typeof (int)), "CanConvertToInt must be true.");
+ Assert.IsTrue (ic.CanConvertTo (typeof (float)), "CanConvertToFloat must be true.");
+ Assert.IsTrue (ic.CanConvertTo (typeof (long)), "CanConvertToLong must be true.");
+ Assert.IsTrue (ic.CanConvertTo (typeof (double)), "CanConvertToDouble must be true.");
+ Assert.IsTrue (ic.CanConvertTo (typeof (string)), "CanConvertToString must be true.");
+ Assert.IsFalse (ic.CanConvertTo (typeof (object)), "CanConvertToObject must be false.");
+ }
+
+ [Test]
+ public void TestConvertFrom ()
+ {
+ Assert.AreEqual (-12, (int) ic.ConvertFrom (null, CultureInfo.InvariantCulture, "-12"), "ConvertFromStr -12");
+ Assert.AreEqual (-1, (int) ic.ConvertFrom (null, CultureInfo.InvariantCulture, "-1"), "ConvertFromStr -1");
+ Assert.AreEqual (1, (int) ic.ConvertFrom (null, CultureInfo.InvariantCulture, "1"), "ConvertFromStr 1");
+
+ try {
+ ic.ConvertFrom (null, CultureInfo.InvariantCulture, 1.2f);
+ Assert.Fail ("ConvertFromFloat did not throw exception.");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "ConvertFromFloat did not throw NotSupportedException.");
+ }
+
+ try {
+ ic.ConvertFrom (null, CultureInfo.InvariantCulture, 1);
+ Assert.Fail ("ConvertFromInt did not throw exception.");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "ConvertFromInt did not throw NotSupportedException.");
+ }
+ }
+
+ [Test]
+ public void TestConvertTo ()
+ {
+ Assert.AreEqual ("(none)", ic.ConvertTo (null, CultureInfo.InvariantCulture, -1, typeof (string)), "ConvertInt_Minus1_ToStr");
+ Assert.AreEqual ("0", ic.ConvertTo (null, CultureInfo.InvariantCulture, 0, typeof (string)), "ConvertInt_0_ToStr");
+ Assert.AreEqual ("1", ic.ConvertTo (null, CultureInfo.InvariantCulture, 1, typeof (string)), "ConvertInt_1_ToStr");
+ Assert.AreEqual (0, ic.ConvertTo (null, CultureInfo.InvariantCulture, 0, typeof (int)), "ConvertInt_0_ToInt");
+ Assert.AreEqual ("(none)", ic.ConvertTo (null, CultureInfo.InvariantCulture, "(none)", typeof (string)), "ConvertStr_none_ToStr");
+ Assert.AreEqual ("-1", ic.ConvertTo (null, CultureInfo.InvariantCulture, "-1", typeof (string)), "ConvertStr_Minus1_ToStr");
+ Assert.AreEqual (-1, ic.ConvertTo (null, CultureInfo.InvariantCulture, -1, typeof (int)), "ConvertInt_Minus1_ToInt");
+ Assert.AreEqual (1, ic.ConvertTo (null, CultureInfo.InvariantCulture, 1, typeof (int)), "ConvertInt_1_ToInt");
+ Assert.AreEqual (-1, ic.ConvertTo (null, CultureInfo.InvariantCulture, "-1", typeof (int)), "ConvertStr_Minus1_ToInt");
+ Assert.AreEqual (0, ic.ConvertTo (null, CultureInfo.InvariantCulture, "0", typeof (int)), "ConvertStr_0_ToInt");
+ Assert.AreEqual (1, ic.ConvertTo (null, CultureInfo.InvariantCulture, "1", typeof (int)), "ConvertStr_1_ToInt");
+
+ Assert.AreEqual (2, ic.ConvertTo (null, CultureInfo.InvariantCulture, 1.5f, typeof (int)), "ConvertFloat_1_5_ToInt must return 2.");
+
+ try {
+ ic.ConvertTo (null, CultureInfo.InvariantCulture, "-1.5f", typeof (int));
+ Assert.Fail("ConvertFloatStrToInt must throw exception.");
+ } catch (Exception e) {
+ Assert.IsTrue (e is FormatException, "ConvertFloatStrToInt must throw FormatException.");
+ }
+
+ Assert.AreEqual (1.5, ic.ConvertTo (null, CultureInfo.InvariantCulture, 1.5f, typeof (float)), "ConvertFloat_1_5_ToFloat");
+ }
+
+ [Test]
+ public void TestGetCreateInstanceSupported ()
+ {
+ Assert.IsFalse (ic.GetCreateInstanceSupported (), "GetCreateInstance must return false.");
+ }
+
+ [Test]
+ public void TestGetStandardValuesSupported ()
+ {
+ Assert.IsTrue (ic.GetStandardValuesSupported (), "GetStandardValuesSupported must return true.");
+ }
+
+ [Test]
+ public void TestGetStandardValuesExclusive ()
+ {
+ Assert.IsFalse (ic.GetStandardValuesExclusive (), "GetStandardValuesExclusive must return false.");
+ }
+
+ [Test]
+ public void TestGetStandardValues ()
+ {
+ TypeConverter.StandardValuesCollection stdVals = ic.GetStandardValues (null);
+ Assert.AreEqual (1, stdVals.Count, "StandardValues count must be 1.");
+ Assert.AreEqual (-1, stdVals [0], "Standard Value count must be -1.");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs
new file mode 100644
index 00000000000..c7b6e66aefd
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs
@@ -0,0 +1,191 @@
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Authors:
+// Ritvik Mayank (mritvik@novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class TextBoxBaseTest
+ {
+ [Test]
+ public void TextBoxBasePropertyTest ()
+ {
+ TextBox tb = new TextBox ();
+ Assert.AreEqual (false, tb.AcceptsTab, "#1a");
+ tb.Multiline = true;
+ tb.AcceptsTab = true;
+ SendKeys.SendWait ("^%");
+ Assert.AreEqual (true, tb.AcceptsTab, "#1b");
+ Assert.AreEqual (true, tb.AutoSize, "#2");
+ Assert.AreEqual ("Window", tb.BackColor.Name, "#3a");
+ tb.BackColor = Color.White;
+ Assert.AreEqual ("White", tb.BackColor.Name, "#3b");
+ Assert.AreEqual (null, tb.BackgroundImage, "#4a");
+ string gif = "M.gif";
+ tb.BackgroundImage = Image.FromFile (gif);
+ // comparing image objects fails on MS .Net so using Size property
+ Assert.AreEqual (Image.FromFile(gif, true).Size, tb.BackgroundImage.Size, "#4b");
+
+ Assert.AreEqual (BorderStyle.Fixed3D, tb.BorderStyle, "#5");
+ Assert.AreEqual (false, tb.CanUndo, "#6a");
+ tb.Paste ();
+ Assert.AreEqual (true, tb.CanUndo, "#6b");
+ tb.ClearUndo ();
+ Assert.AreEqual (false, tb.CanUndo, "#6c");
+ Assert.AreEqual ("WindowText", tb.ForeColor.Name, "#7");
+ Assert.AreEqual (true, tb.HideSelection, "#8");
+ Assert.AreEqual (1, tb.Lines.Length, "#9");
+ Assert.AreEqual (32767, tb.MaxLength, "#10");
+ Assert.AreEqual (true, tb.Modified, "#11");
+ Assert.AreEqual (true, tb.Multiline, "#12a");
+ tb.WordWrap = false;
+ Assert.AreEqual (true, tb.Multiline, "#12b");
+ tb.AcceptsReturn = true;
+ Assert.AreEqual (true, tb.Multiline, "#12c");
+ Assert.AreEqual (20, tb.PreferredHeight, "#13");
+ Assert.AreEqual (false, tb.ReadOnly, "#14");
+ Assert.AreEqual ("", tb.SelectedText, "#15");
+ tb.Text = "sample TextBox";
+ Assert.AreEqual (0, tb.SelectionLength, "#16b");
+ Assert.AreEqual (0, tb.SelectionStart, "#17");
+ tb.WordWrap = false;
+ tb.AcceptsReturn = true;
+ Assert.AreEqual ("sample TextBox", tb.Text, "#18");
+ Assert.AreEqual (14, tb.TextLength, "#19");
+ Assert.AreEqual (false, tb.WordWrap, "#20");
+ }
+
+ [Test]
+ public void TextBoxPropertyTest ()
+ {
+ TextBox tb = new TextBox ();
+ Assert.AreEqual (false, tb.AcceptsReturn, "#21");
+ Assert.AreEqual (CharacterCasing.Normal, tb.CharacterCasing, "#22");
+ Assert.AreEqual ('\0', tb.PasswordChar, "#23");
+ tb.PasswordChar = '*';
+ Assert.AreEqual ('*', tb.PasswordChar, "#23b");
+ Assert.AreEqual (ScrollBars.None, tb.ScrollBars, "#24");
+ Assert.AreEqual (-1, tb.SelectionLength, "#25");
+ Assert.AreEqual (HorizontalAlignment.Left , tb.TextAlign, "#26");
+ }
+
+ [Test]
+ public void AppendTextTest ()
+ {
+ Form f = new Form ();
+ f.Visible = true;
+ TextBox tb1 = new TextBox ();
+ tb1.Visible = true;
+ tb1.Text = "TextBox1";
+ TextBox tb2 = new TextBox ();
+ tb2.Visible = true;
+ f.Controls.Add (tb1);
+ f.Controls.Add (tb2);
+ tb2.AppendText (tb1.Text);
+ Assert.AreEqual ("TextBox1", tb2.Text, "#27");
+ }
+
+ [Test]
+ public void ClearTest ()
+ {
+ TextBox tb1 = new TextBox ();
+ tb1.Text = "TextBox1";
+ Assert.AreEqual ("TextBox1", tb1.Text, "#28a" );
+ tb1.Clear ();
+ Assert.AreEqual ("", tb1.Text, "#28b");
+ }
+
+ [Test]
+ public void ClearUndoTest ()
+ {
+ TextBox tb1 = new TextBox ();
+ tb1.Text = "TextBox1";
+ tb1.SelectionLength = 4;
+ tb1.Copy ();
+ Assert.AreEqual ("Text", tb1.SelectedText, "#29a");
+ tb1.Paste ();
+ Assert.AreEqual (true, tb1.CanUndo, "#29b");
+ tb1.ClearUndo ();
+ Assert.AreEqual (false, tb1.CanUndo, "#29c");
+ }
+
+ [Test]
+ public void CopyTest ()
+ {
+ TextBox tb1 = new TextBox ();
+ tb1.Text = "ABCDE";
+ tb1.SelectionLength = 4;
+ tb1.Copy ();
+ Assert.AreEqual ("ABCD", tb1.SelectedText, "#30");
+ }
+
+ [Test]
+ public void CutTest ()
+ {
+ TextBox tb1 = new TextBox ();
+ tb1.Text = "ABCDE";
+ tb1.SelectionLength = 4;
+ tb1.Cut ();
+ Assert.AreEqual ("E", tb1.Text, "#31");
+ }
+
+ [Test]
+ public void PasteTest ()
+ {
+ TextBox tb1 = new TextBox ();
+ tb1.Text = "ABCDE";
+ tb1.SelectionLength = 4;
+ tb1.SelectionStart = tb1.SelectionStart + tb1.SelectionLength;
+ tb1.Paste ();
+ Assert.AreEqual ("ABCDABCD", tb1.Text, "#32");
+ }
+
+ [Test]
+ public void SelectTest ()
+ {
+ TextBox tb1 = new TextBox ();
+ tb1.Text = "This is a sample test.";
+ tb1.Select (0, 4);
+ Assert.AreEqual ("This", tb1.SelectedText, "#33");
+ }
+
+ [Test]
+ public void SelectAllTest ()
+ {
+ TextBox tb1 = new TextBox ();
+ tb1.Text = "This is a sample test.";
+ tb1.SelectAll ();
+ Assert.AreEqual ("This is a sample test.", tb1.SelectedText, "#34");
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ TextBox tb1 = new TextBox ();
+ Assert.AreEqual ("System.Windows.Forms.TextBox, Text: ", tb1.ToString(), "#35");
+ }
+
+ [Test]
+ public void UndoTest1 ()
+ {
+ TextBox tb1 = new TextBox ();
+ tb1.Text = "ABCDE";
+ tb1.SelectionLength = 4;
+ tb1.Copy ();
+ tb1.SelectionStart = tb1.SelectionStart + tb1.SelectionLength;
+ tb1.Paste ();
+ tb1.Undo ();
+ Assert.AreEqual ("ABCDE", tb1.Text, "#36");
+ }
+
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolBarTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolBarTest.cs
new file mode 100644
index 00000000000..271671a0825
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolBarTest.cs
@@ -0,0 +1,97 @@
+//
+// ToolBarTest.cs: Test cases for ToolBar.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Runtime.Remoting;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ [Ignore ("This test has to be completly reviewed")]
+ public class ToolBarTest
+ {
+
+ [Test]
+ public void ToolBarPropertyTest ()
+ {
+ Form myform = new Form ();
+ 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.BackColor = Color.Red;
+ Assert.AreEqual (255, myToolBar.BackColor.R, "#B2");
+ 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");
+ Assert.AreEqual (39, myToolBar.ButtonSize.Width, "#B8");
+ Assert.AreEqual (36, myToolBar.ButtonSize.Height, "#B9");
+
+ // 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");
+ }
+
+ [Test]
+ public void ToStringMethodTest ()
+ {
+ ToolBar myToolBar = new ToolBar ();
+ myToolBar.Text = "New ToolBar";
+ Assert.AreEqual ("System.Windows.Forms.ToolBar, Buttons.Count: 0", myToolBar.ToString (), "#T3");
+ }
+ }
+ // [MonoTODO ("Add test for ButtonClickEvent (Visual Test)"]
+ // [MonoTODO ("Add test for ButtonDropDownEvent (Visual Test)"]
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolTipTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolTipTest.cs
new file mode 100644
index 00000000000..8287bf30ccf
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolTipTest.cs
@@ -0,0 +1,71 @@
+//
+// ToolTipTest.cs: Test cases for ToolTip.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Runtime.Remoting;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class ToolTipTest
+ {
+
+ [Test]
+ public void ToolTipPropertyTest ()
+ {
+ ToolTip myToolTip = new ToolTip ();
+
+ // A
+ Assert.AreEqual (true, myToolTip.Active, "#A1");
+ Assert.AreEqual (5000, myToolTip.AutoPopDelay, "#A2");
+ Assert.AreEqual (5000, myToolTip.AutoPopDelay, "#A3");
+
+ // I
+ Assert.AreEqual (500, myToolTip.InitialDelay, "#I1");
+
+ // R
+ Assert.AreEqual (100, myToolTip.ReshowDelay, "#R1");
+
+ // S
+ Assert.AreEqual (false, myToolTip.ShowAlways, "#S1");
+ }
+
+ [Test]
+ public void GetAndSetToolTipTest ()
+ {
+ ToolTip myToolTip = new ToolTip ();
+ Button myButton = new Button ();
+ myToolTip.ShowAlways = true;
+ myToolTip.SetToolTip (myButton, "My Button");
+ string myString = myToolTip.GetToolTip (myButton);
+ Assert.AreEqual ("My Button", myString, "#Mtd1");
+ }
+
+ [Test]
+ public void RemoveToolTipTest ()
+ {
+ ToolTip myToolTip = new ToolTip ();
+ Button myButton = new Button ();
+ myToolTip.ShowAlways = true;
+ myToolTip.SetToolTip (myButton, "My Button");
+ myToolTip.RemoveAll ();
+ Assert.AreEqual ("", myToolTip.GetToolTip (myButton), "#Mtd2");
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ ToolTip myToolTip = new ToolTip ();
+ Assert.AreEqual ("System.Windows.Forms.ToolTip InitialDelay: 500, ShowAlways: False", myToolTip.ToString (), "#Mtd3");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TrackBarTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TrackBarTest.cs
new file mode 100644
index 00000000000..ad36f4712ba
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TrackBarTest.cs
@@ -0,0 +1,79 @@
+//
+// TrackBarTest.cs: Test cases for TrackBar.
+//
+// Author:
+// Ritvik Mayank (mritvik@novell.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class TrackBarBaseTest
+ {
+ [Test]
+ public void TrackBarPropertyTest ()
+ {
+ TrackBar myTrackBar = new TrackBar ();
+
+ // A
+ Assert.AreEqual (true, myTrackBar.AutoSize, "#A1");
+
+ // L
+ Assert.AreEqual (5, myTrackBar.LargeChange, "#L1");
+
+ // M
+ Assert.AreEqual (10, myTrackBar.Maximum, "#M1");
+ Assert.AreEqual (0, myTrackBar.Minimum, "#M2");
+
+ // O
+ Assert.AreEqual (Orientation.Horizontal, myTrackBar.Orientation, "#O1");
+
+ // S
+ Assert.AreEqual (1, myTrackBar.SmallChange, "#S1");
+
+ // T
+ Assert.AreEqual (1, myTrackBar.TickFrequency, "#T1");
+ Assert.AreEqual (TickStyle.BottomRight, myTrackBar.TickStyle, "#T2");
+ Assert.AreEqual ("", myTrackBar.Text, "#T3");
+ myTrackBar.Text = "New TrackBar";
+ Assert.AreEqual ("New TrackBar", myTrackBar.Text, "#T4");
+
+ // V
+ Assert.AreEqual (0, myTrackBar.Value, "#V1");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void LargeChangeTest ()
+ {
+ TrackBar myTrackBar = new TrackBar ();
+ myTrackBar.LargeChange = -1;
+ }
+
+ [Test]
+ public void SetRangeTest ()
+ {
+ TrackBar myTrackBar = new TrackBar ();
+ myTrackBar.SetRange (2,9);
+ Assert.AreEqual (9, myTrackBar.Maximum, "#setM1");
+ Assert.AreEqual (2, myTrackBar.Minimum, "#setM2");
+ }
+
+ [Test]
+ public void ToStringMethodTest ()
+ {
+ TrackBar myTrackBar = new TrackBar ();
+ myTrackBar.Text = "New TrackBar";
+ Assert.AreEqual ("System.Windows.Forms.TrackBar, Minimum: 0, Maximum: 10, Value: 0", myTrackBar.ToString (), "#T3");
+ }
+ }
+}
+
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeNodeTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeNodeTest.cs
new file mode 100644
index 00000000000..d269db9c720
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeNodeTest.cs
@@ -0,0 +1,162 @@
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using SystemDrawingNamespace = System.Drawing;
+
+namespace MonoTests.System.Windows.Forms {
+
+
+ [TestFixture]
+ public class TreeNodeTest {
+
+ [Test]
+ public void EmptyCtorTest ()
+ {
+ TreeNode tn = new TreeNode ();
+ Assert.AreEqual ("", tn.Text, "#1");
+ Assert.AreEqual (0, tn.Nodes.Count, "#2");
+ Assert.AreEqual (-1, tn.ImageIndex, "#3");
+ Assert.AreEqual (-1, tn.SelectedImageIndex, "#4");
+
+ // Set simple properties
+ tn.Text = null;
+ Assert.AreEqual ("", tn.Text, "#5");
+ tn.ImageIndex = 67;
+ Assert.AreEqual (67, tn.ImageIndex, "#6");
+ tn.SelectedImageIndex = 99;
+ Assert.AreEqual (99, tn.SelectedImageIndex, "#7");
+ }
+
+ [Test]
+ public void CtorTest () {
+ TreeNode tn = new TreeNode ("label1");
+
+ Assert.AreEqual ("label1", tn.Text);
+ Assert.AreEqual (0, tn.Nodes.Count);
+ Assert.AreEqual (-1, tn.ImageIndex, "II");
+ Assert.AreEqual (-1, tn.SelectedImageIndex, "SI");
+
+ Assert.IsNull (tn.FirstNode);
+ Assert.IsNull (tn.LastNode);
+ Assert.AreEqual ("", new TreeNode (null).Text);
+ }
+
+ [Test]
+ public void CtorTest2 ()
+ {
+ TreeNode tn = new TreeNode ("a1", new TreeNode[] { new TreeNode ("aa1"), new TreeNode ("aa2") } );
+
+ Assert.AreEqual ("a1", tn.Text);
+ Assert.AreEqual (-1, tn.ImageIndex, "II");
+ Assert.AreEqual (-1, tn.SelectedImageIndex, "SI");
+
+ Assert.AreEqual ("aa1", tn.Nodes [0].Text, "#1");
+ Assert.AreEqual ("aa2", tn.Nodes [1].Text, "#2");
+ Assert.AreSame (tn.FirstNode, tn.Nodes [0], "#3");
+ Assert.AreSame (tn.LastNode, tn.Nodes [1], "#4");
+ }
+
+ [Test]
+ public void CtorTest3 ()
+ {
+ TreeNode tn = new TreeNode ("a", 5, 9);
+
+ Assert.AreEqual ("a", tn.Text);
+ Assert.IsNotNull (tn.Nodes);
+ Assert.AreEqual (5, tn.ImageIndex);
+ Assert.AreEqual (9, tn.SelectedImageIndex);
+ Assert.AreEqual ("", new TreeNode (null, 0, 0).Text);
+ }
+
+ [Test, ExpectedException (typeof (ArgumentNullException))]
+ public void CtorException1 ()
+ {
+ new TreeNode ("", 1, 1, null);
+ }
+
+ [Test, ExpectedException (typeof (ArgumentNullException))]
+ public void CtorException2 () {
+ new TreeNode ("tt", null);
+ }
+
+ [Test]
+ public void Traverse ()
+ {
+ TreeNode tn_1 = new TreeNode ("1");
+ TreeNode tn_2 = new TreeNode ("2");
+ TreeNode tn_3 = new TreeNode ("3");
+ TreeNode tn = new TreeNode ("lev1");
+ tn.Nodes.Add (tn_1);
+ Assert.AreSame (tn, tn_1.Parent, "#1");
+ Assert.IsNull (tn_1.NextNode, "#2");
+ Assert.AreEqual (0, tn_1.Parent.Index, "#3");
+ tn.Nodes.Add (tn_2);
+ Assert.IsNull (tn_1.NextNode.NextNode, "#33");
+ tn.Nodes.Add (tn_3);
+ Assert.AreEqual (2, tn_3.Index, "#4");
+
+ Assert.AreEqual (3, tn.Nodes.Count, "#5");
+ Assert.AreSame (tn_2, tn_2.NextNode.PrevNode, "#6");
+ Assert.IsNull (tn_1.PrevNode, "#7");
+ }
+
+ [Test, ExpectedException (typeof (Exception))]
+ public void FullPathException ()
+ {
+ string s = new TreeNode ("").FullPath;
+ // Prevent CS0219, will never write anything
+ // due to previous statement throwing Exception
+ Console.WriteLine(s);
+ }
+
+ [Test]
+ public void FullPathTest ()
+ {
+ TreeNode tn_1 = new TreeNode ("A");
+ TreeNode tn_2 = new TreeNode ("B");
+ tn_2.Nodes.Add (tn_1);
+
+ TreeView tv = new TreeView ();
+ tv.Nodes.Add (tn_1);
+ tv.Nodes [0].Nodes.Add (tn_2);
+
+ Assert.AreEqual ("A", tn_1.FullPath, "#1");
+ Assert.AreEqual ("A", tv.Nodes[0].FullPath, "#2");
+ Assert.AreEqual (@"A\B", tn_2.FullPath, "#3");
+ tv.PathSeparator = "_separator_";
+ Assert.AreEqual ("A_separator_B", tn_2.FullPath, "#4");
+ }
+
+ [Test]
+ public void CloneTest ()
+ {
+ TreeNode orig = new TreeNode ("text", 2, 3, new TreeNode [] { new TreeNode ("child", 22, 33) });
+ orig.Tag = FlatStyle.Flat;
+ orig.Checked = true;
+ orig.BackColor = SystemDrawingNamespace.Color.AliceBlue;
+ orig.ForeColor = SystemDrawingNamespace.Color.Beige;
+
+ TreeNode clone = (TreeNode)orig.Clone ();
+ Assert.AreEqual ("text", clone.Text, "#1");
+ Assert.AreEqual (2, clone.ImageIndex, "#2");
+ Assert.AreEqual (3, clone.SelectedImageIndex, "#3");
+ Assert.AreEqual (1, clone.Nodes.Count, "#4");
+ Assert.AreEqual (FlatStyle.Flat, clone.Tag, "#5");
+ Assert.IsTrue (clone.Checked, "#6");
+ Assert.AreEqual ("child", clone.Nodes [0].Text, "#10");
+ Assert.AreEqual (22, clone.Nodes [0].ImageIndex, "#11");
+ Assert.AreEqual (SystemDrawingNamespace.Color.AliceBlue, clone.BackColor, "#12");
+ Assert.AreEqual (SystemDrawingNamespace.Color.Beige, clone.ForeColor, "#13");
+ }
+
+ [Test]
+ public void SingleNodeIndexTest ()
+ {
+ TreeNode tn_1 = new TreeNode ("A");
+ Assert.AreEqual (0, tn_1.Index, "#1");
+ TreeView tv = new TreeView ();
+ tv.Nodes.Add (tn_1);
+ Assert.AreEqual (0, tn_1.Index, "#2");
+ }
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeViewTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeViewTest.cs
new file mode 100644
index 00000000000..226fccf1774
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeViewTest.cs
@@ -0,0 +1,34 @@
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+using System.Drawing;
+
+[TestFixture]
+public class TreeViewTest {
+
+ [Test]
+ [Ignore ("This test has to be completly reviewed")]
+ public void DefaultCtor ()
+ {
+ TreeView tv = new TreeView ();
+ Assert.AreEqual (121, tv.Width, "#1");
+ Assert.AreEqual (97, tv.Height, "#2");
+ //Assert.AreEqual (BorderStyle.Fixed3D, tv.BorderStyle, "#3");
+
+ // Windows specific
+ Assert.AreEqual (SystemColors.Window, tv.BackColor);
+ }
+
+ [Test]
+ public void SimpleShowTest ()
+ {
+ Form f = new Form ();
+ TreeView tv = new TreeView ();
+ //tv.BorderStyle = BorderStyle.FixedSingle;
+ tv.Location = new Point (20, 20);
+ //tv.Text = "adssssss";
+
+ f.Controls.Add (tv);
+ f.Show ();
+ }
+}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/bitmaps/a.png b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/bitmaps/a.png
new file mode 100644
index 00000000000..c3eb05e9767
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/bitmaps/a.png
Binary files differ
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/tests-ms.sh b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/tests-ms.sh
new file mode 100755
index 00000000000..a3fe29033b4
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/tests-ms.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+if [ $# -eq 0 ]; then
+ echo "You should give a list of test names such as: "
+ echo "$0 System.Windows.Forms.ListViewItemTest"
+ echo "or"
+ echo "$0 all"
+ exit 1
+fi
+
+export MSNet=Yes
+cp ../../System.Windows.Forms_test_default.dll .
+topdir=../../../..
+NUNITCONSOLE=$topdir/class/lib/default/nunit-console.exe
+MONO_PATH=$topdir/nunit20:$topdir/class/lib:.
+
+for i in $@; do
+ if [ "$i" = "all" ]; then
+ fixture=""
+ else
+ fixture="/fixture:MonoTests.${i}"
+ fi
+ MONO_PATH=$MONO_PATH \
+ ${NUNITCONSOLE} System.Windows.Forms_test_default.dll $fixture
+done
+
+
+
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/tests.sh b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/tests.sh
new file mode 100755
index 00000000000..d440326d899
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/tests.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+if [ $# -eq 0 ]; then
+ echo "You should give a list of test names such as: "
+ echo "$0 System.Windows.Forms.ListViewItemTest"
+ echo "or"
+ echo "$0 all"
+ exit 1
+fi
+
+cp ../../System.Windows.Forms_test_default.dll .
+
+topdir=../../../..
+NUNITCONSOLE=$topdir/class/lib/default/nunit-console.exe
+MONO_PATH=$topdir/nunit20:$topdir/class/lib/default:.
+
+
+for i in $@; do
+ if [ "$i" = "all" ]; then
+ fixture=""
+ else
+ fixture="/fixture:MonoTests.${i}"
+ fi
+ MONO_PATH=$MONO_PATH \
+ mono --debug ${NUNITCONSOLE} System.Windows.Forms_test_default.dll $fixture
+done
+
+
+
diff --git a/mcs/class/Managed.Windows.Forms/Test/resources/a.cur b/mcs/class/Managed.Windows.Forms/Test/resources/a.cur
new file mode 100644
index 00000000000..f82e40ac462
--- /dev/null
+++ b/mcs/class/Managed.Windows.Forms/Test/resources/a.cur
Binary files differ