public void Teardown() { foreach (var locale in m_Settings.GetAvailableLocales().Locales) { Object.DestroyImmediate(locale); } Object.DestroyImmediate(m_Settings); }
public void PlayerPrefLocaleSelector_WhenLocaleIsChanged_RecordsLocaleToPlayerPrefs() { var spanish = m_TestSettings.GetAvailableLocales().GetLocale(SystemLanguage.Spanish); Assert.NotNull(spanish); Assert.AreNotEqual(m_TestSettings.GetSelectedLocale(), spanish); m_TestSettings.SetSelectedLocale(spanish); Assert.IsTrue(PlayerPrefs.HasKey(k_PlayerPrefKey), "Expected Player Pref Key to be set when the selected locale was changed."); var pref = PlayerPrefs.GetString(k_PlayerPrefKey); Assert.AreEqual(spanish.Identifier.Code, pref, "Expected the player prefs to contain the selected locale"); }
public void ChangingSelectedLocale_SendsLocaleChangedEvent() { Locale selectedLocale = null; m_Settings.OnSelectedLocaleChanged += (loc) => selectedLocale = loc; // Change the locale resulting in the event being sent. var japaneseLocale = m_Settings.GetAvailableLocales().GetLocale(SystemLanguage.Japanese); Assert.IsNotNull(japaneseLocale, "Expected Japanese locale to be returned but it was not."); m_Settings.SetSelectedLocale(japaneseLocale); Assert.IsNotNull(selectedLocale, "Current language is null, the LocaleChanged event was not sent."); Assert.AreEqual(japaneseLocale, selectedLocale, "Expected current language to be Japanese."); }
public void CreateTestLocalizationSettings() { m_Settings = LocalizationSettingsHelper.CreateEmpty(); m_LocalesProvider = m_Settings.GetAvailableLocales(); m_LocalesProvider.AddLocale(Locale.CreateLocale(SystemLanguage.Arabic)); m_LocalesProvider.AddLocale(Locale.CreateLocale(SystemLanguage.English)); m_LocalesProvider.AddLocale(Locale.CreateLocale(SystemLanguage.French)); m_LocalesProvider.AddLocale(Locale.CreateLocale(SystemLanguage.German)); m_LocalesProvider.AddLocale(Locale.CreateLocale(SystemLanguage.Japanese)); }
public void Init() { m_OriginalSettings = LocalizationSettings.Instance; m_TestSettings = LocalizationSettingsHelper.CreateEmpty(); LocalizationSettings.Instance = m_TestSettings; // Add the test locales var localeProvider = m_TestSettings.GetAvailableLocales(); testLanguages.ForEach(o => localeProvider.AddLocale(Locale.CreateLocale(o))); PlayerPrefs.DeleteKey(k_PlayerPrefKey); m_PlayerPrefLocaleSelector = new PlayerPrefLocaleSelector { PlayerPreferenceKey = k_PlayerPrefKey }; m_TestSettings.GetStartupLocaleSelectors().Add(m_PlayerPrefLocaleSelector); }