public void MenuStrip_WndProc_InvokeMouseActivateWithHandle_Success() { using var control = new SubMenuStrip(); Assert.NotEqual(IntPtr.Zero, control.Handle); int invalidatedCallCount = 0; control.Invalidated += (sender, e) => invalidatedCallCount++; int styleChangedCallCount = 0; control.StyleChanged += (sender, e) => styleChangedCallCount++; int createdCallCount = 0; control.HandleCreated += (sender, e) => createdCallCount++; var m = new Message { Msg = (int)User32.WM.MOUSEACTIVATE, Result = (IntPtr)250 }; control.WndProc(ref m); Assert.Equal(IntPtr.Zero, m.Result); Assert.True(control.IsHandleCreated); Assert.Equal(0, invalidatedCallCount); Assert.Equal(0, styleChangedCallCount); Assert.Equal(0, createdCallCount); }
public void MenuStirp_ProcessCmdKey_InvokeWithCustomParent_ReturnsExpected(Keys keyData, bool result) { using var control = new SubMenuStrip(); var msg = new Message { Msg = 1 }; int callCount = 0; bool action(Message actualMsg, Keys actualKeyData) { Assert.Equal(1, actualMsg.Msg); Assert.Equal(keyData, actualKeyData); callCount++; return(result); } using var parent = new CustomProcessControl { ProcessCmdKeyAction = action }; control.Parent = parent; Assert.Equal(result, control.ProcessCmdKey(ref msg, keyData)); Assert.Equal(1, callCount); Assert.False(control.IsHandleCreated); }
public void MenuStirp_ProcessCmdKey_InvokeWithoutParent_ReturnsFalse(Keys keyData) { using var control = new SubMenuStrip(); var m = new Message(); Assert.False(control.ProcessCmdKey(ref m, keyData)); Assert.False(control.IsHandleCreated); }
public void MenuStrip_DefaultPadding_GetVisibleGrip_ReturnsExpected() { using var control = new SubMenuStrip { GripStyle = ToolStripGripStyle.Visible }; Assert.Equal(new Padding(3, 2, 0, 2), control.DefaultPadding); }
public void MenuStrip_GetStyle_Invoke_ReturnsExpected(ControlStyles flag, bool expected) { using var control = new SubMenuStrip(); Assert.Equal(expected, control.GetStyle(flag)); // Call again to test caching. Assert.Equal(expected, control.GetStyle(flag)); }
public void MenuStrip_CreateDefaultItem_InvokeSeparator_Success(Image image, EventHandler onClick) { using var control = new SubMenuStrip(); ToolStripSeparator separator = Assert.IsType <ToolStripSeparator>(control.CreateDefaultItem("-", image, onClick)); Assert.Empty(separator.Text); Assert.Null(separator.Image); }
public void MenuStrip_CreateDefaultItem_InvokeButton_Success(string text, Image image, EventHandler onClick) { using var control = new SubMenuStrip(); ToolStripMenuItem item = Assert.IsType <ToolStripMenuItem>(control.CreateDefaultItem(text, image, onClick)); Assert.Equal(text, item.Text); Assert.Same(image, item.Image); }
public void MenuStrip_CreateAccessibilityInstance_Invoke_ReturnsExpected() { using var control = new SubMenuStrip(); ToolStrip.ToolStripAccessibleObject instance = Assert.IsAssignableFrom <ToolStrip.ToolStripAccessibleObject>(control.CreateAccessibilityInstance()); Assert.NotNull(instance); Assert.Same(control, instance.Owner); Assert.Equal(AccessibleRole.MenuBar, instance.Role); Assert.NotSame(control.CreateAccessibilityInstance(), instance); Assert.NotSame(control.AccessibilityObject, instance); }
public void MenuStrip_CreateDefaultItem_PerformClick_Success(string text, int expectedCallCount) { int callCount = 0; EventHandler onClick = (sender, e) => callCount++; using var control = new SubMenuStrip(); ToolStripItem item = Assert.IsAssignableFrom <ToolStripItem>(control.CreateDefaultItem(text, null, onClick)); item.PerformClick(); Assert.Equal(expectedCallCount, callCount); }
public void MenuStirp_ProcessCmdKey_InvokeWithParent_ReturnsFalse(Keys keyData) { using var parent = new Control(); using var control = new SubMenuStrip { Parent = parent }; var msg = new Message(); Assert.False(control.ProcessCmdKey(ref msg, keyData)); Assert.False(control.IsHandleCreated); }
public void MenuStrip_WndProc_InvokeMouseActivate_Success() { using var control = new SubMenuStrip(); var m = new Message { Msg = (int)User32.WM.MOUSEACTIVATE, Result = (IntPtr)250 }; control.WndProc(ref m); Assert.Equal(IntPtr.Zero, m.Result); Assert.True(control.IsHandleCreated); }
public void MenuStrip_OnMenuDeactivate_InvokeWithHandle_CallsMenuDeactivate(EventArgs eventArgs) { using var control = new SubMenuStrip(); Assert.NotEqual(IntPtr.Zero, control.Handle); int invalidatedCallCount = 0; control.Invalidated += (sender, e) => invalidatedCallCount++; int styleChangedCallCount = 0; control.StyleChanged += (sender, e) => styleChangedCallCount++; int createdCallCount = 0; control.HandleCreated += (sender, e) => createdCallCount++; int callCount = 0; EventHandler handler = (sender, e) => { Assert.Same(control, sender); Assert.Same(eventArgs, e); callCount++; }; // Call with handler. control.MenuDeactivate += handler; control.OnMenuDeactivate(eventArgs); Assert.Equal(1, callCount); Assert.True(control.IsHandleCreated); Assert.Equal(0, invalidatedCallCount); Assert.Equal(0, styleChangedCallCount); Assert.Equal(0, createdCallCount); // Remove handler. control.MenuDeactivate -= handler; control.OnMenuDeactivate(eventArgs); Assert.Equal(1, callCount); Assert.True(control.IsHandleCreated); Assert.Equal(0, invalidatedCallCount); Assert.Equal(0, styleChangedCallCount); Assert.Equal(0, createdCallCount); }
public void MenuStrip_OnMenuDeactivate_Invoke_CallsMenuDeactivate(EventArgs eventArgs) { using var control = new SubMenuStrip(); int callCount = 0; EventHandler handler = (sender, e) => { Assert.Same(control, sender); Assert.Same(eventArgs, e); callCount++; }; // Call with handler. control.MenuDeactivate += handler; control.OnMenuDeactivate(eventArgs); Assert.Equal(1, callCount); Assert.False(control.IsHandleCreated); // Remove handler. control.MenuDeactivate -= handler; control.OnMenuDeactivate(eventArgs); Assert.Equal(1, callCount); Assert.False(control.IsHandleCreated); }
public void MenuStrip_WndProc_InvokeMouseHoverWithHandle_Success() { using var control = new SubMenuStrip(); Assert.NotEqual(IntPtr.Zero, control.Handle); int invalidatedCallCount = 0; control.Invalidated += (sender, e) => invalidatedCallCount++; int styleChangedCallCount = 0; control.StyleChanged += (sender, e) => styleChangedCallCount++; int createdCallCount = 0; control.HandleCreated += (sender, e) => createdCallCount++; int callCount = 0; control.MouseHover += (sender, e) => { Assert.Same(control, sender); Assert.Same(EventArgs.Empty, e); callCount++; }; var m = new Message { Msg = (int)User32.WM.MOUSEHOVER, Result = (IntPtr)250 }; control.WndProc(ref m); Assert.Equal(IntPtr.Zero, m.Result); Assert.Equal(1, callCount); Assert.True(control.IsHandleCreated); Assert.Equal(0, invalidatedCallCount); Assert.Equal(0, styleChangedCallCount); Assert.Equal(0, createdCallCount); }
public void MenuStrip_GetScrollState_Invoke_ReturnsExpected(int bit, bool expected) { using var control = new SubMenuStrip(); Assert.Equal(expected, control.GetScrollState(bit)); }
public void MenuStrip_GetAutoSizeMode_Invoke_ReturnsExpected() { using var control = new SubMenuStrip(); Assert.Equal(AutoSizeMode.GrowAndShrink, control.GetAutoSizeMode()); }
public void MenuStrip_GetTopLevel_Invoke_ReturnsExpected() { using var control = new SubMenuStrip(); Assert.False(control.GetTopLevel()); }
public void MenuStrip_Ctor_Default() { using var control = new SubMenuStrip(); Assert.Null(control.AccessibleDefaultActionDescription); Assert.Null(control.AccessibleDescription); Assert.Null(control.AccessibleName); Assert.Equal(AccessibleRole.Default, control.AccessibleRole); Assert.False(control.AllowDrop); Assert.False(control.AllowItemReorder); Assert.True(control.AllowMerge); Assert.Equal(AnchorStyles.Top | AnchorStyles.Left, control.Anchor); Assert.False(control.AutoScroll); Assert.Equal(Size.Empty, control.AutoScrollMargin); Assert.Equal(Size.Empty, control.AutoScrollMinSize); Assert.Equal(Point.Empty, control.AutoScrollPosition); Assert.True(control.AutoSize); Assert.Equal(Control.DefaultBackColor, control.BackColor); Assert.Null(control.BackgroundImage); Assert.Equal(ImageLayout.Tile, control.BackgroundImageLayout); Assert.Null(control.BindingContext); Assert.Equal(24, control.Bottom); Assert.Equal(new Rectangle(0, 0, 200, 24), control.Bounds); Assert.True(control.CanEnableIme); Assert.False(control.CanFocus); Assert.False(control.CanOverflow); Assert.True(control.CanRaiseEvents); Assert.False(control.CanSelect); Assert.False(control.Capture); Assert.False(control.CausesValidation); Assert.Equal(new Rectangle(0, 0, 200, 24), control.ClientRectangle); Assert.Equal(new Size(200, 24), control.ClientSize); Assert.Null(control.Container); Assert.False(control.ContainsFocus); Assert.Null(control.ContextMenuStrip); Assert.Empty(control.Controls); Assert.Same(control.Controls, control.Controls); Assert.False(control.Created); Assert.Same(Cursors.Default, control.Cursor); Assert.Same(Cursors.Default, control.DefaultCursor); Assert.Equal(DockStyle.Top, control.DefaultDock); Assert.Equal(ToolStripDropDownDirection.BelowRight, control.DefaultDropDownDirection); Assert.Equal(ImeMode.Inherit, control.DefaultImeMode); Assert.Equal(new Padding(2, 2, 0, 2), control.DefaultGripMargin); Assert.Equal(Padding.Empty, control.DefaultMargin); Assert.Equal(Size.Empty, control.DefaultMaximumSize); Assert.Equal(Size.Empty, control.DefaultMinimumSize); Assert.Equal(new Padding(6, 2, 0, 2), control.DefaultPadding); Assert.Equal(new Size(200, 24), control.DefaultSize); Assert.False(control.DefaultShowItemToolTips); Assert.False(control.DesignMode); Assert.Empty(control.DisplayedItems); Assert.Same(control.DisplayedItems, control.DisplayedItems); Assert.Equal(new Rectangle(6, 2, 194, 20), control.DisplayRectangle); Assert.Equal(DockStyle.Top, control.Dock); Assert.NotNull(control.DockPadding); Assert.Same(control.DockPadding, control.DockPadding); Assert.Equal(2, control.DockPadding.Top); Assert.Equal(2, control.DockPadding.Bottom); Assert.Equal(6, control.DockPadding.Left); Assert.Equal(0, control.DockPadding.Right); Assert.True(control.DoubleBuffered); Assert.True(control.Enabled); Assert.NotNull(control.Events); Assert.Same(control.Events, control.Events); Assert.False(control.Focused); Assert.Equal(Control.DefaultFont, control.Font); Assert.Equal(control.Font.Height, control.FontHeight); Assert.Equal(Control.DefaultForeColor, control.ForeColor); Assert.Equal(ToolStripGripStyle.Hidden, control.GripStyle); Assert.Equal(ToolStripGripDisplayStyle.Vertical, control.GripDisplayStyle); Assert.Equal(new Padding(2, 2, 0, 2), control.GripMargin); Assert.Equal(Rectangle.Empty, control.GripRectangle); Assert.False(control.HasChildren); Assert.Equal(24, control.Height); Assert.NotNull(control.HorizontalScroll); Assert.Same(control.HorizontalScroll, control.HorizontalScroll); Assert.False(control.HScroll); Assert.Null(control.ImageList); Assert.Equal(new Size(16, 16), control.ImageScalingSize); Assert.Equal(ImeMode.NoControl, control.ImeMode); Assert.Equal(ImeMode.NoControl, control.ImeModeBase); Assert.False(control.IsAccessible); Assert.False(control.IsCurrentlyDragging); Assert.False(control.IsDropDown); Assert.False(control.IsMirrored); Assert.Empty(control.Items); Assert.Same(control.Items, control.Items); Assert.NotNull(control.LayoutEngine); Assert.Same(control.LayoutEngine, control.LayoutEngine); Assert.Null(control.LayoutSettings); Assert.Equal(ToolStripLayoutStyle.HorizontalStackWithOverflow, control.LayoutStyle); Assert.Equal(0, control.Left); Assert.Equal(Point.Empty, control.Location); Assert.Equal(Padding.Empty, control.Margin); Assert.Equal(Size.Empty, control.MaximumSize); Assert.Equal(new Size(194, 20), control.MaxItemSize); Assert.Null(control.MdiWindowListItem); Assert.Equal(Size.Empty, control.MinimumSize); Assert.Equal(Orientation.Horizontal, control.Orientation); Assert.NotNull(control.OverflowButton); Assert.Same(control.OverflowButton, control.OverflowButton); Assert.Same(control, control.OverflowButton.GetCurrentParent()); Assert.Equal(new Padding(6, 2, 0, 2), control.Padding); Assert.Null(control.Parent); Assert.True(control.PreferredSize.Width > 0); Assert.True(control.PreferredSize.Height > 0); Assert.Equal("Microsoft\u00AE .NET", control.ProductName); Assert.False(control.RecreatingHandle); Assert.Null(control.Region); Assert.NotNull(control.Renderer); Assert.Same(control.Renderer, control.Renderer); Assert.IsType <ToolStripProfessionalRenderer>(control.Renderer); Assert.Equal(ToolStripRenderMode.ManagerRenderMode, control.RenderMode); Assert.False(control.ResizeRedraw); Assert.Equal(200, control.Right); Assert.Equal(RightToLeft.No, control.RightToLeft); Assert.True(control.ShowFocusCues); Assert.False(control.ShowItemToolTips); Assert.True(control.ShowKeyboardCues); Assert.Null(control.Site); Assert.Equal(new Size(200, 24), control.Size); Assert.True(control.Stretch); Assert.Equal(0, control.TabIndex); Assert.False(control.TabStop); Assert.Empty(control.Text); Assert.Equal(ToolStripTextDirection.Horizontal, control.TextDirection); Assert.Equal(0, control.Top); Assert.Null(control.TopLevelControl); Assert.False(control.UseWaitCursor); Assert.NotNull(control.VerticalScroll); Assert.Same(control.VerticalScroll, control.VerticalScroll); Assert.True(control.Visible); Assert.False(control.VScroll); Assert.Equal(200, control.Width); Assert.False(control.IsHandleCreated); }