use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.
the class LocalizerTest method testLocalizationObservers.
public void testLocalizationObservers() {
Localizer l = new Localizer();
l.addAvailableLocale("test1");
l.addAvailableLocale("test2");
LocalizationObserver lo = new LocalizationObserver();
l.registerLocalizable(lo);
if (lo.flag || lo.locale != null || lo.l != null) {
fail("Improper state in localization observer");
}
l.setLocale("test1");
if (!lo.flag || !"test1".equals(lo.locale) || l != lo.l) {
fail("Improper state in localization observer, or not updated properly");
}
lo.flag = false;
l.setLocale("test2");
if (!lo.flag || !"test2".equals(lo.locale) || l != lo.l) {
fail("Improper state in localization observer, or not updated properly");
}
lo.flag = false;
l.setLocale("test2");
if (lo.flag || !"test2".equals(lo.locale) || l != lo.l) {
fail("Localization observer improperly updated");
}
l.unregisterLocalizable(lo);
l.setLocale("test1");
if (lo.flag || !"test2".equals(lo.locale) || l != lo.l) {
fail("Localization observer updated after unregistered");
}
}
use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.
the class LocalizerTest method testUnsetDefaultLocale.
public void testUnsetDefaultLocale() {
Localizer l = new Localizer();
final String TEST_LOCALE = "test";
l.addAvailableLocale(TEST_LOCALE);
l.setDefaultLocale(TEST_LOCALE);
try {
l.setDefaultLocale(null);
if (l.getDefaultLocale() != null) {
fail("Could not unset default locale");
}
} catch (UnregisteredLocaleException nsee) {
fail("Exception unsetting default locale");
}
}
use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.
the class LocalizerTest method testDestroyLocaleNotExist.
public void testDestroyLocaleNotExist() {
Localizer l = new Localizer();
final String TEST_LOCALE = "test";
boolean result = l.destroyLocale(TEST_LOCALE);
if (result) {
fail("Destroyed non-existent locale");
}
}
use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.
the class LocalizerTest method testGetText.
public void testGetText(int i, int j, int k, String ourLocale, String otherLocale, String textID, int localeCase, int formCase) {
// System.out.println("testing getText: "+localeCase+","+formCase+","+i+","+j+","+k);
Localizer l = buildLocalizer(i, j, k, ourLocale, otherLocale);
String expected = expectedText(textID, l);
String text, text2;
text = l.getText(textID, ourLocale);
if (expected == null ? text != null : !expected.equals(text)) {
fail("Did not retrieve expected text from localizer [" + localeCase + "," + formCase + "," + i + "," + j + "," + k + "]");
}
try {
text2 = l.getLocalizedText(textID);
if (expected == null) {
fail("Should have gotten exception");
} else if (!expected.equals(text2)) {
fail("Did not retrieve expected text");
}
} catch (NoLocalizedTextException nsee) {
if (expected != null) {
fail("Got unexpected exception");
}
}
}
use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.
the class LocalizerTest method testDestroyDefaultLocale.
public void testDestroyDefaultLocale() {
Localizer l = new Localizer();
final String TEST_LOCALE = "test";
l.addAvailableLocale(TEST_LOCALE);
l.setDefaultLocale(TEST_LOCALE);
l.destroyLocale(TEST_LOCALE);
if (l.getDefaultLocale() != null) {
fail("Default locale still set to destroyed locale");
}
}
Aggregations