3434
3535import androidx .test .ext .junit .runners .AndroidJUnit4 ;
3636
37+ import com .smartdevicelink .managers .ISdl ;
3738import com .smartdevicelink .managers .file .FileManager ;
3839import com .smartdevicelink .managers .file .filetypes .SdlArtwork ;
3940import com .smartdevicelink .proxy .rpc .ImageField ;
41+ import com .smartdevicelink .proxy .rpc .SdlMsgVersion ;
4042import com .smartdevicelink .proxy .rpc .WindowCapability ;
4143import com .smartdevicelink .proxy .rpc .enums .ImageFieldName ;
4244import com .smartdevicelink .proxy .rpc .enums .MenuLayout ;
4345import com .smartdevicelink .test .TestValues ;
46+ import com .smartdevicelink .util .Version ;
4447
4548import org .junit .Before ;
4649import org .junit .Test ;
@@ -209,8 +212,77 @@ public void testAddMenuRequestWithCommandId() {
209212 assertEquals (1 , actualMenuCellList .get (4 ).getSubCells ().get (1 ).getSubCells ().size ());
210213 }
211214
215+ @ Test
216+ public void testWindowCapabilitySupportsPrimaryImage () {
217+ WindowCapability windowCapability ;
218+ ISdl internalInterface = mock (ISdl .class );
219+ MenuCell menuCell = mock (MenuCell .class );
220+
221+ // Test case 0
222+ windowCapability = createWindowCapability (false , true );
223+ when (menuCell .isSubMenuCell ()).thenReturn (true );
224+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (4 , 9 , 0 )));
225+ assertTrue (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
226+
227+ // Test case 1
228+ windowCapability = createWindowCapability (false , false );
229+ when (menuCell .isSubMenuCell ()).thenReturn (true );
230+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (4 , 9 , 0 )));
231+ assertFalse (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
232+
233+ // Test case 2
234+ windowCapability = createWindowCapability (false , false );
235+ when (menuCell .isSubMenuCell ()).thenReturn (true );
236+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (5 , 0 , 0 )));
237+ assertTrue (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
238+
239+ // Test case 3
240+ windowCapability = createWindowCapability (false , false );
241+ when (menuCell .isSubMenuCell ()).thenReturn (true );
242+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (6 , 0 , 0 )));
243+ assertTrue (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
244+
245+ // Test case 4
246+ windowCapability = createWindowCapability (false , false );
247+ when (menuCell .isSubMenuCell ()).thenReturn (true );
248+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (7 , 0 , 0 )));
249+ assertTrue (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
250+
251+ // Test case 5
252+ windowCapability = createWindowCapability (false , false );
253+ when (menuCell .isSubMenuCell ()).thenReturn (true );
254+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (7 , 1 , 0 )));
255+ assertFalse (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
256+
257+ // Test case 6
258+ windowCapability = createWindowCapability (false , false );
259+ when (menuCell .isSubMenuCell ()).thenReturn (true );
260+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (8 , 0 , 0 )));
261+ assertFalse (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
262+
263+ // Test case 7
264+ windowCapability = createWindowCapability (false , true );
265+ when (menuCell .isSubMenuCell ()).thenReturn (true );
266+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (8 , 0 , 0 )));
267+ assertTrue (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
268+
269+ // Test case 8
270+ windowCapability = createWindowCapability (false , false );
271+ when (menuCell .isSubMenuCell ()).thenReturn (false );
272+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (8 , 0 , 0 )));
273+ assertFalse (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
274+
275+ // Test case 8
276+ windowCapability = createWindowCapability (true , false );
277+ when (menuCell .isSubMenuCell ()).thenReturn (false );
278+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (8 , 0 , 0 )));
279+ assertTrue (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
280+ }
281+
212282 @ Test
213283 public void testShouldCellIncludeImage () {
284+ ISdl internalInterface = mock (ISdl .class );
285+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (8 , 0 , 0 )));
214286 MenuCell menuCell ;
215287 WindowCapability windowCapability ;
216288 FileManager fileManager ;
@@ -220,31 +292,31 @@ public void testShouldCellIncludeImage() {
220292 menuCell = new MenuCell (TestValues .GENERAL_STRING , TestValues .GENERAL_ARTWORK , voiceCommands , null );
221293 windowCapability = createWindowCapability (true , true );
222294 fileManager = createMockFileManager (true );
223- assertTrue (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (menuCell , fileManager , windowCapability ));
295+ assertTrue (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (internalInterface , menuCell , fileManager , windowCapability ));
224296
225297 // Case 2 - Image are not supported
226298 menuCell = new MenuCell (TestValues .GENERAL_STRING , TestValues .GENERAL_ARTWORK , voiceCommands , null );
227299 windowCapability = createWindowCapability (false , false );
228300 fileManager = createMockFileManager (true );
229- assertFalse (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (menuCell , fileManager , windowCapability ));
301+ assertFalse (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (internalInterface , menuCell , fileManager , windowCapability ));
230302
231303 // Case 3 - Artwork is null
232304 menuCell = new MenuCell (TestValues .GENERAL_STRING , null , voiceCommands , null );
233305 windowCapability = createWindowCapability (true , true );
234306 fileManager = createMockFileManager (true );
235- assertFalse (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (menuCell , fileManager , windowCapability ));
307+ assertFalse (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (internalInterface , menuCell , fileManager , windowCapability ));
236308
237309 // Case 4 - Artwork has not been uploaded
238310 menuCell = new MenuCell (TestValues .GENERAL_STRING , TestValues .GENERAL_ARTWORK , voiceCommands , null );
239311 windowCapability = createWindowCapability (true , true );
240312 fileManager = createMockFileManager (false );
241- assertFalse (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (menuCell , fileManager , windowCapability ));
313+ assertFalse (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (internalInterface , menuCell , fileManager , windowCapability ));
242314
243315 // Case 5 - Artwork is static icon
244316 menuCell = new MenuCell (TestValues .GENERAL_STRING , TestValues .GENERAL_ARTWORK_STATIC , voiceCommands , null );
245317 windowCapability = createWindowCapability (true , true );
246318 fileManager = createMockFileManager (false );
247- assertTrue (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (menuCell , fileManager , windowCapability ));
319+ assertTrue (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (internalInterface , menuCell , fileManager , windowCapability ));
248320 }
249321
250322 private WindowCapability createWindowCapability (boolean supportsCmdIcon , boolean supportsSubMenuIcon ) {
0 commit comments