Loading core/tests/coretests/src/com/android/internal/app/ResolverListControllerTest.java +15 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.internal.app; import static junit.framework.Assert.assertEquals; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Matchers.any; Loading Loading @@ -126,7 +128,7 @@ public class ResolverListControllerTest { String annotation = "test_annotation"; Intent sendIntent = createSendImageIntent(annotation); String refererPackage = "test_referer_package"; List<ResolvedComponentInfo> resolvedComponents = createResolvedComponentsForTest(15); List<ResolvedComponentInfo> resolvedComponents = createResolvedComponentsForTest(10); mUsm = new UsageStatsManager(mMockContext, mMockService); when(mMockContext.getSystemService(Context.USAGE_STATS_SERVICE)).thenReturn(mUsm); mController = new ResolverListController(mMockContext, mMockPackageManager, sendIntent, Loading @@ -135,7 +137,18 @@ public class ResolverListControllerTest { mController.topK(topKList, 5); List<ResolvedComponentInfo> sortList = new ArrayList<>(topKList); mController.sort(sortList); assertThat(sortList.subList(0, 5), is(topKList.subList(0, 5))); assertEquals("Top k elements should be sorted when input size greater than k.", sortList.subList(0, 5), topKList.subList(0, 5)); mController.topK(topKList, 10); sortList = new ArrayList<>(topKList); mController.sort(sortList); assertEquals("All elements should be sorted when input size equals k.", sortList, topKList); mController.topK(topKList, 15); sortList = new ArrayList<>(topKList); mController.sort(sortList); assertEquals("All elements should be sorted when input size less than k.", sortList, topKList); } private UsageStats initStats(String packageName, String action, Loading Loading
core/tests/coretests/src/com/android/internal/app/ResolverListControllerTest.java +15 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.internal.app; import static junit.framework.Assert.assertEquals; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Matchers.any; Loading Loading @@ -126,7 +128,7 @@ public class ResolverListControllerTest { String annotation = "test_annotation"; Intent sendIntent = createSendImageIntent(annotation); String refererPackage = "test_referer_package"; List<ResolvedComponentInfo> resolvedComponents = createResolvedComponentsForTest(15); List<ResolvedComponentInfo> resolvedComponents = createResolvedComponentsForTest(10); mUsm = new UsageStatsManager(mMockContext, mMockService); when(mMockContext.getSystemService(Context.USAGE_STATS_SERVICE)).thenReturn(mUsm); mController = new ResolverListController(mMockContext, mMockPackageManager, sendIntent, Loading @@ -135,7 +137,18 @@ public class ResolverListControllerTest { mController.topK(topKList, 5); List<ResolvedComponentInfo> sortList = new ArrayList<>(topKList); mController.sort(sortList); assertThat(sortList.subList(0, 5), is(topKList.subList(0, 5))); assertEquals("Top k elements should be sorted when input size greater than k.", sortList.subList(0, 5), topKList.subList(0, 5)); mController.topK(topKList, 10); sortList = new ArrayList<>(topKList); mController.sort(sortList); assertEquals("All elements should be sorted when input size equals k.", sortList, topKList); mController.topK(topKList, 15); sortList = new ArrayList<>(topKList); mController.sort(sortList); assertEquals("All elements should be sorted when input size less than k.", sortList, topKList); } private UsageStats initStats(String packageName, String action, Loading