diff options
author | RHenigan <heniganr1@gmail.com> | 2020-06-16 14:46:54 -0400 |
---|---|---|
committer | RHenigan <heniganr1@gmail.com> | 2020-06-16 14:46:54 -0400 |
commit | f70458069383058a584dfdf4761481f44ab36585 (patch) | |
tree | ab01b59b0e0379c4678aeb3b4f6241c509b3506a /android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset | |
parent | c5649735fdcae9600305e1c61613c8f1a86ac02e (diff) | |
download | sdl_android-f70458069383058a584dfdf4761481f44ab36585.tar.gz |
Refactor tests to AndroidJUnit4
Diffstat (limited to 'android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset')
9 files changed, 153 insertions, 72 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/CheckChoiceVROptionalOperationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/CheckChoiceVROptionalOperationTests.java index 7b9696151..cba4ee77d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/CheckChoiceVROptionalOperationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/CheckChoiceVROptionalOperationTests.java @@ -35,32 +35,36 @@ package com.smartdevicelink.managers.screen.choiceset; -import com.smartdevicelink.AndroidTestCase2; +import android.support.test.runner.AndroidJUnit4; + import com.smartdevicelink.proxy.interfaces.ISdl; import com.smartdevicelink.proxy.rpc.Choice; import com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSet; import com.smartdevicelink.proxy.rpc.DeleteInteractionChoiceSet; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.assertNull; import static org.mockito.Mockito.mock; -public class CheckChoiceVROptionalOperationTests extends AndroidTestCase2 { +@RunWith(AndroidJUnit4.class) +public class CheckChoiceVROptionalOperationTests { private CheckChoiceVROptionalOperation checkChoiceVROptionalOperation; - @Override + @Before public void setUp() throws Exception{ - super.setUp(); ISdl internalInterface = mock(ISdl.class); CheckChoiceVROptionalInterface checkChoiceVROptionalInterface = mock(CheckChoiceVROptionalInterface.class); checkChoiceVROptionalOperation = new CheckChoiceVROptionalOperation(internalInterface, checkChoiceVROptionalInterface); } - @Override - public void tearDown() throws Exception { - super.tearDown(); - } - + @Test public void testCreateChoiceNoVR(){ CreateInteractionChoiceSet setNoVR = checkChoiceVROptionalOperation.testCellWithVR(false); assertNotNull(setNoVR); @@ -69,6 +73,7 @@ public class CheckChoiceVROptionalOperationTests extends AndroidTestCase2 { assertNull(choice.getVrCommands()); } + @Test public void testCreateChoiceWithVR(){ CreateInteractionChoiceSet setNoVR = checkChoiceVROptionalOperation.testCellWithVR(true); assertNotNull(setNoVR); @@ -77,6 +82,7 @@ public class CheckChoiceVROptionalOperationTests extends AndroidTestCase2 { assertEquals(choice.getVrCommands().get(0), "Test VR"); } + @Test public void testDeleteInteractionChoiceSet(){ DeleteInteractionChoiceSet deleteSet = checkChoiceVROptionalOperation.createDeleteInteractionChoiceSet(); assertNotNull(deleteSet); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceCellTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceCellTests.java index 2c401e04e..8f1c4f5c1 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceCellTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceCellTests.java @@ -32,26 +32,26 @@ package com.smartdevicelink.managers.screen.choiceset; -import com.smartdevicelink.AndroidTestCase2; +import android.support.test.runner.AndroidJUnit4; + import com.smartdevicelink.managers.file.filetypes.SdlArtwork; import com.smartdevicelink.proxy.rpc.enums.FileType; import com.smartdevicelink.test.TestValues; -public class ChoiceCellTests extends AndroidTestCase2 { +import org.junit.Test; +import org.junit.runner.RunWith; - private static final int MAX_ID = 2000000000; - private SdlArtwork artwork = new SdlArtwork("image", FileType.GRAPHIC_PNG, 1, true); +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.assertTrue; - @Override - public void setUp() throws Exception{ - super.setUp(); - } +@RunWith(AndroidJUnit4.class) +public class ChoiceCellTests { - @Override - public void tearDown() throws Exception { - super.tearDown(); - } + private static final int MAX_ID = 2000000000; + private SdlArtwork artwork = new SdlArtwork("image", FileType.GRAPHIC_PNG, 1, true); + @Test public void testSettersAndGetters(){ // set everything @@ -72,6 +72,7 @@ public class ChoiceCellTests extends AndroidTestCase2 { assertEquals(choiceCell.getChoiceId(), MAX_ID); } + @Test public void testConstructors() { // first constructor was tested in previous method, use the rest here @@ -98,6 +99,7 @@ public class ChoiceCellTests extends AndroidTestCase2 { assertEquals(choiceCell.getChoiceId(), MAX_ID); } + @Test public void testCellEquality(){ ChoiceCell choiceCell = new ChoiceCell(TestValues.GENERAL_STRING, TestValues.GENERAL_STRING_LIST, artwork); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetLayoutTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetLayoutTests.java index 3f147f128..854fc61f7 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetLayoutTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetLayoutTests.java @@ -32,16 +32,26 @@ package com.smartdevicelink.managers.screen.choiceset; -import com.smartdevicelink.AndroidTestCase2; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class ChoiceSetLayoutTests extends AndroidTestCase2 { +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.assertNull; +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; + +@RunWith(AndroidJUnit4.class) +public class ChoiceSetLayoutTests { /** * Verifies that the enum values are not null upon valid assignment. */ + @Test public void testValidEnums() { ChoiceSetLayout choiceSetLayoutList = ChoiceSetLayout.valueForString("CHOICE_SET_LAYOUT_LIST"); ChoiceSetLayout choiceSetLayoutTiles = ChoiceSetLayout.valueForString("CHOICE_SET_LAYOUT_TILES"); @@ -52,6 +62,7 @@ public class ChoiceSetLayoutTests extends AndroidTestCase2 { /** * Verifies that an invalid assignment is null. */ + @Test public void testInvalidEnum() { String example = "deFaUlt"; try { @@ -65,6 +76,7 @@ public class ChoiceSetLayoutTests extends AndroidTestCase2 { /** * Verifies that a null assignment is invalid. */ + @Test public void testNullEnum() { String example = null; try { @@ -78,6 +90,7 @@ public class ChoiceSetLayoutTests extends AndroidTestCase2 { /** * Verifies the possible enum values of DynamicMenuUpdatesMode. */ + @Test public void testListEnum() { List<ChoiceSetLayout> enumValueList = Arrays.asList(ChoiceSetLayout.values()); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManagerTests.java index 1a9efffbe..f483ea3dd 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManagerTests.java @@ -35,7 +35,8 @@ package com.smartdevicelink.managers.screen.choiceset; -import com.smartdevicelink.AndroidTestCase2; +import android.support.test.runner.AndroidJUnit4; + import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.file.FileManager; import com.smartdevicelink.proxy.interfaces.ISdl; @@ -47,6 +48,11 @@ import com.smartdevicelink.proxy.rpc.enums.Language; import com.smartdevicelink.proxy.rpc.enums.SystemContext; import com.smartdevicelink.proxy.rpc.enums.TriggerSource; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -54,6 +60,12 @@ import java.util.HashSet; import java.util.List; import java.util.concurrent.LinkedBlockingQueue; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.assertNotSame; +import static junit.framework.TestCase.assertNull; +import static junit.framework.TestCase.assertTrue; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -61,13 +73,13 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class ChoiceSetManagerTests extends AndroidTestCase2 { +@RunWith(AndroidJUnit4.class) +public class ChoiceSetManagerTests { private ChoiceSetManager csm; - @Override + @Before public void setUp() throws Exception{ - super.setUp(); ISdl internalInterface = mock(ISdl.class); FileManager fileManager = mock(FileManager.class); @@ -89,7 +101,7 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 { assertNull(csm.pendingPresentOperation); } - @Override + @After public void tearDown() throws Exception { csm.dispose(); @@ -108,9 +120,9 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 { assertEquals(csm.getState(), BaseSubManager.SHUTDOWN); - super.tearDown(); } + @Test public void testDefaultKeyboardConfiguration(){ KeyboardProperties properties = csm.defaultKeyboardConfiguration(); assertEquals(properties.getLanguage(), Language.EN_US); @@ -118,6 +130,7 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 { assertEquals(properties.getKeypressMode(), KeypressMode.RESEND_CURRENT_ENTRY); } + @Test public void testSetupChoiceSet(){ ChoiceSetSelectionListener choiceSetSelectionListener = new ChoiceSetSelectionListener() { @@ -157,6 +170,7 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 { assertTrue(csm.setUpChoiceSet(choiceSet5)); } + @Test public void testFindIfPresent(){ ChoiceCell cell1 = new ChoiceCell("test"); @@ -170,6 +184,7 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 { assertNull(csm.findIfPresent(cell3, cellSet)); } + @Test public void testUpdateIdsOnChoices(){ ChoiceCell cell1 = new ChoiceCell("test"); @@ -190,6 +205,7 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 { assertNotSame(cell3.getChoiceId(), 2000000000); } + @Test public void testChoicesToBeRemovedFromPendingWithArray(){ ChoiceCell cell1 = new ChoiceCell("test"); @@ -215,6 +231,7 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 { } } + @Test public void testChoicesToBeUploadedWithArray(){ ChoiceCell cell1 = new ChoiceCell("test"); @@ -240,6 +257,7 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 { } } + @Test public void testPresentingKeyboardShouldReturnCancelIDIfKeyboardCanBeSent() { ISdl internalInterface = mock(ISdl.class); FileManager fileManager = mock(FileManager.class); @@ -252,6 +270,7 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 { assertNotNull(cancelId); } + @Test public void testPresentingKeyboardShouldNotReturnCancelIDIfKeyboardCannotBeSent() { ISdl internalInterface = mock(ISdl.class); FileManager fileManager = mock(FileManager.class); @@ -264,6 +283,7 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 { assertNull(cancelId); } + @Test public void testDismissingExecutingKeyboard(){ Integer testCancelID = 42; PresentKeyboardOperation testKeyboardOp = mock(PresentKeyboardOperation.class); @@ -273,6 +293,7 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 { verify(testKeyboardOp, times(1)).dismissKeyboard(); } + @Test public void testDismissingQueuedKeyboard(){ Integer testCancelID = 42; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetTests.java index b20357a4b..c7cda00fb 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetTests.java @@ -32,15 +32,23 @@ package com.smartdevicelink.managers.screen.choiceset; -import com.smartdevicelink.AndroidTestCase2; +import android.support.test.runner.AndroidJUnit4; + import com.smartdevicelink.test.TestValues; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + import java.util.Arrays; import java.util.List; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertTrue; import static org.mockito.Mockito.mock; -public class ChoiceSetTests extends AndroidTestCase2 { +@RunWith(AndroidJUnit4.class) +public class ChoiceSetTests { private ChoiceSetSelectionListener listener; private ChoiceSetLayout layout; @@ -48,9 +56,8 @@ public class ChoiceSetTests extends AndroidTestCase2 { private Integer defaultTimeout; private Boolean canceledHandlerCalled; - @Override + @Before public void setUp() throws Exception{ - super.setUp(); listener = mock(ChoiceSetSelectionListener.class); layout = ChoiceSetLayout.CHOICE_SET_LAYOUT_LIST; @@ -59,11 +66,8 @@ public class ChoiceSetTests extends AndroidTestCase2 { canceledHandlerCalled = false; } - @Override - public void tearDown() throws Exception { - super.tearDown(); - } + @Test public void testSettersAndGetters(){ // test small constructor @@ -77,6 +81,7 @@ public class ChoiceSetTests extends AndroidTestCase2 { assertEquals(choiceSet.getChoiceSetSelectionListener(), listener); } + @Test public void testConstructors() { // first constructor was tested in previous method, use the rest here @@ -101,6 +106,7 @@ public class ChoiceSetTests extends AndroidTestCase2 { assertEquals(choiceSet2.getChoiceSetSelectionListener(), listener); } + @Test public void testCancelingChoiceSet() { ChoiceSet choiceSet = new ChoiceSet(TestValues.GENERAL_STRING, choices, listener); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/DeleteChoicesOperationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/DeleteChoicesOperationTests.java index 67200d0fe..e2cdcf7ae 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/DeleteChoicesOperationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/DeleteChoicesOperationTests.java @@ -35,22 +35,29 @@ package com.smartdevicelink.managers.screen.choiceset; -import com.smartdevicelink.AndroidTestCase2; +import android.support.test.runner.AndroidJUnit4; + import com.smartdevicelink.proxy.interfaces.ISdl; import com.smartdevicelink.proxy.rpc.DeleteInteractionChoiceSet; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + import java.util.HashSet; import java.util.List; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertNotNull; import static org.mockito.Mockito.mock; -public class DeleteChoicesOperationTests extends AndroidTestCase2 { +@RunWith(AndroidJUnit4.class) +public class DeleteChoicesOperationTests { private DeleteChoicesOperation deleteChoicesOperation; - @Override + @Before public void setUp() throws Exception{ - super.setUp(); ChoiceCell cell1 = new ChoiceCell("cell 1"); ChoiceCell cell2 = new ChoiceCell("cell 2"); @@ -62,11 +69,8 @@ public class DeleteChoicesOperationTests extends AndroidTestCase2 { deleteChoicesOperation = new DeleteChoicesOperation(internalInterface, cellsToDelete, null); } - @Override - public void tearDown() throws Exception { - super.tearDown(); - } + @Test public void testCreateListDeleteInteractionSets(){ List<DeleteInteractionChoiceSet> deletes = deleteChoicesOperation.createDeleteSets(); assertNotNull(deletes); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PreloadChoicesOperationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PreloadChoicesOperationTests.java index 9b20f1bc1..b8be6edc5 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PreloadChoicesOperationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PreloadChoicesOperationTests.java @@ -35,7 +35,8 @@ package com.smartdevicelink.managers.screen.choiceset; -import com.smartdevicelink.AndroidTestCase2; +import android.support.test.runner.AndroidJUnit4; + import com.smartdevicelink.managers.file.FileManager; import com.smartdevicelink.managers.file.filetypes.SdlArtwork; import com.smartdevicelink.proxy.interfaces.ISdl; @@ -49,25 +50,32 @@ import com.smartdevicelink.proxy.rpc.enums.ImageType; import com.smartdevicelink.proxy.rpc.enums.TextFieldName; import com.smartdevicelink.test.TestValues; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.assertTrue; import static org.mockito.Mockito.mock; -public class PreloadChoicesOperationTests extends AndroidTestCase2 { +@RunWith(AndroidJUnit4.class) +public class PreloadChoicesOperationTests { private PreloadChoicesOperation preloadChoicesOperation; private PreloadChoicesOperation preloadChoicesOperationNullCapability; private PreloadChoicesOperation preloadChoicesOperationEmptyCapability; - @Override + @Before public void setUp() throws Exception{ - super.setUp(); - ChoiceCell cell1 = new ChoiceCell("cell 1"); ChoiceCell cell2 = new ChoiceCell("cell 2", null, TestValues.GENERAL_ARTWORK); HashSet<ChoiceCell> cellsToPreload = new HashSet<>(); @@ -140,16 +148,13 @@ public class PreloadChoicesOperationTests extends AndroidTestCase2 { } - @Override - public void tearDown() throws Exception { - super.tearDown(); - } - + @Test public void testArtworkNeedsUpload(){ boolean test = preloadChoicesOperation.artworkNeedsUpload(TestValues.GENERAL_ARTWORK); assertTrue(test); } + @Test public void testArtworksToUpload(){ List<SdlArtwork> artworksToUpload = preloadChoicesOperation.artworksToUpload(); assertNotNull(artworksToUpload); @@ -159,6 +164,7 @@ public class PreloadChoicesOperationTests extends AndroidTestCase2 { /** * Testing shouldSend method's with varying WindowCapability set. */ + @Test public void testShouldSendText() { setUpNullWindowCapability(); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperationTests.java index c0b3c32fa..8e2df6181 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperationTests.java @@ -35,7 +35,8 @@ package com.smartdevicelink.managers.screen.choiceset; -import com.smartdevicelink.AndroidTestCase2; +import android.support.test.runner.AndroidJUnit4; + import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCResponse; import com.smartdevicelink.proxy.interfaces.ISdl; @@ -50,6 +51,9 @@ import com.smartdevicelink.proxy.rpc.enums.Language; import com.smartdevicelink.proxy.rpc.enums.LayoutMode; import com.smartdevicelink.test.TestValues; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -58,6 +62,10 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.assertNull; +import static junit.framework.TestCase.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; @@ -66,7 +74,8 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class PresentChoiceSetOperationTests extends AndroidTestCase2 { +@RunWith(AndroidJUnit4.class) +public class PresentChoiceSetOperationTests { private PresentChoiceSetOperation presentChoiceSetOperation; private ChoiceSet choiceSet; @@ -76,9 +85,8 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 { private ExecutorService executor; - @Override + @Before public void setUp() throws Exception{ - super.setUp(); internalInterface = mock(ISdl.class); @@ -92,10 +100,6 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 { executor = Executors.newCachedThreadPool(); } - @Override - public void tearDown() throws Exception { - super.tearDown(); - } private KeyboardProperties getKeyBoardProperties(){ KeyboardProperties properties = new KeyboardProperties(); @@ -105,6 +109,7 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 { return properties; } + @Test public void testGetLayoutMode(){ // First we will check knowing our keyboard listener is NOT NULL presentChoiceSetOperation = new PresentChoiceSetOperation(internalInterface, choiceSet, InteractionMode.MANUAL_ONLY, getKeyBoardProperties(), keyboardListener, choiceSetSelectionListener, TestValues.GENERAL_INTEGER); @@ -114,6 +119,7 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 { assertEquals(presentChoiceSetOperation.getLayoutMode(), LayoutMode.LIST_ONLY); } + @Test public void testGetPerformInteraction(){ presentChoiceSetOperation = new PresentChoiceSetOperation(internalInterface, choiceSet, InteractionMode.MANUAL_ONLY, getKeyBoardProperties(), keyboardListener, choiceSetSelectionListener, TestValues.GENERAL_INTEGER); @@ -127,6 +133,7 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 { assertEquals(presentChoiceSetOperation.getLayoutMode(), LayoutMode.LIST_WITH_SEARCH); } + @Test public void testSetSelectedCellWithId(){ presentChoiceSetOperation = new PresentChoiceSetOperation(internalInterface, choiceSet, InteractionMode.MANUAL_ONLY, getKeyBoardProperties(), keyboardListener, choiceSetSelectionListener, TestValues.GENERAL_INTEGER); @@ -135,6 +142,7 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 { assertEquals(presentChoiceSetOperation.selectedCellRow, Integer.valueOf(0)); } + @Test public void testCancelingChoiceSetSuccessfullyIfThreadIsRunning(){ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0)); presentChoiceSetOperation = new PresentChoiceSetOperation(internalInterface, choiceSet, InteractionMode.MANUAL_ONLY, null, null, choiceSetSelectionListener, TestValues.GENERAL_INTEGER); @@ -175,6 +183,7 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 { assertFalse(presentChoiceSetOperation.isCancelled()); } + @Test public void testCancelingChoiceSetUnsuccessfullyIfThreadIsRunning(){ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0)); presentChoiceSetOperation = new PresentChoiceSetOperation(internalInterface, choiceSet, InteractionMode.MANUAL_ONLY, null, null, choiceSetSelectionListener, TestValues.GENERAL_INTEGER); @@ -214,6 +223,7 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 { assertFalse(presentChoiceSetOperation.isCancelled()); } + @Test public void testCancelingChoiceSetIfThreadHasFinished(){ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0)); presentChoiceSetOperation = new PresentChoiceSetOperation(internalInterface, choiceSet, InteractionMode.MANUAL_ONLY, null, null, choiceSetSelectionListener, TestValues.GENERAL_INTEGER); @@ -231,6 +241,7 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 { assertFalse(presentChoiceSetOperation.isCancelled()); } + @Test public void testCancelingChoiceSetIfThreadHasNotYetRun(){ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0)); presentChoiceSetOperation = new PresentChoiceSetOperation(internalInterface, choiceSet, InteractionMode.MANUAL_ONLY, null, null, choiceSetSelectionListener, TestValues.GENERAL_INTEGER); @@ -256,6 +267,7 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 { verify(internalInterface, never()).sendRPC(any(PerformInteraction.class)); } + @Test public void testCancelingChoiceSetIfHeadUnitDoesNotSupportFeature(){ // Cancel Interaction is only supported on RPC specs v.6.0.0+ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(5, 3)); @@ -275,6 +287,7 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 { verify(internalInterface, times(1)).sendRPC(any(PerformInteraction.class)); } + @Test public void testCancelingChoiceSetIfHeadUnitDoesNotSupportFeatureButThreadIsNotRunning(){ // Cancel Interaction is only supported on RPC specs v.6.0.0+ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(5, 3)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperationTests.java index 109535c11..8316a79a5 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperationTests.java @@ -35,7 +35,8 @@ package com.smartdevicelink.managers.screen.choiceset; -import com.smartdevicelink.AndroidTestCase2; +import android.support.test.runner.AndroidJUnit4; + import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCResponse; import com.smartdevicelink.proxy.interfaces.ISdl; @@ -50,6 +51,9 @@ import com.smartdevicelink.proxy.rpc.enums.Language; import com.smartdevicelink.proxy.rpc.enums.LayoutMode; import com.smartdevicelink.test.TestValues; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -57,6 +61,10 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.assertNull; +import static junit.framework.TestCase.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; @@ -65,7 +73,8 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class PresentKeyboardOperationTests extends AndroidTestCase2 { +@RunWith(AndroidJUnit4.class) +public class PresentKeyboardOperationTests { private PresentKeyboardOperation presentKeyboardOperation; private KeyboardListener keyboardListener; @@ -73,9 +82,8 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 { private ExecutorService executor; - @Override + @Before public void setUp() throws Exception{ - super.setUp(); internalInterface = mock(ISdl.class); keyboardListener = mock(KeyboardListener.class); @@ -98,11 +106,6 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 { executor = Executors.newCachedThreadPool(); } - @Override - public void tearDown() throws Exception { - super.tearDown(); - } - private KeyboardProperties getKeyBoardProperties(){ KeyboardProperties properties = new KeyboardProperties(); properties.setLanguage(Language.EN_US); @@ -111,6 +114,7 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 { return properties; } + @Test public void testGetPerformInteraction(){ presentKeyboardOperation = new PresentKeyboardOperation(internalInterface, getKeyBoardProperties(), "Test", null, keyboardListener, TestValues.GENERAL_INTEGER); @@ -123,6 +127,7 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 { assertEquals(pi.getCancelID(), TestValues.GENERAL_INTEGER); } + @Test public void testCancelingKeyboardSuccessfullyIfThreadIsRunning(){ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0)); presentKeyboardOperation = new PresentKeyboardOperation(internalInterface, null, "Test", null, null, TestValues.GENERAL_INTEGER); @@ -162,6 +167,7 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 { assertFalse(presentKeyboardOperation.isCancelled()); } + @Test public void testCancelingKeyboardUnsuccessfullyIfThreadIsRunning(){ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0)); presentKeyboardOperation = new PresentKeyboardOperation(internalInterface, null, "Test", null, null, TestValues.GENERAL_INTEGER); @@ -197,6 +203,7 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 { assertFalse(presentKeyboardOperation.isCancelled()); } + @Test public void testCancelingKeyboardIfThreadHasFinished(){ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0)); presentKeyboardOperation = new PresentKeyboardOperation(internalInterface, null, "Test", null, null, TestValues.GENERAL_INTEGER); @@ -214,6 +221,7 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 { assertFalse(presentKeyboardOperation.isCancelled()); } + @Test public void testCancelingKeyboardIfThreadHasNotYetRun(){ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0)); presentKeyboardOperation = new PresentKeyboardOperation(internalInterface, null, "Test", null, null, TestValues.GENERAL_INTEGER); @@ -239,6 +247,7 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 { verify(internalInterface, never()).sendRPC(any(PerformInteraction.class)); } + @Test public void testCancelingChoiceSetIfHeadUnitDoesNotSupportFeature(){ // Cancel Interaction is only supported on RPC specs v.6.0.0+ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(5, 3)); @@ -258,6 +267,7 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 { verify(internalInterface, times(1)).sendRPC(any(PerformInteraction.class)); } + @Test public void testCancelingChoiceSetIfHeadUnitDoesNotSupportFeatureButThreadIsNotRunning(){ // Cancel Interaction is only supported on RPC specs v.6.0.0+ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(5, 3)); |