diff options
author | BrettyWhite <brett@livio.io> | 2017-04-05 09:23:13 -0400 |
---|---|---|
committer | BrettyWhite <brett@livio.io> | 2017-04-05 09:23:13 -0400 |
commit | a7affe0d0755920d74957c111d1e764b484386dd (patch) | |
tree | ee9c6ed4baafdb93bcd528d4a210b3c5c1ff4413 /sdl_android | |
parent | 08f8d9ef9883fa31b6cbb06a6f37c4d056892945 (diff) | |
download | sdl_android-a7affe0d0755920d74957c111d1e764b484386dd.tar.gz |
cleaned log / added null test
Diffstat (limited to 'sdl_android')
-rw-r--r-- | sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java | 24 | ||||
-rw-r--r-- | sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java | 4 |
2 files changed, 25 insertions, 3 deletions
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java index 6a66eb36d..1603f0e4f 100644 --- a/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java @@ -36,5 +36,29 @@ public class RegisteredAppTests extends AndroidTestCase { } }); } + + public void testNullBuffer() { + + // Run Test in Main Thread + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + + // Instantiate SdlRouterService and Registered App class + SdlRouterService router = new SdlRouterService(); + SdlRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, messenger); + + // Force Null Buffer + app.buffer = null; + + // Call Handle Message - Making sure it doesn't init buffer + app.handleMessage(TransportConstants.BYTES_TO_SEND_FLAG_NONE,bytes); + + // Insure that the buffer is not null, if it is the test will fail + assertNull(app.buffer); + + } + }); + } } diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java index 38ad6dfb2..2bae96e27 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java +++ b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java @@ -2263,9 +2263,7 @@ public class SdlRouterService extends Service{ buffer = new ByteAraryMessageAssembler(); buffer.init(); } - if(buffer == null){ - Log.e(TAG, "Unable to assemble message as buffer was null/not started"); - }else { + if(buffer != null){ if (!buffer.handleMessage(flags, packet)) { //If this returns false Log.e(TAG, "Error handling bytes"); } |