diff options
author | BrettyWhite <geekman3454@protonmail.com> | 2017-05-04 15:51:46 -0400 |
---|---|---|
committer | BrettyWhite <geekman3454@protonmail.com> | 2017-05-04 15:51:46 -0400 |
commit | 8b6ba0aea2592b1d75d23a4c80b3b328b1f251ce (patch) | |
tree | b16e921f8f48ce15d5924d9d586d4a7da6778b40 | |
parent | 9b5dc788df241018dd2a4666a0ff2cc4fa2aebe6 (diff) | |
download | sdl_android-bugfix/utest_RegisteredAppTests.tar.gz |
not calling main thread anymorebugfix/utest_RegisteredAppTests
new knowledge of loopers :)
-rw-r--r-- | sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java | 53 |
1 files changed, 25 insertions, 28 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 a4d4e1395..7d6c922c1 100644 --- a/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java @@ -18,47 +18,44 @@ public class RegisteredAppTests extends AndroidTestCase { public void testHandleMessage() { - // Run Test in Main Thread - new Handler(Looper.getMainLooper()).post(new Runnable() { - @Override - public void run() { + if (Looper.myLooper() == null) + { + Looper.prepare(); + } - // Instantiate SdlRouterService and Registered App class - SdlRouterService router = new SdlRouterService(); - SdlRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, messenger); + // Instantiate SdlRouterService and Registered App class + SdlRouterService router = new SdlRouterService(); + SdlRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, messenger); - // Call Handle Message - app.handleMessage(TransportConstants.BYTES_TO_SEND_FLAG_LARGE_PACKET_START,bytes); + // Call Handle Message + app.handleMessage(TransportConstants.BYTES_TO_SEND_FLAG_LARGE_PACKET_START,bytes); + + // Insure that the buffer is not null, if it is the test will fail + assertNotNull(app.buffer); - // Insure that the buffer is not null, if it is the test will fail - assertNotNull(app.buffer); - } - }); } public void testNullBuffer() { - // Run Test in Main Thread - new Handler(Looper.getMainLooper()).post(new Runnable() { - @Override - public void run() { + if (Looper.myLooper() == null) + { + Looper.prepare(); + } - // Instantiate SdlRouterService and Registered App class - SdlRouterService router = new SdlRouterService(); - SdlRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, messenger); + // 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; + // 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); + // Call Handle Message - Making sure it doesn't init buffer + app.handleMessage(TransportConstants.BYTES_TO_SEND_FLAG_NONE,bytes); - // Insure that the buffer is null. and no NPE - assertNull(app.buffer); + // Insure that the buffer is null. and no NPE + assertNull(app.buffer); - } - }); } } |