use of android.support.test.filters.SmallTest in project platform_frameworks_base by android.
the class BatteryStatsTimerTest method testResetNoDetach.
/**
* Tests that reset() clears the correct times.
*/
@SmallTest
public void testResetNoDetach() throws Exception {
TimeBase timeBase = new TimeBase();
MockClocks clocks = new MockClocks();
TestTimer timer = new TestTimer(clocks, 0, timeBase);
timer.setCount(1);
timer.setLoadedCount(2);
timer.setLastCount(3);
timer.setUnpluggedCount(4);
timer.setTotalTime(9223372036854775807L);
timer.setLoadedTime(9223372036854775806L);
timer.setLastTime(9223372036854775805L);
timer.setUnpluggedTime(9223372036854775804L);
timer.setTimeBeforeMark(9223372036854775803L);
timer.reset(false);
Assert.assertEquals(0, timer.getCount());
Assert.assertEquals(0, timer.getLoadedCount());
Assert.assertEquals(0, timer.getLastCount());
Assert.assertEquals(4, timer.getUnpluggedCount());
Assert.assertEquals(0, timer.getTotalTime());
Assert.assertEquals(0, timer.getLoadedTime());
Assert.assertEquals(0, timer.getLastTime());
Assert.assertEquals(9223372036854775804L, timer.getUnpluggedTime());
Assert.assertEquals(0, timer.getTimeBeforeMark());
// reset(false) shouldn't remove it from the list
Assert.assertEquals(true, timeBase.hasObserver(timer));
}
use of android.support.test.filters.SmallTest in project platform_frameworks_base by android.
the class BatteryStatsTimerTest method testGetTotalTimeLocked.
/**
* Tests getTotalTimeLocked
*/
@SmallTest
public void testGetTotalTimeLocked() throws Exception {
TimeBase timeBase = new TimeBase();
timeBase.setRunning(true, 10, 20);
timeBase.setRunning(false, 45, 60);
Assert.assertEquals(40, timeBase.getRealtime(200));
MockClocks clocks = new MockClocks();
TestTimer timer = new TestTimer(clocks, 0, timeBase);
timer.setCount(1);
timer.setLoadedCount(2);
timer.setLastCount(3);
timer.setUnpluggedCount(4);
timer.setTotalTime(100);
timer.setLoadedTime(200);
timer.setLastTime(300);
timer.setUnpluggedTime(400);
timer.setTimeBeforeMark(500);
timer.nextComputeRunTime = 10000;
// Timer.getTotalTimeLocked(STATS_SINCE_CHARGED)
timer.lastComputeRunTimeRealtime = -1;
Assert.assertEquals(10000, timer.getTotalTimeLocked(66, BatteryStats.STATS_SINCE_CHARGED));
Assert.assertEquals(40, timer.lastComputeRunTimeRealtime);
// Timer.getTotalTimeLocked(STATS_CURRENT)
timer.lastComputeRunTimeRealtime = -1;
Assert.assertEquals(9800, timer.getTotalTimeLocked(66, BatteryStats.STATS_CURRENT));
Assert.assertEquals(40, timer.lastComputeRunTimeRealtime);
// Timer.getTotalTimeLocked(STATS_SINCE_UNPLUGGED)
timer.lastComputeRunTimeRealtime = -1;
Assert.assertEquals(9600, timer.getTotalTimeLocked(66, BatteryStats.STATS_SINCE_UNPLUGGED));
Assert.assertEquals(40, timer.lastComputeRunTimeRealtime);
}
use of android.support.test.filters.SmallTest in project platform_frameworks_base by android.
the class BatteryStatsTimerTest method testGetTimeSinceMarked.
/**
* Tests getTimeSinceMarkLocked
*/
@SmallTest
public void testGetTimeSinceMarked() throws Exception {
TimeBase timeBase = new TimeBase();
timeBase.setRunning(true, 10, 20);
timeBase.setRunning(false, 45, 60);
Assert.assertEquals(40, timeBase.getRealtime(200));
MockClocks clocks = new MockClocks();
TestTimer timer = new TestTimer(clocks, 0, timeBase);
timer.setCount(1);
timer.setLoadedCount(2);
timer.setLastCount(3);
timer.setUnpluggedCount(4);
timer.setTotalTime(100);
timer.setLoadedTime(200);
timer.setLastTime(300);
timer.setUnpluggedTime(400);
timer.setTimeBeforeMark(500);
timer.nextComputeRunTime = 10000;
Assert.assertEquals(9500, timer.getTimeSinceMarkLocked(666));
}
use of android.support.test.filters.SmallTest in project platform_frameworks_base by android.
the class ResourcesLocaleTest method testEnglishIsAlwaysConsideredSupported.
@SmallTest
public void testEnglishIsAlwaysConsideredSupported() throws Exception {
final Resources resources = createResourcesWithApk(R.raw.locales);
ensureNoLanguage(resources, "en");
final LocaleList preferredLocales = LocaleList.forLanguageTags("en-US,pl-PL");
final Configuration config = new Configuration();
config.setLocales(preferredLocales);
resources.updateConfiguration(config, null);
// The APK we loaded has default and Polish languages. If English is first in the list,
// always take it the default (assumed to be English).
assertEquals(Locale.forLanguageTag("en-US"), resources.getConfiguration().getLocales().get(0));
}
use of android.support.test.filters.SmallTest in project platform_frameworks_base by android.
the class ResourcesManagerTest method testThemesGetUpdatedWithNewImpl.
@SmallTest
public void testThemesGetUpdatedWithNewImpl() {
Binder activity1 = new Binder();
Resources resources1 = mResourcesManager.createBaseActivityResources(activity1, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
assertNotNull(resources1);
Resources.Theme theme = resources1.newTheme();
assertSame(resources1, theme.getResources());
theme.applyStyle(android.R.style.Theme_NoTitleBar, false);
TypedValue value = new TypedValue();
assertTrue(theme.resolveAttribute(android.R.attr.windowNoTitle, value, true));
assertEquals(TypedValue.TYPE_INT_BOOLEAN, value.type);
assertTrue(value.data != 0);
final Configuration overrideConfig = new Configuration();
overrideConfig.orientation = Configuration.ORIENTATION_LANDSCAPE;
mResourcesManager.updateResourcesForActivity(activity1, overrideConfig);
assertSame(resources1, theme.getResources());
// Make sure we can still access the data.
assertTrue(theme.resolveAttribute(android.R.attr.windowNoTitle, value, true));
assertEquals(TypedValue.TYPE_INT_BOOLEAN, value.type);
assertTrue(value.data != 0);
}
Aggregations