public void GetKeyboard_FromInputLanguage_ExistingKeyboardReturnsKeyboard() { var keyboard = Keyboard.Controller.CreateKeyboardDefinition("foo", "en-US"); KeyboardController.Manager.RegisterKeyboard(keyboard); var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); Assert.That(Keyboard.Controller.GetKeyboard(inputLanguage), Is.EqualTo(keyboard)); }
public void DefaultForWritingSystem_OldFwKeymanKeyboard() { var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); var expectedKeyboard = new KeyboardDescription("IPA Unicode 1.1.1 - English (US)", "IPA Unicode 1.1.1", "en-US", inputLanguage, KeyboardController.Adaptors[0]); KeyboardController.Manager.RegisterKeyboard(expectedKeyboard); // FieldWorks sets the keyboard property for Keyman keyboards to <layoutname> and WindowsLcid to <lcid> var ws = new MockWritingSystemDefinition { Keyboard = "IPA Unicode 1.1.1", WindowsLcid = 0x409.ToString() }; Assert.That(Keyboard.Controller.DefaultForWritingSystem(ws), Is.EqualTo(expectedKeyboard)); }
public void CreateKeyboardDefinition_ExistingKeyboard_ReturnsReference() { var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); var expectedKeyboard = new KeyboardDescription("foo - English (US)", "foo", "en-US", inputLanguage, KeyboardController.Adaptors[0]); KeyboardController.Manager.RegisterKeyboard(expectedKeyboard); var keyboard = Keyboard.Controller.CreateKeyboardDefinition("foo", "en-US"); Assert.That(keyboard, Is.SameAs(expectedKeyboard)); Assert.That(keyboard, Is.TypeOf<KeyboardDescription>()); Assert.That((keyboard as KeyboardDescription).InputLanguage, Is.EqualTo(inputLanguage)); }
public WinKeyboardDescription(string locale, string layout, IKeyboardAdaptor engine) : base(engine, KeyboardType.System) { InputLanguageWrapper inputLanguage = null; try { inputLanguage = new InputLanguageWrapper(new CultureInfo(locale), IntPtr.Zero, layout); } catch (CultureNotFoundException) { // ignore if we can't find a culture (this can happen e.g. when a language gets // removed that was previously assigned to a WS) - see LT-15333 } Initialize(locale, new WinKeyboardAdaptor.LayoutName(layout), locale, inputLanguage); }
public void DefaultForWritingSystem_OldFwSystemKeyboard() { // 0x001C is Albanian (see http://msdn.microsoft.com/en-us/goglobal/bb896001.aspx). // Make sure it's not installed on current system. if (InputLanguage.InstalledInputLanguages.Cast<InputLanguage>().Any(lang => lang.Culture.LCID == 0x041C)) Assert.Ignore("Input language 'Albanian (Albania)' is installed on current system. Can't run this test."); var inputLanguage = new InputLanguageWrapper("sq-AL", IntPtr.Zero, "US"); var expectedKeyboard = new KeyboardDescription("US - Albanian (Albania)", "US", "sq-AL", inputLanguage, KeyboardController.Adaptors[0]); KeyboardController.Manager.RegisterKeyboard(expectedKeyboard); // FieldWorks sets the WindowsLcid property for System keyboards to <lcid> var ws = new MockWritingSystemDefinition { WindowsLcid = 0x041C.ToString() }; Assert.That(Keyboard.Controller.DefaultForWritingSystem(ws), Is.EqualTo(expectedKeyboard)); }
internal void AddKeyboardForLayout(XklConfigRegistry.LayoutDescription layout, uint iGroup, IKeyboardSwitchingAdaptor engine) { var description = GetDescription(layout); CultureInfo culture = null; try { culture = new CultureInfo(layout.LocaleId); } catch (ArgumentException) { // This can happen if the locale is not supported. // TODO: fix mono's list of supported locales. Doesn't support e.g. de-BE. // See mono/tools/locale-builder. } var inputLanguage = new InputLanguageWrapper(culture, IntPtr.Zero, layout.Language); var keyboard = new XkbKeyboardDescription(description, layout.LayoutId, layout.LocaleId, inputLanguage, engine, (int)iGroup); KeyboardController.Manager.RegisterKeyboard(keyboard); }
/// <summary> /// Creates and returns a keyboard definition object based on the layout and locale. /// </summary> public override IKeyboardDefinition CreateKeyboardDefinition(string layout, string locale) { var inputLanguage = new InputLanguageWrapper(new CultureInfo(locale), IntPtr.Zero, layout); return new KeyboardDescription(layout, layout, locale, inputLanguage, KeyboardController.Adaptors[0]); }
public void WrapperAndOriginalAreEqual() { var wrapper = new InputLanguageWrapper(InputLanguage.CurrentInputLanguage); Assert.That(wrapper.Equals(InputLanguage.CurrentInputLanguage)); }
public void GetKeyboard_FromInputLanguage_NonExistingKeyboard() { var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); Assert.That(Keyboard.Controller.GetKeyboard(inputLanguage), Is.EqualTo(KeyboardDescription.Zero)); }
public void DefaultForWritingSystem_OldPalasoWinIMEKeyboard() { var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); var expectedKeyboard = new KeyboardDescription("foo - English (US)", "foo", "en-US", inputLanguage, KeyboardController.Adaptors[0]); KeyboardController.Manager.RegisterKeyboard(expectedKeyboard); // Palaso sets the keyboard property for Windows system keyboards to <layoutname>-<locale> var ws = new MockWritingSystemDefinition { Keyboard = "foo-en-US" }; Assert.That(Keyboard.Controller.DefaultForWritingSystem(ws), Is.EqualTo(expectedKeyboard)); }
public void DefaultForWritingSystem_OldPalasoKeymanKeyboard() { var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); KeyboardDescription expectedKeyboard; if (Keyboard.Controller.AllAvailableKeyboards.Any(kbd => kbd.Layout == "IPA Unicode 1.1.1")) { expectedKeyboard = Keyboard.Controller.AllAvailableKeyboards.First(kbd => kbd.Layout == "IPA Unicode 1.1.1") as KeyboardDescription; } else { expectedKeyboard = new KeyboardDescription("IPA Unicode 1.1.1 - English (US)", "IPA Unicode 1.1.1", "en-US", inputLanguage, KeyboardController.Adaptors[0]); KeyboardController.Manager.RegisterKeyboard(expectedKeyboard); } // Palaso sets the keyboard property for Keyman keyboards to <layoutname> var ws = new MockWritingSystemDefinition { Keyboard = "IPA Unicode 1.1.1" }; Assert.That(Keyboard.Controller.DefaultForWritingSystem(ws), Is.EqualTo(expectedKeyboard)); }
public void DefaultForWritingSystem_OldPalasoIbusKeyboard() { #if __MonoCS__ // For this test on Linux we only use the XkbKeyboardAdaptor and simulate an available // IBus keyboard. This is necessary because otherwise the test might return an // installed Danish IBus keyboard (m17n:da:post) instead of our expected dummy one. KeyboardController.Manager.SetKeyboardAdaptors(new[] { new Palaso.UI.WindowsForms.Keyboarding.Linux.XkbKeyboardAdaptor() }); #endif var inputLanguage = new InputLanguageWrapper(new CultureInfo("en-US"), IntPtr.Zero, "foo"); var expectedKeyboard = new KeyboardDescription("m17n:da:post - English (US)", "m17n:da:post", "en-US", inputLanguage, KeyboardController.Adaptors[0]); KeyboardController.Manager.RegisterKeyboard(expectedKeyboard); // Palaso sets the keyboard property for Ibus keyboards to <ibus longname> var ws = new MockWritingSystemDefinition { Keyboard = "m17n:da:post" }; Assert.That(Keyboard.Controller.DefaultForWritingSystem(ws), Is.EqualTo(expectedKeyboard)); }