use of android.support.test.filters.SmallTest in project android_frameworks_base by crdroidandroid.
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 android_frameworks_base by crdroidandroid.
the class BatteryStatsServTest method testParceling.
/**
* Test parceling and unparceling.
*/
@SmallTest
public void testParceling() throws Exception {
MockBatteryStatsImpl bsi = new MockBatteryStatsImpl();
TestServ orig = new TestServ(bsi);
orig.populate();
Parcel parcel = Parcel.obtain();
orig.writeToParcelLocked(parcel);
parcel.setDataPosition(0);
TestServ serv = new TestServ(bsi);
serv.readFromParcelLocked(parcel);
Assert.assertEquals(1010, serv.getStartTime());
Assert.assertEquals(2021, serv.getRunningSince());
Assert.assertTrue(serv.getRunning());
Assert.assertEquals(4042, serv.getStarts());
Assert.assertEquals(5053, serv.getLaunchedTime());
Assert.assertEquals(6064, serv.getLaunchedSince());
Assert.assertTrue(serv.getLaunched());
Assert.assertEquals(8085, serv.getLaunches());
Assert.assertEquals(9096, serv.getLoadedStartTime());
Assert.assertEquals(10017, serv.getLoadedStarts());
Assert.assertEquals(11118, serv.getLoadedLaunches());
Assert.assertEquals(0, serv.getLastStartTime());
Assert.assertEquals(0, serv.getLastStarts());
Assert.assertEquals(0, serv.getLastLaunches());
Assert.assertEquals(15512, serv.getUnpluggedStartTime());
Assert.assertEquals(16613, serv.getUnpluggedStarts());
Assert.assertEquals(17714, serv.getUnpluggedLaunches());
}
use of android.support.test.filters.SmallTest in project android_frameworks_base by crdroidandroid.
the class BatteryStatsTimeBaseTest method testParcellingWhileNotRunning.
/**
* Test writeToParcel and readFromParcel
*/
@SmallTest
public void testParcellingWhileNotRunning() throws Exception {
TestTimeBase tb1 = new TestTimeBase();
tb1.populate(100, 200, false, 300, 400, 500, 600, 700, 800);
Parcel parcel = Parcel.obtain();
tb1.writeToParcel(parcel, 666, 6666);
parcel.setDataPosition(0);
TestTimeBase tb2 = new TestTimeBase();
tb2.readFromParcel(parcel);
tb2.verify(100, 200, false, 300, 400, 500, 600, 700, 800);
}
use of android.support.test.filters.SmallTest in project android_frameworks_base by AOSPA.
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 android_frameworks_base by AOSPA.
the class ResourcesManagerTest method testUpdateConfigurationUpdatesAllAssetManagers.
@SmallTest
public void testUpdateConfigurationUpdatesAllAssetManagers() {
Resources resources1 = mResourcesManager.getResources(null, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
assertNotNull(resources1);
Resources resources2 = mResourcesManager.getResources(null, APP_TWO_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
assertNotNull(resources2);
Binder activity = new Binder();
final Configuration overrideConfig = new Configuration();
overrideConfig.orientation = Configuration.ORIENTATION_LANDSCAPE;
Resources resources3 = mResourcesManager.getResources(activity, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, overrideConfig, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
assertNotNull(resources3);
// No Resources object should be the same.
assertNotSame(resources1, resources2);
assertNotSame(resources1, resources3);
assertNotSame(resources2, resources3);
// Each ResourcesImpl should be different.
assertNotSame(resources1.getImpl(), resources2.getImpl());
assertNotSame(resources1.getImpl(), resources3.getImpl());
assertNotSame(resources2.getImpl(), resources3.getImpl());
Configuration newConfig = new Configuration();
newConfig.orientation = Configuration.ORIENTATION_LANDSCAPE;
mResourcesManager.applyConfigurationToResourcesLocked(newConfig, null);
final Configuration expectedConfig = new Configuration();
expectedConfig.setLocales(LocaleList.getAdjustedDefault());
expectedConfig.densityDpi = mDisplayMetrics.densityDpi;
expectedConfig.orientation = Configuration.ORIENTATION_LANDSCAPE;
assertEquals(expectedConfig, resources1.getConfiguration());
assertEquals(expectedConfig, resources2.getConfiguration());
assertEquals(expectedConfig, resources3.getConfiguration());
}
Aggregations