void CheckVerticalLayout(TestingSplitterBox splitter, float x) { int left = (int)Math.Max(0, x * splitter.Width - SplitterBox.SPLITTER_HALFSIZE); left = Math.Min(left, splitter.Width - SplitterBox.SPLITTER_SIZE); Assert.That(splitter.Orientation, Is.EqualTo(Orientation.Vertical)); Assert.False(splitter.SplitterRectangle.IsEmpty); Assert.That(splitter.SplitterRectangle.Left, Is.EqualTo(left)); Assert.That(splitter.SplitterRectangle.Top, Is.EqualTo(0)); Assert.That(splitter.SplitterRectangle.Width, Is.EqualTo(SplitterBox.SPLITTER_SIZE)); Assert.That(splitter.SplitterRectangle.Height, Is.EqualTo(splitter.Height)); Assert.That(splitter.Control1.Left, Is.EqualTo(0)); Assert.That(splitter.Control1.Top, Is.EqualTo(0)); Assert.That(splitter.Control1.Right, Is.EqualTo(splitter.SplitterRectangle.Left)); Assert.That(splitter.Control1.Height, Is.EqualTo(splitter.Height)); Assert.That(splitter.Control2.Left, Is.EqualTo(splitter.SplitterRectangle.Right)); Assert.That(splitter.Control2.Top, Is.EqualTo(0)); Assert.That(splitter.Control2.Right, Is.EqualTo(splitter.Width)); Assert.That(splitter.Control2.Height, Is.EqualTo(splitter.Height)); return; }
void CheckVerticalRectangles(TestingSplitterBox splitter) { Assert.False(splitter.Collapse1Rectangle.IsEmpty); Assert.False(splitter.DirectionRectangle.IsEmpty); Assert.False(splitter.Collapse2Rectangle.IsEmpty); int y = (splitter.Height - 41) / 2; Assert.That(splitter.SplitterRectangle.Left, Is.GreaterThanOrEqualTo(0)); Assert.That(splitter.SplitterRectangle.Right, Is.LessThanOrEqualTo(150)); Assert.That(splitter.Collapse1Rectangle, Is.EqualTo(new Rectangle(splitter.SplitterRectangle.Left, y, SplitterBox.SPLITTER_SIZE, SplitterBox.BUTTON_SIZE))); Assert.That(splitter.DirectionRectangle, Is.EqualTo(new Rectangle( splitter.SplitterRectangle.Left, splitter.Collapse1Rectangle.Bottom + 2, SplitterBox.SPLITTER_SIZE, SplitterBox.BUTTON_SIZE))); Assert.That(splitter.Collapse2Rectangle, Is.EqualTo(new Rectangle( splitter.SplitterRectangle.Left, splitter.DirectionRectangle.Bottom + 2, SplitterBox.SPLITTER_SIZE, SplitterBox.BUTTON_SIZE))); return; }
public void SetUp() { _vertical = new TestingSplitterBox(); _horizontal = new TestingSplitterBox(); _horizontal.Orientation = Orientation.Horizontal; return; }
void CheckHorizontalLayout(TestingSplitterBox splitter, float y) { int top = (int)Math.Max(0, y * splitter.Height - SplitterBox.SPLITTER_HALFSIZE); top = Math.Min(top, splitter.Height - SplitterBox.SPLITTER_SIZE); Assert.That(splitter.Orientation, Is.EqualTo(Orientation.Horizontal)); Assert.False(splitter.SplitterRectangle.IsEmpty); Assert.That(splitter.SplitterRectangle, Is.EqualTo(new Rectangle(0, top, splitter.Width, SplitterBox.SPLITTER_SIZE))); Assert.That(splitter.Control1.Left, Is.EqualTo(0)); Assert.That(splitter.Control1.Top, Is.EqualTo(0)); Assert.That(splitter.Control1.Right, Is.EqualTo(splitter.Width)); Assert.That(splitter.Control1.Height, Is.EqualTo(splitter.SplitterRectangle.Top)); Assert.That(splitter.Control2.Left, Is.EqualTo(0)); Assert.That(splitter.Control2.Top, Is.EqualTo(splitter.SplitterRectangle.Bottom)); Assert.That(splitter.Control2.Right, Is.EqualTo(splitter.Width)); Assert.That(splitter.Control2.Bottom, Is.EqualTo(splitter.Height)); return; }
void CheckHorizontalRectangles(TestingSplitterBox splitter) { Assert.False(splitter.Collapse1Rectangle.IsEmpty); Assert.False(splitter.DirectionRectangle.IsEmpty); Assert.False(splitter.Collapse2Rectangle.IsEmpty); int x = (splitter.Width - 41) / 2; int y = splitter.SplitterRectangle.Top; Assert.That(splitter.SplitterRectangle.Top, Is.GreaterThanOrEqualTo(0)); Assert.That(splitter.SplitterRectangle.Bottom, Is.LessThanOrEqualTo(splitter.Height)); Assert.That(splitter.Collapse1Rectangle, Is.EqualTo(new Rectangle(x, y, SplitterBox.BUTTON_SIZE, SplitterBox.SPLITTER_SIZE))); Assert.That(splitter.DirectionRectangle, Is.EqualTo(new Rectangle(splitter.Collapse1Rectangle.Right + 2, y, SplitterBox.BUTTON_SIZE, SplitterBox.SPLITTER_SIZE))); Assert.That(splitter.Collapse2Rectangle, Is.EqualTo(new Rectangle(splitter.DirectionRectangle.Right + 2, y, SplitterBox.BUTTON_SIZE, SplitterBox.SPLITTER_SIZE))); return; }
public void MouseActions() { // test 1: check ability to move splitter _vertical = new TestingSplitterBox(); _vertical.FireMouseDown(_vertical.SplitterRectangle.Left + 1, 1); _vertical.FireMouseMove(0, 1); _vertical.FireMouseUp(0, 1); Assert.That(_vertical.SplitterDistance, Is.EqualTo(0)); // test 2: splitter doesn't move when mouse down occurs while // the mouse is hovering Collapse1Rectangle _vertical = new TestingSplitterBox(); _vertical.FireMouseDown( _vertical.Collapse1Rectangle.Left + 1, _vertical.Collapse1Rectangle.Top + 1); _vertical.FireMouseMove(0, 1); _vertical.FireMouseUp(0, 1); Assert.That(_vertical.SplitterDistance, Is.EqualTo(0.5f)); // test 3: mouse down occurs on SplitterRectangle area (except the buttons) // mouse up occurs on Collapse1Rectangle // CollapseControl1() should not be triggered and splitter // should be at the last notified mouse position _vertical = new TestingSplitterBox(); _vertical.FireMouseDown(_vertical.SplitterRectangle.Left + 1, 1); _vertical.FireMouseMove(150, 0); _vertical.FireMouseUp(_vertical.Collapse1Rectangle.Left + 1, _vertical.Collapse1Rectangle.Top + 1); Assert.That(_vertical.SplitterDistance, Is.EqualTo(1)); // test 4: mouse down occurs on SplitterRectangle // mouse up occurs on Collapse2Rectangle // CollapseControl2 shouldn't be triggered and splitter // should be at the last notified mouse position _vertical = new TestingSplitterBox(); _vertical.FireMouseDown(_vertical.SplitterRectangle.Left + 1, 1); _vertical.FireMouseMove(0, 0); _vertical.FireMouseUp(_vertical.Collapse2Rectangle.Left + 1, _vertical.Collapse2Rectangle.Top + 1); Assert.That(_vertical.SplitterDistance, Is.EqualTo(0)); // test 5: mouse down occurs on SplitterRectangle // mouse up occurs on DirectionRectangle // Orientation shouldn't be triggered and splitter // should be at the last notified mouse position _vertical = new TestingSplitterBox(); _vertical.FireMouseDown(_vertical.SplitterRectangle.Left + 1, 1); _vertical.FireMouseMove(0, 0); _vertical.FireMouseUp(_vertical.DirectionRectangle.Left + 1, _vertical.DirectionRectangle.Top + 1); Assert.That(_vertical.SplitterDistance, Is.EqualTo(0)); Assert.That(_vertical.Orientation, Is.EqualTo(Orientation.Vertical)); return; }