public void TestInjectButtonPress() { Screen screen = new Screen(); GamePadTestControl control = new GamePadTestControl(); screen.Desktop.Children.Add(control); screen.InjectButtonPress(Buttons.A); Assert.AreEqual(1, control.HeldButtonCount); }
public void TestButtonPressWithFocusedControl() { Screen screen = new Screen(100.0f, 100.0f); GamePadTestControl child1 = new GamePadTestControl(); GamePadTestControl child2 = new GamePadTestControl(); screen.Desktop.Children.Add(child1); screen.Desktop.Children.Add(child2); screen.FocusedControl = child2; screen.InjectButtonPress(Buttons.A); Assert.AreEqual(0, child1.HeldButtonCount); Assert.AreEqual(1, child2.HeldButtonCount); screen.InjectButtonRelease(Buttons.A); Assert.AreEqual(0, child1.HeldButtonCount); Assert.AreEqual(0, child2.HeldButtonCount); }
public void TestButtonPressWithActivatedControl() { Screen screen = new Screen(100.0f, 100.0f); GamePadTestControl child1 = new GamePadTestControl(); GamePadTestControl child2 = new GamePadTestControl(); 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.InjectButtonPress(Buttons.A); Assert.AreEqual(0, child1.HeldButtonCount); Assert.AreEqual(1, child2.HeldButtonCount); screen.InjectButtonRelease(Buttons.A); Assert.AreEqual(0, child1.HeldButtonCount); Assert.AreEqual(0, child2.HeldButtonCount); }