Merge pull request #425 from deton/fix-nullresult-fromthread

CB-12218: (android) Fix consistency of null result message
This commit is contained in:
Joe Bowser 2018-01-03 11:24:24 -08:00 committed by GitHub
commit fcf705e007
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -511,6 +511,9 @@ public class NativeToJsMessageQueue {
.append(pluginResult.getMessage())
.append("')");
break;
case PluginResult.MESSAGE_TYPE_NULL:
sb.append("null");
break;
default:
sb.append(pluginResult.getMessage());
}

View File

@ -161,4 +161,17 @@ public class NativeToJsMessageQueueTest {
assertEquals(result, "cordova.callbackFromNative('37',true,1,[0,1,2,3,4],false);");
}
@Test
public void testNullPopAndEncodeAsJs()
{
NativeToJsMessageQueue queue = new NativeToJsMessageQueue();
queue.addBridgeMode(new NativeToJsMessageQueue.NoOpBridgeMode());
queue.setBridgeMode(0);
PluginResult result = new PluginResult(PluginResult.Status.OK, (String)null);
queue.addPluginResult(result, TEST_CALLBACK_ID);
assertFalse(queue.isEmpty());
String resultString = queue.popAndEncodeAsJs();
assertEquals(resultString, "cordova.callbackFromNative('" + TEST_CALLBACK_ID + "',true,1,[null],false);");
}
}