@@ -84,10 +84,8 @@ public void performQueryTextActions() {
8484 new ProcessTextChannel (mockBinaryMessenger , mockPackageManager );
8585
8686 // Set up mocked result for PackageManager.queryIntentActivities.
87- ResolveInfo action1 = mock (ResolveInfo .class );
88- when (action1 .loadLabel (mockPackageManager )).thenReturn ("Action1" );
89- ResolveInfo action2 = mock (ResolveInfo .class );
90- when (action2 .loadLabel (mockPackageManager )).thenReturn ("Action2" );
87+ ResolveInfo action1 = createFakeResolveInfo ("Action1" , mockPackageManager );
88+ ResolveInfo action2 = createFakeResolveInfo ("Action2" , mockPackageManager );
9189 List <ResolveInfo > infos = new ArrayList <ResolveInfo >(Arrays .asList (action1 , action2 ));
9290 Intent intent = new Intent ().setAction (Intent .ACTION_PROCESS_TEXT ).setType ("text/plain" );
9391 when (mockPackageManager .queryIntentActivities (
@@ -96,9 +94,9 @@ public void performQueryTextActions() {
9694
9795 // ProcessTextPlugin should retrieve the mocked text actions.
9896 ProcessTextPlugin processTextPlugin = new ProcessTextPlugin (processTextChannel );
99- Map <Integer , String > textActions = processTextPlugin .queryTextActions ();
100- final int action1Id = 0 ;
101- final int action2Id = 1 ;
97+ Map <String , String > textActions = processTextPlugin .queryTextActions ();
98+ final String action1Id = "mockActivityName.Action1" ;
99+ final String action2Id = "mockActivityName.Action2" ;
102100 assertEquals (textActions , Map .of (action1Id , "Action1" , action2Id , "Action2" ));
103101 }
104102
@@ -121,9 +119,9 @@ public void performProcessTextActionWithNoReturnedValue() {
121119
122120 // ProcessTextPlugin should retrieve the mocked text actions.
123121 ProcessTextPlugin processTextPlugin = new ProcessTextPlugin (processTextChannel );
124- Map <Integer , String > textActions = processTextPlugin .queryTextActions ();
125- final int action1Id = 0 ;
126- final int action2Id = 1 ;
122+ Map <String , String > textActions = processTextPlugin .queryTextActions ();
123+ final String action1Id = "mockActivityName.Action1" ;
124+ final String action2Id = "mockActivityName.Action2" ;
127125 assertEquals (textActions , Map .of (action1Id , "Action1" , action2Id , "Action2" ));
128126
129127 // Set up the activity binding.
@@ -170,9 +168,9 @@ public void performProcessTextActionWithReturnedValue() {
170168
171169 // ProcessTextPlugin should retrieve the mocked text actions.
172170 ProcessTextPlugin processTextPlugin = new ProcessTextPlugin (processTextChannel );
173- Map <Integer , String > textActions = processTextPlugin .queryTextActions ();
174- final int action1Id = 0 ;
175- final int action2Id = 1 ;
171+ Map <String , String > textActions = processTextPlugin .queryTextActions ();
172+ final String action1Id = "mockActivityName.Action1" ;
173+ final String action2Id = "mockActivityName.Action2" ;
176174 assertEquals (textActions , Map .of (action1Id , "Action1" , action2Id , "Action2" ));
177175
178176 // Set up the activity binding.
@@ -217,7 +215,7 @@ private ResolveInfo createFakeResolveInfo(String label, PackageManager mockPacka
217215 packageNameField .set (activityInfo , "mockActivityPackageName" );
218216 Field nameField = PackageItemInfo .class .getDeclaredField ("name" );
219217 nameField .setAccessible (true );
220- nameField .set (activityInfo , "mockActivityName" );
218+ nameField .set (activityInfo , "mockActivityName." + label );
221219 } catch (Exception ex ) {
222220 // Test will failed if reflection APIs throw.
223221 }
0 commit comments