mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 01:42:58 +08:00
parent
52878d6c5b
commit
19220de388
@ -1,31 +0,0 @@
|
|||||||
package org.apache.cordova.test;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import org.apache.cordova.NativeToJsMessageQueue;
|
|
||||||
import org.apache.cordova.PluginResult;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class MultipartMessageTest extends BaseCordovaIntegrationTest {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
setUpWithStartUrl(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testMultipartMessages() throws Throwable {
|
|
||||||
ArrayList<PluginResult> multiparts = new ArrayList<PluginResult>();
|
|
||||||
for (int i=0; i<5; i++) {
|
|
||||||
multiparts.add(new PluginResult(PluginResult.Status.OK, i));
|
|
||||||
}
|
|
||||||
PluginResult multipartresult = new PluginResult(PluginResult.Status.OK, multiparts);
|
|
||||||
NativeToJsMessageQueue q = new NativeToJsMessageQueue();
|
|
||||||
q.addBridgeMode(new NativeToJsMessageQueue.NoOpBridgeMode());
|
|
||||||
q.setBridgeMode(0);
|
|
||||||
q.addPluginResult(multipartresult, "37");
|
|
||||||
String result = q.popAndEncodeAsJs();
|
|
||||||
assertEquals(result, "cordova.callbackFromNative('37',true,1,[0,1,2,3,4],false);");
|
|
||||||
Log.v("MultiPartMessageTest", result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -20,6 +20,7 @@ import org.json.JSONObject;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
@ -123,4 +124,22 @@ public class NativeToJsMessageQueueTest {
|
|||||||
assertTrue(resultString.startsWith("cordova.callbackFromNative"));
|
assertTrue(resultString.startsWith("cordova.callbackFromNative"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//This test is for the evalBridge, which directly calls cordova.callbackFromNative, skipping
|
||||||
|
//platform specific NativeToJs code
|
||||||
|
@Test
|
||||||
|
public void testMultipartPopAndEncodeAsJs()
|
||||||
|
{
|
||||||
|
ArrayList<PluginResult> multiparts = new ArrayList<PluginResult>();
|
||||||
|
for (int i=0; i<5; i++) {
|
||||||
|
multiparts.add(new PluginResult(PluginResult.Status.OK, i));
|
||||||
|
}
|
||||||
|
PluginResult multipartresult = new PluginResult(PluginResult.Status.OK, multiparts);
|
||||||
|
NativeToJsMessageQueue queue = new NativeToJsMessageQueue();
|
||||||
|
queue.addBridgeMode(new NativeToJsMessageQueue.NoOpBridgeMode());
|
||||||
|
queue.setBridgeMode(0);
|
||||||
|
queue.addPluginResult(multipartresult, "37");
|
||||||
|
String result = queue.popAndEncodeAsJs();
|
||||||
|
assertEquals(result, "cordova.callbackFromNative('37',true,1,[0,1,2,3,4],false);");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user