Skip to content

Commit

Permalink
Modifies instrumenetation tests
Browse files Browse the repository at this point in the history
Makes the test case for checking for all flags to work correctly
  • Loading branch information
blongho committed Apr 5, 2020
1 parent ae2769e commit 505d6f9
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;

import android.content.Context;
import android.util.Log;
Expand All @@ -43,7 +43,8 @@
public class WorldTest {

private static final String TAG = "WorldTest";
private static Context context;
private static Context context;

@BeforeClass
public static void setUp() {
context = InstrumentationRegistry.getInstrumentation().getContext();
Expand Down Expand Up @@ -98,22 +99,23 @@ public void getAllCurrencies() {
assertNotNull(currencies.get(0));
log("Currency list size= " + currencies.size());
}
@Test
public void allCountriesHaveFlags(){
final List<Country> countries = World.getAllCountries();

@Test
public void allCountriesHaveFlags() {
final List<Country> countries = World.getAllCountries();

for (final Country country : countries) {
final String resource = "drawable/" + country.getAlpha2().toLowerCase();
int countryFlag = context.getResources()
.getIdentifier(resource, null, context.getPackageName());
if(country.getAlpha2().equalsIgnoreCase("do")){
if (country.getAlpha2().equalsIgnoreCase("do")) {
countryFlag = com.blongho.country_data.test.R.drawable.dominican;
}
if(country.getAlpha2().equalsIgnoreCase("xx")){
if (country.getAlpha2().equalsIgnoreCase("xx")) {
countryFlag = com.blongho.country_data.test.R.drawable.globe;
}
log("allCountriesHaveFlags: country= " + country.getAlpha2() + " flag " + countryFlag);
assertNotSame(country.getFlagResource(), 0);
assertTrue(countryFlag > 0);
}
}
}

0 comments on commit 505d6f9

Please sign in to comment.