diff options
| author | 2022-10-28 14:16:24 -0700 | |
|---|---|---|
| committer | 2022-11-03 12:56:18 -0700 | |
| commit | 578b259bd38d2a75fc7b1ecca1bfeb2009d99e07 (patch) | |
| tree | af643554131e6c9c1eccf0851b59ad4ffc761e6d /java/tests | |
| parent | 9bcaf18b0fda7adb1a93c5d170e390bf3b7ce0e3 (diff) | |
Remove ChooserListAdapter notifyDataSetChange throttling
ChooserListAdapter notifyDataSetChange throttling period has been,
practically, reduced to 0 and this change removes the logic completely.
The remaining ChooserHandler's message turned into posting on the UI
thread and thus ChooserHandler is also removed.
Safety Check
All ChooserListAdapter#notifyDataSetChanged invocations I've found
(posted below) are originated by some posting on the main thread i.e.
not initiated from a view binding in the adapter.
Invocations
- ChooserActivity.onHandlePackageChanged (and
- ResolverActivity.onHandlePackageChanged)
- ChooserListAdapter.onListRebuilt
- ChooserListAdapter.updateAlphabeticalList
- ChooserListAdapter.addServiceResults
- ChooserListAdapter.completeServiceTargetLoading
- ChooserListAdapter$<sorting task> from #createSortingTask
- ChooserListAdapter.LoadDirectShareIconTask
- ResolverListAdapter.LoadIconTask
- ResolverListAdapter.LoadLabelTask
Fix: 257285237
Test: manual test
Test: atest IntentResolverUnitTests
Change-Id: I70eeababa2fa684f0a160ff6ed9ab0900e3c9648
Diffstat (limited to 'java/tests')
| -rw-r--r-- | java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java | 51 |
1 files changed, 10 insertions, 41 deletions
diff --git a/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java b/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java index ee801101..dfdbeda7 100644 --- a/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java +++ b/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java @@ -636,7 +636,7 @@ public class UnbundledChooserActivityTest { } @Test @Ignore - public void hasOtherProfileOneOption() throws Exception { + public void hasOtherProfileOneOption() { List<ResolvedComponentInfo> personalResolvedComponentInfos = createResolvedComponentsForTestWithOtherProfile(2, /* userId */ 10); List<ResolvedComponentInfo> workResolvedComponentInfos = createResolvedComponentsForTest(4); @@ -662,7 +662,6 @@ public class UnbundledChooserActivityTest { List<ResolvedComponentInfo> stableCopy = createResolvedComponentsForTestWithOtherProfile(2, /* userId= */ 10); waitForIdle(); - Thread.sleep(((ChooserActivity) activity).mListViewUpdateDelayMs); onView(first(withText(stableCopy.get(1).getResolveInfoAt(0).activityInfo.name))) .perform(click()); @@ -1278,7 +1277,7 @@ public class UnbundledChooserActivityTest { // This test is too long and too slow and should not be taken as an example for future tests. @Test @Ignore - public void testDirectTargetSelectionLogging() throws InterruptedException { + public void testDirectTargetSelectionLogging() { Intent sendIntent = createSendTextIntent(); // We need app targets for direct targets to get displayed List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2); @@ -1321,11 +1320,6 @@ public class UnbundledChooserActivityTest { /* directShareToAppTargets */ null) ); - // Thread.sleep shouldn't be a thing in an integration test but it's - // necessary here because of the way the code is structured - // TODO: restructure the tests b/129870719 - Thread.sleep(((ChooserActivity) activity).mListViewUpdateDelayMs); - assertThat("Chooser should have 3 targets (2 apps, 1 direct)", activity.getAdapter().getCount(), is(3)); assertThat("Chooser should have exactly one selectable direct target", @@ -1356,7 +1350,7 @@ public class UnbundledChooserActivityTest { // This test is too long and too slow and should not be taken as an example for future tests. @Test @Ignore - public void testDirectTargetLoggingWithRankedAppTarget() throws InterruptedException { + public void testDirectTargetLoggingWithRankedAppTarget() { Intent sendIntent = createSendTextIntent(); // We need app targets for direct targets to get displayed List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2); @@ -1399,10 +1393,6 @@ public class UnbundledChooserActivityTest { directShareToShortcutInfos, /* directShareToAppTargets */ null) ); - // Thread.sleep shouldn't be a thing in an integration test but it's - // necessary here because of the way the code is structured - // TODO: restructure the tests b/129870719 - Thread.sleep(((ChooserActivity) activity).mListViewUpdateDelayMs); assertThat("Chooser should have 3 targets (2 apps, 1 direct)", activity.getAdapter().getCount(), is(3)); @@ -1429,7 +1419,7 @@ public class UnbundledChooserActivityTest { } @Test @Ignore - public void testShortcutTargetWithApplyAppLimits() throws InterruptedException { + public void testShortcutTargetWithApplyAppLimits() { // Set up resources ChooserActivityOverrideData.getInstance().resources = Mockito.spy( InstrumentationRegistry.getInstrumentation().getContext().getResources()); @@ -1482,10 +1472,6 @@ public class UnbundledChooserActivityTest { directShareToShortcutInfos, /* directShareToAppTargets */ null) ); - // Thread.sleep shouldn't be a thing in an integration test but it's - // necessary here because of the way the code is structured - // TODO: restructure the tests b/129870719 - Thread.sleep(((ChooserActivity) activity).mListViewUpdateDelayMs); assertThat("Chooser should have 3 targets (2 apps, 1 direct)", wrapper.getAdapter().getCount(), is(3)); @@ -1498,7 +1484,7 @@ public class UnbundledChooserActivityTest { } @Test @Ignore - public void testShortcutTargetWithoutApplyAppLimits() throws InterruptedException { + public void testShortcutTargetWithoutApplyAppLimits() { setDeviceConfigProperty( SystemUiDeviceConfigFlags.APPLY_SHARING_APP_LIMITS_IN_SYSUI, Boolean.toString(false)); @@ -1554,10 +1540,6 @@ public class UnbundledChooserActivityTest { directShareToShortcutInfos, /* directShareToAppTargets */ null) ); - // Thread.sleep shouldn't be a thing in an integration test but it's - // necessary here because of the way the code is structured - // TODO: restructure the tests b/129870719 - Thread.sleep(((ChooserActivity) activity).mListViewUpdateDelayMs); assertThat("Chooser should have 4 targets (2 apps, 2 direct)", wrapper.getAdapter().getCount(), is(4)); @@ -1604,8 +1586,7 @@ public class UnbundledChooserActivityTest { } private void testDirectTargetLoggingWithAppTargetNotRanked( - int orientation, int appTargetsExpected - ) throws InterruptedException { + int orientation, int appTargetsExpected) { Configuration configuration = new Configuration(InstrumentationRegistry.getInstrumentation().getContext() .getResources().getConfiguration()); @@ -1643,9 +1624,8 @@ public class UnbundledChooserActivityTest { ResolveInfo ri = ResolverDataProvider.createResolveInfo(16, 0); // Start activity - final IChooserWrapper activity = (IChooserWrapper) + final IChooserWrapper wrapper = (IChooserWrapper) mActivityRule.launchActivity(Intent.createChooser(sendIntent, null)); - final IChooserWrapper wrapper = (IChooserWrapper) activity; // Insert the direct share target Map<ChooserTarget, ShortcutInfo> directShareToShortcutInfos = new HashMap<>(); directShareToShortcutInfos.put(serviceTargets.get(0), null); @@ -1662,10 +1642,6 @@ public class UnbundledChooserActivityTest { directShareToShortcutInfos, /* directShareToAppTargets */ null) ); - // Thread.sleep shouldn't be a thing in an integration test but it's - // necessary here because of the way the code is structured - // TODO: restructure the tests b/129870719 - Thread.sleep(((ChooserActivity) activity).mListViewUpdateDelayMs); assertThat( String.format("Chooser should have %d targets (%d apps, 1 direct, 15 A-Z)", @@ -1764,7 +1740,7 @@ public class UnbundledChooserActivityTest { } @Test @Ignore - public void testWorkTab_selectingWorkTabAppOpensAppInWorkProfile() throws InterruptedException { + public void testWorkTab_selectingWorkTabAppOpensAppInWorkProfile() { markWorkProfileUserAvailable(); List<ResolvedComponentInfo> personalResolvedComponentInfos = createResolvedComponentsForTestWithOtherProfile(3, /* userId */ 10); @@ -1780,13 +1756,10 @@ public class UnbundledChooserActivityTest { return true; }; - final IChooserWrapper activity = (IChooserWrapper) - mActivityRule.launchActivity(Intent.createChooser(sendIntent, "work tab test")); + mActivityRule.launchActivity(Intent.createChooser(sendIntent, "work tab test")); waitForIdle(); onView(withText(R.string.resolver_work_tab)).perform(click()); waitForIdle(); - // wait for the share sheet to expand - Thread.sleep(((ChooserActivity) activity).mListViewUpdateDelayMs); onView(first(allOf( withText(workResolvedComponentInfos.get(0) @@ -1957,7 +1930,7 @@ public class UnbundledChooserActivityTest { } @Test @Ignore - public void testDirectTargetLogging() throws InterruptedException { + public void testDirectTargetLogging() { Intent sendIntent = createSendTextIntent(); // We need app targets for direct targets to get displayed List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2); @@ -1997,10 +1970,6 @@ public class UnbundledChooserActivityTest { directShareToShortcutInfos, /* directShareToAppTargets */ null) ); - // Thread.sleep shouldn't be a thing in an integration test but it's - // necessary here because of the way the code is structured - // TODO: restructure the tests b/129870719 - Thread.sleep(((ChooserActivity) activity).mListViewUpdateDelayMs); assertThat("Chooser should have 3 targets (2 apps, 1 direct)", activity.getAdapter().getCount(), is(3)); |