Browse Source

* FormHandleTest.cs: Fixed build using csc 1.x.
* MdiFormHandleTest.cs: Fixed build using csc 1.x. Removed extra tabs.
* ControlHandleTest.cs: Fixed build using csc 1.x.
* TextBoxTest.cs: Improved test for BackColor. Added test for
ForeColor.
* TextBox.cs: Set for foreground color.
* TextBoxBase.cs: Remove Invalidate when setting BackColor, since
this is already done in Control.

svn path=/trunk/mcs/; revision=74052

Gert Driesen 19 years ago
parent
commit
b400eaac8a

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

@@ -1,3 +1,9 @@
+2007-03-10  Gert Driesen  <[email protected]>
+
+	* TextBox.cs: Set for foreground color.
+	* TextBoxBase.cs: Remove Invalidate when setting BackColor, since
+	this is already done in Control.
+
 2007-03-10  Jackson Harper  <[email protected]>
 
 	* TextBox.cs: Set the background color, but reset the

+ 1 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs

@@ -64,6 +64,7 @@ namespace System.Windows.Forms {
 			this.LostFocus +=new EventHandler(TextBox_LostFocus);
 
 			BackColor = SystemColors.Window;
+			ForeColor = SystemColors.WindowText;
 			backcolor_set = false;
 
 			SetStyle (ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, false);

+ 0 - 1
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs

@@ -236,7 +236,6 @@ namespace System.Windows.Forms {
 			set {
 				backcolor_set = true;
 				base.BackColor = value;
-				Invalidate ();
 			}
 		}
 

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

@@ -1,3 +1,11 @@
+2007-03-10  Gert Driesen  <[email protected]>
+
+	* FormHandleTest.cs: Fixed build using csc 1.x.
+	* MdiFormHandleTest.cs: Fixed build using csc 1.x. Removed extra tabs.
+	* ControlHandleTest.cs: Fixed build using csc 1.x.
+	* TextBoxTest.cs: Improved test for BackColor. Added test for
+	ForeColor.
+
 2007-03-10  Gert Driesen  <[email protected]>
 
 	* TextBoxTest.cs: Isolate BackColor tests.

+ 20 - 15
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlHandleTest.cs

@@ -61,11 +61,11 @@ namespace MonoTests.System.Windows.Forms
 			Assert.IsFalse (c.IsHandleCreated, "A5");
 			// If we don't reset the control, handle creation will fail
 			// because AllowDrop requires STAThread, which Nunit doesn't do
-			c = new Control();	
+			c = new Control();
 			o = c.Anchor;
 			c.Anchor = AnchorStyles.Right;
 			Assert.IsFalse (c.IsHandleCreated, "A6");
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			o = c.AutoScrollOffset;
 			c.AutoScrollOffset = new Point (40, 40);
 			Assert.IsFalse (c.IsHandleCreated, "A7");
@@ -180,7 +180,7 @@ namespace MonoTests.System.Windows.Forms
 			Assert.IsFalse (c.IsHandleCreated, "A42");
 			o = c.IsDisposed;
 			Assert.IsFalse (c.IsHandleCreated, "A43");
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			o = c.IsMirrored;
 			Assert.IsFalse (c.IsHandleCreated, "A44");
 #endif
@@ -259,7 +259,7 @@ namespace MonoTests.System.Windows.Forms
 			Assert.IsFalse (c.IsHandleCreated, "A66");
 			o = c.TopLevelControl;
 			Assert.IsFalse (c.IsHandleCreated, "A67");
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			o = c.UseWaitCursor;
 			c.UseWaitCursor = true;
 			Assert.IsFalse (c.IsHandleCreated, "A68");
@@ -284,7 +284,7 @@ namespace MonoTests.System.Windows.Forms
 			ProtectedPropertyControl c = new ProtectedPropertyControl ();
 
 			object o;
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			o = c.PublicCanRaiseEvents;
 			Assert.IsFalse (c.IsHandleCreated, "A1");
 #endif
@@ -319,7 +319,7 @@ namespace MonoTests.System.Windows.Forms
 			o = c.PublicResizeRedraw;
 			c.PublicResizeRedraw = !c.PublicResizeRedraw;
 			Assert.IsFalse (c.IsHandleCreated, "A13");
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			o = c.PublicScaleChildren;
 			Assert.IsFalse (c.IsHandleCreated, "A14");
 #endif
@@ -447,11 +447,16 @@ namespace MonoTests.System.Windows.Forms
 		{
 			Control c = new Control ();
 			Assert.IsFalse (c.IsHandleCreated, "A1");
-			c.HandleCreated += delegate (object sender, EventArgs e) { Console.WriteLine (Environment.StackTrace); };
+			c.HandleCreated += new EventHandler (HandleCreated_WriteStackTrace);
 			c.Show ();
 			Assert.IsFalse (c.IsHandleCreated, "A2");
 		}
 
+		void HandleCreated_WriteStackTrace (object sender, EventArgs e)
+		{
+			Console.WriteLine (Environment.StackTrace);
+		}
+
 		public delegate void InvokeDelegate ();
 		public void InvokeMethod () { invokecontrol.Text = "methodinvoked"; }
 		
@@ -465,7 +470,7 @@ namespace MonoTests.System.Windows.Forms
 		
 		private class ProtectedPropertyControl : Control
 		{
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			public bool PublicCanRaiseEvents { get { return base.CanRaiseEvents; } }
 #endif
 			public CreateParams PublicCreateParams { get { return base.CreateParams; } }
@@ -484,7 +489,7 @@ namespace MonoTests.System.Windows.Forms
 			public int PublicFontHeight { get { return base.FontHeight; } set { base.FontHeight = value; } }
 			public bool PublicRenderRightToLeft { get { return base.RenderRightToLeft; } }
 			public bool PublicResizeRedraw { get { return base.ResizeRedraw; } set { base.ResizeRedraw = value; } }
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			public bool PublicScaleChildren { get { return base.ScaleChildren; } }
 #endif
 			public bool PublicShowFocusCues { get { return base.ShowFocusCues; } }
@@ -522,7 +527,7 @@ namespace MonoTests.System.Windows.Forms
 			c.PublicGetAccessibilityObjectById (0);
 			Assert.IsFalse (c.IsHandleCreated, "A6");
 #endif
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			c.PublicGetAutoSizeMode ();
 			Assert.IsFalse (c.IsHandleCreated, "A7");
 			c.PublicGetScaledBounds (new Rectangle (0, 0, 100, 100), new SizeF (1.5f, 1.5f), BoundsSpecified.All);
@@ -576,7 +581,7 @@ namespace MonoTests.System.Windows.Forms
 			Assert.IsFalse (c.IsHandleCreated, "A29");
 			c.PublicRtlTranslateLeftRight (LeftRightAlignment.Left);
 			Assert.IsFalse (c.IsHandleCreated, "A30");
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			c.PublicScaleControl (new SizeF (1.5f, 1.5f), BoundsSpecified.All);
 			Assert.IsFalse (c.IsHandleCreated, "A31");
 #endif
@@ -584,7 +589,7 @@ namespace MonoTests.System.Windows.Forms
 			Assert.IsFalse (c.IsHandleCreated, "A32");
 			c.PublicSelect ();
 			Assert.IsFalse (c.IsHandleCreated, "A33");
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			c.PublicSetAutoSizeMode (AutoSizeMode.GrowAndShrink);
 			Assert.IsFalse (c.IsHandleCreated, "A34");
 #endif
@@ -621,7 +626,7 @@ namespace MonoTests.System.Windows.Forms
 #if NET_2_0
 			public AccessibleObject PublicGetAccessibilityObjectById (int objectId) { return base.GetAccessibilityObjectById (objectId); }
 #endif
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			public AutoSizeMode PublicGetAutoSizeMode () { return base.GetAutoSizeMode (); }
 			public Rectangle PublicGetScaledBounds (Rectangle bounds, SizeF factor, BoundsSpecified specified) { return base.GetScaledBounds (bounds, factor, specified); }
 #endif
@@ -647,12 +652,12 @@ namespace MonoTests.System.Windows.Forms
 			public ContentAlignment PublicRtlTranslateContent (ContentAlignment align) { return base.RtlTranslateContent (align); }
 			public HorizontalAlignment PublicRtlTranslateHorizontal (HorizontalAlignment align) { return base.RtlTranslateHorizontal (align); }
 			public LeftRightAlignment PublicRtlTranslateLeftRight (LeftRightAlignment align) { return base.RtlTranslateLeftRight (align); }
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			public void PublicScaleControl (SizeF factor, BoundsSpecified specified) { base.ScaleControl (factor, specified); }
 #endif
 			public void PublicScaleCore (float dx, float dy) { base.ScaleCore (dx, dy); }
 			public void PublicSelect () { base.Select (); }
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			public void PublicSetAutoSizeMode (AutoSizeMode mode) { base.SetAutoSizeMode (mode); }
 #endif
 			public void PublicSetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified) { base.SetBoundsCore (x, y, width, height, specified); }

+ 20 - 15
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormHandleTest.cs

@@ -67,7 +67,7 @@ namespace MonoTests.System.Windows.Forms
 			o = c.Anchor;
 			c.Anchor = AnchorStyles.Right;
 			Assert.IsFalse (c.IsHandleCreated, "A6");
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			o = c.AutoScrollOffset;
 			c.AutoScrollOffset = new Point (40, 40);
 			Assert.IsFalse (c.IsHandleCreated, "A7");
@@ -308,7 +308,7 @@ namespace MonoTests.System.Windows.Forms
 			Assert.IsFalse (c.IsHandleCreated, "A42");
 			o = c.IsDisposed;
 			Assert.IsFalse (c.IsHandleCreated, "A43");
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			o = c.IsMirrored;
 			Assert.IsFalse (c.IsHandleCreated, "A44");
 #endif
@@ -474,7 +474,7 @@ namespace MonoTests.System.Windows.Forms
 			Assert.IsFalse (c.IsHandleCreated, "A66");
 			o = c.TopLevelControl;
 			Assert.IsFalse (c.IsHandleCreated, "A67");
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			o = c.UseWaitCursor;
 			c.UseWaitCursor = true;
 			Assert.IsFalse (c.IsHandleCreated, "A68");
@@ -539,7 +539,7 @@ namespace MonoTests.System.Windows.Forms
 			
 			o = c.WindowState;
 			c.WindowState = FormWindowState.Maximized;
-			Assert.IsFalse (c.IsHandleCreated, "FW1");	
+			Assert.IsFalse (c.IsHandleCreated, "FW1");
 
 			TestHelper.RemoveWarning (o);
 		}
@@ -552,7 +552,7 @@ namespace MonoTests.System.Windows.Forms
 			ProtectedPropertyForm c = new ProtectedPropertyForm ();
 
 			object o;
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			o = c.PublicCanRaiseEvents;
 			Assert.IsFalse (c.IsHandleCreated, "A1");
 #endif
@@ -587,7 +587,7 @@ namespace MonoTests.System.Windows.Forms
 			o = c.PublicResizeRedraw;
 			c.PublicResizeRedraw = !c.PublicResizeRedraw;
 			Assert.IsFalse (c.IsHandleCreated, "A13");
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			o = c.PublicScaleChildren;
 			Assert.IsFalse (c.IsHandleCreated, "A14");
 #endif
@@ -828,12 +828,17 @@ namespace MonoTests.System.Windows.Forms
 		{
 			Form c = new Form ();
 			Assert.IsFalse (c.IsHandleCreated, "A1");
-			c.HandleCreated += delegate (object sender, EventArgs e) { Console.WriteLine (Environment.StackTrace); };
+			c.HandleCreated += new EventHandler (HandleCreated_WriteStackTrace);
 			c.Show ();
 			Assert.IsTrue (c.IsHandleCreated, "A2");
 			c.Dispose ();
 		}
 
+		void HandleCreated_WriteStackTrace (object sender, EventArgs e)
+		{
+			Console.WriteLine (Environment.StackTrace);
+		}
+
 		public delegate void InvokeDelegate ();
 		public void InvokeMethod () { invokeform.Text = "methodinvoked"; }
 
@@ -850,7 +855,7 @@ namespace MonoTests.System.Windows.Forms
 #if NET_2_0
 			public SizeF PublicAutoScaleFactor { get { return base.AutoScaleFactor; } } 
 #endif
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			public bool PublicCanRaiseEvents { get { return base.CanRaiseEvents; } }
 #endif
 			public CreateParams PublicCreateParams { get { return base.CreateParams; } }
@@ -875,7 +880,7 @@ namespace MonoTests.System.Windows.Forms
 			public Rectangle PublicMaximizedBounds { get {return base.MaximizedBounds; } set { base.MaximizedBounds = value; }}
 			public bool PublicRenderRightToLeft { get { return base.RenderRightToLeft; } }
 			public bool PublicResizeRedraw { get { return base.ResizeRedraw; } set { base.ResizeRedraw = value; } }
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			public bool PublicScaleChildren { get { return base.ScaleChildren; } }
 #endif
 			public bool PublicShowFocusCues { get { return base.ShowFocusCues; } }
@@ -920,7 +925,7 @@ namespace MonoTests.System.Windows.Forms
 			c.PublicGetAccessibilityObjectById (0);
 			Assert.IsFalse (c.IsHandleCreated, "A6");
 #endif
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			c.PublicGetAutoSizeMode ();
 			Assert.IsFalse (c.IsHandleCreated, "A7");
 			c.PublicGetScaledBounds (new Rectangle (0, 0, 100, 100), new SizeF (1.5f, 1.5f), BoundsSpecified.All);
@@ -975,7 +980,7 @@ namespace MonoTests.System.Windows.Forms
 			Assert.IsFalse (c.IsHandleCreated, "A29");
 			c.PublicRtlTranslateLeftRight (LeftRightAlignment.Left);
 			Assert.IsFalse (c.IsHandleCreated, "A30");
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			c.PublicScaleControl (new SizeF (1.5f, 1.5f), BoundsSpecified.All);
 			Assert.IsFalse (c.IsHandleCreated, "A31");
 #endif
@@ -984,7 +989,7 @@ namespace MonoTests.System.Windows.Forms
 			c.PublicSelect ();
 			Assert.IsTrue (c.IsHandleCreated, "A33");
 			c = new ProtectedMethodsForm ();
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			c.PublicSetAutoSizeMode (AutoSizeMode.GrowAndShrink);
 			Assert.IsFalse (c.IsHandleCreated, "A34");
 #endif
@@ -1102,7 +1107,7 @@ namespace MonoTests.System.Windows.Forms
 #if NET_2_0
 			public AccessibleObject PublicGetAccessibilityObjectById (int objectId) { return base.GetAccessibilityObjectById (objectId); }
 #endif
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			public AutoSizeMode PublicGetAutoSizeMode () { return base.GetAutoSizeMode (); }
 			public Rectangle PublicGetScaledBounds (Rectangle bounds, SizeF factor, BoundsSpecified specified) { return base.GetScaledBounds (bounds, factor, specified); }
 #endif
@@ -1138,7 +1143,7 @@ namespace MonoTests.System.Windows.Forms
 			public ContentAlignment PublicRtlTranslateContent (ContentAlignment align) { return base.RtlTranslateContent (align); }
 			public HorizontalAlignment PublicRtlTranslateHorizontal (HorizontalAlignment align) { return base.RtlTranslateHorizontal (align); }
 			public LeftRightAlignment PublicRtlTranslateLeftRight (LeftRightAlignment align) { return base.RtlTranslateLeftRight (align); }
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			public void PublicScaleControl (SizeF factor, BoundsSpecified specified) { base.ScaleControl (factor, specified); }
 #endif
 			public void PublicScaleCore (float dx, float dy) { base.ScaleCore (dx, dy); }
@@ -1148,7 +1153,7 @@ namespace MonoTests.System.Windows.Forms
 			public void PublicSelect () { base.Select (); }
 			public void PublicSelect (bool directed, bool forward) { base.Select (directed, forward); }
 
-#if !__MonoCS__
+#if !__MonoCS__ && NET_2_0
 			public void PublicSetAutoSizeMode (AutoSizeMode mode) { base.SetAutoSizeMode (mode); }
 #endif
 			public void PublicSetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified) { base.SetBoundsCore (x, y, width, height, specified); }

File diff suppressed because it is too large
+ 197 - 198
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MdiFormHandleTest.cs


+ 82 - 3
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs

@@ -18,11 +18,16 @@ namespace MonoTests.System.Windows.Forms
 	public class TextBoxTest
 	{
 		TextBox textBox;
+		int _invalidated;
+		int _paint;
 
 		[SetUp]
 		public void SetUp()
 		{
 			textBox = new TextBox();
+			textBox.Invalidated += new InvalidateEventHandler (TextBox_Invalidated);
+			textBox.Paint += new PaintEventHandler (TextBox_Paint);
+			Reset ();
 		}
 
 		[Test]
@@ -51,7 +56,6 @@ namespace MonoTests.System.Windows.Forms
 			textBox.ClearUndo ();
 			Assert.AreEqual (false, textBox.CanUndo, "#6c");
 
-			Assert.AreEqual ("WindowText", textBox.ForeColor.Name, "#7");
 			Assert.AreEqual (true, textBox.HideSelection, "#8");
 			Assert.AreEqual (1, textBox.Lines.Length, "#9");
 			Assert.AreEqual (32767, textBox.MaxLength, "#10");
@@ -202,9 +206,34 @@ namespace MonoTests.System.Windows.Forms
 		[Test]
 		public void BackColorTest ()
 		{
-			Assert.AreEqual (SystemColors.Window, textBox.BackColor, "#1");
+			Assert.AreEqual (SystemColors.Window, textBox.BackColor, "#A1");
+			textBox.BackColor = Color.Red;
+			Assert.AreEqual (Color.Red, textBox.BackColor, "#A2");
 			textBox.BackColor = Color.White;
-			Assert.AreEqual (Color.White, textBox.BackColor, "#2");
+			Assert.AreEqual (Color.White, textBox.BackColor, "#A3");
+			Assert.AreEqual (0, _invalidated, "#A4");
+			Assert.AreEqual (0, _paint, "#A5");
+
+			Form form = new Form ();
+			form.ShowInTaskbar = false;
+			form.Controls.Add (textBox);
+			form.Show ();
+
+			Assert.AreEqual (Color.White, textBox.BackColor, "#B1");
+			Assert.AreEqual (0, _invalidated, "#B2");
+			Assert.AreEqual (0, _paint, "#B3");
+			textBox.BackColor = Color.Red;
+			Assert.AreEqual (Color.Red, textBox.BackColor, "#B4");
+			Assert.AreEqual (1, _invalidated, "#B5");
+			Assert.AreEqual (0, _paint, "#B6");
+			textBox.BackColor = Color.Red;
+			Assert.AreEqual (Color.Red, textBox.BackColor, "#B7");
+			Assert.AreEqual (1, _invalidated, "#B8");
+			Assert.AreEqual (0, _paint, "#B9");
+			textBox.BackColor = Color.Blue;
+			Assert.AreEqual (Color.Blue, textBox.BackColor, "#B10");
+			Assert.AreEqual (2, _invalidated, "#B11");
+			Assert.AreEqual (0, _paint, "#B12");
 		}
 
 		[Test]
@@ -310,6 +339,40 @@ namespace MonoTests.System.Windows.Forms
 			Assert.AreEqual ("This is a sample test.", textBox.SelectedText, "#34");
 		}
 
+		[Test]
+		[Category ("NotWorking")]
+		public void ForeColorTest ()
+		{
+			Assert.AreEqual (SystemColors.WindowText, textBox.ForeColor, "#A1");
+			textBox.ForeColor = Color.Red;
+			Assert.AreEqual (Color.Red, textBox.ForeColor, "#A2");
+			textBox.ForeColor = Color.White;
+			Assert.AreEqual (Color.White, textBox.ForeColor, "#A3");
+			Assert.AreEqual (0, _invalidated, "#A4");
+			Assert.AreEqual (0, _paint, "#A5");
+
+			Form form = new Form ();
+			form.ShowInTaskbar = false;
+			form.Controls.Add (textBox);
+			form.Show ();
+
+			Assert.AreEqual (Color.White, textBox.ForeColor, "#B1");
+			Assert.AreEqual (0, _invalidated, "#B2");
+			Assert.AreEqual (0, _paint, "#B3");
+			textBox.ForeColor = Color.Red;
+			Assert.AreEqual (Color.Red, textBox.ForeColor, "#B4");
+			Assert.AreEqual (1, _invalidated, "#B5");
+			Assert.AreEqual (0, _paint, "#B6");
+			textBox.ForeColor = Color.Red;
+			Assert.AreEqual (Color.Red, textBox.ForeColor, "#B7");
+			Assert.AreEqual (1, _invalidated, "#B8");
+			Assert.AreEqual (0, _paint, "#B9");
+			textBox.ForeColor = Color.Blue;
+			Assert.AreEqual (Color.Blue, textBox.ForeColor, "#B10");
+			Assert.AreEqual (2, _invalidated, "#B11");
+			Assert.AreEqual (0, _paint, "#B12");
+		}
+
 		[Test]
 		public void ToStringTest ()
 		{
@@ -387,5 +450,21 @@ namespace MonoTests.System.Windows.Forms
 			textBox.Text = "TEXT";
 			Assert.AreEqual (false, textBox.Modified, "modified-3");
 		}
+
+		void TextBox_Invalidated (object sender, InvalidateEventArgs e)
+		{
+			_invalidated++;
+		}
+
+		void TextBox_Paint (object sender, PaintEventArgs e)
+		{
+			_paint++;
+		}
+
+		void Reset ()
+		{
+			_invalidated = 0;
+			_paint = 0;
+		}
 	}
 }

Some files were not shown because too many files changed in this diff