1package io.flutter.plugin.common;
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertNotNull;
5import static org.junit.Assert.assertNull;
6import static org.junit.Assert.assertTrue;
7import static org.junit.Assert.fail;
9import androidx.test.ext.junit.runners.AndroidJUnit4;
10import java.nio.ByteBuffer;
11import java.nio.ByteOrder;
12import java.util.HashMap;
15import org.junit.runner.RunWith;
16import org.robolectric.annotation.Config;
19@RunWith(AndroidJUnit4.class)
24 final Map<String, String>
args =
new HashMap<>();
25 args.put(
"testArg",
"testValue");
31 assertEquals(call.method,
result.method);
32 assertEquals(call.arguments,
result.arguments);
37 final Map<String, Integer> success =
new HashMap<>();
38 success.put(
"result", 1);
43 assertEquals(success,
result);
51 fail(
"Should have failed to convert unsupported type.");
52 }
catch (IllegalArgumentException e) {
65 fail(
"Should have thrown a FlutterException since this is an error envelope.");
67 assertEquals(
"code",
result.code);
68 assertEquals(
"error",
result.getMessage());
69 assertNull(
result.details);
75 final Exception e =
new IllegalArgumentException(
"foo");
82 fail(
"Should have thrown a FlutterException since this is an error envelope.");
84 assertEquals(
"code",
result.code);
85 assertEquals(
"foo",
result.getMessage());
87 String stack = (String)
result.details;
90 "at io.flutter.plugin.common.StandardMethodCodecTest.encodeErrorEnvelopeWithThrowableTest(StandardMethodCodecTest.java:"));
96 final Exception e =
new IllegalArgumentException(
"foo");
99 "code", e.getMessage(), e,
"error stacktrace");
102 buffer.order(ByteOrder.nativeOrder());
108 assertEquals(
"code", (String) code);
109 assertEquals(
"foo", (String)
message);
110 String stack = (String) details;
113 "at io.flutter.plugin.common.StandardMethodCodecTest.encodeErrorEnvelopeWithStacktraceTest(StandardMethodCodecTest.java:"));
114 assertEquals(
"error stacktrace", (String) stacktrace);
static void fail(const SkString &err)
final Object readValue(@NonNull ByteBuffer buffer)
static final StandardMessageCodec INSTANCE
void encodeSuccessEnvelopeUnsupportedObjectTest()
void encodeSuccessEnvelopeTest()
void encodeErrorEnvelopeWithStacktraceTest()
void encodeErrorEnvelopeWithThrowableTest()
void encodeErrorEnvelopeWithNullDetailsTest()
ByteBuffer encodeSuccessEnvelope(@NonNull Object result)
ByteBuffer encodeErrorEnvelopeWithStacktrace( @NonNull String errorCode, @NonNull String errorMessage, @NonNull Object errorDetails, @NonNull String errorStacktrace)
ByteBuffer encodeErrorEnvelope( @NonNull String errorCode, @NonNull String errorMessage, @NonNull Object errorDetails)
Object decodeEnvelope(@NonNull ByteBuffer envelope)
ByteBuffer encodeMethodCall(@NonNull MethodCall methodCall)
MethodCall decodeMethodCall(@NonNull ByteBuffer methodCall)
static final StandardMethodCodec INSTANCE
FlutterSemanticsFlag flag
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static const uint8_t buffer[]