mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
Merge pull request #425 from deton/fix-nullresult-fromthread
CB-12218: (android) Fix consistency of null result message
This commit is contained in:
commit
fcf705e007
@ -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());
|
||||
}
|
||||
|
@ -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);");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user