Skip to content

Commit

Permalink
In Test/System.Windows.Forms:
Browse files Browse the repository at this point in the history
2007-03-05  Chris Toshok  <toshok@ximian.com>

	* ControlHandleTest.cs: make this build on both 1.1 and 2.0
	profiles.

In System.Windows.Forms:
2007-03-05  Chris Toshok  <toshok@ximian.com>

	* Control.cs (AccessibilityNotifyClients): turns out in 1.1 this
	causes handle creation.


svn path=/branches/mwf-handle-branch/; revision=73757
  • Loading branch information
Chris Toshok committed Mar 5, 2007
1 parent fb09257 commit a566251
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 4 deletions.
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,8 @@
2007-03-05 Chris Toshok <toshok@ximian.com>

* Control.cs (AccessibilityNotifyClients): turns out in 1.1 this
causes handle creation.

2007-02-28 Chris Toshok <toshok@ximian.com> 2007-02-28 Chris Toshok <toshok@ximian.com>


* ApplicationContext.cs: Add a flag to make sure we only raise the * ApplicationContext.cs: Add a flag to make sure we only raise the
Expand Down
15 changes: 15 additions & 0 deletions mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3733,6 +3733,21 @@ public void Update() {
#region Protected Instance Methods #region Protected Instance Methods
[EditorBrowsable(EditorBrowsableState.Advanced)] [EditorBrowsable(EditorBrowsableState.Advanced)]
protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) { protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
// turns out this method causes handle
// creation in 1.1. at first I thought this
// would be accomplished just by using
// get_AccessibilityObject, which would route
// through CreateAccessibilityInstance, which
// calls CreateControl. This isn't the case,
// though (as overriding
// CreateAccessibilityInstance and adding a
// CWL shows nothing. So we fudge it and put
// a CreateHandle here.

#if ONLY_1_1
CreateHandle ();
#endif

if (accessibility_object != null && accessibility_object is ControlAccessibleObject) if (accessibility_object != null && accessibility_object is ControlAccessibleObject)
((ControlAccessibleObject)accessibility_object).NotifyClients (accEvent, childID); ((ControlAccessibleObject)accessibility_object).NotifyClients (accEvent, childID);
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,8 @@
2007-03-05 Chris Toshok <toshok@ximian.com>

* ControlHandleTest.cs: make this build on both 1.1 and 2.0
profiles.

2007-02-28 Chris Toshok <toshok@ximian.com> 2007-02-28 Chris Toshok <toshok@ximian.com>


* ControlTest.cs: Flesh out ControlInvokeTest to make sure that * ControlTest.cs: Flesh out ControlInvokeTest to make sure that
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,3 @@
#if NET_2_0
// This test is designed to find exactly what conditions cause the control's // This test is designed to find exactly what conditions cause the control's
// Handle to be created. // Handle to be created.
using System; using System;
Expand Down Expand Up @@ -71,9 +70,11 @@ public void TestPublicProperties ()
c.AutoScrollOffset = new Point (40, 40); c.AutoScrollOffset = new Point (40, 40);
Assert.IsFalse (c.IsHandleCreated, "A7"); Assert.IsFalse (c.IsHandleCreated, "A7");
#endif #endif
#if NET_2_0
o = c.AutoSize; o = c.AutoSize;
c.AutoSize = true; c.AutoSize = true;
Assert.IsFalse (c.IsHandleCreated, "A8"); Assert.IsFalse (c.IsHandleCreated, "A8");
#endif


// B // B
o = c.BackColor; o = c.BackColor;
Expand All @@ -82,9 +83,11 @@ public void TestPublicProperties ()
o = c.BackgroundImage; o = c.BackgroundImage;
c.BackgroundImage = new Bitmap (1, 1); c.BackgroundImage = new Bitmap (1, 1);
Assert.IsFalse (c.IsHandleCreated, "A10"); Assert.IsFalse (c.IsHandleCreated, "A10");
#if NET_2_0
o = c.BackgroundImageLayout; o = c.BackgroundImageLayout;
c.BackgroundImageLayout = ImageLayout.Stretch; c.BackgroundImageLayout = ImageLayout.Stretch;
Assert.IsFalse (c.IsHandleCreated, "A11"); Assert.IsFalse (c.IsHandleCreated, "A11");
#endif
o = c.BindingContext; o = c.BindingContext;
c.BindingContext = new BindingContext (); c.BindingContext = new BindingContext ();
Assert.IsFalse (c.IsHandleCreated, "A12"); Assert.IsFalse (c.IsHandleCreated, "A12");
Expand Down Expand Up @@ -121,9 +124,11 @@ public void TestPublicProperties ()
o = c.ContextMenu; o = c.ContextMenu;
c.ContextMenu = new ContextMenu (); c.ContextMenu = new ContextMenu ();
Assert.IsFalse (c.IsHandleCreated, "A24"); Assert.IsFalse (c.IsHandleCreated, "A24");
#if NET_2_0
o = c.ContextMenuStrip; o = c.ContextMenuStrip;
c.ContextMenuStrip = new ContextMenuStrip (); c.ContextMenuStrip = new ContextMenuStrip ();
Assert.IsFalse (c.IsHandleCreated, "A25"); Assert.IsFalse (c.IsHandleCreated, "A25");
#endif
o = c.Controls; o = c.Controls;
Assert.IsFalse (c.IsHandleCreated, "A26"); Assert.IsFalse (c.IsHandleCreated, "A26");
o = c.Created; o = c.Created;
Expand Down Expand Up @@ -179,8 +184,10 @@ public void TestPublicProperties ()
o = c.IsMirrored; o = c.IsMirrored;
Assert.IsFalse (c.IsHandleCreated, "A44"); Assert.IsFalse (c.IsHandleCreated, "A44");
#endif #endif
#if NET_2_0
o = c.LayoutEngine; o = c.LayoutEngine;
Assert.IsFalse (c.IsHandleCreated, "A45"); Assert.IsFalse (c.IsHandleCreated, "A45");
#endif
o = c.Left; o = c.Left;
c.Left = 15; c.Left = 15;
Assert.IsFalse (c.IsHandleCreated, "A46"); Assert.IsFalse (c.IsHandleCreated, "A46");
Expand All @@ -189,6 +196,7 @@ public void TestPublicProperties ()
Assert.IsFalse (c.IsHandleCreated, "A47"); Assert.IsFalse (c.IsHandleCreated, "A47");


// M - N // M - N
#if NET_2_0
o = c.Margin; o = c.Margin;
c.Margin = new Padding (6); c.Margin = new Padding (6);
Assert.IsFalse (c.IsHandleCreated, "A48"); Assert.IsFalse (c.IsHandleCreated, "A48");
Expand All @@ -198,19 +206,24 @@ public void TestPublicProperties ()
o = c.MinimumSize; o = c.MinimumSize;
c.MinimumSize = new Size (100, 100); c.MinimumSize = new Size (100, 100);
Assert.IsFalse (c.IsHandleCreated, "A50"); Assert.IsFalse (c.IsHandleCreated, "A50");
#endif
o = c.Name; o = c.Name;
c.Name = "web"; c.Name = "web";
Assert.IsFalse (c.IsHandleCreated, "A51"); Assert.IsFalse (c.IsHandleCreated, "A51");


// P - R // P - R
#if NET_2_0
o = c.Padding; o = c.Padding;
c.Padding = new Padding (4); c.Padding = new Padding (4);
Assert.IsFalse (c.IsHandleCreated, "A52"); Assert.IsFalse (c.IsHandleCreated, "A52");
#endif
o = c.Parent; o = c.Parent;
c.Parent = new Control (); c.Parent = new Control ();
Assert.IsFalse (c.IsHandleCreated, "A53"); Assert.IsFalse (c.IsHandleCreated, "A53");
#if NET_2_0
o = c.PreferredSize; o = c.PreferredSize;
Assert.IsFalse (c.IsHandleCreated, "A54"); Assert.IsFalse (c.IsHandleCreated, "A54");
#endif
o = c.ProductName; o = c.ProductName;
Assert.IsFalse (c.IsHandleCreated, "A55"); Assert.IsFalse (c.IsHandleCreated, "A55");
o = c.ProductVersion; o = c.ProductVersion;
Expand Down Expand Up @@ -275,10 +288,13 @@ public void TestProtectedProperties ()
#endif #endif
o = c.PublicCreateParams; o = c.PublicCreateParams;
Assert.IsFalse (c.IsHandleCreated, "A2"); Assert.IsFalse (c.IsHandleCreated, "A2");
#if NET_2_0
o = c.PublicDefaultCursor; o = c.PublicDefaultCursor;
Assert.IsFalse (c.IsHandleCreated, "A3"); Assert.IsFalse (c.IsHandleCreated, "A3");
#endif
o = c.PublicDefaultImeMode; o = c.PublicDefaultImeMode;
Assert.IsFalse (c.IsHandleCreated, "A4"); Assert.IsFalse (c.IsHandleCreated, "A4");
#if NET_2_0
o = c.PublicDefaultMargin; o = c.PublicDefaultMargin;
Assert.IsFalse (c.IsHandleCreated, "A5"); Assert.IsFalse (c.IsHandleCreated, "A5");
o = c.PublicDefaultMaximumSize; o = c.PublicDefaultMaximumSize;
Expand All @@ -292,6 +308,7 @@ public void TestProtectedProperties ()
o = c.PublicDoubleBuffered; o = c.PublicDoubleBuffered;
c.PublicDoubleBuffered = !c.PublicDoubleBuffered; c.PublicDoubleBuffered = !c.PublicDoubleBuffered;
Assert.IsFalse (c.IsHandleCreated, "A10"); Assert.IsFalse (c.IsHandleCreated, "A10");
#endif
o = c.PublicFontHeight; o = c.PublicFontHeight;
c.PublicFontHeight = c.PublicFontHeight + 1; c.PublicFontHeight = c.PublicFontHeight + 1;
Assert.IsFalse (c.IsHandleCreated, "A11"); Assert.IsFalse (c.IsHandleCreated, "A11");
Expand Down Expand Up @@ -359,8 +376,10 @@ public void TestPublicMethods ()
Assert.IsFalse (c.IsHandleCreated, "A11"); Assert.IsFalse (c.IsHandleCreated, "A11");
c.GetNextControl (new Control (), true); c.GetNextControl (new Control (), true);
Assert.IsFalse (c.IsHandleCreated, "A12"); Assert.IsFalse (c.IsHandleCreated, "A12");
#if NET_2_0
c.GetPreferredSize (Size.Empty); c.GetPreferredSize (Size.Empty);
Assert.IsFalse (c.IsHandleCreated, "A13"); Assert.IsFalse (c.IsHandleCreated, "A13");
#endif
c.Hide (); c.Hide ();
Assert.IsFalse (c.IsHandleCreated, "A14"); Assert.IsFalse (c.IsHandleCreated, "A14");
c.Invalidate (); c.Invalidate ();
Expand Down Expand Up @@ -405,8 +424,10 @@ public void TestPublicMethods ()
Assert.IsFalse (c.IsHandleCreated, "A31"); Assert.IsFalse (c.IsHandleCreated, "A31");
c.ResumeLayout (); c.ResumeLayout ();
Assert.IsFalse (c.IsHandleCreated, "A32"); Assert.IsFalse (c.IsHandleCreated, "A32");
#if NET_2_0
c.Scale (new SizeF (1.5f, 1.5f)); c.Scale (new SizeF (1.5f, 1.5f));
Assert.IsFalse (c.IsHandleCreated, "A33"); Assert.IsFalse (c.IsHandleCreated, "A33");
#endif
c.Select (); c.Select ();
Assert.IsFalse (c.IsHandleCreated, "A34"); Assert.IsFalse (c.IsHandleCreated, "A34");
c.SelectNextControl (new Control (), true, true, true, true); c.SelectNextControl (new Control (), true, true, true, true);
Expand Down Expand Up @@ -444,14 +465,18 @@ private class ProtectedPropertyControl : Control
public bool PublicCanRaiseEvents { get { return base.CanRaiseEvents; } } public bool PublicCanRaiseEvents { get { return base.CanRaiseEvents; } }
#endif #endif
public CreateParams PublicCreateParams { get { return base.CreateParams; } } public CreateParams PublicCreateParams { get { return base.CreateParams; } }
#if NET_2_0
public Cursor PublicDefaultCursor { get { return base.DefaultCursor; } } public Cursor PublicDefaultCursor { get { return base.DefaultCursor; } }
#endif
public ImeMode PublicDefaultImeMode { get { return base.DefaultImeMode; } } public ImeMode PublicDefaultImeMode { get { return base.DefaultImeMode; } }
#if NET_2_0
public Padding PublicDefaultMargin { get { return base.DefaultMargin; } } public Padding PublicDefaultMargin { get { return base.DefaultMargin; } }
public Size PublicDefaultMaximumSize { get { return base.DefaultMaximumSize; } } public Size PublicDefaultMaximumSize { get { return base.DefaultMaximumSize; } }
public Size PublicDefaultMinimumSize { get { return base.DefaultMinimumSize; } } public Size PublicDefaultMinimumSize { get { return base.DefaultMinimumSize; } }
public Padding PublicDefaultPadding { get { return base.DefaultPadding; } } public Padding PublicDefaultPadding { get { return base.DefaultPadding; } }
public Size PublicDefaultSize { get { return base.DefaultSize; } } public Size PublicDefaultSize { get { return base.DefaultSize; } }
public bool PublicDoubleBuffered { get { return base.DoubleBuffered; } set { base.DoubleBuffered = value; } } public bool PublicDoubleBuffered { get { return base.DoubleBuffered; } set { base.DoubleBuffered = value; } }
#endif
public int PublicFontHeight { get { return base.FontHeight; } set { base.FontHeight = value; } } public int PublicFontHeight { get { return base.FontHeight; } set { base.FontHeight = value; } }
public bool PublicRenderRightToLeft { get { return base.RenderRightToLeft; } } public bool PublicRenderRightToLeft { get { return base.RenderRightToLeft; } }
public bool PublicResizeRedraw { get { return base.ResizeRedraw; } set { base.ResizeRedraw = value; } } public bool PublicResizeRedraw { get { return base.ResizeRedraw; } set { base.ResizeRedraw = value; } }
Expand All @@ -473,7 +498,11 @@ public void TestProtectedMethods ()
ProtectedMethodsControl c = new ProtectedMethodsControl (); ProtectedMethodsControl c = new ProtectedMethodsControl ();


c.PublicAccessibilityNotifyClients (AccessibleEvents.Focus, 0); c.PublicAccessibilityNotifyClients (AccessibleEvents.Focus, 0);
#if NET_2_0
Assert.IsFalse (c.IsHandleCreated, "A1"); Assert.IsFalse (c.IsHandleCreated, "A1");
#else
Assert.IsTrue (c.IsHandleCreated, "A1");
#endif
c.PublicCreateAccessibilityInstance (); c.PublicCreateAccessibilityInstance ();
Assert.IsTrue (c.IsHandleCreated, "A2"); Assert.IsTrue (c.IsHandleCreated, "A2");
c = new ProtectedMethodsControl (); c = new ProtectedMethodsControl ();
Expand All @@ -485,8 +514,10 @@ public void TestProtectedMethods ()
c.PublicDestroyHandle (); c.PublicDestroyHandle ();
Assert.IsFalse (c.IsHandleCreated, "A5"); Assert.IsFalse (c.IsHandleCreated, "A5");
c = new ProtectedMethodsControl (); c = new ProtectedMethodsControl ();
#if NET_2_0
c.PublicGetAccessibilityObjectById (0); c.PublicGetAccessibilityObjectById (0);
Assert.IsFalse (c.IsHandleCreated, "A6"); Assert.IsFalse (c.IsHandleCreated, "A6");
#endif
#if !__MonoCS__ #if !__MonoCS__
c.PublicGetAutoSizeMode (); c.PublicGetAutoSizeMode ();
Assert.IsFalse (c.IsHandleCreated, "A7"); Assert.IsFalse (c.IsHandleCreated, "A7");
Expand Down Expand Up @@ -518,7 +549,7 @@ public void TestProtectedMethods ()
Assert.IsFalse (c.IsHandleCreated, "A19"); Assert.IsFalse (c.IsHandleCreated, "A19");
Form f = new Form (); Form f = new Form ();
f.Controls.Add (c); f.Controls.Add (c);
c.OnVisibleChanged (EventArgs.Empty); c.PublicOnVisibleChanged (EventArgs.Empty);
Assert.IsFalse (c.IsHandleCreated, "A20"); Assert.IsFalse (c.IsHandleCreated, "A20");
c = new ProtectedMethodsControl (); c = new ProtectedMethodsControl ();
c.PublicRaiseDragEvent (null, null); c.PublicRaiseDragEvent (null, null);
Expand Down Expand Up @@ -564,8 +595,10 @@ public void TestProtectedMethods ()
c = new ProtectedMethodsControl (); c = new ProtectedMethodsControl ();
c.PublicSetVisibleCore (true); c.PublicSetVisibleCore (true);
Assert.IsFalse (c.IsHandleCreated, "A39"); Assert.IsFalse (c.IsHandleCreated, "A39");
#if NET_2_0
c.PublicSizeFromClientSize (new Size (160, 160)); c.PublicSizeFromClientSize (new Size (160, 160));
Assert.IsFalse (c.IsHandleCreated, "A40"); Assert.IsFalse (c.IsHandleCreated, "A40");
#endif
c.PublicUpdateBounds (); c.PublicUpdateBounds ();
Assert.IsFalse (c.IsHandleCreated, "A41"); Assert.IsFalse (c.IsHandleCreated, "A41");
c.PublicUpdateStyles (); c.PublicUpdateStyles ();
Expand All @@ -581,7 +614,9 @@ private class ProtectedMethodsControl : Control
public void PublicCreateControlsInstance () { base.CreateControlsInstance (); } public void PublicCreateControlsInstance () { base.CreateControlsInstance (); }
public void PublicCreateHandle () { base.CreateHandle (); } public void PublicCreateHandle () { base.CreateHandle (); }
public void PublicDestroyHandle () { base.DestroyHandle (); } public void PublicDestroyHandle () { base.DestroyHandle (); }
#if NET_2_0
public AccessibleObject PublicGetAccessibilityObjectById (int objectId) { return base.GetAccessibilityObjectById (objectId); } public AccessibleObject PublicGetAccessibilityObjectById (int objectId) { return base.GetAccessibilityObjectById (objectId); }
#endif
#if !__MonoCS__ #if !__MonoCS__
public AutoSizeMode PublicGetAutoSizeMode () { return base.GetAutoSizeMode (); } public AutoSizeMode PublicGetAutoSizeMode () { return base.GetAutoSizeMode (); }
public Rectangle PublicGetScaledBounds (Rectangle bounds, SizeF factor, BoundsSpecified specified) { return base.GetScaledBounds (bounds, factor, specified); } public Rectangle PublicGetScaledBounds (Rectangle bounds, SizeF factor, BoundsSpecified specified) { return base.GetScaledBounds (bounds, factor, specified); }
Expand All @@ -597,7 +632,7 @@ private class ProtectedMethodsControl : Control
public bool PublicIsInputChar (char charCode) { return base.IsInputChar (charCode); } public bool PublicIsInputChar (char charCode) { return base.IsInputChar (charCode); }
public bool PublicIsInputKey (Keys keyData) { return base.IsInputKey (keyData); } public bool PublicIsInputKey (Keys keyData) { return base.IsInputKey (keyData); }
public void PublicNotifyInvalidate (Rectangle invalidatedArea) { base.NotifyInvalidate (invalidatedArea); } public void PublicNotifyInvalidate (Rectangle invalidatedArea) { base.NotifyInvalidate (invalidatedArea); }
public void OnVisibleChanged (EventArgs e) { base.OnVisibleChanged (e); } public void PublicOnVisibleChanged (EventArgs e) { base.OnVisibleChanged (e); }
public void PublicRaiseDragEvent (Object key, DragEventArgs e) { base.RaiseDragEvent (key, e); } public void PublicRaiseDragEvent (Object key, DragEventArgs e) { base.RaiseDragEvent (key, e); }
public void PublicRaiseKeyEvent (Object key, KeyEventArgs e) { base.RaiseKeyEvent (key, e); } public void PublicRaiseKeyEvent (Object key, KeyEventArgs e) { base.RaiseKeyEvent (key, e); }
public void PublicRaiseMouseEvent (Object key, MouseEventArgs e) { base.RaiseMouseEvent (key, e); } public void PublicRaiseMouseEvent (Object key, MouseEventArgs e) { base.RaiseMouseEvent (key, e); }
Expand All @@ -621,11 +656,12 @@ private class ProtectedMethodsControl : Control
public void PublicSetStyle (ControlStyles flag, bool value) { base.SetStyle (flag, value); } public void PublicSetStyle (ControlStyles flag, bool value) { base.SetStyle (flag, value); }
public void PublicSetTopLevel (bool value) { base.SetTopLevel (value); } public void PublicSetTopLevel (bool value) { base.SetTopLevel (value); }
public void PublicSetVisibleCore (bool value) { base.SetVisibleCore (value); } public void PublicSetVisibleCore (bool value) { base.SetVisibleCore (value); }
#if NET_2_0
public Size PublicSizeFromClientSize (Size clientSize) { return base.SizeFromClientSize (clientSize); } public Size PublicSizeFromClientSize (Size clientSize) { return base.SizeFromClientSize (clientSize); }
#endif
public void PublicUpdateBounds () { base.UpdateBounds (); } public void PublicUpdateBounds () { base.UpdateBounds (); }
public void PublicUpdateStyles () { base.UpdateStyles (); } public void PublicUpdateStyles () { base.UpdateStyles (); }
public void PublicUpdateZOrder () { base.UpdateZOrder (); } public void PublicUpdateZOrder () { base.UpdateZOrder (); }
} }
} }
} }
#endif

0 comments on commit a566251

Please sign in to comment.