Merge "Fix issue "open battery settings, switch locale, apps are still in old locale" into pi-dev" into pi-dev
This commit is contained in:
@@ -39,6 +39,8 @@ import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class BatteryEntryTest {
|
||||
|
||||
@@ -148,4 +150,17 @@ public class BatteryEntryTest {
|
||||
|
||||
assertThat(entry.extractPackagesFromSipper(entry.sipper)).isEqualTo(entry.sipper.mPackages);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUidCache_switchLocale_shouldCleanCache() {
|
||||
BatteryEntry.stopRequestQueue();
|
||||
|
||||
Locale.setDefault(new Locale("en_US"));
|
||||
BatteryEntry.sUidCache.put(Integer.toString(APP_UID), null);
|
||||
assertThat(BatteryEntry.sUidCache).isNotEmpty();
|
||||
|
||||
Locale.setDefault(new Locale("zh_TW"));
|
||||
createBatteryEntryForApp();
|
||||
assertThat(BatteryEntry.sUidCache).isEmpty(); // check if cache is clear
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user