Exemplo n.º 1
0
        public void TestClickTwiceOnClearButton()
        {
            KeyBindingRow firstRow = null;

            AddStep("click first row", () =>
            {
                firstRow = panel.ChildrenOfType <KeyBindingRow>().First();
                InputManager.MoveMouseTo(firstRow);
                InputManager.Click(MouseButton.Left);
            });

            AddStep("schedule button clicks", () =>
            {
                var clearButton = firstRow.ChildrenOfType <KeyBindingRow.ClearButton>().Single();

                InputManager.MoveMouseTo(clearButton);

                int buttonClicks = 0;
                ScheduledDelegate clickDelegate = null;

                clickDelegate = Scheduler.AddDelayed(() =>
                {
                    InputManager.PressButton(MouseButton.Left);
                    InputManager.ReleaseButton(MouseButton.Left);

                    if (++buttonClicks == 2)
                    {
                        // ReSharper disable once AccessToModifiedClosure
                        Debug.Assert(clickDelegate != null);
                        // ReSharper disable once AccessToModifiedClosure
                        clickDelegate.Cancel();
                    }
                }, 0, true);
            });
        }
Exemplo n.º 2
0
        public void TestClickRowSelectsFirstBinding()
        {
            KeyBindingRow multiBindingRow = null;

            AddStep("click first row with two bindings", () =>
            {
                multiBindingRow = panel.ChildrenOfType <KeyBindingRow>().First(row => row.Defaults.Count() > 1);
                InputManager.MoveMouseTo(multiBindingRow);
                InputManager.Click(MouseButton.Left);
            });

            AddAssert("first binding selected", () => multiBindingRow.ChildrenOfType <KeyBindingRow.KeyButton>().First().IsBinding);

            AddStep("click second binding", () =>
            {
                var target = multiBindingRow.ChildrenOfType <KeyBindingRow.KeyButton>().ElementAt(1);

                InputManager.MoveMouseTo(target);
                InputManager.Click(MouseButton.Left);
            });

            AddStep("click back binding row", () =>
            {
                multiBindingRow = panel.ChildrenOfType <KeyBindingRow>().ElementAt(10);
                InputManager.MoveMouseTo(multiBindingRow);
                InputManager.Click(MouseButton.Left);
            });

            AddAssert("first binding selected", () => multiBindingRow.ChildrenOfType <KeyBindingRow.KeyButton>().First().IsBinding);
        }
Exemplo n.º 3
0
        public void TestResetAllBindingsButton()
        {
            KeyBindingRow settingsKeyBindingRow = null;

            AddStep("click first row", () =>
            {
                settingsKeyBindingRow = panel.ChildrenOfType <KeyBindingRow>().First();

                InputManager.MoveMouseTo(settingsKeyBindingRow);
                InputManager.Click(MouseButton.Left);
                InputManager.PressKey(Key.P);
                InputManager.ReleaseKey(Key.P);
            });

            AddUntilStep("restore button shown", () => settingsKeyBindingRow.ChildrenOfType <RestoreDefaultValueButton <bool> >().First().Alpha > 0);

            AddStep("click reset button for bindings", () =>
            {
                var resetButton = panel.ChildrenOfType <ResetButton>().First();

                resetButton.TriggerClick();
            });

            AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType <RestoreDefaultValueButton <bool> >().First().Alpha == 0);

            AddAssert("binding cleared", () => settingsKeyBindingRow.ChildrenOfType <KeyBindingRow.KeyButton>().ElementAt(0).KeyBinding.KeyCombination.Equals(settingsKeyBindingRow.Defaults.ElementAt(0)));
        }
Exemplo n.º 4
0
        public void TestClickRowSelectsFirstBinding()
        {
            KeyBindingRow backBindingRow = null;

            AddStep("click back binding row", () =>
            {
                backBindingRow = panel.ChildrenOfType <KeyBindingRow>().ElementAt(10);
                InputManager.MoveMouseTo(backBindingRow);
                InputManager.Click(MouseButton.Left);
            });

            AddAssert("first binding selected", () => backBindingRow.ChildrenOfType <KeyBindingRow.KeyButton>().First().IsBinding);

            AddStep("click second binding", () =>
            {
                var target = backBindingRow.ChildrenOfType <KeyBindingRow.KeyButton>().ElementAt(1);

                InputManager.MoveMouseTo(target);
                InputManager.Click(MouseButton.Left);
            });

            AddStep("click back binding row", () =>
            {
                backBindingRow = panel.ChildrenOfType <KeyBindingRow>().ElementAt(10);
                InputManager.MoveMouseTo(backBindingRow);
                InputManager.Click(MouseButton.Left);
            });

            AddAssert("first binding selected", () => backBindingRow.ChildrenOfType <KeyBindingRow.KeyButton>().First().IsBinding);
        }
Exemplo n.º 5
0
        public void TestClearButtonOnBindings()
        {
            KeyBindingRow multiBindingRow = null;

            AddStep("click first row with two bindings", () =>
            {
                multiBindingRow = panel.ChildrenOfType <KeyBindingRow>().First(row => row.Defaults.Count() > 1);
                InputManager.MoveMouseTo(multiBindingRow);
                InputManager.Click(MouseButton.Left);
            });

            clickClearButton();

            AddAssert("first binding cleared", () => string.IsNullOrEmpty(multiBindingRow.ChildrenOfType <KeyBindingRow.KeyButton>().First().Text.Text.ToString()));

            AddStep("click second binding", () =>
            {
                var target = multiBindingRow.ChildrenOfType <KeyBindingRow.KeyButton>().ElementAt(1);

                InputManager.MoveMouseTo(target);
                InputManager.Click(MouseButton.Left);
            });

            clickClearButton();

            AddAssert("second binding cleared", () => string.IsNullOrEmpty(multiBindingRow.ChildrenOfType <KeyBindingRow.KeyButton>().ElementAt(1).Text.Text.ToString()));

            void clickClearButton()
            {
                AddStep("click clear button", () =>
                {
                    var clearButton = multiBindingRow.ChildrenOfType <KeyBindingRow.ClearButton>().Single();

                    InputManager.MoveMouseTo(clearButton);
                    InputManager.Click(MouseButton.Left);
                });
            }
        }
Exemplo n.º 6
0
        public void TestClearButtonOnBindings()
        {
            KeyBindingRow backBindingRow = null;

            AddStep("click back binding row", () =>
            {
                backBindingRow = panel.ChildrenOfType <KeyBindingRow>().ElementAt(10);
                InputManager.MoveMouseTo(backBindingRow);
                InputManager.Click(MouseButton.Left);
            });

            clickClearButton();

            AddAssert("first binding cleared", () => string.IsNullOrEmpty(backBindingRow.ChildrenOfType <KeyBindingRow.KeyButton>().First().Text.Text));

            AddStep("click second binding", () =>
            {
                var target = backBindingRow.ChildrenOfType <KeyBindingRow.KeyButton>().ElementAt(1);

                InputManager.MoveMouseTo(target);
                InputManager.Click(MouseButton.Left);
            });

            clickClearButton();

            AddAssert("second binding cleared", () => string.IsNullOrEmpty(backBindingRow.ChildrenOfType <KeyBindingRow.KeyButton>().ElementAt(1).Text.Text));

            void clickClearButton()
            {
                AddStep("click clear button", () =>
                {
                    var clearButton = backBindingRow.ChildrenOfType <KeyBindingRow.ClearButton>().Single();

                    InputManager.MoveMouseTo(clearButton);
                    InputManager.Click(MouseButton.Left);
                });
            }
        }