mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-21 16:02:04 +02:00
Set language in test using preference option
This commit is contained in:
@@ -36,6 +36,7 @@ import com.health.openscale.core.OpenScale;
|
|||||||
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
||||||
import com.health.openscale.core.datatypes.ScaleUser;
|
import com.health.openscale.core.datatypes.ScaleUser;
|
||||||
import com.health.openscale.core.utils.CsvHelper;
|
import com.health.openscale.core.utils.CsvHelper;
|
||||||
|
import com.health.openscale.gui.activities.BaseAppCompatActivity;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@@ -74,15 +75,6 @@ public class ScreenshotRecorder {
|
|||||||
@Rule
|
@Rule
|
||||||
public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class, false , false);
|
public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class, false , false);
|
||||||
|
|
||||||
private void setLangauge(String language, String country) {
|
|
||||||
Locale locale = new Locale(language, country);
|
|
||||||
Locale.setDefault(locale);
|
|
||||||
Resources res = context.getResources();
|
|
||||||
Configuration config = res.getConfiguration();
|
|
||||||
config.locale = locale;
|
|
||||||
res.updateConfiguration(config, res.getDisplayMetrics());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void initRecorder() {
|
public void initRecorder() {
|
||||||
context = InstrumentationRegistry.getTargetContext();
|
context = InstrumentationRegistry.getTargetContext();
|
||||||
@@ -111,12 +103,16 @@ public class ScreenshotRecorder {
|
|||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
prefs.edit().remove("lastFragmentId").commit();
|
prefs.edit()
|
||||||
setLangauge("en", "EN");
|
.remove("lastFragmentId")
|
||||||
|
.putString(BaseAppCompatActivity.PREFERENCE_LANGUAGE, "en")
|
||||||
|
.commit();
|
||||||
screenshotRecorder();
|
screenshotRecorder();
|
||||||
|
|
||||||
prefs.edit().remove("lastFragmentId").commit();
|
prefs.edit()
|
||||||
setLangauge("de", "DE");
|
.remove("lastFragmentId")
|
||||||
|
.putString(BaseAppCompatActivity.PREFERENCE_LANGUAGE, "de")
|
||||||
|
.commit();
|
||||||
screenshotRecorder();
|
screenshotRecorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user