public void GlobalStore_WritingSystemsToIgnore() { string storePath1 = PrepareTempStore("Store1"); string storePath2 = PrepareTempStore("Store2"); string globalStorePath = PrepareTempStore("GlobalStore"); var globalStore = new GlobalFileWritingSystemStore(globalStorePath); var wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath1, globalStore), globalStore); var ws = wsManager.Set("en-US"); ws.SpellCheckingId = "id1"; wsManager.Save(); Thread.Sleep(1000); wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath2, globalStore), globalStore); ws = wsManager.Set("en-US"); ws.SpellCheckingId = "id2"; wsManager.Save(); wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath1, globalStore), globalStore); IEnumerable <IWritingSystem> sharedWss = wsManager.CheckForNewerGlobalWritingSystems(); Assert.AreEqual(1, sharedWss.Count()); Assert.AreEqual("en-US", sharedWss.First().Id); ws = wsManager.Get("en-US"); Assert.AreEqual("id1", ws.SpellCheckingId); wsManager.Save(); wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath1, globalStore), globalStore); sharedWss = wsManager.CheckForNewerGlobalWritingSystems(); Assert.AreEqual(0, sharedWss.Count()); wsManager.Save(); Thread.Sleep(1000); wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath2, globalStore), globalStore); ws = wsManager.Get("en-US"); ws.LegacyMapping = "encoding converter"; wsManager.Save(); wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath1, globalStore), globalStore); ws = wsManager.Get("en-US"); Assert.IsNullOrEmpty(ws.LegacyMapping); sharedWss = wsManager.CheckForNewerGlobalWritingSystems(); Assert.AreEqual(1, sharedWss.Count()); IWritingSystem sharedWs = sharedWss.First(); Assert.AreEqual("en-US", sharedWs.Id); wsManager.Replace(sharedWs); wsManager.Save(); ws = wsManager.Get("en-US"); Assert.AreEqual("encoding converter", ws.LegacyMapping); }
public void get_RendererFromChrp_Graphite() { using (GraphicsManager gm = new GraphicsManager(new Form())) { gm.Init(1.0f); try { var wsManager = new PalasoWritingSystemManager(); // by default Graphite is disabled IWritingSystem ws = wsManager.Set("en-US"); var chrp = new LgCharRenderProps { ws = ws.Handle, szFaceName = new ushort[32] }; MarshalEx.StringToUShort("Charis SIL", chrp.szFaceName); IRenderEngine engine = wsManager.get_RendererFromChrp(gm.VwGraphics, ref chrp); Assert.IsNotNull(engine); Assert.AreSame(wsManager, engine.WritingSystemFactory); Assert.IsInstanceOf(typeof(UniscribeEngine), engine); ws.IsGraphiteEnabled = true; engine = wsManager.get_RendererFromChrp(gm.VwGraphics, ref chrp); Assert.IsNotNull(engine); Assert.AreSame(wsManager, engine.WritingSystemFactory); Assert.IsInstanceOf(typeof(FwGrEngine), engine); wsManager.Save(); } finally { gm.Uninit(); } } }
public void InterpretChrp() { var wsManager = new PalasoWritingSystemManager(); IWritingSystem ws = wsManager.Create("en-US"); var chrp = new LgCharRenderProps { ws = ws.Handle, szFaceName = new ushort[32], dympHeight = 10000, ssv = (int)FwSuperscriptVal.kssvSuper }; MarshalEx.StringToUShort("<default font>", chrp.szFaceName); ws.InterpretChrp(ref chrp); Assert.AreEqual(ws.DefaultFontName, MarshalEx.UShortToString(chrp.szFaceName)); Assert.AreEqual(10000 / 3, chrp.dympOffset); Assert.AreEqual((10000 * 2) / 3, chrp.dympHeight); Assert.AreEqual((int)FwSuperscriptVal.kssvOff, chrp.ssv); chrp.ssv = (int)FwSuperscriptVal.kssvSub; chrp.dympHeight = 10000; chrp.dympOffset = 0; ws.InterpretChrp(ref chrp); Assert.AreEqual(-(10000 / 5), chrp.dympOffset); Assert.AreEqual((10000 * 2) / 3, chrp.dympHeight); Assert.AreEqual((int)FwSuperscriptVal.kssvOff, chrp.ssv); wsManager.Save(); }
public void get_CharPropEngine() { var wsManager = new PalasoWritingSystemManager(); IWritingSystem ws = wsManager.Set("zh-CN"); ws.ValidChars = "<?xml version=\"1.0\" encoding=\"utf-16\"?>" + "<ValidCharacters><WordForming>e\uFFFCf\uFFFCg\uFFFCh\uFFFC'</WordForming>" + "<Numeric>4\uFFFC5</Numeric>" + "<Other>,\uFFFC!\uFFFC*</Other>" + "</ValidCharacters>"; ILgCharacterPropertyEngine cpe = wsManager.get_CharPropEngine(ws.Handle); Assert.IsNotNull(cpe); Assert.IsTrue(cpe.get_IsWordForming('\'')); Assert.IsFalse(cpe.get_IsWordForming('"')); Assert.AreEqual(0x0804, cpe.Locale); ws.ValidChars = null; cpe = wsManager.get_CharPropEngine(ws.Handle); Assert.IsNotNull(cpe); Assert.IsFalse(cpe.get_IsWordForming('\'')); Assert.IsFalse(cpe.get_IsWordForming('"')); Assert.AreEqual(0x0804, cpe.Locale); wsManager.Save(); }
public void SerializeDeserialize() { string storePath = PrepareTempStore("Store"); // serialize var wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath)); var ws = wsManager.Set("en-US"); ws.SpellCheckingId = "en-US"; ws.MatchedPairs = "matched pairs"; ws.LCID = 0x409; ws.ValidChars = "valid characters"; ws.LegacyMapping = "legacy mapping"; wsManager.Save(); // deserialize wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath)); Assert.IsTrue(wsManager.Exists("en-US")); ws = wsManager.Get("en-US"); Assert.AreEqual("Eng", ws.Abbreviation); Assert.AreEqual("English", ws.LanguageSubtag.Name); Assert.AreEqual("en-US", ws.SpellCheckingId); Assert.AreEqual("United States", ws.RegionSubtag.Name); Assert.AreEqual("matched pairs", ws.MatchedPairs); Assert.AreEqual(0x409, ws.LCID); Assert.AreEqual("valid characters", ws.ValidChars); Assert.AreEqual("legacy mapping", ws.LegacyMapping); Assert.AreEqual("eng", ws.ISO3); wsManager.Save(); }
public void FieldWorksExtensionsAreNotDuplicatedOnRoundTrip() { var storePath = PrepareTempStore("Store"); // serialize var wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath)); var ws = wsManager.Set("en-US"); ws.SpellCheckingId = "en-US"; ws.MatchedPairs = "matched pairs"; ((ILegacyWritingSystemDefinition)ws).WindowsLcid = 0x409.ToString(CultureInfo.InvariantCulture); ws.ValidChars = "valid characters"; ws.LegacyMapping = "legacy mapping"; wsManager.Save(); // deserialize wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath)); Assert.IsTrue(wsManager.Exists("en-US"), "broken before SUT."); ws = wsManager.Get("en-US"); Assert.AreEqual("valid characters", ws.ValidChars, "broken before SUT"); //change the valid chars data and save back out, this was duplicating in LT-15048 ws.ValidChars = "more valid characters"; wsManager.Save(); var xmlDoc = new XmlDocument(); xmlDoc.Load(Path.Combine(storePath, "en-US.ldml")); Assert.AreEqual(1, xmlDoc.SelectNodes("//special/*[local-name()='validChars']").Count, "Special fw elements were duplicated"); Assert.AreEqual(1, xmlDoc.SelectNodes("//special/*[local-name()='validChars' and @value='more valid characters']").Count, "special fw changes not saved"); }
public void SerializeDeserialize() { string storePath = PrepareTempStore("Store"); // serialize var wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath)); var ws = wsManager.Set("en-US"); ws.SpellCheckingId = "en-US"; ws.MatchedPairs = "matched pairs"; ((ILegacyWritingSystemDefinition)ws).WindowsLcid = 0x409.ToString(CultureInfo.InvariantCulture); ws.ValidChars = "valid characters"; ws.LegacyMapping = "legacy mapping"; wsManager.Save(); // deserialize wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath)); Assert.IsTrue(wsManager.Exists("en-US")); ws = wsManager.Get("en-US"); Assert.AreEqual("Eng", ws.Abbreviation); Assert.AreEqual("English", ws.LanguageSubtag.Name); Assert.AreEqual("en-US", ws.SpellCheckingId); Assert.AreEqual("United States", ws.RegionSubtag.Name); Assert.AreEqual("matched pairs", ws.MatchedPairs); Assert.AreEqual(0x409.ToString(CultureInfo.InvariantCulture), ((ILegacyWritingSystemDefinition)ws).WindowsLcid); Assert.AreEqual("valid characters", ws.ValidChars); Assert.AreEqual("legacy mapping", ws.LegacyMapping); Assert.AreEqual("eng", ws.ISO3); wsManager.Save(); }
public void get_EngineOrNull() { var wsManager = new PalasoWritingSystemManager(); Assert.IsNull(wsManager.get_EngineOrNull(1)); IWritingSystem ws = wsManager.Set("en-US"); Assert.AreSame(ws, wsManager.get_EngineOrNull(ws.Handle)); wsManager.Save(); }
public void GetWsFromStr() { var wsManager = new PalasoWritingSystemManager(); Assert.AreEqual(0, wsManager.GetWsFromStr("en-US")); IWritingSystem ws = wsManager.Set("en-US"); Assert.AreEqual(ws.Handle, wsManager.GetWsFromStr("en-US")); wsManager.Save(); }
public void GetStrFromWs() { var wsManager = new PalasoWritingSystemManager(); Assert.IsNull(wsManager.GetStrFromWs(1)); IWritingSystem ws = wsManager.Set("en-US"); Assert.AreEqual("en-US", wsManager.GetStrFromWs(ws.Handle)); wsManager.Save(); }
public void GlobalStore() { string storePath1 = PrepareTempStore("Store1"); string storePath2 = PrepareTempStore("Store2"); string globalStorePath = PrepareTempStore("GlobalStore"); var globalStore = new GlobalFileWritingSystemStore(globalStorePath); var wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath1, globalStore), globalStore); var ws = wsManager.Set("en-US"); ws.SpellCheckingId = "id1"; wsManager.Save(); Assert.IsTrue(File.Exists(Path.Combine(storePath1, "en-US.ldml"))); Assert.IsTrue(File.Exists(Path.Combine(globalStorePath, "en-US.ldml"))); Thread.Sleep(1000); DateTime lastModified = File.GetLastWriteTime(Path.Combine(globalStorePath, "en-US.ldml")); wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath2, globalStore), globalStore); ws = wsManager.Set("en-US"); ws.SpellCheckingId = "id2"; wsManager.Save(); Assert.Less(lastModified, File.GetLastWriteTime(Path.Combine(globalStorePath, "en-US.ldml"))); lastModified = File.GetLastWriteTime(Path.Combine(storePath1, "en-US.ldml")); wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath1, globalStore), globalStore); ws = wsManager.Get("en-US"); Assert.AreEqual("id1", ws.SpellCheckingId); IEnumerable <IWritingSystem> sharedWss = wsManager.CheckForNewerGlobalWritingSystems(); Assert.AreEqual(1, sharedWss.Count()); IWritingSystem sharedWs = sharedWss.First(); Assert.AreEqual("en-US", sharedWs.Id); wsManager.Replace(sharedWs); wsManager.Save(); ws = wsManager.Get("en-US"); Assert.AreEqual("id2", ws.SpellCheckingId); Assert.Less(lastModified, File.GetLastWriteTime(Path.Combine(storePath1, "en-US.ldml"))); }
public void get_Engine() { var wsManager = new PalasoWritingSystemManager(); IWritingSystem enWs = wsManager.Set("en-US"); ILgWritingSystem enLgWs = wsManager.get_Engine("en-US"); Assert.AreSame(enWs, enLgWs); Assert.IsFalse(wsManager.Exists("en-Latn-US")); // this should create a new writing system, since it doesn't exist ILgWritingSystem enUsLgWs = wsManager.get_Engine("en-Latn-US"); Assert.IsTrue(wsManager.Exists("en-Latn-US")); Assert.IsTrue(wsManager.Exists(enUsLgWs.Handle)); IWritingSystem enUsWs = wsManager.Get("en-Latn-US"); Assert.AreSame(enUsWs, enUsLgWs); wsManager.Save(); }
public void Create() { var wsManager = new PalasoWritingSystemManager(); IWritingSystem enWs = wsManager.Create("en-Latn-US-fonipa"); Assert.AreEqual("Eng", enWs.Abbreviation); Assert.AreEqual("English", enWs.LanguageSubtag.Name); Assert.AreEqual("Latin", enWs.ScriptSubtag.Name); Assert.AreEqual("United States", enWs.RegionSubtag.Name); Assert.AreEqual("International Phonetic Alphabet", enWs.VariantSubtag.Name); Assert.AreEqual(null, ((ILegacyWritingSystemDefinition)enWs).WindowsLcid); IWritingSystem chWs = wsManager.Create("zh-CN"); Assert.AreEqual("Man", chWs.Abbreviation); Assert.AreEqual("Mandarin Chinese", chWs.LanguageSubtag.Name); Assert.AreEqual("China", chWs.RegionSubtag.Name); Assert.AreEqual("Charis SIL", chWs.DefaultFontName); Assert.AreEqual(WritingSystemDefinition.SortRulesType.OtherLanguage, chWs.SortUsing); Assert.AreEqual("zh-CN", chWs.SortRules); wsManager.Save(); }
public void Create() { var wsManager = new PalasoWritingSystemManager(); IWritingSystem enWs = wsManager.Create("en-Latn-US-fonipa"); Assert.AreEqual("Eng", enWs.Abbreviation); Assert.AreEqual("English", enWs.LanguageSubtag.Name); Assert.AreEqual("Latin", enWs.ScriptSubtag.Name); Assert.AreEqual("United States", enWs.RegionSubtag.Name); Assert.AreEqual("International Phonetic Alphabet", enWs.VariantSubtag.Name); // On Linux InstalledInputLanguages or DefaultInputLanguage doesn't do anything sensible. // see: https://bugzilla.novell.com/show_bug.cgi?id=613014 Assert.AreEqual(MiscUtils.IsUnix ? 0x409 : InputLanguage.DefaultInputLanguage.Culture.LCID, enWs.LCID); IWritingSystem chWs = wsManager.Create("zh-CN"); Assert.AreEqual("Man", chWs.Abbreviation); Assert.AreEqual("Mandarin Chinese", chWs.LanguageSubtag.Name); Assert.AreEqual("China", chWs.RegionSubtag.Name); Assert.AreEqual("Charis SIL", chWs.DefaultFontName); Assert.AreEqual(WritingSystemDefinition.SortRulesType.OtherLanguage, chWs.SortUsing); Assert.AreEqual("zh-CN", chWs.SortRules); wsManager.Save(); }
public void InterpretChrp() { var wsManager = new PalasoWritingSystemManager(); IWritingSystem ws = wsManager.Create("en-US"); var chrp = new LgCharRenderProps { ws = ws.Handle, szFaceName = new ushort[32], dympHeight = 10000, ssv = (int) FwSuperscriptVal.kssvSuper }; MarshalEx.StringToUShort("<default font>", chrp.szFaceName); ws.InterpretChrp(ref chrp); Assert.AreEqual(ws.DefaultFontName, MarshalEx.UShortToString(chrp.szFaceName)); Assert.AreEqual(10000 / 3, chrp.dympOffset); Assert.AreEqual((10000 * 2) / 3, chrp.dympHeight); Assert.AreEqual((int) FwSuperscriptVal.kssvOff, chrp.ssv); chrp.ssv = (int) FwSuperscriptVal.kssvSub; chrp.dympHeight = 10000; chrp.dympOffset = 0; ws.InterpretChrp(ref chrp); Assert.AreEqual(-(10000 / 5), chrp.dympOffset); Assert.AreEqual((10000 * 2) / 3, chrp.dympHeight); Assert.AreEqual((int)FwSuperscriptVal.kssvOff, chrp.ssv); wsManager.Save(); }
public void GlobalStore() { string storePath1 = PrepareTempStore("Store1"); string storePath2 = PrepareTempStore("Store2"); string globalStorePath = PrepareTempStore("GlobalStore"); var globalStore = new GlobalFileWritingSystemStore(globalStorePath); var wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath1, globalStore), globalStore); var ws = wsManager.Set("en-US"); ws.SpellCheckingId = "id1"; wsManager.Save(); Assert.IsTrue(File.Exists(Path.Combine(storePath1, "en-US.ldml"))); Assert.IsTrue(File.Exists(Path.Combine(globalStorePath, "en-US.ldml"))); Thread.Sleep(1000); DateTime lastModified = File.GetLastWriteTime(Path.Combine(globalStorePath, "en-US.ldml")); wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath2, globalStore), globalStore); ws = wsManager.Set("en-US"); ws.SpellCheckingId = "id2"; wsManager.Save(); Assert.Less(lastModified, File.GetLastWriteTime(Path.Combine(globalStorePath, "en-US.ldml"))); lastModified = File.GetLastWriteTime(Path.Combine(storePath1, "en-US.ldml")); wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath1, globalStore), globalStore); ws = wsManager.Get("en-US"); Assert.AreEqual("id1", ws.SpellCheckingId); IEnumerable<IWritingSystem> sharedWss = wsManager.CheckForNewerGlobalWritingSystems(); Assert.AreEqual(1, sharedWss.Count()); IWritingSystem sharedWs = sharedWss.First(); Assert.AreEqual("en-US", sharedWs.Id); wsManager.Replace(sharedWs); wsManager.Save(); ws = wsManager.Get("en-US"); Assert.AreEqual("id2", ws.SpellCheckingId); Assert.Less(lastModified, File.GetLastWriteTime(Path.Combine(storePath1, "en-US.ldml"))); }
public void GlobalStore_WritingSystemsToIgnore() { string storePath1 = PrepareTempStore("Store1"); string storePath2 = PrepareTempStore("Store2"); string globalStorePath = PrepareTempStore("GlobalStore"); var globalStore = new GlobalFileWritingSystemStore(globalStorePath); var wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath1, globalStore), globalStore); var ws = wsManager.Set("en-US"); ws.SpellCheckingId = "id1"; wsManager.Save(); Thread.Sleep(1000); wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath2, globalStore), globalStore); ws = wsManager.Set("en-US"); ws.SpellCheckingId = "id2"; wsManager.Save(); wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath1, globalStore), globalStore); IEnumerable<IWritingSystem> sharedWss = wsManager.CheckForNewerGlobalWritingSystems(); Assert.AreEqual(1, sharedWss.Count()); Assert.AreEqual("en-US", sharedWss.First().Id); ws = wsManager.Get("en-US"); Assert.AreEqual("id1", ws.SpellCheckingId); wsManager.Save(); wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath1, globalStore), globalStore); sharedWss = wsManager.CheckForNewerGlobalWritingSystems(); Assert.AreEqual(0, sharedWss.Count()); wsManager.Save(); Thread.Sleep(1000); wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath2, globalStore), globalStore); ws = wsManager.Get("en-US"); ws.LegacyMapping = "encoding converter"; wsManager.Save(); wsManager = new PalasoWritingSystemManager( new LocalFileWritingSystemStore(storePath1, globalStore), globalStore); ws = wsManager.Get("en-US"); Assert.IsNullOrEmpty(ws.LegacyMapping); sharedWss = wsManager.CheckForNewerGlobalWritingSystems(); Assert.AreEqual(1, sharedWss.Count()); IWritingSystem sharedWs = sharedWss.First(); Assert.AreEqual("en-US", sharedWs.Id); wsManager.Replace(sharedWs); wsManager.Save(); ws = wsManager.Get("en-US"); Assert.AreEqual("encoding converter", ws.LegacyMapping); }
public void get_RendererFromChrp_Graphite() { using (GraphicsManager gm = new GraphicsManager(new Form())) { gm.Init(1.0f); try { var wsManager = new PalasoWritingSystemManager(); // by default Graphite is disabled IWritingSystem ws = wsManager.Set("en-US"); var chrp = new LgCharRenderProps { ws = ws.Handle, szFaceName = new ushort[32] }; MarshalEx.StringToUShort("Charis SIL", chrp.szFaceName); IRenderEngine engine = wsManager.get_RendererFromChrp(gm.VwGraphics, ref chrp); Assert.IsNotNull(engine); Assert.AreSame(wsManager, engine.WritingSystemFactory); Assert.IsInstanceOf(typeof(UniscribeEngine), engine); ws.IsGraphiteEnabled = true; engine = wsManager.get_RendererFromChrp(gm.VwGraphics, ref chrp); Assert.IsNotNull(engine); Assert.AreSame(wsManager, engine.WritingSystemFactory); Assert.IsInstanceOf(typeof(GraphiteEngine), engine); wsManager.Save(); } finally { gm.Uninit(); } } }