Search in sources :

Example 31 with SparseLongArray

use of android.util.SparseLongArray in project AndroidUtilCode by Blankj.

the class ObjectUtilsTest method isEmpty.

@Test
public void isEmpty() {
    StringBuilder sb = new StringBuilder("");
    StringBuilder sb1 = new StringBuilder(" ");
    String string = "";
    String string1 = " ";
    int[][] arr = new int[][] {};
    LinkedList<Integer> list = new LinkedList<>();
    HashMap<String, Integer> map = new HashMap<>();
    SimpleArrayMap<String, Integer> sam = new SimpleArrayMap<>();
    SparseArray<String> sa = new SparseArray<>();
    SparseBooleanArray sba = new SparseBooleanArray();
    SparseIntArray sia = new SparseIntArray();
    SparseLongArray sla = new SparseLongArray();
    LongSparseArray<String> lsa = new LongSparseArray<>();
    android.util.LongSparseArray<String> lsaV4 = new android.util.LongSparseArray<>();
    assertTrue(ObjectUtils.isEmpty(sb));
    assertFalse(ObjectUtils.isEmpty(sb1));
    assertTrue(ObjectUtils.isEmpty(string));
    assertFalse(ObjectUtils.isEmpty(string1));
    assertTrue(ObjectUtils.isEmpty(arr));
    assertTrue(ObjectUtils.isEmpty(list));
    assertTrue(ObjectUtils.isEmpty(map));
    assertTrue(ObjectUtils.isEmpty(sam));
    assertTrue(ObjectUtils.isEmpty(sa));
    assertTrue(ObjectUtils.isEmpty(sba));
    assertTrue(ObjectUtils.isEmpty(sia));
    assertTrue(ObjectUtils.isEmpty(sla));
    assertTrue(ObjectUtils.isEmpty(lsa));
    assertTrue(ObjectUtils.isEmpty(lsaV4));
    assertTrue(!ObjectUtils.isNotEmpty(sb));
    assertFalse(!ObjectUtils.isNotEmpty(sb1));
    assertTrue(!ObjectUtils.isNotEmpty(string));
    assertFalse(!ObjectUtils.isNotEmpty(string1));
    assertTrue(!ObjectUtils.isNotEmpty(arr));
    assertTrue(!ObjectUtils.isNotEmpty(list));
    assertTrue(!ObjectUtils.isNotEmpty(map));
    assertTrue(!ObjectUtils.isNotEmpty(sam));
    assertTrue(!ObjectUtils.isNotEmpty(sa));
    assertTrue(!ObjectUtils.isNotEmpty(sba));
    assertTrue(!ObjectUtils.isNotEmpty(sia));
    assertTrue(!ObjectUtils.isNotEmpty(sla));
    assertTrue(!ObjectUtils.isNotEmpty(lsa));
    assertTrue(!ObjectUtils.isNotEmpty(lsaV4));
}
Also used : LongSparseArray(androidx.collection.LongSparseArray) HashMap(java.util.HashMap) SimpleArrayMap(androidx.collection.SimpleArrayMap) SparseLongArray(android.util.SparseLongArray) LinkedList(java.util.LinkedList) SparseArray(android.util.SparseArray) LongSparseArray(androidx.collection.LongSparseArray) SparseIntArray(android.util.SparseIntArray) SparseBooleanArray(android.util.SparseBooleanArray) Test(org.junit.Test)

Example 32 with SparseLongArray

use of android.util.SparseLongArray in project robolectric by robolectric.

the class PackageRollbackInfoBuilderTest method build_onQ.

@Test
@Config(sdk = Build.VERSION_CODES.Q)
public void build_onQ() {
    PackageRollbackInfo packageRollbackInfo = PackageRollbackInfoBuilder.newBuilder().setPackageRolledBackFrom(packageRolledBackFrom).setPackageRolledBackTo(packageRolledBackTo).addPendingBackup(BACKUP_ID).addPendingRestore(RESTORE_INFO_USER_ID, RESTORE_INFO_APP_ID, RESTORE_INFO_SEINFO).setIsApex(true).addInstalledUser(INSTALLED_USER_ID).setCeSnapshotInodes(ceSnapshotInodes).build();
    assertThat(packageRollbackInfo).isNotNull();
    assertThat(packageRollbackInfo.getVersionRolledBackFrom()).isEqualTo(packageRolledBackFrom);
    assertThat(packageRollbackInfo.getVersionRolledBackTo()).isEqualTo(packageRolledBackTo);
    int[] pendingBackups = ((IntArray) ReflectionHelpers.callInstanceMethod(packageRollbackInfo, "getPendingBackups")).toArray();
    assertThat(pendingBackups).asList().containsExactly(BACKUP_ID);
    assertThat(packageRollbackInfo.getPendingRestores()).hasSize(1);
    assertThat(packageRollbackInfo.getPendingRestores().get(0).userId).isEqualTo(RESTORE_INFO_USER_ID);
    assertThat(packageRollbackInfo.getPendingRestores().get(0).appId).isEqualTo(RESTORE_INFO_APP_ID);
    assertThat(packageRollbackInfo.getPendingRestores().get(0).seInfo).isEqualTo(RESTORE_INFO_SEINFO);
    assertThat(packageRollbackInfo.isApex()).isTrue();
    IntArray installedUsers = ReflectionHelpers.callInstanceMethod(packageRollbackInfo, "getInstalledUsers");
    assertThat(installedUsers.toArray()).hasLength(1);
    assertThat(installedUsers.get(0)).isEqualTo(INSTALLED_USER_ID);
    if (RuntimeEnvironment.getApiLevel() <= Build.VERSION_CODES.R) {
        assertThat((SparseLongArray) ReflectionHelpers.callInstanceMethod(packageRollbackInfo, "getCeSnapshotInodes")).isEqualTo(ceSnapshotInodes);
    }
}
Also used : IntArray(android.util.IntArray) PackageRollbackInfo(android.content.rollback.PackageRollbackInfo) SparseLongArray(android.util.SparseLongArray) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

SparseLongArray (android.util.SparseLongArray)32 BatteryStats (android.os.BatteryStats)7 BatterySipper (com.android.internal.os.BatterySipper)7 Test (org.junit.Test)7 VisibleForTesting (android.support.annotation.VisibleForTesting)6 Animator (android.animation.Animator)5 SurfaceView (android.view.SurfaceView)5 TextureView (android.view.TextureView)5 View (android.view.View)5 ListView (android.widget.ListView)5 NetworkStats (android.net.NetworkStats)4 IOException (java.io.IOException)4 LinkedList (java.util.LinkedList)4 PackageRollbackInfo (android.content.rollback.PackageRollbackInfo)2 IntArray (android.util.IntArray)2 SparseArray (android.util.SparseArray)2 SparseBooleanArray (android.util.SparseBooleanArray)2 SparseIntArray (android.util.SparseIntArray)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2 CheckBoxPreference (androidx.preference.CheckBoxPreference)2