Example #1
0
        public void TestMousePressWithActivatedControl()
        {
            Screen           screen = new Screen(100.0f, 100.0f);
            MouseTestControl child  = new MouseTestControl();

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

            screen.InjectKeyPress(Keys.A);

            screen.InjectMousePress(MouseButtons.Left);
            Assert.AreEqual(MouseButtons.Left, child.HeldMouseButtons);
        }
Example #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);
        }
Example #3
0
    public void TestMousePressWithActivatedControl() {
      Screen screen = new Screen(100.0f, 100.0f);
      MouseTestControl child = new MouseTestControl();
      child.Bounds = new UniRectangle(55.0f, 10.0f, 35.0f, 80.0f);
      screen.Desktop.Children.Add(child);

      screen.InjectKeyPress(Keys.A);

      screen.InjectMousePress(MouseButtons.Left);
      Assert.AreEqual(MouseButtons.Left, child.HeldMouseButtons);
    }
Example #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);
    }