Ejemplo n.º 1
0
        public void TestMouseWheel()
        {
            Screen           screen  = new Screen();
            MouseTestControl control = new MouseTestControl();

            control.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
            screen.Desktop.Children.Add(control);

            screen.InjectMouseMove(50.0f, 50.0f);
            screen.InjectMouseWheel(12.34f);
            Assert.AreEqual(12.34f, control.MouseWheelTicks);
        }
Ejemplo n.º 2
0
        public void TestKeyPressWithActivatedControl()
        {
            Screen screen = new Screen(100.0f, 100.0f);
            KeyboardTestControl child1 = new KeyboardTestControl();
            KeyboardTestControl child2 = new KeyboardTestControl();

            child2.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
            screen.Desktop.Children.Add(child1);
            screen.Desktop.Children.Add(child2);

            // Click on child 2
            screen.InjectMouseMove(50.0f, 50.0f);
            screen.InjectMousePress(MouseButtons.Left);

            // Now child 2 should be receiving the input instead of child 1
            screen.InjectKeyPress(Keys.A);
            Assert.AreEqual(0, child1.HeldKeyCount);
            Assert.AreEqual(1, child2.HeldKeyCount);
            screen.InjectKeyRelease(Keys.A);
            Assert.AreEqual(0, child1.HeldKeyCount);
            Assert.AreEqual(0, child2.HeldKeyCount);
        }
Ejemplo n.º 3
0
    public void TestMouseWheel() {
      Screen screen = new Screen();
      MouseTestControl control = new MouseTestControl();
      control.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
      screen.Desktop.Children.Add(control);

      screen.InjectMouseMove(50.0f, 50.0f);
      screen.InjectMouseWheel(12.34f);
      Assert.AreEqual(12.34f, control.MouseWheelTicks);
    }
Ejemplo n.º 4
0
    public void TestKeyPressWithActivatedControl() {
      Screen screen = new Screen(100.0f, 100.0f);
      KeyboardTestControl child1 = new KeyboardTestControl();
      KeyboardTestControl child2 = new KeyboardTestControl();
      child2.Bounds = new UniRectangle(10.0f, 10.0f, 80.0f, 80.0f);
      screen.Desktop.Children.Add(child1);
      screen.Desktop.Children.Add(child2);

      // Click on child 2
      screen.InjectMouseMove(50.0f, 50.0f);
      screen.InjectMousePress(MouseButtons.Left);

      // Now child 2 should be receiving the input instead of child 1
      screen.InjectKeyPress(Keys.A);
      Assert.AreEqual(0, child1.HeldKeyCount);
      Assert.AreEqual(1, child2.HeldKeyCount);
      screen.InjectKeyRelease(Keys.A);
      Assert.AreEqual(0, child1.HeldKeyCount);
      Assert.AreEqual(0, child2.HeldKeyCount);
    }