use of android.support.test.filters.SmallTest in project android_frameworks_base by AOSPA.
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 android_frameworks_base by AOSPA.
the class BatteryStatsTimerTest method testParceling.
/**
* Tests that the parcel can be parceled and unparceled without losing anything.
*/
@SmallTest
public void testParceling() throws Exception {
TimeBase timeBase = new TimeBase();
MockClocks clocks = new MockClocks();
// Test write then read
TestTimer timer1 = new TestTimer(clocks, 0, timeBase);
timer1.setCount(1);
timer1.setLoadedCount(3);
timer1.setLastCount(4);
timer1.setUnpluggedCount(5);
timer1.setTotalTime(9223372036854775807L);
timer1.setLoadedTime(9223372036854775806L);
timer1.setLastTime(9223372036854775805L);
timer1.setUnpluggedTime(9223372036854775804L);
timer1.setTimeBeforeMark(9223372036854775803L);
timer1.nextComputeRunTime = 201;
timer1.nextComputeCurrentCount = 2;
Parcel parcel = Parcel.obtain();
Timer.writeTimerToParcel(parcel, timer1, 77);
parcel.setDataPosition(0);
Assert.assertTrue("parcel null object", parcel.readInt() != 0);
TestTimer timer2 = new TestTimer(clocks, 0, timeBase, parcel);
// from computeTotalCountLocked()
Assert.assertEquals(2, timer2.getCount());
Assert.assertEquals(3, timer2.getLoadedCount());
// NOT saved
Assert.assertEquals(0, timer2.getLastCount());
Assert.assertEquals(5, timer2.getUnpluggedCount());
// from computeRunTimeLocked()
Assert.assertEquals(201, timer2.getTotalTime());
Assert.assertEquals(9223372036854775806L, timer2.getLoadedTime());
// NOT saved
Assert.assertEquals(0, timer2.getLastTime());
Assert.assertEquals(9223372036854775804L, timer2.getUnpluggedTime());
Assert.assertEquals(9223372036854775803L, timer2.getTimeBeforeMark());
parcel.recycle();
}
use of android.support.test.filters.SmallTest in project android_frameworks_base by AOSPA.
the class BatteryStatsTimerTest method testRunning.
/**
* Tests that the flow through TimeBase.setRunning propagates through
* to the timer.
*/
@SmallTest
public void testRunning() throws Exception {
TimeBase timeBase = new TimeBase();
MockClocks clocks = new MockClocks();
TestTimer timer = new TestTimer(clocks, 0, timeBase);
timer.nextComputeCurrentCount = 3000;
// Test that starting the timer counts the unplugged time and counters
timer.nextComputeRunTime = 4;
timer.onTimeStarted(10, 20, 50);
Assert.assertEquals(50, timer.lastComputeRunTimeRealtime);
Assert.assertEquals(4, timer.getUnpluggedTime());
Assert.assertEquals(3000, timer.getUnpluggedCount());
// Test that stopping the timer updates mTotalTime and mCount
timer.nextComputeRunTime = 17;
timer.onTimeStopped(100, 130, 170);
Assert.assertEquals(17, timer.getTotalTime());
Assert.assertEquals(3000, timer.getCount());
}
use of android.support.test.filters.SmallTest in project android_frameworks_base by AOSPA.
the class BatteryStatsTimeBaseTest method testSummary.
/**
* Test writeSummaryToParcel and readSummaryFromParcel
*/
@SmallTest
public void testSummary() throws Exception {
TestTimeBase tb1 = new TestTimeBase();
tb1.populate(100, 200, true, 300, 400, 500, 600, 700, 800);
Parcel parcel = Parcel.obtain();
tb1.writeSummaryToParcel(parcel, 666, 6666);
parcel.setDataPosition(0);
TestTimeBase tb2 = new TestTimeBase();
// readSummaryFromParcel doesn't affect the other fields.
// Not sure if this is deliberate
tb2.populate(1, 2, true, 3, 4, 5, 6, 7, 8);
tb2.readSummaryFromParcel(parcel);
tb2.verify(666, 6766, true, 3, 4, 5, 6, 7, 8);
}
use of android.support.test.filters.SmallTest in project AnyMemo by helloworld1.
the class CardDaoTest method testGetCardsByCategory.
@SmallTest
@Test
public void testGetCardsByCategory() throws Exception {
CardDao cardDao = helper.getCardDao();
CategoryDao categoryDao = helper.getCategoryDao();
setupThreeCategories();
Category filterCategory1 = categoryDao.createOrReturn("My category");
// If category specified is null, return all cards up to limit
List<Card> cards1 = cardDao.getCardsByCategory(null, false, 50);
assertEquals(28, cards1.size());
// No category specified but with limit
List<Card> cards2 = cardDao.getCardsByCategory(null, false, 10);
assertEquals(10, cards2.size());
// Get by category
List<Card> cards3 = cardDao.getCardsByCategory(filterCategory1, false, 50);
assertEquals(3, cards3.size());
// Get by category with limit
List<Card> cards4 = cardDao.getCardsByCategory(filterCategory1, false, 2);
assertEquals(2, cards4.size());
// Random cards shouldn't affect number of cards to get
List<Card> cards5 = cardDao.getCardsByCategory(filterCategory1, true, 50);
assertEquals(3, cards5.size());
}
Aggregations