summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorRHenigan <heniganr1@gmail.com>2020-06-15 15:42:36 -0400
committerRHenigan <heniganr1@gmail.com>2020-06-15 15:42:36 -0400
commite0bef51a64117e6bf5c6cb8898e5f0a479395905 (patch)
tree8ce081d4d8b9ce855b911c9be7ee86ede75a26e7 /android
parent6b52e38eb9cb29e4c28e98191c312d2c1fd82607 (diff)
downloadsdl_android-e0bef51a64117e6bf5c6cb8898e5f0a479395905.tar.gz
Refactor some test classes for AndroidJUnit4
Diffstat (limited to 'android')
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java29
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/FileManagerTests.java43
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlArtworkTests.java14
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlFileTests.java14
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/LifecycleConfigurationUpdateTest.java18
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/RpcConverterTest.java14
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuCellTests.java27
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java41
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportManagerTests.java28
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/util/MediaStreamingStatusTests.java21
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java1
11 files changed, 179 insertions, 71 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java
index 84865f21e..9a24ba5f1 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java
@@ -1,8 +1,8 @@
package com.smartdevicelink.managers;
import android.content.Context;
+import android.support.test.runner.AndroidJUnit4;
-import com.smartdevicelink.AndroidTestCase2;
import com.smartdevicelink.managers.lifecycle.LifecycleConfigurationUpdate;
import com.smartdevicelink.managers.lockscreen.LockScreenConfig;
import com.smartdevicelink.protocol.enums.FunctionID;
@@ -24,6 +24,8 @@ import com.smartdevicelink.test.Test;
import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.transport.TCPTransportConfig;
+import org.junit.Before;
+import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -32,6 +34,10 @@ import java.util.Arrays;
import java.util.List;
import java.util.Vector;
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertNotNull;
+import static junit.framework.TestCase.assertSame;
+import static junit.framework.TestCase.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -40,7 +46,8 @@ import static org.mockito.Mockito.mock;
* This is a unit test class for the SmartDeviceLink library manager class :
* {@link com.smartdevicelink.managers.SdlManager}
*/
-public class SdlManagerTests extends AndroidTestCase2 {
+@RunWith(AndroidJUnit4.class)
+public class SdlManagerTests {
public static BaseTransportConfig transport = null;
private Context mTestContext;
@@ -56,10 +63,8 @@ public class SdlManagerTests extends AndroidTestCase2 {
@SuppressWarnings("FieldCanBeLocal")
private String DEV_MACHINE_IP_ADDRESS = "0.0.0.0";
- @Override
+ @Before
public void setUp() throws Exception{
- super.setUp();
-
mTestContext = Mockito.mock(Context.class);
// set transport
@@ -78,11 +83,6 @@ public class SdlManagerTests extends AndroidTestCase2 {
sdlManager = createSampleManager("heyApp", "123456", Test.GENERAL_LOCKSCREENCONFIG);
}
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// SETUP / HELPERS
private Context getTestContext() {
@@ -144,10 +144,12 @@ public class SdlManagerTests extends AndroidTestCase2 {
// TESTS
+ @org.junit.Test
public void testNotNull(){
assertNotNull(createSampleManager("app","123456", Test.GENERAL_LOCKSCREENCONFIG));
}
+ @org.junit.Test
public void testMissingAppName() {
try {
createSampleManager(null,"123456", Test.GENERAL_LOCKSCREENCONFIG);
@@ -156,6 +158,7 @@ public class SdlManagerTests extends AndroidTestCase2 {
}
}
+ @org.junit.Test
public void testMissingAppId() {
try {
createSampleManager("app",null, Test.GENERAL_LOCKSCREENCONFIG);
@@ -164,6 +167,7 @@ public class SdlManagerTests extends AndroidTestCase2 {
}
}
+ @org.junit.Test
public void testManagerSetters() {
assertEquals("123456", sdlManager.getAppId());
assertEquals("heyApp", sdlManager.getAppName());
@@ -181,6 +185,7 @@ public class SdlManagerTests extends AndroidTestCase2 {
assertEquals(Test.GENERAL_VERSION, sdlManager.getMinimumRPCVersion());
}
+ @org.junit.Test
public void testStartingManager(){
listenerCalledCounter = 0;
@@ -203,6 +208,7 @@ public class SdlManagerTests extends AndroidTestCase2 {
assertEquals("Listener was not called or called more/less frequently than expected", 1, listenerCalledCounter);
}
+ @org.junit.Test
public void testManagerStates() {
SdlManager sdlManager = createSampleManager("test", "00000", new LockScreenConfig());
sdlManager.initialize();
@@ -313,6 +319,7 @@ public class SdlManagerTests extends AndroidTestCase2 {
assertEquals(BaseSubManager.SHUTDOWN, sdlManager.getState());
}
+ @org.junit.Test
public void testSendRPC(){
listenerCalledCounter = 0;
@@ -348,10 +355,12 @@ public class SdlManagerTests extends AndroidTestCase2 {
assertEquals("Listener was not called or called more/less frequently than expected", 1, listenerCalledCounter);
}
+ @org.junit.Test
public void testSendRPCs(){
testSendMultipleRPCs(false);
}
+ @org.junit.Test
public void testSendSequentialRPCs(){
testSendMultipleRPCs(true);
}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/FileManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/FileManagerTests.java
index 3e6d160d5..a5e1620f8 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/FileManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/FileManagerTests.java
@@ -2,8 +2,8 @@ package com.smartdevicelink.managers.file;
import android.content.Context;
import android.net.Uri;
+import android.support.test.runner.AndroidJUnit4;
-import com.smartdevicelink.AndroidTestCase2;
import com.smartdevicelink.managers.BaseSubManager;
import com.smartdevicelink.managers.CompletionListener;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
@@ -23,6 +23,8 @@ import com.smartdevicelink.proxy.rpc.enums.StaticIconName;
import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener;
import com.smartdevicelink.test.Test;
+import org.junit.Before;
+import org.junit.runner.RunWith;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -30,6 +32,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import static android.support.test.InstrumentationRegistry.getContext;
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -40,28 +47,23 @@ import static org.mockito.Mockito.verify;
* This is a unit test class for the SmartDeviceLink library manager class :
* {@link FileManager}
*/
-public class FileManagerTests extends AndroidTestCase2 {
+@RunWith(AndroidJUnit4.class)
+public class FileManagerTests {
public static final String TAG = "FileManagerTests";
private Context mTestContext;
private SdlFile validFile;
// SETUP / HELPERS
- @Override
+ @Before
public void setUp() throws Exception{
- super.setUp();
- mTestContext = this.getContext();
+ mTestContext = getContext();
validFile = new SdlFile();
validFile.setName(Test.GENERAL_STRING);
validFile.setFileData(Test.GENERAL_BYTE_ARRAY);
validFile.setPersistent(false);
}
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
private Answer<Void> onPutFileFailureOnError = new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
@@ -242,6 +244,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Test deleting list of files, success
*/
+ @org.junit.Test
public void testDeleteRemoteFilesWithNamesSuccess(){
final ISdl internalInterface = mock(ISdl.class);
@@ -273,6 +276,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Test deleting list of files, fail
*/
+ @org.junit.Test
public void testDeleteRemoteFilesWithNamesFail(){
final ISdl internalInterface = mock(ISdl.class);
@@ -304,6 +308,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Test reUploading failed file
*/
+ @org.junit.Test
public void testFileUploadRetry(){
final ISdl internalInterface = mock(ISdl.class);
@@ -335,6 +340,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Test reUploading failed Artwork
*/
+ @org.junit.Test
public void testArtworkUploadRetry(){
final ISdl internalInterface = mock(ISdl.class);
@@ -393,6 +399,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Test retry uploading failed list of files
*/
+ @org.junit.Test
public void testListFilesUploadRetry(){
final ISdl internalInterface = mock(ISdl.class);
@@ -434,6 +441,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Testing the initialization of FileManager
*/
+ @org.junit.Test
public void testInitializationSuccess() {
ISdl internalInterface = mock(ISdl.class);
@@ -455,6 +463,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Test file upload, success
*/
+ @org.junit.Test
public void testFileUploadSuccess() {
ISdl internalInterface = mock(ISdl.class);
@@ -484,6 +493,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Testing failed file upload.
*/
+ @org.junit.Test
public void testFileUploadFailure() {
ISdl internalInterface = mock(ISdl.class);
@@ -511,6 +521,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Testing uploadFile for a staticIcon, verifying that it doesn't actually upload.
*/
+ @org.junit.Test
public void testFileUploadForStaticIcon() {
ISdl internalInterface = mock(ISdl.class);
@@ -537,6 +548,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Testing uploadFiles for staticIcons, verifying that it doesn't actually upload.
*/
+ @org.junit.Test
public void testMultipleFileUploadsForStaticIcon() {
ISdl internalInterface = mock(ISdl.class);
@@ -568,6 +580,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Testing uploadFiles for static icons and nonStatic icons in the same list.
*/
+ @org.junit.Test
public void testMultipleFileUploadsForPartialStaticIcon() {
ISdl internalInterface = mock(ISdl.class);
@@ -600,6 +613,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Test to make sure you cannot upload an SdlFile with invalid data
*/
+ @org.junit.Test
public void testInvalidSdlFileInput() {
ISdl internalInterface = mock(ISdl.class);
@@ -662,6 +676,7 @@ public class FileManagerTests extends AndroidTestCase2 {
* Test Invalid SdlArtWork FileTypes
* SdlArtwork FileTypes can only be: GRAPHIC_BMP, GRAPHIC_PNG or GRAPHIC_JPEG
*/
+ @org.junit.Test
public void testInvalidSdlArtworkInput(){
SdlArtwork sdlArtwork = new SdlArtwork();
// Set invalid type
@@ -683,6 +698,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Test Multiple File Uploads, success
*/
+ @org.junit.Test
public void testMultipleFileUpload() {
ISdl internalInterface = mock(ISdl.class);
@@ -719,6 +735,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Testing uploading multiple files with some failing.
*/
+ @org.junit.Test
public void testMultipleFileUploadPartialFailure() {
ISdl internalInterface = mock(ISdl.class);
@@ -767,6 +784,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Testing uploading multiple SdlArtwork files.
*/
+ @org.junit.Test
public void testMultipleArtworkUploadSuccess(){
ISdl internalInterface = mock(ISdl.class);
@@ -813,6 +831,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Testing uploading persistent SdlFile
*/
+ @org.junit.Test
public void testPersistentFileUploaded(){
ISdl internalInterface = mock(ISdl.class);
@@ -835,6 +854,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Test FileManagerConfig
*/
+ @org.junit.Test
public void testFileManagerConfig() {
FileManagerConfig fileManagerConfig = new FileManagerConfig();
fileManagerConfig.setFileRetryCount(2);
@@ -847,6 +867,7 @@ public class FileManagerTests extends AndroidTestCase2 {
* Tests overwrite property for uploading a file.
* Checks to make sure file does not overwrite itself if overwrite property is set to false
*/
+ @org.junit.Test
public void testOverwriteFileProperty() {
ISdl internalInterface = mock(ISdl.class);
@@ -883,6 +904,7 @@ public class FileManagerTests extends AndroidTestCase2 {
* Tests overwrite property for uploading a list of files.
* Checks to make sure files do not overwrite themselves if overwrite property is set to false.
*/
+ @org.junit.Test
public void testOverWriteFilePropertyListFiles() {
final ISdl internalInterface = mock(ISdl.class);
@@ -929,6 +951,7 @@ public class FileManagerTests extends AndroidTestCase2 {
/**
* Test custom overridden SdlFile equals method
*/
+ @org.junit.Test
public void testSdlFileEquals() {
// Case 1: object is null, assertFalse
SdlFile artwork1 = new SdlFile("image1", FileType.GRAPHIC_PNG, 1, true);
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlArtworkTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlArtworkTests.java
index 395b06e27..0f3154c84 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlArtworkTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlArtworkTests.java
@@ -1,12 +1,22 @@
package com.smartdevicelink.managers.file;
-import com.smartdevicelink.AndroidTestCase2;
+import android.support.test.runner.AndroidJUnit4;
+
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
import com.smartdevicelink.proxy.rpc.enums.StaticIconName;
import com.smartdevicelink.test.Test;
-public class SdlArtworkTests extends AndroidTestCase2 {
+import org.junit.runner.RunWith;
+
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertNotNull;
+import static junit.framework.TestCase.assertNotSame;
+import static junit.framework.TestCase.assertTrue;
+
+@RunWith(AndroidJUnit4.class)
+public class SdlArtworkTests {
+ @org.junit.Test
public void testClone(){
SdlArtwork original = Test.GENERAL_ARTWORK;
SdlArtwork clone = original.clone();
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlFileTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlFileTests.java
index 7dd13ec7c..58b3e4af5 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlFileTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlFileTests.java
@@ -32,11 +32,18 @@
package com.smartdevicelink.managers.file.filetypes;
-import com.smartdevicelink.AndroidTestCase2;
+import android.support.test.runner.AndroidJUnit4;
+
import com.smartdevicelink.test.Test;
-public class SdlFileTests extends AndroidTestCase2 {
+import org.junit.runner.RunWith;
+
+import static junit.framework.TestCase.assertEquals;
+
+@RunWith(AndroidJUnit4.class)
+public class SdlFileTests {
+ @org.junit.Test
public void testConstructorWithNoParams() {
SdlFile sdlFile;
@@ -80,6 +87,7 @@ public class SdlFileTests extends AndroidTestCase2 {
assertEquals(sdlFile.isPersistent(), Test.GENERAL_BOOLEAN);
}
+ @org.junit.Test
public void testConstructorWithResourceId() {
// Case1 (Set the name manually)
SdlFile sdlFile1 = new SdlFile(Test.GENERAL_STRING, Test.GENERAL_FILETYPE, Test.GENERAL_INTEGER, Test.GENERAL_BOOLEAN);
@@ -98,6 +106,7 @@ public class SdlFileTests extends AndroidTestCase2 {
assertEquals(sdlFile2.isPersistent(), Test.GENERAL_BOOLEAN);
}
+ @org.junit.Test
public void testConstructorWithData() {
// Case1 (Set the name manually)
SdlFile sdlFile1 = new SdlFile(Test.GENERAL_STRING, Test.GENERAL_FILETYPE, Test.GENERAL_BYTE_ARRAY, Test.GENERAL_BOOLEAN);
@@ -116,6 +125,7 @@ public class SdlFileTests extends AndroidTestCase2 {
assertEquals(sdlFile2.isPersistent(), Test.GENERAL_BOOLEAN);
}
+ @org.junit.Test
public void testConstructorWithUri() {
// Case1 (Set the name manually)
SdlFile sdlFile1 = new SdlFile(Test.GENERAL_STRING, Test.GENERAL_FILETYPE, Test.GENERAL_URI, Test.GENERAL_BOOLEAN);
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/LifecycleConfigurationUpdateTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/LifecycleConfigurationUpdateTest.java
index 6ed606648..7678abeec 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/LifecycleConfigurationUpdateTest.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/LifecycleConfigurationUpdateTest.java
@@ -35,21 +35,18 @@
package com.smartdevicelink.managers.lifecycle;
-import com.smartdevicelink.AndroidTestCase2;
+import android.support.test.runner.AndroidJUnit4;
+
import com.smartdevicelink.test.Test;
-public class LifecycleConfigurationUpdateTest extends AndroidTestCase2 {
+import org.junit.runner.RunWith;
- @Override
- public void setUp() throws Exception {
- super.setUp();
- }
+import static junit.framework.TestCase.assertEquals;
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
+@RunWith(AndroidJUnit4.class)
+public class LifecycleConfigurationUpdateTest {
+ @org.junit.Test
public void testIndividualSettersAndGetters(){
LifecycleConfigurationUpdate lifecycleConfigurationUpdate = new LifecycleConfigurationUpdate();
@@ -65,6 +62,7 @@ public class LifecycleConfigurationUpdateTest extends AndroidTestCase2 {
assertEquals(Test.GENERAL_VECTOR_STRING, lifecycleConfigurationUpdate.getVoiceRecognitionCommandNames());
}
+ @org.junit.Test
public void testHelperConstructor(){
LifecycleConfigurationUpdate lifecycleConfigurationUpdate = new LifecycleConfigurationUpdate(Test.GENERAL_STRING, Test.GENERAL_STRING, Test.GENERAL_VECTOR_TTS_CHUNKS, Test.GENERAL_VECTOR_STRING);
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/RpcConverterTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/RpcConverterTest.java
index 34b3f71aa..1031fc652 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/RpcConverterTest.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/RpcConverterTest.java
@@ -1,6 +1,7 @@
package com.smartdevicelink.managers.lifecycle;
-import com.smartdevicelink.AndroidTestCase2;
+import android.support.test.runner.AndroidJUnit4;
+
import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.protocol.ProtocolMessage;
import com.smartdevicelink.protocol.enums.FunctionID;
@@ -9,9 +10,16 @@ import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.proxy.RPCMessage;
import com.smartdevicelink.util.Version;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.lang.reflect.InvocationTargetException;
-public class RpcConverterTest extends AndroidTestCase2 {
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertNotNull;
+
+@RunWith(AndroidJUnit4.class)
+public class RpcConverterTest {
private static final String RPC_PACKAGE = "com.smartdevicelink.proxy.rpc.";
private static final String RESPONSE_KEY = "Response";
@@ -21,6 +29,7 @@ public class RpcConverterTest extends AndroidTestCase2 {
* The RPC converter relies on the function id json name to match the class name exactly.
* Therefore we will test to ensure that they match up first.
*/
+ @Test
public void testFunctionIdsAgainstFileNames(){
FunctionID[] functionIDs = FunctionID.values();
for(FunctionID functionID : functionIDs) {
@@ -87,6 +96,7 @@ public class RpcConverterTest extends AndroidTestCase2 {
return null;
}
+ @Test
public void testRpcCreation(){
FunctionID[] functionIDs = FunctionID.values();
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuCellTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuCellTests.java
index 0a629d808..25a5c64f3 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuCellTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuCellTests.java
@@ -32,17 +32,26 @@
package com.smartdevicelink.managers.screen.menu;
-import com.smartdevicelink.AndroidTestCase2;
+import android.support.test.runner.AndroidJUnit4;
+
import com.smartdevicelink.managers.file.SdlArtworkTests;
import com.smartdevicelink.proxy.rpc.enums.MenuLayout;
import com.smartdevicelink.proxy.rpc.enums.TriggerSource;
import com.smartdevicelink.test.Test;
+import org.junit.runner.RunWith;
+
import java.util.ArrayList;
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.assertNotSame;
+import static junit.framework.TestCase.assertTrue;
-public class MenuCellTests extends AndroidTestCase2 {
+@RunWith(AndroidJUnit4.class)
+public class MenuCellTests {
private MenuSelectionListener menuSelectionListener = new MenuSelectionListener() {
@Override
@@ -51,16 +60,7 @@ public class MenuCellTests extends AndroidTestCase2 {
}
};
- @Override
- public void setUp() throws Exception{
- super.setUp();
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
+ @org.junit.Test
public void testSettersAndGetters(){
// set everything
@@ -80,6 +80,7 @@ public class MenuCellTests extends AndroidTestCase2 {
assertEquals(menuCell.getSubMenuLayout(), Test.GENERAL_MENU_LAYOUT);
}
+ @org.junit.Test
public void testConstructors(){
// first constructor was tested in previous method, use the last two here
@@ -101,6 +102,7 @@ public class MenuCellTests extends AndroidTestCase2 {
assertEquals(menuCell5.getSubCells(), Test.GENERAL_MENUCELL_LIST);
}
+ @org.junit.Test
public void testEquality(){
//We should use assertTrue (or assertFalse) because we want to use the overridden equals() method
@@ -120,6 +122,7 @@ public class MenuCellTests extends AndroidTestCase2 {
assertFalse(menuCell.equals(menuCell3));
}
+ @org.junit.Test
public void testClone(){
MenuCell original = new MenuCell(Test.GENERAL_STRING, Test.GENERAL_ARTWORK, Test.GENERAL_STRING_LIST, menuSelectionListener);
MenuCell clone = original.clone();
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java
index ac97857ad..29f407285 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java
@@ -5,19 +5,28 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
+import android.support.test.runner.AndroidJUnit4;
-import com.smartdevicelink.AndroidTestCase2;
import com.smartdevicelink.test.SdlUnitTestContants;
import com.smartdevicelink.test.util.DeviceUtil;
-public class TransportBrokerTest extends AndroidTestCase2 {
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static android.support.test.InstrumentationRegistry.getContext;
+import static junit.framework.TestCase.assertFalse;
+import static junit.framework.TestCase.assertNotNull;
+import static junit.framework.TestCase.assertTrue;
+
+@RunWith(AndroidJUnit4.class)
+public class TransportBrokerTest {
RouterServiceValidator rsvp;
// public TransportBrokerThread(Context context, String appId, ComponentName service){
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- rsvp = new RouterServiceValidator(this.mContext);
+ @Before
+ public void setUp() throws Exception {
+ rsvp = new RouterServiceValidator(getContext());
rsvp.validate();
}
@@ -27,25 +36,27 @@ public class TransportBrokerTest extends AndroidTestCase2 {
Thread.sleep(500);
}catch(Exception e){}
}
-
+
+ @Test
public void testStart(){
if (Looper.myLooper() == null) {
Looper.prepare();
}
- TransportBroker broker = new TransportBroker(mContext, SdlUnitTestContants.TEST_APP_ID,rsvp.getService());
+ TransportBroker broker = new TransportBroker(getContext(), SdlUnitTestContants.TEST_APP_ID,rsvp.getService());
if(!DeviceUtil.isEmulator()){ // Cannot perform MBT operations in emulator
assertTrue(broker.start());
}
broker.stop();
}
-
+
+ @Test
public void testSendPacket(){
if (Looper.myLooper() == null) {
Looper.prepare();
}
- TransportBroker broker = new TransportBroker(mContext, SdlUnitTestContants.TEST_APP_ID,rsvp.getService());
+ TransportBroker broker = new TransportBroker(getContext(), SdlUnitTestContants.TEST_APP_ID,rsvp.getService());
if(!DeviceUtil.isEmulator()){ // Cannot perform MBT operations in emulator
assertTrue(broker.start());
@@ -73,24 +84,26 @@ public class TransportBrokerTest extends AndroidTestCase2 {
broker.stop();
}
-
+
+ @Test
public void testOnPacketReceived(){
if (Looper.myLooper() == null) {
Looper.prepare();
}
- TransportBroker broker = new TransportBroker(mContext, SdlUnitTestContants.TEST_APP_ID, rsvp.getService());
+ TransportBroker broker = new TransportBroker(getContext(), SdlUnitTestContants.TEST_APP_ID, rsvp.getService());
if(!DeviceUtil.isEmulator()){ // Cannot perform MBT operations in emulator
assertTrue(broker.start());
}
}
-
+
+ @Test
public void testSendMessageToRouterService(){
if (Looper.myLooper() == null) {
Looper.prepare();
}
- TransportBroker broker = new TransportBroker(mContext, SdlUnitTestContants.TEST_APP_ID, rsvp.getService());
+ TransportBroker broker = new TransportBroker(getContext(), SdlUnitTestContants.TEST_APP_ID, rsvp.getService());
Handler handler = new Handler();
Message message = new Message();
broker.routerServiceMessenger = null;
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportManagerTests.java
index b73460c72..454a32633 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportManagerTests.java
@@ -2,8 +2,8 @@ package com.smartdevicelink.transport;
import android.content.ComponentName;
import android.os.Looper;
+import android.support.test.runner.AndroidJUnit4;
-import com.smartdevicelink.AndroidTestCase2;
import com.smartdevicelink.protocol.SdlPacket;
import com.smartdevicelink.protocol.SdlPacketFactory;
import com.smartdevicelink.protocol.enums.SessionType;
@@ -11,10 +11,22 @@ import com.smartdevicelink.test.SdlUnitTestContants;
import com.smartdevicelink.transport.enums.TransportType;
import com.smartdevicelink.transport.utl.TransportRecord;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.Collections;
import java.util.List;
-public class TransportManagerTests extends AndroidTestCase2 {
+import static android.support.test.InstrumentationRegistry.getContext;
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertFalse;
+import static junit.framework.TestCase.assertNotNull;
+import static junit.framework.TestCase.assertNull;
+import static junit.framework.TestCase.assertTrue;
+
+@RunWith(AndroidJUnit4.class)
+public class TransportManagerTests {
MultiplexTransportConfig config;
final TransportRecord defaultBtRecord = new TransportRecord(TransportType.BLUETOOTH, "12:34:56:78:90");
@@ -36,9 +48,9 @@ public class TransportManagerTests extends AndroidTestCase2 {
};
- @Override
- protected void setUp() throws Exception {
- config = new MultiplexTransportConfig(this.mContext, SdlUnitTestContants.TEST_APP_ID);
+ @Before
+ public void setUp() throws Exception {
+ config = new MultiplexTransportConfig(getContext(), SdlUnitTestContants.TEST_APP_ID);
config.setService(routerServiceComponentName);
if (Looper.myLooper() == null) {
Looper.prepare();
@@ -54,18 +66,20 @@ public class TransportManagerTests extends AndroidTestCase2 {
assertNull(manager.legacyBluetoothHandler);
manager.exitLegacyMode("Test");
- manager.transport = manager.new TransportBrokerImpl(mContext, config.appId, routerServiceComponentName);
+ manager.transport = manager.new TransportBrokerImpl(getContext(), config.appId, routerServiceComponentName);
manager.start();
assert true;
return manager;
}
+ @Test
public void testBase(){
TransportManager manager = new TransportManager(config,defaultListener);
assertNotNull(manager);
}
+ @Test
public void testConnectionStatus(){
TransportManager manager = new TransportManager(config,defaultListener);
@@ -91,6 +105,7 @@ public class TransportManagerTests extends AndroidTestCase2 {
}
+ @Test
public void testOnTransportConnections(){
TransportManager manager = createTransportManager();
@@ -112,6 +127,7 @@ public class TransportManagerTests extends AndroidTestCase2 {
}
+ @Test
public void testOnPacket(){
TransportManager manager = createTransportManager();
assertNotNull(manager.transportListener);
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/util/MediaStreamingStatusTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/util/MediaStreamingStatusTests.java
index 471bc19f0..13e0193f7 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/util/MediaStreamingStatusTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/util/MediaStreamingStatusTests.java
@@ -4,25 +4,33 @@ import android.content.Context;
import android.media.AudioDeviceInfo;
import android.media.AudioManager;
import android.os.Build;
+import android.support.test.runner.AndroidJUnit4;
-import com.smartdevicelink.AndroidTestCase2;
import com.smartdevicelink.managers.SdlManager;
import com.smartdevicelink.managers.SdlManagerListener;
import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
import com.smartdevicelink.test.Test;
import com.smartdevicelink.transport.MultiplexTransportConfig;
+import org.junit.Before;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import java.util.Vector;
+import static android.support.test.InstrumentationRegistry.getContext;
+import static junit.framework.TestCase.assertFalse;
+import static junit.framework.TestCase.assertNotNull;
+import static junit.framework.TestCase.assertNull;
+import static junit.framework.TestCase.assertTrue;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
-public class MediaStreamingStatusTests extends AndroidTestCase2 {
+@RunWith(AndroidJUnit4.class)
+public class MediaStreamingStatusTests {
@@ -48,7 +56,7 @@ public class MediaStreamingStatusTests extends AndroidTestCase2 {
};
- @Override
+ @Before
public void setUp() throws Exception{
mockedContext = mock(Context.class);
doAnswer(onGetSystemService).when(mockedContext).getSystemService(Context.AUDIO_SERVICE);
@@ -56,6 +64,7 @@ public class MediaStreamingStatusTests extends AndroidTestCase2 {
}
+ @org.junit.Test
public void testEmptyAudioDeviceInfoList(){
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
assertNotNull(mockedContext);
@@ -77,6 +86,7 @@ public class MediaStreamingStatusTests extends AndroidTestCase2 {
}
}
+ @org.junit.Test
public void testNullAudioDeviceInfoList(){
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
assertNotNull(mockedContext);
@@ -93,6 +103,7 @@ public class MediaStreamingStatusTests extends AndroidTestCase2 {
}
+ @org.junit.Test
public void testSdlManagerMedia(){
SdlManager.Builder builder = new SdlManager.Builder(getContext(), Test.GENERAL_FULL_APP_ID, Test.GENERAL_STRING, mock(SdlManagerListener.class));
Vector<AppHMIType> appType = new Vector<>();
@@ -110,6 +121,7 @@ public class MediaStreamingStatusTests extends AndroidTestCase2 {
assertTrue(multiplexTransportConfig.requiresAudioSupport());
}
+ @org.junit.Test
public void testSdlManagerNonMedia(){
SdlManager.Builder builder = new SdlManager.Builder(getContext(), Test.GENERAL_FULL_APP_ID, Test.GENERAL_STRING, mock(SdlManagerListener.class));
Vector<AppHMIType> appType = new Vector<>();
@@ -127,6 +139,7 @@ public class MediaStreamingStatusTests extends AndroidTestCase2 {
assertFalse(multiplexTransportConfig.requiresAudioSupport());
}
+ @org.junit.Test
public void testAcceptedBTDevices(){
MediaStreamingStatus mediaStreamingStatus = spy(new MediaStreamingStatus(getContext(), mock(MediaStreamingStatus.Callback.class)));
@@ -141,6 +154,7 @@ public class MediaStreamingStatusTests extends AndroidTestCase2 {
assertTrue(mediaStreamingStatus.isSupportedAudioDevice(AudioDeviceInfo.TYPE_BLUETOOTH_A2DP));
}
+ @org.junit.Test
public void testAcceptedUSBDevices(){
MediaStreamingStatus mediaStreamingStatus = spy(new MediaStreamingStatus(getContext(), mock(MediaStreamingStatus.Callback.class)));
@@ -158,6 +172,7 @@ public class MediaStreamingStatusTests extends AndroidTestCase2 {
assertTrue(mediaStreamingStatus.isSupportedAudioDevice(AudioDeviceInfo.TYPE_DOCK));
}
+ @org.junit.Test
public void testAcceptedLineDevices(){
assertTrue(defaultMediaStreamingStatus.isSupportedAudioDevice(AudioDeviceInfo.TYPE_LINE_ANALOG));
assertTrue(defaultMediaStreamingStatus.isSupportedAudioDevice(AudioDeviceInfo.TYPE_LINE_DIGITAL));
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java
index b6f49a9a4..ba1646fd8 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java
@@ -146,6 +146,7 @@ public class VideoStreamManager extends BaseVideoStreamManager {
private final OnRPCNotificationListener hmiListener = new OnRPCNotificationListener() {
@Override
public void onNotified(RPCNotification notification) {
+ Log.e(TAG, "TESTING");
if(notification != null){
OnHMIStatus onHMIStatus = (OnHMIStatus) notification;
if (onHMIStatus.getWindowID() != null && onHMIStatus.getWindowID() != PredefinedWindows.DEFAULT_WINDOW.getValue()) {