move all App.setLocalized() tests into LocaleSelectionTest class
This commit is contained in:
parent
a11d214039
commit
5c7be1e852
@ -6,7 +6,6 @@ import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import androidx.core.os.LocaleListCompat;
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.TestUtils;
|
||||
import org.fdroid.fdroid.data.Schema.AppMetadataTable.Cols;
|
||||
@ -19,10 +18,8 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static org.fdroid.fdroid.Assert.assertContainsOnly;
|
||||
@ -281,58 +278,6 @@ public class AppProviderTest extends FDroidProviderTest {
|
||||
assertEquals("F-Droid", otherApp.name);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAppSetLocalized() {
|
||||
final String enSummary = "utility for getting information about the APKs that are installed on your device";
|
||||
HashMap<String, Object> en = new HashMap<>();
|
||||
en.put("summary", enSummary);
|
||||
|
||||
final String esSummary = "utilidad para obtener información sobre los APKs instalados en su dispositivo";
|
||||
HashMap<String, Object> es = new HashMap<>();
|
||||
es.put("summary", esSummary);
|
||||
|
||||
final String frSummary = "utilitaire pour obtenir des informations sur les APKs qui sont installés sur vot";
|
||||
HashMap<String, Object> fr = new HashMap<>();
|
||||
fr.put("summary", frSummary);
|
||||
|
||||
final String nlSummary = "hulpprogramma voor het verkrijgen van informatie over de APK die zijn geïnstalle";
|
||||
HashMap<String, Object> nl = new HashMap<>();
|
||||
nl.put("summary", nlSummary);
|
||||
|
||||
App app = new App();
|
||||
Map<String, Map<String, Object>> localized = new HashMap<>();
|
||||
localized.put("es", es);
|
||||
localized.put("fr", fr);
|
||||
|
||||
App.systemLocaleList = LocaleListCompat.forLanguageTags("nl-NL");
|
||||
app.setLocalized(localized);
|
||||
assertFalse(app.isLocalized);
|
||||
|
||||
localized.put("nl", nl);
|
||||
app.setLocalized(localized);
|
||||
assertTrue(app.isLocalized);
|
||||
assertEquals(nlSummary, app.summary);
|
||||
|
||||
app = new App();
|
||||
localized.clear();
|
||||
localized.put("nl", nl);
|
||||
app.setLocalized(localized);
|
||||
assertTrue(app.isLocalized);
|
||||
|
||||
app = new App();
|
||||
localized.clear();
|
||||
localized.put("en-US", en);
|
||||
app.setLocalized(localized);
|
||||
assertFalse(app.isLocalized);
|
||||
|
||||
App.systemLocaleList = LocaleListCompat.forLanguageTags("en-US");
|
||||
app = new App();
|
||||
localized.clear();
|
||||
localized.put("en-US", en);
|
||||
app.setLocalized(localized);
|
||||
assertTrue(app.isLocalized);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsertTrimsNamesAndSummary() {
|
||||
// Insert a new record with unwanted newlines...
|
||||
|
@ -250,4 +250,56 @@ public class LocaleSelectionTest {
|
||||
assertEquals(EN_US_SEVEN_INCH_SCREENSHOT, app.sevenInchScreenshots[0]);
|
||||
assertTrue(app.isLocalized);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsLocalized() {
|
||||
final String enSummary = "utility for getting information about the APKs that are installed on your device";
|
||||
HashMap<String, Object> en = new HashMap<>();
|
||||
en.put("summary", enSummary);
|
||||
|
||||
final String esSummary = "utilidad para obtener información sobre los APKs instalados en su dispositivo";
|
||||
HashMap<String, Object> es = new HashMap<>();
|
||||
es.put("summary", esSummary);
|
||||
|
||||
final String frSummary = "utilitaire pour obtenir des informations sur les APKs qui sont installés sur vot";
|
||||
HashMap<String, Object> fr = new HashMap<>();
|
||||
fr.put("summary", frSummary);
|
||||
|
||||
final String nlSummary = "hulpprogramma voor het verkrijgen van informatie over de APK die zijn geïnstalle";
|
||||
HashMap<String, Object> nl = new HashMap<>();
|
||||
nl.put("summary", nlSummary);
|
||||
|
||||
App app = new App();
|
||||
Map<String, Map<String, Object>> localized = new HashMap<>();
|
||||
localized.put("es", es);
|
||||
localized.put("fr", fr);
|
||||
|
||||
App.systemLocaleList = LocaleListCompat.forLanguageTags("nl-NL");
|
||||
app.setLocalized(localized);
|
||||
assertFalse(app.isLocalized);
|
||||
|
||||
localized.put("nl", nl);
|
||||
app.setLocalized(localized);
|
||||
assertTrue(app.isLocalized);
|
||||
assertEquals(nlSummary, app.summary);
|
||||
|
||||
app = new App();
|
||||
localized.clear();
|
||||
localized.put("nl", nl);
|
||||
app.setLocalized(localized);
|
||||
assertTrue(app.isLocalized);
|
||||
|
||||
app = new App();
|
||||
localized.clear();
|
||||
localized.put("en-US", en);
|
||||
app.setLocalized(localized);
|
||||
assertFalse(app.isLocalized);
|
||||
|
||||
App.systemLocaleList = LocaleListCompat.forLanguageTags("en-US");
|
||||
app = new App();
|
||||
localized.clear();
|
||||
localized.put("en-US", en);
|
||||
app.setLocalized(localized);
|
||||
assertTrue(app.isLocalized);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user