Exemple #1
0
        public void Button_StateChangesOnMouseEvent_Test()
        {
            var button = new Button(new TestHelpers.RootElement(), AssetManager)
            {
                DestRect = new Rectangle(0.0f, 0.0f, 0.5f, 0.5f)
            };

            // We need to check that "template" does not consume our event.
            var block = new TextBlock(button, AssetManager) { Name = "Normal TextBlock" };
            button.SetTemplate(ButtonState.Normal, block.Name);

            button.InjectMouseMoveEvent(0.0f, 0.0f);
            Assert.AreEqual(ButtonState.Hover, button.State);

            button.InjectMouseDownEvent(0.0f, 0.0f, MouseButton.Left);
            Assert.AreEqual(ButtonState.Pushed, button.State);

            button.InjectMouseUpEvent(0.0f, 0.0f, MouseButton.Left);
            Assert.AreEqual(ButtonState.Hover, button.State);

            button.InjectMouseDownEvent(0.0f, 0.0f, MouseButton.Right);
            Assert.AreEqual(ButtonState.Hover, button.State);

            button.InjectMouseMoveEvent(button.AbsRect.Left - 1, button.AbsRect.Top - 1);
            Assert.AreEqual(ButtonState.Normal, button.State);
        }