diff options
author | Bilal Alsharifi <bilal.alsharifi@gmail.com> | 2021-10-25 11:17:52 -0400 |
---|---|---|
committer | Bilal Alsharifi <bilal.alsharifi@gmail.com> | 2021-10-25 11:17:52 -0400 |
commit | cdadf4e8de5e93a4c64a6139fa072f350a6b2f72 (patch) | |
tree | 1397ebaf0c377b8b1a51f55b5bd075f3e14567a0 | |
parent | 445c57632084fe13cff843767323d7ec166d15b4 (diff) | |
download | sdl_android-cdadf4e8de5e93a4c64a6139fa072f350a6b2f72.tar.gz |
Update unit tests to include tests for WindowCapabilitySupportsPrimaryImage()
2 files changed, 81 insertions, 6 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuManagerTests.java index 6f8bff69d..84ef09b7c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuManagerTests.java @@ -261,12 +261,15 @@ public class MenuManagerTests { @Test public void testUpdatingOldWay() { + ISdl internalInterface = mock(ISdl.class); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(8, 0, 0))); + // Force Menu Manager to use the old way of deleting / sending all menuManager.setDynamicUpdatesMode(DynamicMenuUpdatesMode.FORCE_OFF); assertEquals(menuManager.dynamicMenuUpdatesMode, DynamicMenuUpdatesMode.FORCE_OFF); // when we only send one command to update, we should only be returned one add command List<MenuCell> newArray = Arrays.asList(mainCell1, mainCell4); - assertEquals(MenuReplaceUtilities.allCommandsForCells(newArray, menuManager.fileManager.get(), menuManager.windowCapability, MenuLayout.LIST).size(), 4); // 1 root cells, 1 sub menu root cell, 2 sub menu cells + assertEquals(MenuReplaceUtilities.allCommandsForCells(internalInterface, newArray, menuManager.fileManager.get(), menuManager.windowCapability, MenuLayout.LIST).size(), 4); // 1 root cells, 1 sub menu root cell, 2 sub menu cells menuManager.currentHMILevel = HMILevel.HMI_FULL; menuManager.setMenuCells(newArray); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuReplaceUtilitiesTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuReplaceUtilitiesTests.java index 61587dbdc..f0a09c792 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuReplaceUtilitiesTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuReplaceUtilitiesTests.java @@ -34,13 +34,16 @@ package com.smartdevicelink.managers.screen.menu; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.managers.file.FileManager; import com.smartdevicelink.managers.file.filetypes.SdlArtwork; import com.smartdevicelink.proxy.rpc.ImageField; +import com.smartdevicelink.proxy.rpc.SdlMsgVersion; import com.smartdevicelink.proxy.rpc.WindowCapability; import com.smartdevicelink.proxy.rpc.enums.ImageFieldName; import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import com.smartdevicelink.test.TestValues; +import com.smartdevicelink.util.Version; import org.junit.Before; import org.junit.Test; @@ -210,7 +213,76 @@ public class MenuReplaceUtilitiesTests { } @Test + public void testWindowCapabilitySupportsPrimaryImage() { + WindowCapability windowCapability; + ISdl internalInterface = mock(ISdl.class); + MenuCell menuCell = mock(MenuCell.class); + + // Test case 0 + windowCapability = createWindowCapability(false, true); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(4, 9, 0))); + assertTrue(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 1 + windowCapability = createWindowCapability(false, false); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(4, 9, 0))); + assertFalse(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 2 + windowCapability = createWindowCapability(false, false); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(5, 0, 0))); + assertTrue(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 3 + windowCapability = createWindowCapability(false, false); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(6, 0, 0))); + assertTrue(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 4 + windowCapability = createWindowCapability(false, false); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(7, 0, 0))); + assertTrue(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 5 + windowCapability = createWindowCapability(false, false); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(7, 1, 0))); + assertFalse(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 6 + windowCapability = createWindowCapability(false, false); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(8, 0, 0))); + assertFalse(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 7 + windowCapability = createWindowCapability(false, true); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(8, 0, 0))); + assertTrue(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 8 + windowCapability = createWindowCapability(false, false); + when(menuCell.isSubMenuCell()).thenReturn(false); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(8, 0, 0))); + assertFalse(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 8 + windowCapability = createWindowCapability(true, false); + when(menuCell.isSubMenuCell()).thenReturn(false); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(8, 0, 0))); + assertTrue(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + } + + @Test public void testShouldCellIncludeImage() { + ISdl internalInterface = mock(ISdl.class); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(8, 0, 0))); MenuCell menuCell; WindowCapability windowCapability; FileManager fileManager; @@ -220,31 +292,31 @@ public class MenuReplaceUtilitiesTests { menuCell = new MenuCell(TestValues.GENERAL_STRING, TestValues.GENERAL_ARTWORK, voiceCommands, null); windowCapability = createWindowCapability(true, true); fileManager = createMockFileManager(true); - assertTrue(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(menuCell, fileManager, windowCapability)); + assertTrue(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(internalInterface, menuCell, fileManager, windowCapability)); // Case 2 - Image are not supported menuCell = new MenuCell(TestValues.GENERAL_STRING, TestValues.GENERAL_ARTWORK, voiceCommands, null); windowCapability = createWindowCapability(false, false); fileManager = createMockFileManager(true); - assertFalse(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(menuCell, fileManager, windowCapability)); + assertFalse(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(internalInterface, menuCell, fileManager, windowCapability)); // Case 3 - Artwork is null menuCell = new MenuCell(TestValues.GENERAL_STRING, null, voiceCommands, null); windowCapability = createWindowCapability(true, true); fileManager = createMockFileManager(true); - assertFalse(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(menuCell, fileManager, windowCapability)); + assertFalse(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(internalInterface, menuCell, fileManager, windowCapability)); // Case 4 - Artwork has not been uploaded menuCell = new MenuCell(TestValues.GENERAL_STRING, TestValues.GENERAL_ARTWORK, voiceCommands, null); windowCapability = createWindowCapability(true, true); fileManager = createMockFileManager(false); - assertFalse(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(menuCell, fileManager, windowCapability)); + assertFalse(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(internalInterface, menuCell, fileManager, windowCapability)); // Case 5 - Artwork is static icon menuCell = new MenuCell(TestValues.GENERAL_STRING, TestValues.GENERAL_ARTWORK_STATIC, voiceCommands, null); windowCapability = createWindowCapability(true, true); fileManager = createMockFileManager(false); - assertTrue(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(menuCell, fileManager, windowCapability)); + assertTrue(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(internalInterface, menuCell, fileManager, windowCapability)); } private WindowCapability createWindowCapability (boolean supportsCmdIcon, boolean supportsSubMenuIcon) { |