Search in sources :

Example 51 with SmallTest

use of android.support.test.filters.SmallTest in project android_frameworks_base by AOSPA.

the class ResourcesManagerTest method testTwoActivitiesWithIdenticalParametersShareImpl.

@SmallTest
public void testTwoActivitiesWithIdenticalParametersShareImpl() {
    Binder activity1 = new Binder();
    Resources resources1 = mResourcesManager.getResources(activity1, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
    assertNotNull(resources1);
    Binder activity2 = new Binder();
    Resources resources2 = mResourcesManager.getResources(activity2, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
    assertNotNull(resources1);
    // The references themselves should be unique.
    assertNotSame(resources1, resources2);
    // The implementations should be the same.
    assertSame(resources1.getImpl(), resources2.getImpl());
}
Also used : Binder(android.os.Binder) SmallTest(android.support.test.filters.SmallTest)

Example 52 with SmallTest

use of android.support.test.filters.SmallTest in project android_frameworks_base by AOSPA.

the class BatteryStatsTimerTest method testParcelingNull.

/**
     * Tests that the parcel can be parceled and unparceled without losing anything.
     */
@SmallTest
public void testParcelingNull() throws Exception {
    // Test writing null
    Parcel parcel = Parcel.obtain();
    Timer.writeTimerToParcel(parcel, null, 88);
    parcel.setDataPosition(0);
    Assert.assertEquals(0, parcel.readInt());
    parcel.recycle();
}
Also used : Parcel(android.os.Parcel) SmallTest(android.support.test.filters.SmallTest)

Example 53 with SmallTest

use of android.support.test.filters.SmallTest in project android_frameworks_base by AOSPA.

the class BatteryStatsTimerTest method testResetDetach.

/**
     * Tests that reset() clears the correct times.
     */
@SmallTest
public void testResetDetach() 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(true);
    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(true) should remove it from the list
    Assert.assertEquals(false, timeBase.hasObserver(timer));
}
Also used : TimeBase(com.android.internal.os.BatteryStatsImpl.TimeBase) SmallTest(android.support.test.filters.SmallTest)

Example 54 with SmallTest

use of android.support.test.filters.SmallTest in project android_frameworks_base by AOSPA.

the class BatteryStatsTimerTest method testSummaryParceling.

/**
     * Tests reading and writing the summary to a parcel
     */
@SmallTest
public void testSummaryParceling() throws Exception {
    TimeBase timeBase = new TimeBase();
    timeBase.setRunning(true, 10, 20);
    timeBase.setRunning(false, 45, 60);
    Assert.assertEquals(40, timeBase.getRealtime(200));
    // the past uptime is 35 and the past runtime is 40
    MockClocks clocks = new MockClocks();
    TestTimer timer1 = new TestTimer(clocks, 0, timeBase);
    timer1.setCount(1);
    timer1.setLoadedCount(2);
    timer1.setLastCount(3);
    timer1.setUnpluggedCount(4);
    timer1.setTotalTime(9223372036854775807L);
    timer1.setLoadedTime(9223372036854775806L);
    timer1.setLastTime(9223372036854775805L);
    timer1.setUnpluggedTime(9223372036854775804L);
    timer1.setTimeBeforeMark(9223372036854775803L);
    Parcel parcel = Parcel.obtain();
    timer1.nextComputeRunTime = 9223372036854775800L;
    timer1.nextComputeCurrentCount = 1;
    timer1.writeSummaryFromParcelLocked(parcel, 201);
    Assert.assertEquals(40, timer1.lastComputeRunTimeRealtime);
    TestTimer timer2 = new TestTimer(clocks, 0, timeBase);
    // Make sure that all the values get touched
    timer2.setCount(666);
    timer2.setLoadedCount(666);
    timer2.setLastCount(666);
    timer2.setUnpluggedCount(666);
    timer2.setTotalTime(666);
    timer2.setLoadedTime(666);
    timer2.setLastTime(666);
    timer2.setUnpluggedTime(666);
    timer2.setTimeBeforeMark(666);
    parcel.setDataPosition(0);
    parcel.setDataPosition(0);
    timer2.readSummaryFromParcelLocked(parcel);
    Assert.assertEquals(1, timer2.getCount());
    Assert.assertEquals(1, timer2.getLoadedCount());
    Assert.assertEquals(0, timer2.getLastCount());
    Assert.assertEquals(1, timer2.getUnpluggedCount());
    Assert.assertEquals(9223372036854775800L, timer2.getTotalTime());
    Assert.assertEquals(9223372036854775800L, timer2.getLoadedTime());
    Assert.assertEquals(0, timer2.getLastTime());
    Assert.assertEquals(9223372036854775800L, timer2.getUnpluggedTime());
    Assert.assertEquals(9223372036854775800L, timer2.getTimeBeforeMark());
    parcel.recycle();
}
Also used : Parcel(android.os.Parcel) TimeBase(com.android.internal.os.BatteryStatsImpl.TimeBase) SmallTest(android.support.test.filters.SmallTest)

Example 55 with SmallTest

use of android.support.test.filters.SmallTest in project android_frameworks_base by AOSPA.

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);
}
Also used : TimeBase(com.android.internal.os.BatteryStatsImpl.TimeBase) SmallTest(android.support.test.filters.SmallTest)

Aggregations

SmallTest (android.support.test.filters.SmallTest)252 Test (org.junit.Test)137 AbstractExistingDBTest (org.liberty.android.fantastischmemo.test.AbstractExistingDBTest)86 Parcel (android.os.Parcel)48 TimeBase (com.android.internal.os.BatteryStatsImpl.TimeBase)45 Card (org.liberty.android.fantastischmemo.entity.Card)43 CardDao (org.liberty.android.fantastischmemo.dao.CardDao)37 Setting (org.liberty.android.fantastischmemo.entity.Setting)21 Binder (android.os.Binder)20 Category (org.liberty.android.fantastischmemo.entity.Category)17 AbstractPreferencesTest (org.liberty.android.fantastischmemo.test.AbstractPreferencesTest)17 LearningData (org.liberty.android.fantastischmemo.entity.LearningData)15 UiThreadTest (android.support.test.annotation.UiThreadTest)14 CategoryDao (org.liberty.android.fantastischmemo.dao.CategoryDao)13 LocaleList (android.os.LocaleList)10 Option (org.liberty.android.fantastischmemo.entity.Option)9 QueueManager (org.liberty.android.fantastischmemo.queue.QueueManager)9 ContentResolver (android.content.ContentResolver)8 Cursor (android.database.Cursor)8 OnTickListener (com.tmall.wireless.tangram.support.TimerSupport.OnTickListener)8