public void TestProtectedMethods() { // Protected Methods that force Handle creation: // - CreateAccessibilityInstance () // - CreateHandle () // - IsInputChar () // - SetTopLevel () ProtectedMethodsControl c = new ProtectedMethodsControl(); c.PublicAccessibilityNotifyClients(AccessibleEvents.Focus, 0); #if NET_2_0 Assert.IsFalse(c.IsHandleCreated, "A1"); #else Assert.IsTrue(c.IsHandleCreated, "A1"); #endif c.PublicCreateAccessibilityInstance(); Assert.IsTrue(c.IsHandleCreated, "A2"); c = new ProtectedMethodsControl(); c.PublicCreateControlsInstance(); Assert.IsFalse(c.IsHandleCreated, "A3"); c.PublicCreateHandle(); Assert.IsTrue(c.IsHandleCreated, "A4"); c = new ProtectedMethodsControl(); c.PublicDestroyHandle(); Assert.IsFalse(c.IsHandleCreated, "A5"); c = new ProtectedMethodsControl(); #if NET_2_0 c.PublicGetAccessibilityObjectById(0); Assert.IsFalse(c.IsHandleCreated, "A6"); #endif #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); Assert.IsFalse(c.IsHandleCreated, "A8"); #endif c.PublicGetStyle(ControlStyles.FixedHeight); Assert.IsFalse(c.IsHandleCreated, "A9"); c.PublicGetTopLevel(); Assert.IsFalse(c.IsHandleCreated, "A10"); c.PublicInitLayout(); Assert.IsFalse(c.IsHandleCreated, "A11"); c.PublicInvokeGotFocus(c, EventArgs.Empty); Assert.IsFalse(c.IsHandleCreated, "A12"); c.PublicInvokeLostFocus(c, EventArgs.Empty); Assert.IsFalse(c.IsHandleCreated, "A13"); c.PublicInvokeOnClick(c, EventArgs.Empty); Assert.IsFalse(c.IsHandleCreated, "A14"); c.PublicInvokePaint(c, new PaintEventArgs(Graphics.FromImage(new Bitmap(1, 1)), Rectangle.Empty)); Assert.IsFalse(c.IsHandleCreated, "A15"); c.PublicInvokePaintBackground(c, new PaintEventArgs(Graphics.FromImage(new Bitmap(1, 1)), Rectangle.Empty)); Assert.IsFalse(c.IsHandleCreated, "A16"); c.PublicIsInputChar('c'); Assert.IsTrue(c.IsHandleCreated, "A17"); c = new ProtectedMethodsControl(); c.PublicIsInputKey(Keys.B); Assert.IsFalse(c.IsHandleCreated, "A18"); c.PublicNotifyInvalidate(Rectangle.Empty); Assert.IsFalse(c.IsHandleCreated, "A19"); Form f = new Form(); f.Controls.Add(c); c.PublicOnVisibleChanged(EventArgs.Empty); Assert.IsFalse(c.IsHandleCreated, "A20"); c = new ProtectedMethodsControl(); c.PublicRaiseDragEvent(null, null); Assert.IsFalse(c.IsHandleCreated, "A21"); c.PublicRaiseKeyEvent(null, null); Assert.IsFalse(c.IsHandleCreated, "A22"); c.PublicRaiseMouseEvent(null, null); Assert.IsFalse(c.IsHandleCreated, "A23"); c.PublicRaisePaintEvent(null, null); Assert.IsFalse(c.IsHandleCreated, "A24"); c.PublicRecreateHandle(); Assert.IsFalse(c.IsHandleCreated, "A25"); c.PublicResetMouseEventArgs(); Assert.IsFalse(c.IsHandleCreated, "A26"); c.PublicRtlTranslateAlignment(ContentAlignment.BottomLeft); Assert.IsFalse(c.IsHandleCreated, "A27"); c.PublicRtlTranslateContent(ContentAlignment.BottomLeft); Assert.IsFalse(c.IsHandleCreated, "A28"); c.PublicRtlTranslateHorizontal(HorizontalAlignment.Left); Assert.IsFalse(c.IsHandleCreated, "A29"); c.PublicRtlTranslateLeftRight(LeftRightAlignment.Left); Assert.IsFalse(c.IsHandleCreated, "A30"); #if !__MonoCS__ && NET_2_0 c.PublicScaleControl(new SizeF(1.5f, 1.5f), BoundsSpecified.All); Assert.IsFalse(c.IsHandleCreated, "A31"); #endif c.PublicScaleCore(1.5f, 1.5f); Assert.IsFalse(c.IsHandleCreated, "A32"); c.PublicSelect(); Assert.IsFalse(c.IsHandleCreated, "A33"); #if !__MonoCS__ && NET_2_0 c.PublicSetAutoSizeMode(AutoSizeMode.GrowAndShrink); Assert.IsFalse(c.IsHandleCreated, "A34"); #endif c.PublicSetBoundsCore(0, 0, 100, 100, BoundsSpecified.All); Assert.IsFalse(c.IsHandleCreated, "A35"); c.PublicSetClientSizeCore(122, 122); Assert.IsFalse(c.IsHandleCreated, "A36"); c.PublicSetStyle(ControlStyles.FixedHeight, true); Assert.IsFalse(c.IsHandleCreated, "A37"); c.PublicSetTopLevel(true); Assert.IsTrue(c.IsHandleCreated, "A38"); c = new ProtectedMethodsControl(); c.PublicSetVisibleCore(true); Assert.IsFalse(c.IsHandleCreated, "A39"); #if NET_2_0 c.PublicSizeFromClientSize(new Size(160, 160)); Assert.IsFalse(c.IsHandleCreated, "A40"); #endif c.PublicUpdateBounds(); Assert.IsFalse(c.IsHandleCreated, "A41"); c.PublicUpdateBounds(1, 2, 3, 4); Assert.IsFalse(c.IsHandleCreated, "A41-b"); c.PublicUpdateBounds(1, 2, 3, 4, 5, 6); Assert.IsFalse(c.IsHandleCreated, "A41-c"); c.PublicUpdateStyles(); Assert.IsFalse(c.IsHandleCreated, "A42"); c.PublicUpdateZOrder(); Assert.IsFalse(c.IsHandleCreated, "A43"); }
public void TestProtectedMethods () { // Protected Methods that force Handle creation: // - CreateAccessibilityInstance () // - CreateHandle () // - IsInputChar () // - SetTopLevel () ProtectedMethodsControl c = new ProtectedMethodsControl (); c.PublicAccessibilityNotifyClients (AccessibleEvents.Focus, 0); #if NET_2_0 Assert.IsFalse (c.IsHandleCreated, "A1"); #else Assert.IsTrue (c.IsHandleCreated, "A1"); #endif c.PublicCreateAccessibilityInstance (); Assert.IsTrue (c.IsHandleCreated, "A2"); c = new ProtectedMethodsControl (); c.PublicCreateControlsInstance (); Assert.IsFalse (c.IsHandleCreated, "A3"); c.PublicCreateHandle (); Assert.IsTrue (c.IsHandleCreated, "A4"); c = new ProtectedMethodsControl (); c.PublicDestroyHandle (); Assert.IsFalse (c.IsHandleCreated, "A5"); c = new ProtectedMethodsControl (); #if NET_2_0 c.PublicGetAccessibilityObjectById (0); Assert.IsFalse (c.IsHandleCreated, "A6"); #endif #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); Assert.IsFalse (c.IsHandleCreated, "A8"); #endif c.PublicGetStyle (ControlStyles.FixedHeight); Assert.IsFalse (c.IsHandleCreated, "A9"); c.PublicGetTopLevel (); Assert.IsFalse (c.IsHandleCreated, "A10"); c.PublicInitLayout (); Assert.IsFalse (c.IsHandleCreated, "A11"); c.PublicInvokeGotFocus (c, EventArgs.Empty); Assert.IsFalse (c.IsHandleCreated, "A12"); c.PublicInvokeLostFocus (c, EventArgs.Empty); Assert.IsFalse (c.IsHandleCreated, "A13"); c.PublicInvokeOnClick (c, EventArgs.Empty); Assert.IsFalse (c.IsHandleCreated, "A14"); c.PublicInvokePaint (c, new PaintEventArgs (Graphics.FromImage (new Bitmap (1, 1)), Rectangle.Empty)); Assert.IsFalse (c.IsHandleCreated, "A15"); c.PublicInvokePaintBackground (c, new PaintEventArgs (Graphics.FromImage (new Bitmap (1, 1)), Rectangle.Empty)); Assert.IsFalse (c.IsHandleCreated, "A16"); c.PublicIsInputChar ('c'); Assert.IsTrue (c.IsHandleCreated, "A17"); c = new ProtectedMethodsControl (); c.PublicIsInputKey (Keys.B); Assert.IsFalse (c.IsHandleCreated, "A18"); c.PublicNotifyInvalidate (Rectangle.Empty); Assert.IsFalse (c.IsHandleCreated, "A19"); Form f = new Form (); f.Controls.Add (c); c.PublicOnVisibleChanged (EventArgs.Empty); Assert.IsFalse (c.IsHandleCreated, "A20"); c = new ProtectedMethodsControl (); c.PublicRaiseDragEvent (null, null); Assert.IsFalse (c.IsHandleCreated, "A21"); c.PublicRaiseKeyEvent (null, null); Assert.IsFalse (c.IsHandleCreated, "A22"); c.PublicRaiseMouseEvent (null, null); Assert.IsFalse (c.IsHandleCreated, "A23"); c.PublicRaisePaintEvent (null, null); Assert.IsFalse (c.IsHandleCreated, "A24"); c.PublicRecreateHandle (); Assert.IsFalse (c.IsHandleCreated, "A25"); c.PublicResetMouseEventArgs (); Assert.IsFalse (c.IsHandleCreated, "A26"); c.PublicRtlTranslateAlignment (ContentAlignment.BottomLeft); Assert.IsFalse (c.IsHandleCreated, "A27"); c.PublicRtlTranslateContent (ContentAlignment.BottomLeft); Assert.IsFalse (c.IsHandleCreated, "A28"); c.PublicRtlTranslateHorizontal (HorizontalAlignment.Left); Assert.IsFalse (c.IsHandleCreated, "A29"); c.PublicRtlTranslateLeftRight (LeftRightAlignment.Left); Assert.IsFalse (c.IsHandleCreated, "A30"); #if !__MonoCS__ && NET_2_0 c.PublicScaleControl (new SizeF (1.5f, 1.5f), BoundsSpecified.All); Assert.IsFalse (c.IsHandleCreated, "A31"); #endif c.PublicScaleCore (1.5f, 1.5f); Assert.IsFalse (c.IsHandleCreated, "A32"); c.PublicSelect (); Assert.IsFalse (c.IsHandleCreated, "A33"); #if !__MonoCS__ && NET_2_0 c.PublicSetAutoSizeMode (AutoSizeMode.GrowAndShrink); Assert.IsFalse (c.IsHandleCreated, "A34"); #endif c.PublicSetBoundsCore (0, 0, 100, 100, BoundsSpecified.All); Assert.IsFalse (c.IsHandleCreated, "A35"); c.PublicSetClientSizeCore (122, 122); Assert.IsFalse (c.IsHandleCreated, "A36"); c.PublicSetStyle (ControlStyles.FixedHeight, true); Assert.IsFalse (c.IsHandleCreated, "A37"); c.PublicSetTopLevel (true); Assert.IsTrue (c.IsHandleCreated, "A38"); c = new ProtectedMethodsControl (); c.PublicSetVisibleCore (true); Assert.IsFalse (c.IsHandleCreated, "A39"); #if NET_2_0 c.PublicSizeFromClientSize (new Size (160, 160)); Assert.IsFalse (c.IsHandleCreated, "A40"); #endif c.PublicUpdateBounds (); Assert.IsFalse (c.IsHandleCreated, "A41"); c.PublicUpdateBounds (1, 2, 3, 4); Assert.IsFalse (c.IsHandleCreated, "A41-b"); c.PublicUpdateBounds (1, 2, 3, 4, 5, 6); Assert.IsFalse (c.IsHandleCreated, "A41-c"); c.PublicUpdateStyles (); Assert.IsFalse (c.IsHandleCreated, "A42"); c.PublicUpdateZOrder (); Assert.IsFalse (c.IsHandleCreated, "A43"); }