I am writing a multi-language android app and I would like to test if the labels and others texts are correct. For example, in the English version the button will have the label "Download", in Germany "Nachladen", in Czech "Stahnout".
My test code work fine for the language which is set in the testing device, but how do I programmatically run the test for every language on one device?
import android.content.Intent;
import android.test.ActivityUnitTestCase;
import android.widget.Button;
public class MenuActivityTest extends ActivityUnitTestCase<MenuActivity> {
private Intent launchIntent;
private MenuActivity activity;
public MenuActivityTest() {
super(MenuActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
launchIntent = new Intent(getInstrumentation().getTargetContext(),
MenuActivity.class);
}
public void testSettingsButtonText() {
startActivity(launchIntent, null, null);
activity = getActivity();
final String expected = activity
.getText(R.string.menu_button_text_settings).toString();
final Button button = (Button) activity
.findViewById(R.id.menu_button_settings);
final String actual = button.getText().toString();
assertEquals("Button text for Settings is wrong", expected, actual);
}
}