@@ -84,10 +84,8 @@ public void performQueryTextActions() {
84
84
new ProcessTextChannel (mockBinaryMessenger , mockPackageManager );
85
85
86
86
// 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 );
91
89
List <ResolveInfo > infos = new ArrayList <ResolveInfo >(Arrays .asList (action1 , action2 ));
92
90
Intent intent = new Intent ().setAction (Intent .ACTION_PROCESS_TEXT ).setType ("text/plain" );
93
91
when (mockPackageManager .queryIntentActivities (
@@ -96,9 +94,9 @@ public void performQueryTextActions() {
96
94
97
95
// ProcessTextPlugin should retrieve the mocked text actions.
98
96
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" ;
102
100
assertEquals (textActions , Map .of (action1Id , "Action1" , action2Id , "Action2" ));
103
101
}
104
102
@@ -121,9 +119,9 @@ public void performProcessTextActionWithNoReturnedValue() {
121
119
122
120
// ProcessTextPlugin should retrieve the mocked text actions.
123
121
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" ;
127
125
assertEquals (textActions , Map .of (action1Id , "Action1" , action2Id , "Action2" ));
128
126
129
127
// Set up the activity binding.
@@ -170,9 +168,9 @@ public void performProcessTextActionWithReturnedValue() {
170
168
171
169
// ProcessTextPlugin should retrieve the mocked text actions.
172
170
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" ;
176
174
assertEquals (textActions , Map .of (action1Id , "Action1" , action2Id , "Action2" ));
177
175
178
176
// Set up the activity binding.
@@ -217,7 +215,7 @@ private ResolveInfo createFakeResolveInfo(String label, PackageManager mockPacka
217
215
packageNameField .set (activityInfo , "mockActivityPackageName" );
218
216
Field nameField = PackageItemInfo .class .getDeclaredField ("name" );
219
217
nameField .setAccessible (true );
220
- nameField .set (activityInfo , "mockActivityName" );
218
+ nameField .set (activityInfo , "mockActivityName." + label );
221
219
} catch (Exception ex ) {
222
220
// Test will failed if reflection APIs throw.
223
221
}
0 commit comments