Esempio n. 1
0
        private void InitializeHotkeysManager()
        {
            var hotkeyManager = new HotkeyManager(this.Hwnd);

            this.HotkeyMessageHandler = hotkeyManager.GetMessageHandler();
            HotkeysControl.SetHotkeyManager(hotkeyManager);
        }
Esempio n. 2
0
        public void SystemHotkeyShouldNotPassHotkeysValidation()
        {
            //arrange
            var systemHotkey = new HotKey(Key.F12);

            //act and assert
            Assert.True(HotkeysControl.HotkeyIsValid(systemHotkey) == ErrorMessageType.F12);
            Assert.True(HotkeysControl.HotkeysAreValid(systemHotkey, new HotKey(Key.A)) == ErrorMessageType.F12);
        }
Esempio n. 3
0
        public void NullsShouldNotPassHotkeysValidation()
        {
            //arrange
            var hotkey = new HotKey(Key.A);

            //act and assert
            Assert.True(HotkeysControl.HotkeysAreValid(null, hotkey) != ErrorMessageType.None);
            Assert.True(HotkeysControl.HotkeysAreValid(hotkey, null) != ErrorMessageType.None);
            Assert.True(HotkeysControl.HotkeyIsValid(null) != ErrorMessageType.None);
        }
Esempio n. 4
0
        public void HotkeysValidationShouldReturn_DiffError()
        {
            //arrange
            var upHotkey   = new HotKey(Key.A);
            var downHotkey = new HotKey(Key.A);

            //act
            var errorType = HotkeysControl.HotkeysAreValid(upHotkey, downHotkey);

            //assert
            Assert.True(errorType == ErrorMessageType.Diff);
        }
Esempio n. 5
0
        public void HotkeysValidationShouldReturn_ExistsError()
        {
            var existingHotkey = new HotKey(Key.F1, ModifierKeys.Control);
            var settings       = SettingsProvider.Settings.HotkeysSettings;
            var muteKey        = settings.GetType().GetField("DeviceMuteKey", BindingFlags.NonPublic | BindingFlags.Instance);
            var muteModeKeys   = settings.GetType().GetField("DeviceMuteModifiers", BindingFlags.NonPublic | BindingFlags.Instance);

            muteKey.SetValue(settings, existingHotkey.Key);
            muteModeKeys.SetValue(settings, existingHotkey.ModifierKeys);

            //act and assert
            Assert.True(HotkeysControl.HotkeyIsValid(existingHotkey) == ErrorMessageType.HotkeyExists);
            Assert.True(HotkeysControl.HotkeysAreValid(existingHotkey, new HotKey(Key.Down)) ==
                        ErrorMessageType.HotkeyExists);
        }
Esempio n. 6
0
        public void RandomHotkeyShouldNotChangeVolume()
        {
            //arrange
            var hManagerMock = new Mock <IHotkeyManager>();

            HotkeysControl.SetHotkeyManager(hManagerMock.Object);
            var upHotkey   = new HotKey(Key.A);
            var downHotkey = new HotKey(Key.B);

            this.model.SetVolumeHotkeys(upHotkey, downHotkey);

            //act
            hManagerMock.Raise(m => m.HotkeyPressed += null, new HotKey(Key.C));

            //assert
            //verify increment/decrement volume calls to external API are not made
            this.sessionVolumeMock.Verify(m => m.SetVolume(this.model.Volume + HotkeysControl.VolumeStep, ref GuidValue.Internal.Empty), Times.Never);
            this.sessionVolumeMock.Verify(m => m.SetVolume(this.model.Volume - HotkeysControl.VolumeStep, ref GuidValue.Internal.Empty), Times.Never);
        }
Esempio n. 7
0
        public void HotkeyShouldIncrementVolume()
        {
            //arrange
            var hManagerMock = new Mock <IHotkeyManager>();

            HotkeysControl.SetHotkeyManager(hManagerMock.Object);
            var upHotkey   = new HotKey(Key.A);
            var downHotkey = new HotKey(Key.B);

            this.model.SetVolumeHotkeys(upHotkey, downHotkey);
            var newVolume = this.model.Volume + HotkeysControl.VolumeStep;

            //act
            hManagerMock.Raise(m => m.HotkeyPressed += null, upHotkey);

            //assert
            //verify the call to external API is made
            this.sessionVolumeMock.Verify(m => m.SetVolume(newVolume, ref GuidValue.Internal.Empty), Times.AtLeastOnce);
            //simualate callback from external API
            this.mVolumeNotifMock.Raise(m => m.VolumeChanged += null, new VolumeChangedEventArgs(newVolume, this.model.IsMuted));
            Assert.Equal(newVolume, this.model.Volume);
        }
Esempio n. 8
0
        private void SetupHotkeyManager()
        {
            var hotkeyManager = new HotkeyManager(this.windowHandle);

            this.HotkeyManagerMessageHandler = hotkeyManager.GetMessageHandler();
            HotkeysControl.SetHotkeyManager(hotkeyManager);

            // IHotkeyManager hm = null;
            // if(blockHotkeysInSystem)
            // {
            //     //Prevent creating manager right now since it's dependent on the window handle, which was not passed yet by window.
            //     if(this.windowHandle == IntPtr.Zero)
            //         return;
            //     var hotkeyManager = new HotkeyManager(this.windowHandle);
            //     this.HotkeyManagerMessageHandler = hotkeyManager.GetMessageHandler();
            //     hm = hotkeyManager;
            // }
            // else
            // {
            //     this.HotkeyManagerMessageHandler = null;
            //     hm = new HotkeyHookManager();
            // }
            // HotkeysControl.SetHotkeyManager(hm);
        }