Search in sources :

Example 26 with SmallTest

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

Example 27 with SmallTest

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

Example 28 with SmallTest

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

Example 29 with SmallTest

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

Example 30 with SmallTest

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);
}
Also used : Binder(android.os.Binder) TypedValue(android.util.TypedValue) 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