Пример #1
0
        public void TestButtonPressWithActivatedControl()
        {
            Control parent = new Control();

            parent.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
            GamePadTestControl child1 = new GamePadTestControl(true);
            GamePadTestControl child2 = new GamePadTestControl(true);

            child2.Bounds = new UniRectangle(10.0f, 10.0f, 25.0f, 60.0f);

            parent.Children.Add(child1);
            parent.Children.Add(child2);

            parent.ProcessMouseMove(100.0f, 100.0f, 20.0f, 30.0f);
            parent.ProcessMousePress(MouseButtons.Left);

            Assert.AreEqual(0, child1.HeldButtonCount);
            Assert.AreEqual(0, child2.HeldButtonCount);
            parent.ProcessButtonPress(Buttons.A);
            Assert.AreEqual(0, child1.HeldButtonCount);
            Assert.AreEqual(1, child2.HeldButtonCount); // Because child 1 was activated
            parent.ProcessButtonRelease(Buttons.A);
            Assert.AreEqual(0, child1.HeldButtonCount);
            Assert.AreEqual(0, child2.HeldButtonCount);
        }
Пример #2
0
        public void TestMouseWheelWithActivatedControl()
        {
            Control parent = new Control();
            MouseWheelTestControl child = new MouseWheelTestControl();

            child.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
            parent.Children.Add(child);

            parent.ProcessMouseMove(100.0f, 100.0f, 50.0f, 50.0f);
            parent.ProcessMousePress(MouseButtons.Left);
            parent.ProcessMouseMove(100.0f, 100.0f, -1.0f, -1.0f);

            Assert.AreEqual(0.0f, child.Ticks);
            parent.ProcessMouseWheel(12.34f);
            Assert.AreEqual(12.34f, child.Ticks);
        }
Пример #3
0
        public void TestKeyPressWithActivatedControl()
        {
            Control parent = new Control();

            parent.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
            KeyboardTestControl child1 = new KeyboardTestControl(true);
            KeyboardTestControl child2 = new KeyboardTestControl(true);

            child2.Bounds = new UniRectangle(10.0f, 10.0f, 25.0f, 60.0f);

            parent.Children.Add(child1);
            parent.Children.Add(child2);

            parent.ProcessMouseMove(100.0f, 100.0f, 20.0f, 30.0f);
            parent.ProcessMousePress(MouseButtons.Left);

            Assert.AreEqual(0, child1.HeldKeyCount);
            Assert.AreEqual(0, child2.HeldKeyCount);
            parent.ProcessKeyPress(Keys.A, false);
            Assert.AreEqual(0, child1.HeldKeyCount);
            Assert.AreEqual(1, child2.HeldKeyCount); // Because child 1 was activated
            parent.ProcessKeyRelease(Keys.A);
            Assert.AreEqual(0, child1.HeldKeyCount);
            Assert.AreEqual(0, child2.HeldKeyCount);
        }
Пример #4
0
        public void TestMouseOverWithActivatedControl()
        {
            Control parent = new Control();

            parent.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
            MouseOverTestControl child = new MouseOverTestControl();

            child.Bounds = new UniRectangle(10.0f, 10.0f, 25.0f, 60.0f);
            parent.Children.Add(child);

            parent.ProcessMouseMove(100.0f, 100.0f, 20.0f, 30.0f);
            Assert.IsTrue(child.MouseOver);

            parent.ProcessMousePress(MouseButtons.Left);
            parent.ProcessMouseMove(100.0f, 100.0f, -1.0f, -1.0f);

            Assert.IsFalse(child.MouseOver);
        }
Пример #5
0
        public void TestIgnoreMousePress()
        {
            Control control = new Control();

            control.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);

            control.ProcessMouseMove(100.0f, 100.0f, 20.0f, 20.0f);
            control.ProcessMousePress(MouseButtons.Left);
            control.ProcessMouseRelease(MouseButtons.Left);
        }
Пример #6
0
        public void TestMouseWheelWithMouseOverControl()
        {
            Control parent = new Control();
            MouseWheelTestControl child = new MouseWheelTestControl();

            child.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
            parent.Children.Add(child);

            parent.ProcessMouseMove(100.0f, 100.0f, 50.0f, 50.0f);

            Assert.AreEqual(0.0f, child.Ticks);
            parent.ProcessMouseWheel(12.34f);
            Assert.AreEqual(12.34f, child.Ticks);
        }
Пример #7
0
        public void TestMouseOverChildren()
        {
            Control parent = new Control();

            parent.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
            MouseOverTestControl child1 = new MouseOverTestControl();

            child1.Bounds = new UniRectangle(10.0f, 10.0f, 25.0f, 60.0f);
            MouseOverTestControl child2 = new MouseOverTestControl();

            child2.Bounds = new UniRectangle(45.0f, 10.0f, 25.0f, 60.0f);

            parent.Children.Add(child1);
            parent.Children.Add(child2);

            Assert.IsFalse(child1.MouseOver);
            Assert.IsFalse(child2.MouseOver);
            parent.ProcessMouseMove(100.0f, 100.0f, 20.0f, 30.0f);
            Assert.IsTrue(child1.MouseOver);
            Assert.IsFalse(child2.MouseOver);
            parent.ProcessMouseMove(100.0f, 100.0f, 60.0f, 30.0f);
            Assert.IsFalse(child1.MouseOver);
            Assert.IsTrue(child2.MouseOver);
        }
Пример #8
0
        public void TestReorderControlsOnMousePress()
        {
            Control parent = new Control();

            parent.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
            Controls.Desktop.WindowControl child1 = new Controls.Desktop.WindowControl();
            child1.Bounds = new UniRectangle(10.0f, 10.0f, 25.0f, 60.0f);
            Controls.Desktop.WindowControl child2 = new Controls.Desktop.WindowControl();
            child2.Bounds = new UniRectangle(45.0f, 10.0f, 25.0f, 60.0f);

            parent.Children.Add(child1);
            parent.Children.Add(child2);

            Assert.AreSame(child1, parent.Children[0]);
            Assert.AreSame(child2, parent.Children[1]);

            parent.ProcessMouseMove(100.0f, 100.0f, 60.0f, 30.0f);
            parent.ProcessMousePress(MouseButtons.Left);

            Assert.AreSame(child2, parent.Children[0]);
            Assert.AreSame(child1, parent.Children[1]);
        }
Пример #9
0
    public void TestButtonPressWithActivatedControl() {
      Control parent = new Control();
      parent.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
      GamePadTestControl child1 = new GamePadTestControl(true);
      GamePadTestControl child2 = new GamePadTestControl(true);
      child2.Bounds = new UniRectangle(10.0f, 10.0f, 25.0f, 60.0f);

      parent.Children.Add(child1);
      parent.Children.Add(child2);

      parent.ProcessMouseMove(100.0f, 100.0f, 20.0f, 30.0f);
      parent.ProcessMousePress(MouseButtons.Left);

      Assert.AreEqual(0, child1.HeldButtonCount);
      Assert.AreEqual(0, child2.HeldButtonCount);
      parent.ProcessButtonPress(Buttons.A);
      Assert.AreEqual(0, child1.HeldButtonCount);
      Assert.AreEqual(1, child2.HeldButtonCount); // Because child 1 was activated
      parent.ProcessButtonRelease(Buttons.A);
      Assert.AreEqual(0, child1.HeldButtonCount);
      Assert.AreEqual(0, child2.HeldButtonCount);
    }
Пример #10
0
    public void TestKeyPressWithActivatedControl() {
      Control parent = new Control();
      parent.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
      KeyboardTestControl child1 = new KeyboardTestControl(true);
      KeyboardTestControl child2 = new KeyboardTestControl(true);
      child2.Bounds = new UniRectangle(10.0f, 10.0f, 25.0f, 60.0f);

      parent.Children.Add(child1);
      parent.Children.Add(child2);

      parent.ProcessMouseMove(100.0f, 100.0f, 20.0f, 30.0f);
      parent.ProcessMousePress(MouseButtons.Left);
      
      Assert.AreEqual(0, child1.HeldKeyCount);
      Assert.AreEqual(0, child2.HeldKeyCount);
      parent.ProcessKeyPress(Keys.A, false);
      Assert.AreEqual(0, child1.HeldKeyCount);
      Assert.AreEqual(1, child2.HeldKeyCount); // Because child 1 was activated
      parent.ProcessKeyRelease(Keys.A);
      Assert.AreEqual(0, child1.HeldKeyCount);
      Assert.AreEqual(0, child2.HeldKeyCount);
    }
Пример #11
0
    public void TestMouseWheelWithMouseOverControl() {
      Control parent = new Control();
      MouseWheelTestControl child = new MouseWheelTestControl();
      child.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
      parent.Children.Add(child);

      parent.ProcessMouseMove(100.0f, 100.0f, 50.0f, 50.0f);

      Assert.AreEqual(0.0f, child.Ticks);
      parent.ProcessMouseWheel(12.34f);
      Assert.AreEqual(12.34f, child.Ticks);
    }
Пример #12
0
    public void TestMouseWheelWithActivatedControl() {
      Control parent = new Control();
      MouseWheelTestControl child = new MouseWheelTestControl();
      child.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
      parent.Children.Add(child);

      parent.ProcessMouseMove(100.0f, 100.0f, 50.0f, 50.0f);
      parent.ProcessMousePress(MouseButtons.Left);
      parent.ProcessMouseMove(100.0f, 100.0f, -1.0f, -1.0f);
      
      Assert.AreEqual(0.0f, child.Ticks);
      parent.ProcessMouseWheel(12.34f);
      Assert.AreEqual(12.34f, child.Ticks);
    }
Пример #13
0
    public void TestReorderControlsOnMousePress() {
      Control parent = new Control();
      parent.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
      Controls.Desktop.WindowControl child1 = new Controls.Desktop.WindowControl();
      child1.Bounds = new UniRectangle(10.0f, 10.0f, 25.0f, 60.0f);
      Controls.Desktop.WindowControl child2 = new Controls.Desktop.WindowControl();
      child2.Bounds = new UniRectangle(45.0f, 10.0f, 25.0f, 60.0f);

      parent.Children.Add(child1);
      parent.Children.Add(child2);

      Assert.AreSame(child1, parent.Children[0]);
      Assert.AreSame(child2, parent.Children[1]);
      
      parent.ProcessMouseMove(100.0f, 100.0f, 60.0f, 30.0f);
      parent.ProcessMousePress(MouseButtons.Left);

      Assert.AreSame(child2, parent.Children[0]);
      Assert.AreSame(child1, parent.Children[1]);
    }
Пример #14
0
    public void TestIgnoreMousePress() {
      Control control = new Control();
      control.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);

      control.ProcessMouseMove(100.0f, 100.0f, 20.0f, 20.0f);
      control.ProcessMousePress(MouseButtons.Left);
      control.ProcessMouseRelease(MouseButtons.Left);
    }
Пример #15
0
    public void TestMouseOverWithActivatedControl() {
      Control parent = new Control();
      parent.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
      MouseOverTestControl child = new MouseOverTestControl();
      child.Bounds = new UniRectangle(10.0f, 10.0f, 25.0f, 60.0f);
      parent.Children.Add(child);

      parent.ProcessMouseMove(100.0f, 100.0f, 20.0f, 30.0f);
      Assert.IsTrue(child.MouseOver);

      parent.ProcessMousePress(MouseButtons.Left);
      parent.ProcessMouseMove(100.0f, 100.0f, -1.0f, -1.0f);
      
      Assert.IsFalse(child.MouseOver);
    }
Пример #16
0
    public void TestMouseOverChildren() {
      Control parent = new Control();
      parent.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
      MouseOverTestControl child1 = new MouseOverTestControl();
      child1.Bounds = new UniRectangle(10.0f, 10.0f, 25.0f, 60.0f);
      MouseOverTestControl child2 = new MouseOverTestControl();
      child2.Bounds = new UniRectangle(45.0f, 10.0f, 25.0f, 60.0f);
      
      parent.Children.Add(child1);
      parent.Children.Add(child2);

      Assert.IsFalse(child1.MouseOver);
      Assert.IsFalse(child2.MouseOver);
      parent.ProcessMouseMove(100.0f, 100.0f, 20.0f, 30.0f);
      Assert.IsTrue(child1.MouseOver);
      Assert.IsFalse(child2.MouseOver);
      parent.ProcessMouseMove(100.0f, 100.0f, 60.0f, 30.0f);
      Assert.IsFalse(child1.MouseOver);
      Assert.IsTrue(child2.MouseOver);
    }