1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 10:05:49 +01:00

Fix up the testcases

Please check if transliteration of Hebrew in LnaguageUtilsTest is
correct. It works just fine if you follow the mapping in LanguageUtils.

Test all transliteration in LanguageUtils only, the test in
DeviceCommunicationServiceTest does not need to be done for every
language.

Also use assertEquals(expected, value) instead of assertTrue(expected.equals(value));
This commit is contained in:
cpfeiffer 2017-03-05 19:44:31 +01:00
parent 09d4f81ce8
commit 0b45fe63f0
3 changed files with 13 additions and 19 deletions

View File

@ -102,7 +102,7 @@ public class DeviceCommunicationServiceTestCase extends TestBase {
}
@Test
public void testTransliterationSupportCyrillic() {
public void testTransliterationSupport() {
SharedPreferences settings = GBApplication.getPrefs().getPreferences();
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("transliteration", true);
@ -112,20 +112,6 @@ public class DeviceCommunicationServiceTestCase extends TestBase {
mDeviceService.invokeService(intent);
String result = intent.getStringExtra(EXTRA_NOTIFICATION_BODY);
assertTrue("Transliteration support fail!", result.equals("Prosto tekct"));
}
@Test
public void testTransliterationSupportHebrew() {
SharedPreferences settings = GBApplication.getPrefs().getPreferences();
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("transliteration", true);
editor.commit();
Intent intent = mDeviceService.createIntent().putExtra(EXTRA_NOTIFICATION_BODY, "בדיקה עברית");
mDeviceService.invokeService(intent);
String result = intent.getStringExtra(EXTRA_NOTIFICATION_BODY);
assertTrue("Transliteration support fail!", result.equals("bdykh 'vrith"));
assertEquals("Transliteration support fail!", "Prosto tekct", result);
}
}

View File

@ -7,6 +7,7 @@ import org.junit.Test;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.util.LanguageUtils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -21,7 +22,7 @@ public class LanguageUtilsTest extends TestBase {
String output = LanguageUtils.transliterate(input);
String result = "Prosto tekct";
assertTrue(String.format("Transliteration fail! Expected '%s', but found '%s'}", result, output), output.equals(result));
assertEquals("Transliteration failed", result, output);
}
@Test
@ -29,9 +30,9 @@ public class LanguageUtilsTest extends TestBase {
//input with cyrillic and diacritic letters
String input = "בדיקה עברית";
String output = LanguageUtils.transliterate(input);
String result = "bdykh 'brith";
String result = "bdykh 'bryth";
assertTrue(String.format("Transliteration fail! Expected '%s', but found '%s'}", result, output), output.equals(result));
assertEquals("Transliteration failed", result, output);
}
@Test

View File

@ -26,6 +26,13 @@ import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
import static org.junit.Assert.assertNotNull;
/**
* Base class for all testcases in Gadgetbridge that are supposed to run locally
* with robolectric.
*
* Important: To run them, create a run configuration and execute them in the Gadgetbridge/app/
* directory.
*/
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 19)
// need sdk 19 because "WITHOUT ROWID" is not supported in robolectric/sqlite4java