Beispiel #1
0
        public void MouseHover_DoesNotFireAfterMove()
        {
            MockApplication testView = MockApplication.Setup <InputSystemTestThing2>();

            testView.Update();
            testView.SetViewportRect(new Rect(0, 0, 1000, 1000));
            InputSystemTestThing2 root = (InputSystemTestThing2)testView.RootElement;

            root.ignoreHover = false;

            testView.InputSystem.SetMousePosition(new Vector2(20, 10));
            testView.Update();

            Assert.AreEqual(new string[0], root.clickList.ToArray());

            testView.InputSystem.SetMousePosition(new Vector2(20, 10));
            testView.Update();

            Assert.AreEqual(new[] { "hover:child0", "hover:root" }, root.clickList.ToArray());

            testView.InputSystem.SetMousePosition(new Vector2(21, 10));
            testView.Update();

            Assert.AreEqual(new[] { "hover:child0", "hover:root" }, root.clickList.ToArray());
        }
Beispiel #2
0
        public void MouseExit_FireAgainWhenReenteredElement()
        {
            MockApplication testView = MockApplication.Setup <InputSystemTestThing2>();

            testView.Update();
            testView.SetViewportRect(new Rect(0, 0, 1000, 1000));
            InputSystemTestThing2 root = (InputSystemTestThing2)testView.RootElement;

            root.ignoreExit = false;

            testView.InputSystem.SetMousePosition(new Vector2(20, 10));
            testView.Update();

            Assert.AreEqual(new string[0], root.clickList.ToArray());

            testView.InputSystem.SetMousePosition(new Vector2(120, 10));
            testView.Update();

            testView.InputSystem.SetMousePosition(new Vector2(20, 10));
            testView.Update();

            testView.InputSystem.SetMousePosition(new Vector2(120, 10));
            testView.Update();

            Assert.AreEqual(new[] { "exit:child0", "exit:child0" }, root.clickList.ToArray());
        }
Beispiel #3
0
        public void MouseEnter_FiresForReEnteringElement()
        {
            MockApplication testView = MockApplication.Setup <InputSystemTestThing2>();

            testView.Update();
            testView.SetViewportRect(new Rect(0, 0, 1000, 1000));
            InputSystemTestThing2 root = (InputSystemTestThing2)testView.RootElement;

            root.ignoreEnter = false;
            MouseState mouseState = new MouseState();

            mouseState.mousePosition = new Vector2(20, 10);
            testView.InputSystem.SetMouseState(mouseState);
            testView.Update();

            mouseState.mousePosition = new Vector2(240, 10);
            testView.InputSystem.SetMouseState(mouseState);
            testView.Update();

            mouseState.mousePosition = new Vector2(20, 10);
            testView.InputSystem.SetMouseState(mouseState);
            testView.Update();

            Assert.AreEqual(new[] { "enter:child0", "enter:root", "enter:child2", "enter:child0" }, root.clickList.ToArray());
        }
Beispiel #4
0
        public void MouseDown_StopPropagationInBubble()
        {
            MockApplication testView = MockApplication.Setup <InputSystemTestThing2>();

            testView.Update();
            testView.SetViewportRect(new Rect(0, 0, 1000, 1000));
            InputSystemTestThing2 root = (InputSystemTestThing2)testView.RootElement;

            testView.InputSystem.MouseDown(new Vector2(120, 10));
            root.shouldStopPropagation = true;
            testView.Update();

            Assert.AreEqual(-1, root.clickedChildIndex);
            Assert.IsTrue(root.wasMouseDown);

            testView.InputSystem.ClearClickState();
            testView.Update();

            root.wasMouseDown = false;

            root.shouldStopPropagation = false;
            testView.InputSystem.MouseDown(new Vector2(120, 10));
            testView.Update();

            Assert.AreEqual(1, root.clickedChildIndex);
            Assert.IsTrue(root.wasMouseDown);
        }
Beispiel #5
0
        public void MouseMove_FiresAndPropagates()
        {
            MockApplication testView = MockApplication.Setup <InputSystemTestThing2>();

            testView.Update();
            testView.SetViewportRect(new Rect(0, 0, 1000, 1000));
            InputSystemTestThing2 root = (InputSystemTestThing2)testView.RootElement;

            root.ignoreMove = false;

            testView.InputSystem.SetMousePosition(new Vector2(20, 10));
            testView.Update();

            Assert.AreEqual(new[] { "move:child0", "move:root" }, root.clickList.ToArray());
        }
Beispiel #6
0
        public void MouseUp_FiresAndPropagates()
        {
            MockApplication testView = MockApplication.Setup <InputSystemTestThing2>();

            testView.Update();
            testView.SetViewportRect(new Rect(0, 0, 1000, 1000));
            InputSystemTestThing2 root = (InputSystemTestThing2)testView.RootElement;

            MouseState mouseState = new MouseState();

            mouseState.leftMouseButtonState.isUpThisFrame = true;
            mouseState.mousePosition = new Vector2(220, 10);
            testView.InputSystem.SetMouseState(mouseState);
            testView.Update();

            Assert.AreEqual(new[] { "up:child2", "up:root" }, root.clickList.ToArray());
        }
Beispiel #7
0
        public void MouseUp_OutOfBounds()
        {
            MockApplication testView = MockApplication.Setup <InputSystemTestThing2>();

            testView.Update();
            testView.SetViewportRect(new Rect(0, 0, 1000, 1000));
            InputSystemTestThing2 root = (InputSystemTestThing2)testView.RootElement;

            MouseState mouseState = new MouseState();

            mouseState.leftMouseButtonState.isUpThisFrame = true;

            mouseState.mousePosition = new Vector2(1200, 10);
            testView.InputSystem.SetMouseState(mouseState);
            testView.Update();

            Assert.AreEqual(new string[0], root.clickList.ToArray());
        }
Beispiel #8
0
        public void MouseDown_BubbleThenCapture()
        {
            MockApplication testView = MockApplication.Setup <InputSystemTestThing2>();

            testView.Update();
            testView.SetViewportRect(new Rect(0, 0, 1000, 1000));
            InputSystemTestThing2 root = (InputSystemTestThing2)testView.RootElement;

            testView.Update();
            MouseState mouseState = new MouseState();

            mouseState.leftMouseButtonState.isDown          = true;
            mouseState.leftMouseButtonState.isDownThisFrame = true;

            mouseState.mousePosition = new Vector2(120, 10);
            testView.InputSystem.SetMouseState(mouseState);
            testView.Update();

            Assert.AreEqual(new[] { "down:root", "down:child1" }, root.clickList.ToArray());
        }