Loading core/tests/coretests/src/com/android/internal/app/ResolverActivityTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import android.view.View; import android.widget.RelativeLayout; import androidx.test.InstrumentationRegistry; import androidx.test.espresso.Espresso; import androidx.test.rule.ActivityTestRule; import androidx.test.runner.AndroidJUnit4; Loading Loading @@ -82,6 +83,7 @@ public class ResolverActivityTest { Mockito.isA(List.class))).thenReturn(resolvedComponentInfos); final ResolverWrapperActivity activity = mActivityRule.launchActivity(sendIntent); Espresso.registerIdlingResources(activity.getLabelIdlingResource()); waitForIdle(); assertThat(activity.getAdapter().getCount(), is(2)); Loading Loading @@ -214,6 +216,7 @@ public class ResolverActivityTest { Mockito.isA(List.class))).thenReturn(resolvedComponentInfos); final ResolverWrapperActivity activity = mActivityRule.launchActivity(sendIntent); Espresso.registerIdlingResources(activity.getLabelIdlingResource()); waitForIdle(); // The other entry is filtered to the last used slot Loading Loading @@ -251,6 +254,7 @@ public class ResolverActivityTest { Mockito.isA(List.class))).thenReturn(resolvedComponentInfos); final ResolverWrapperActivity activity = mActivityRule.launchActivity(sendIntent); Espresso.registerIdlingResources(activity.getLabelIdlingResource()); waitForIdle(); // The other entry is filtered to the other profile slot Loading Loading @@ -296,6 +300,7 @@ public class ResolverActivityTest { .thenReturn(resolvedComponentInfos.get(1).getResolveInfoAt(0)); final ResolverWrapperActivity activity = mActivityRule.launchActivity(sendIntent); Espresso.registerIdlingResources(activity.getLabelIdlingResource()); waitForIdle(); // The other entry is filtered to the other profile slot Loading core/tests/coretests/src/com/android/internal/app/ResolverWrapperActivity.java +31 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import static org.mockito.Mockito.mock; import android.app.usage.UsageStatsManager; import android.content.pm.PackageManager; import androidx.test.espresso.idling.CountingIdlingResource; import java.util.function.Function; /* Loading @@ -29,6 +31,12 @@ import java.util.function.Function; public class ResolverWrapperActivity extends ResolverActivity { static final OverrideData sOverrides = new OverrideData(); private UsageStatsManager mUsm; private CountingIdlingResource mLabelIdlingResource = new CountingIdlingResource("LoadLabelTask"); public CountingIdlingResource getLabelIdlingResource() { return mLabelIdlingResource; } ResolveListAdapter getAdapter() { return mAdapter; Loading Loading @@ -64,6 +72,11 @@ public class ResolverWrapperActivity extends ResolverActivity { return super.getPackageManager(); } @Override protected LoadLabelTask getLoadLabelTask(DisplayResolveInfo info, ViewHolder holder) { return new LoadLabelWrapperTask(info, holder); } /** * We cannot directly mock the activity created since instrumentation creates it. * <p> Loading @@ -83,4 +96,22 @@ public class ResolverWrapperActivity extends ResolverActivity { resolverListController = mock(ResolverListController.class); } } class LoadLabelWrapperTask extends LoadLabelTask { protected LoadLabelWrapperTask(DisplayResolveInfo dri, ViewHolder holder) { super(dri, holder); } @Override protected void onPreExecute() { mLabelIdlingResource.increment(); } @Override protected void onPostExecute(CharSequence[] result) { super.onPostExecute(result); mLabelIdlingResource.decrement(); } } } No newline at end of file Loading
core/tests/coretests/src/com/android/internal/app/ResolverActivityTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import android.view.View; import android.widget.RelativeLayout; import androidx.test.InstrumentationRegistry; import androidx.test.espresso.Espresso; import androidx.test.rule.ActivityTestRule; import androidx.test.runner.AndroidJUnit4; Loading Loading @@ -82,6 +83,7 @@ public class ResolverActivityTest { Mockito.isA(List.class))).thenReturn(resolvedComponentInfos); final ResolverWrapperActivity activity = mActivityRule.launchActivity(sendIntent); Espresso.registerIdlingResources(activity.getLabelIdlingResource()); waitForIdle(); assertThat(activity.getAdapter().getCount(), is(2)); Loading Loading @@ -214,6 +216,7 @@ public class ResolverActivityTest { Mockito.isA(List.class))).thenReturn(resolvedComponentInfos); final ResolverWrapperActivity activity = mActivityRule.launchActivity(sendIntent); Espresso.registerIdlingResources(activity.getLabelIdlingResource()); waitForIdle(); // The other entry is filtered to the last used slot Loading Loading @@ -251,6 +254,7 @@ public class ResolverActivityTest { Mockito.isA(List.class))).thenReturn(resolvedComponentInfos); final ResolverWrapperActivity activity = mActivityRule.launchActivity(sendIntent); Espresso.registerIdlingResources(activity.getLabelIdlingResource()); waitForIdle(); // The other entry is filtered to the other profile slot Loading Loading @@ -296,6 +300,7 @@ public class ResolverActivityTest { .thenReturn(resolvedComponentInfos.get(1).getResolveInfoAt(0)); final ResolverWrapperActivity activity = mActivityRule.launchActivity(sendIntent); Espresso.registerIdlingResources(activity.getLabelIdlingResource()); waitForIdle(); // The other entry is filtered to the other profile slot Loading
core/tests/coretests/src/com/android/internal/app/ResolverWrapperActivity.java +31 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import static org.mockito.Mockito.mock; import android.app.usage.UsageStatsManager; import android.content.pm.PackageManager; import androidx.test.espresso.idling.CountingIdlingResource; import java.util.function.Function; /* Loading @@ -29,6 +31,12 @@ import java.util.function.Function; public class ResolverWrapperActivity extends ResolverActivity { static final OverrideData sOverrides = new OverrideData(); private UsageStatsManager mUsm; private CountingIdlingResource mLabelIdlingResource = new CountingIdlingResource("LoadLabelTask"); public CountingIdlingResource getLabelIdlingResource() { return mLabelIdlingResource; } ResolveListAdapter getAdapter() { return mAdapter; Loading Loading @@ -64,6 +72,11 @@ public class ResolverWrapperActivity extends ResolverActivity { return super.getPackageManager(); } @Override protected LoadLabelTask getLoadLabelTask(DisplayResolveInfo info, ViewHolder holder) { return new LoadLabelWrapperTask(info, holder); } /** * We cannot directly mock the activity created since instrumentation creates it. * <p> Loading @@ -83,4 +96,22 @@ public class ResolverWrapperActivity extends ResolverActivity { resolverListController = mock(ResolverListController.class); } } class LoadLabelWrapperTask extends LoadLabelTask { protected LoadLabelWrapperTask(DisplayResolveInfo dri, ViewHolder holder) { super(dri, holder); } @Override protected void onPreExecute() { mLabelIdlingResource.increment(); } @Override protected void onPostExecute(CharSequence[] result) { super.onPostExecute(result); mLabelIdlingResource.decrement(); } } } No newline at end of file