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,89 @@ 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+ assertFalse (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
238+
239+ // Test case 3
240+ windowCapability = createWindowCapability (true , false );
241+ when (menuCell .isSubMenuCell ()).thenReturn (true );
242+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (5 , 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 (6 , 0 , 0 )));
249+ assertFalse (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
250+
251+ // Test case 5
252+ windowCapability = createWindowCapability (true , false );
253+ when (menuCell .isSubMenuCell ()).thenReturn (true );
254+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (6 , 0 , 0 )));
255+ assertTrue (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 (7 , 0 , 0 )));
261+ assertFalse (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
262+
263+ // Test case 7
264+ windowCapability = createWindowCapability (false , false );
265+ when (menuCell .isSubMenuCell ()).thenReturn (true );
266+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (7 , 1 , 0 )));
267+ assertFalse (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
268+
269+ // Test case 8
270+ windowCapability = createWindowCapability (false , false );
271+ when (menuCell .isSubMenuCell ()).thenReturn (true );
272+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (8 , 0 , 0 )));
273+ assertFalse (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
274+
275+ // Test case 9
276+ windowCapability = createWindowCapability (false , true );
277+ when (menuCell .isSubMenuCell ()).thenReturn (true );
278+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (8 , 0 , 0 )));
279+ assertTrue (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
280+
281+ // Test case 10
282+ windowCapability = createWindowCapability (false , false );
283+ when (menuCell .isSubMenuCell ()).thenReturn (false );
284+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (8 , 0 , 0 )));
285+ assertFalse (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
286+
287+ // Test case 11
288+ windowCapability = createWindowCapability (true , false );
289+ when (menuCell .isSubMenuCell ()).thenReturn (false );
290+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (8 , 0 , 0 )));
291+ assertTrue (MenuReplaceUtilities .windowCapabilitySupportsPrimaryImage (internalInterface , windowCapability , menuCell ));
292+ }
293+
212294 @ Test
213295 public void testShouldCellIncludeImage () {
296+ ISdl internalInterface = mock (ISdl .class );
297+ when (internalInterface .getSdlMsgVersion ()).thenReturn (new SdlMsgVersion (new Version (8 , 0 , 0 )));
214298 MenuCell menuCell ;
215299 WindowCapability windowCapability ;
216300 FileManager fileManager ;
@@ -220,31 +304,31 @@ public void testShouldCellIncludeImage() {
220304 menuCell = new MenuCell (TestValues .GENERAL_STRING , TestValues .GENERAL_ARTWORK , voiceCommands , null );
221305 windowCapability = createWindowCapability (true , true );
222306 fileManager = createMockFileManager (true );
223- assertTrue (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (menuCell , fileManager , windowCapability ));
307+ assertTrue (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (internalInterface , menuCell , fileManager , windowCapability ));
224308
225309 // Case 2 - Image are not supported
226310 menuCell = new MenuCell (TestValues .GENERAL_STRING , TestValues .GENERAL_ARTWORK , voiceCommands , null );
227311 windowCapability = createWindowCapability (false , false );
228312 fileManager = createMockFileManager (true );
229- assertFalse (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (menuCell , fileManager , windowCapability ));
313+ assertFalse (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (internalInterface , menuCell , fileManager , windowCapability ));
230314
231315 // Case 3 - Artwork is null
232316 menuCell = new MenuCell (TestValues .GENERAL_STRING , null , voiceCommands , null );
233317 windowCapability = createWindowCapability (true , true );
234318 fileManager = createMockFileManager (true );
235- assertFalse (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (menuCell , fileManager , windowCapability ));
319+ assertFalse (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (internalInterface , menuCell , fileManager , windowCapability ));
236320
237321 // Case 4 - Artwork has not been uploaded
238322 menuCell = new MenuCell (TestValues .GENERAL_STRING , TestValues .GENERAL_ARTWORK , voiceCommands , null );
239323 windowCapability = createWindowCapability (true , true );
240324 fileManager = createMockFileManager (false );
241- assertFalse (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (menuCell , fileManager , windowCapability ));
325+ assertFalse (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (internalInterface , menuCell , fileManager , windowCapability ));
242326
243327 // Case 5 - Artwork is static icon
244328 menuCell = new MenuCell (TestValues .GENERAL_STRING , TestValues .GENERAL_ARTWORK_STATIC , voiceCommands , null );
245329 windowCapability = createWindowCapability (true , true );
246330 fileManager = createMockFileManager (false );
247- assertTrue (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (menuCell , fileManager , windowCapability ));
331+ assertTrue (MenuReplaceUtilities .shouldCellIncludePrimaryImageFromCell (internalInterface , menuCell , fileManager , windowCapability ));
248332 }
249333
250334 private WindowCapability createWindowCapability (boolean supportsCmdIcon , boolean supportsSubMenuIcon ) {
0 commit comments