Esempio n. 1
0
        /// <summary>
        /// Check that xxx1_Wwww_YY2_ZZZ3 installed correctly
        /// </summary>
        private void Checkel_Mysc_UNH_IPAResults()
        {
            Icu.UErrorCode error;
            string         result;

            Icu.SetDataDirectory(TestUtils.GetIcuDataDir());
            Icu.GetDisplayName("el_Mysc_UNH_IPA", "en", out result, out error);
            Assert.AreEqual("Greek (MyScript, UnheardOf, IPA)", result, "Data not put into the ICUFiles");
            Icu.GetDisplayLanguage("el_Mysc_UNH_IPA", "en", out result, out error);
            Assert.AreEqual("Greek", result, "Greek should not be changed as it is a factory value.");
            Icu.GetDisplayScript("el_Mysc_UNH_IPA", "en", out result, out error);
            Assert.AreEqual("MyScript", result, "The display script should be changed.");
            Icu.GetDisplayCountry("el_Mysc_UNH_IPA", "en", out result, out error);
            Assert.AreEqual("UnheardOf", result, "The display country should be changed.");
            Icu.GetDisplayVariant("el_Mysc_UNH_IPA", "en", out result, out error);
            Assert.AreEqual("IPA", result, "The display variant should not be changed.");

            StreamReader reader;

            TestUtils.RunProgram("InstallLanguage", "-q -customLanguages", 0, out reader);
            string output = reader.ReadToEnd();

            Assert.IsTrue(output.IndexOf("<el>") == -1,
                          "Should not have installed factory locale 'el' as a custom language." +
                          "Installed Custom Languages: " + output.ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// Check that xxx1_Wwww_YY2_ZZZ3 installed correctly
        /// </summary>
        private void Checkxxx1_Wwww_YY2_ZZZ3Results()
        {
            Icu.UErrorCode error;
            string         result;

            Icu.SetDataDirectory(TestUtils.GetIcuDataDir());
            Icu.GetDisplayName("xxx1_Wwww_YY2_ZZZ3", "en", out result, out error);
            Assert.AreEqual("XXXLanguage1 (WWScript2, YYCountry2, ZZZVariant3)", result, "Data not put into the ICUFiles");
        }
Esempio n. 3
0
        /// <summary>
        /// Check that ICU was correctly restored for xxx1_Wwww_YY2_ZZZ3
        /// </summary>
        public static void Checkxxx1_Wwww_YY2_ZZZ3Restored()
        {
            Icu.UErrorCode error;
            string         result;

            Icu.SetDataDirectory(TestUtils.GetIcuDataDir());
            Icu.GetDisplayName("xxx1_Wwww_YY2_ZZZ3", "en", out result, out error);
            Icu.Cleanup();                      // clean up the ICU files / data
            Assert.AreEqual("xxx1 (Wwww, YY2, ZZZ3)", result, "Data 'xxx1_Wwww_YY2_ZZZ3' not removed from the ICU Files");
        }
Esempio n. 4
0
        /// <summary>
        /// Checks to make sure that "InstallLanguage pig" did what is was supposed to.
        /// Use the ICU methods to see if the minimal 'pig' language was installed.
        /// </summary>
        public void CheckLDPigResults()
        {
            // Now use the ICU methods to see if the minimal 'pig' language was installed
            Icu.SetDataDirectory(TestUtils.GetIcuDataDir());
            string result;

            SIL.FieldWorks.Common.FwUtils.Icu.UErrorCode error;
            Icu.GetDisplayName("pig", "en", out result, out error);
            Assert.AreEqual("Piggy", result, "Data 'pig' not put into the ICUFiles");
        }
Esempio n. 5
0
        public void GetDisplayName()
        {
            string result;

            Icu.UErrorCode err;
            int            nResult = Icu.GetDisplayName("en_US_X_ETIC", "fr", out result, out err);

            Assert.AreEqual(34, nResult);
            Assert.AreEqual("anglais (États-Unis, informatique)", result);
            Assert.AreEqual(Icu.UErrorCode.U_ZERO_ERROR, err);
        }
Esempio n. 6
0
        /// <summary>
        /// Check that ICU was correctly restored for xxx1_Wwww_YY2_ZZZ3
        /// </summary>
        private void Checkel_Mysc_UNH_IPARestored()
        {
            Icu.UErrorCode error;
            string         result;

            Icu.SetDataDirectory(TestUtils.GetIcuDataDir());
            Icu.GetDisplayName("el_Mysc_UNH_IPA", "en", out result, out error);
            Icu.Cleanup();                      // clean up the ICU files / data
            // Note "Greek" and "IPA" are already added as "factory" locales.
            Assert.AreEqual("Greek (Mysc, UNH, IPA)", result, "Data 'el_Mysc_UNH_IPA' not removed from the ICU Files");
        }
            /// --------------------------------------------------------------------------------
            /// <summary>
            /// Displays the name.
            /// </summary>
            /// <param name="sLocale">The s locale.</param>
            /// <returns></returns>
            /// --------------------------------------------------------------------------------
            private static string DisplayName(string sLocale)
            {
                string sName;

                try
                {
                    var ci = new CultureInfo(sLocale);
                    sName = ci.NativeName;
                }
                catch
                {
                    Icu.UErrorCode uerr;
                    Icu.GetDisplayName(sLocale, sLocale, out sName, out uerr);
                }
                return(sName);
            }
Esempio n. 8
0
            /// --------------------------------------------------------------------------------
            /// <summary>
            /// Displays the name.
            /// </summary>
            /// <param name="sLocale">The s locale.</param>
            /// <returns></returns>
            /// --------------------------------------------------------------------------------
            internal static string DisplayName(string sLocale)
            {
                string sName;

                try
                {
                    CultureInfo ci = new CultureInfo(sLocale.Replace('_', '-'));
                    sName = ci.NativeName;
                }
                catch
                {
                    Icu.UErrorCode uerr = Icu.UErrorCode.U_ZERO_ERROR;
                    Icu.GetDisplayName(sLocale, sLocale, out sName, out uerr);
                }
                return(sName);
            }
Esempio n. 9
0
        public void TestInstallLanguage_PigAndPUA()
        {
            // First backup the 'important' icu files and unidata files
            ArrayList saveFiles = new ArrayList();

            LDInstallSaveFiles(saveFiles);
            PUAInstallSaveFiles(saveFiles);

            System.CodeDom.Compiler.TempFileCollection tempFiles;
            ArrayList backupFiles;

            TestUtils.MakeTempFiles(saveFiles, out backupFiles, out tempFiles);

            LDPigTempFiles(tempFiles);

            string puaTestFile = MoveLDF("puapig.xml");

            // remove file when done with test
            tempFiles.AddFile(puaTestFile, false);

            try
            {
                TestUtils.RunProgram("InstallLanguage.exe", "-i -c " + puaTestFile + " -q", 0);
                CheckLDPigResults();
                Check_for_PUA_Results();
                Icu.Cleanup();                          // clean up the ICU files / data
                TestUtils.RunProgram("InstallLanguage.exe", "-r puapig -q", 0);
            }
            finally
            {
                TestUtils.CleanUpAndRestore(saveFiles, backupFiles, tempFiles);
            }

            // Now make sure the Language was uninstalled / icu restored properly
            Icu.SetDataDirectory(TestUtils.GetIcuDataDir());
            string result2;

            SIL.FieldWorks.Common.FwUtils.Icu.UErrorCode error;
            Icu.GetDisplayName("pig", "en", out result2, out error);
            Icu.Cleanup();
            Assert.AreEqual("pig", result2, "Data 'pig' not removed from the ICU Files");

            //Make sure the unicodeData file was restored properly
            TestUtils.Check_PUA(0xF171, "COMBINING MACRON-ACUTE", LgGeneralCharCategory.kccMn);
        }
Esempio n. 10
0
        public void TestInstallLanguage_pig()
        {
            ArrayList saveFiles = new ArrayList();
            ArrayList backupFiles;

            System.CodeDom.Compiler.TempFileCollection tempFiles;

            // Decide what files we want to save (LD pig related)
            LDInstallSaveFiles(saveFiles);
            // Save the backup
            TestUtils.MakeTempFiles(saveFiles, out backupFiles, out tempFiles);

            // Adds files to "tempFiles" that need to be removed when we are done
            LDPigTempFiles(tempFiles);

            string pigFile = MoveLDF("pig.xml");

            // remove file when done with test
            tempFiles.AddFile(pigFile, false);

            Icu.UErrorCode error;
            try
            {
                TestUtils.RunProgram("InstallLanguage.exe", "-i " + pigFile + " -q", 0);
                CheckLDPigResults();
                Icu.Cleanup();
                TestUtils.RunProgram("InstallLanguage.exe", "-r pig -q", 0);
            }
            finally
            {
                TestUtils.CleanUpAndRestore(saveFiles, backupFiles, tempFiles);
            }

            // Now make sure the Language was uninstalled / icu restored properly
            Icu.SetDataDirectory(TestUtils.GetIcuDataDir());
            string result2;

            Icu.GetDisplayName("pig", "en", out result2, out error);
            Icu.Cleanup();
            Assert.AreEqual("pig", result2, "Data 'pig' not removed from the ICU Files");
        }
Esempio n. 11
0
        public void TestAdd_and_Remove_pig()
        {
            string icuDataDir;
            string icuDir;
            string icuPrefix;

            GetIcuLocationInfo(out icuDataDir, out icuDir, out icuPrefix);

            try
            {
                CreateBackupFiles();

                InstallLocal("pig");
                string         result;
                Icu.UErrorCode error;

                Icu.SetDataDirectory(icuDataDir);
                Icu.GetDisplayName("frm__snz", "en", out result, out error);
                Icu.GetDisplayName("pig", "en", out result, out error);
                Icu.Cleanup();                          // clean up the ICU files / data

                Assert.AreEqual("Piggy", result, "Data 'pig' not put into the ICUFiles");

                RemoveLocal("pig");
                Icu.SetDataDirectory(icuDataDir);
                Icu.GetDisplayName("pig", "en", out result, out error);
                Icu.Cleanup();                          // clean up the ICU files / data

                Assert.AreEqual("pig", result, "Data 'pig' not removed from the ICUFiles");
            }
            finally
            {
                Icu.Cleanup();                          // clean up the ICU files / data
                RemoveLocal("pig");
                RestoreBackupFiles();
                TestUtils.DeleteFile(icuDir + icuPrefix + "pig.res");
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Produce IBus keyboard identifier which is simular to the actual ibus switcher menu.
        /// </summary>
        internal string FormatKeyboardIdentifier(IBusEngineDesc engineDesc)
        {
            string id           = engineDesc.Language;
            string languageName = string.IsNullOrEmpty(id) ? ResourceHelper.GetResourceString("kstidOtherLanguage") : Icu.GetDisplayName(id);

            return(String.Format("{0} - {1}", languageName, engineDesc.Name));
        }