Пример #1
0
        public void InputTextKeyHello()
        {
            MockInputSimulator inputSimulator = new MockInputSimulator();
            TestabelKeyboard   keyboard       = CreateKeyboard(inputSimulator);

            MockButton btn = keyboard.Children[4] as MockButton;

            btn.ClickButton();

            Assert.AreEqual("Hello World!", inputSimulator.GetTextInput());
        }
Пример #2
0
        public void GetKeyText()
        {
            MockInputSimulator inputSimulator = new MockInputSimulator();
            TestabelKeyboard   keyboard       = CreateKeyboard(inputSimulator);

            MockButton btn = keyboard.Children[4] as MockButton;

            string text = Keyboard.GetOutputText(btn);

            Assert.AreEqual("Hello World!", text);
        }
Пример #3
0
        public void GetBehaviour()
        {
            MockInputSimulator inputSimulator = new MockInputSimulator();
            TestabelKeyboard   keyboard       = CreateKeyboard(inputSimulator);

            MockButton btn = keyboard.Children[3] as MockButton;

            KeyBehaviour behaviour = Keyboard.GetKeyBehaviour(btn);

            Assert.AreEqual(KeyBehaviour.VirtualKey, behaviour);
        }
Пример #4
0
        public void GetKeyCode()
        {
            MockInputSimulator inputSimulator = new MockInputSimulator();
            TestabelKeyboard   keyboard       = CreateKeyboard(inputSimulator);

            MockButton btn = keyboard.Children[3] as MockButton;

            VirtualKeyCode keyCode = Keyboard.GetKeyCode(btn);

            Assert.AreEqual(VirtualKeyCode.VkA, keyCode);
        }
Пример #5
0
        public void GetKeyChord()
        {
            MockInputSimulator inputSimulator = new MockInputSimulator();
            TestabelKeyboard   keyboard       = CreateKeyboard(inputSimulator);

            MockButton btn = keyboard.Children[5] as MockButton;

            VirtualKeyCollection chordKeys = Keyboard.GetChordKeys(btn);

            Assert.AreEqual(1, chordKeys.Count);
            Assert.AreEqual(VirtualKeyCode.Control, chordKeys[0]);
        }
Пример #6
0
        public void InputVirtualKeyA()
        {
            MockInputSimulator inputSimulator = new MockInputSimulator();
            TestabelKeyboard   keyboard       = CreateKeyboard(inputSimulator);

            MockButton btn = keyboard.Children[3] as MockButton;

            btn.ClickButton();

            Assert.AreEqual(1, inputSimulator.KeyActions.Count);
            Assert.AreEqual(WindowsInput.Native.VirtualKeyCode.VK_A, inputSimulator.KeyActions[0].KeyCode);
        }
Пример #7
0
        public void InputCopyCommand()
        {
            MockInputSimulator inputSimulator = new MockInputSimulator();
            TestabelKeyboard   keyboard       = CreateKeyboard(inputSimulator);

            MockButton btn = keyboard.Children[5] as MockButton;

            btn.ClickButton();

            Assert.AreEqual(3, inputSimulator.KeyActions.Count);
            Assert.AreEqual(WindowsInput.Native.VirtualKeyCode.CONTROL, inputSimulator.KeyActions[0].KeyCode);
            Assert.AreEqual(WindowsInput.Native.VirtualKeyCode.VK_C, inputSimulator.KeyActions[1].KeyCode);
            Assert.AreEqual(WindowsInput.Native.VirtualKeyCode.CONTROL, inputSimulator.KeyActions[2].KeyCode);
        }
Пример #8
0
        public void ChangeTextKey()
        {
            MockInputSimulator inputSimulator = new MockInputSimulator();
            TestabelKeyboard   keyboard       = CreateKeyboard(inputSimulator);

            MockButton btn = keyboard.Children[4] as MockButton;

            btn.ClickButton();

            Assert.AreEqual("Hello World!", inputSimulator.GetTextInput());

            inputSimulator.ClearState();
            Keyboard.SetOutputText(btn, "Goodbye");

            btn.ClickButton();
            Assert.AreEqual("Goodbye", inputSimulator.GetTextInput());
        }
Пример #9
0
        public void ChangeKeyAtoZ()
        {
            MockInputSimulator inputSimulator = new MockInputSimulator();
            TestabelKeyboard   keyboard       = CreateKeyboard(inputSimulator);

            MockButton btn = keyboard.Children[3] as MockButton;

            btn.ClickButton();

            Assert.AreEqual(1, inputSimulator.KeyActions.Count);
            Assert.AreEqual(WindowsInput.Native.VirtualKeyCode.VK_A, inputSimulator.KeyActions[0].KeyCode);

            inputSimulator.ClearState();

            Keyboard.SetKeyCode(btn, VirtualKeyCode.VkZ);
            btn.ClickButton();

            Assert.AreEqual(1, inputSimulator.KeyActions.Count);
            Assert.AreEqual(WindowsInput.Native.VirtualKeyCode.VK_Z, inputSimulator.KeyActions[0].KeyCode);
        }
Пример #10
0
        public void ChangeKeyBehaviour()
        {
            MockInputSimulator inputSimulator = new MockInputSimulator();
            TestabelKeyboard   keyboard       = CreateKeyboard(inputSimulator);

            MockButton btn = keyboard.Children[3] as MockButton;

            btn.ClickButton();

            Assert.AreEqual(1, inputSimulator.KeyActions.Count);
            Assert.AreEqual(WindowsInput.Native.VirtualKeyCode.VK_A, inputSimulator.KeyActions[0].KeyCode);
            Assert.AreEqual(string.Empty, inputSimulator.GetTextInput());

            inputSimulator.ClearState();

            Keyboard.SetKeyBehaviour(btn, KeyBehaviour.Text);
            btn.ClickButton();

            Assert.AreEqual(0, inputSimulator.KeyActions.Count);
            Assert.AreEqual("Virtual Key", inputSimulator.GetTextInput());
        }
Пример #11
0
        private TestabelKeyboard CreateKeyboard(MockInputSimulator inputSimulator)
        {
            TestabelKeyboard keyboard = new TestabelKeyboard
            {
                InputSimulator = inputSimulator
            };

            keyboard.BeginInit();

            keyboard.Width  = 550;
            keyboard.Height = 350;

            ColumnDefinition col1 = new ColumnDefinition();
            ColumnDefinition col2 = new ColumnDefinition();
            ColumnDefinition col3 = new ColumnDefinition();
            ColumnDefinition col4 = new ColumnDefinition();
            ColumnDefinition col5 = new ColumnDefinition();
            ColumnDefinition col6 = new ColumnDefinition();

            keyboard.ColumnDefinitions.Add(col1);
            keyboard.ColumnDefinitions.Add(col2);
            keyboard.ColumnDefinitions.Add(col3);
            keyboard.ColumnDefinitions.Add(col4);
            keyboard.ColumnDefinitions.Add(col5);
            keyboard.ColumnDefinitions.Add(col6);

            MockButton btnShift = new MockButton();

            Keyboard.SetColumn(btnShift, 0);
            Keyboard.SetKeyBehaviour(btnShift, KeyBehaviour.InstantaneousModifier);
            Keyboard.SetKeyCode(btnShift, VirtualKeyCode.Shift);

            MockButton btnCaps = new MockButton();

            Keyboard.SetColumn(btnCaps, 1);
            Keyboard.SetKeyBehaviour(btnCaps, KeyBehaviour.TogglingModifier);
            Keyboard.SetKeyCode(btnCaps, VirtualKeyCode.Capital);

            MockButton btnCtrl = new MockButton();

            Keyboard.SetColumn(btnCtrl, 2);
            Keyboard.SetKeyBehaviour(btnCtrl, KeyBehaviour.InstantaneousModifier);
            Keyboard.SetKeyCode(btnCtrl, VirtualKeyCode.Control);

            MockButton btnA = new MockButton();

            Keyboard.SetColumn(btnA, 3);
            Keyboard.SetKeyBehaviour(btnA, KeyBehaviour.VirtualKey);
            Keyboard.SetKeyCode(btnA, VirtualKeyCode.VkA);
            Keyboard.SetOutputText(btnA, "Virtual Key");

            MockButton btnHello = new MockButton();

            Keyboard.SetColumn(btnHello, 4);
            Keyboard.SetKeyBehaviour(btnHello, KeyBehaviour.Text);
            Keyboard.SetKeyCode(btnHello, VirtualKeyCode.None);
            Keyboard.SetOutputText(btnHello, "Hello World!");

            MockButton           btnCopy   = new MockButton();
            VirtualKeyCollection chordKeys = new VirtualKeyCollection();

            chordKeys.Add(VirtualKeyCode.Control);
            Keyboard.SetColumn(btnCopy, 5);
            Keyboard.SetKeyBehaviour(btnCopy, KeyBehaviour.Chord);
            Keyboard.SetKeyCode(btnCopy, VirtualKeyCode.VkC);
            Keyboard.SetChordKeys(btnCopy, chordKeys);

            keyboard.Children.Add(btnShift);
            keyboard.Children.Add(btnCaps);
            keyboard.Children.Add(btnCtrl);
            keyboard.Children.Add(btnA);
            keyboard.Children.Add(btnHello);
            keyboard.Children.Add(btnCopy);

            keyboard.EndInit();

            return(keyboard);
        }