Esempio n. 1
0
        public void KeyboardTooltipStateMachine_DismissalKeyUp_NonPersistent_NotDismissed(Keys keys)
        {
            using TestControl control = new();
            using ToolTip toolTip     = new();

            control.CreateControl();
            _ = toolTip.Handle;

            toolTip.SetToolTip(control, "Non-persistent");
            toolTip.AutoPopDelay = 888;

            // Simulate that the toolTip is shown.
            KeyboardToolTipStateMachine instance = KeyboardToolTipStateMachine.Instance;

            instance.TestAccessor().Dynamic._currentTool = control;
            instance.TestAccessor().Dynamic._currentState = KeyboardToolTipStateMachine.SmState.Shown;

            control.SimulateKeyUp(keys);

            IKeyboardToolTip currentTool  = instance.TestAccessor().Dynamic._currentTool;
            string           currentState = instance.TestAccessor().Dynamic._currentState.ToString();

            Assert.Equal(control, currentTool);
            Assert.Equal("Shown", currentState);
        }
Esempio n. 2
0
        public void KeyboardTooltipStateMachine_DismissalKeyUp(Keys keys, bool isPersistent)
        {
            using TestControl control = new();
            using ToolTip toolTip     = new();

            control.CreateControl();
            _ = toolTip.Handle;

            toolTip.SetToolTip(control, "test");
            toolTip.IsPersistent = isPersistent;

            // Simulate that the toolTip is shown.
            KeyboardToolTipStateMachine instance = KeyboardToolTipStateMachine.Instance;

            instance.TestAccessor().Dynamic._currentTool = control;
            instance.TestAccessor().Dynamic._currentState = KeyboardToolTipStateMachine.SmState.Shown;

            control.SimulateKeyUp(keys);

            IKeyboardToolTip currentTool  = instance.TestAccessor().Dynamic._currentTool;
            string           currentState = instance.TestAccessor().Dynamic._currentState.ToString();

            Assert.Equal(isPersistent && OsVersion.IsWindows11_OrGreater ? "Hidden" : "Shown", currentState);
        }
Esempio n. 3
0
 internal static KeyboardToolTipStateMachineTestAccessor TestAccessor(this KeyboardToolTipStateMachine instance)
 => new KeyboardToolTipStateMachineTestAccessor(instance);