Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
io.flutter.plugin.common.StandardMethodCodecTest Class Reference

Public Member Functions

void encodeMethodTest ()
 
void encodeSuccessEnvelopeTest ()
 
void encodeSuccessEnvelopeUnsupportedObjectTest ()
 
void encodeErrorEnvelopeWithNullDetailsTest ()
 
void encodeErrorEnvelopeWithThrowableTest ()
 
void encodeErrorEnvelopeWithStacktraceTest ()
 

Detailed Description

Definition at line 20 of file StandardMethodCodecTest.java.

Member Function Documentation

◆ encodeErrorEnvelopeWithNullDetailsTest()

void io.flutter.plugin.common.StandardMethodCodecTest.encodeErrorEnvelopeWithNullDetailsTest ( )
inline

Definition at line 58 of file StandardMethodCodecTest.java.

58 {
59 final ByteBuffer buffer =
60 StandardMethodCodec.INSTANCE.encodeErrorEnvelope("code", "error", null);
61 assertNotNull(buffer);
62 buffer.flip();
63 try {
64 StandardMethodCodec.INSTANCE.decodeEnvelope(buffer);
65 fail("Should have thrown a FlutterException since this is an error envelope.");
66 } catch (FlutterException result) {
67 assertEquals("code", result.code);
68 assertEquals("error", result.getMessage());
69 assertNull(result.details);
70 }
71 }
static void fail(const SkString &err)
Definition: DM.cpp:234
GAsyncResult * result
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ encodeErrorEnvelopeWithStacktraceTest()

void io.flutter.plugin.common.StandardMethodCodecTest.encodeErrorEnvelopeWithStacktraceTest ( )
inline

Definition at line 95 of file StandardMethodCodecTest.java.

95 {
96 final Exception e = new IllegalArgumentException("foo");
97 final ByteBuffer buffer =
98 StandardMethodCodec.INSTANCE.encodeErrorEnvelopeWithStacktrace(
99 "code", e.getMessage(), e, "error stacktrace");
100 assertNotNull(buffer);
101 buffer.flip();
102 buffer.order(ByteOrder.nativeOrder());
103 final byte flag = buffer.get();
104 final Object code = StandardMessageCodec.INSTANCE.readValue(buffer);
105 final Object message = StandardMessageCodec.INSTANCE.readValue(buffer);
106 final Object details = StandardMessageCodec.INSTANCE.readValue(buffer);
107 final Object stacktrace = StandardMessageCodec.INSTANCE.readValue(buffer);
108 assertEquals("code", (String) code);
109 assertEquals("foo", (String) message);
110 String stack = (String) details;
111 assertTrue(
112 stack.contains(
113 "at io.flutter.plugin.common.StandardMethodCodecTest.encodeErrorEnvelopeWithStacktraceTest(StandardMethodCodecTest.java:"));
114 assertEquals("error stacktrace", (String) stacktrace);
115 }
FlutterSemanticsFlag flag
Win32Message message

◆ encodeErrorEnvelopeWithThrowableTest()

void io.flutter.plugin.common.StandardMethodCodecTest.encodeErrorEnvelopeWithThrowableTest ( )
inline

Definition at line 74 of file StandardMethodCodecTest.java.

74 {
75 final Exception e = new IllegalArgumentException("foo");
76 final ByteBuffer buffer =
77 StandardMethodCodec.INSTANCE.encodeErrorEnvelope("code", e.getMessage(), e);
78 assertNotNull(buffer);
79 buffer.flip();
80 try {
81 StandardMethodCodec.INSTANCE.decodeEnvelope(buffer);
82 fail("Should have thrown a FlutterException since this is an error envelope.");
83 } catch (FlutterException result) {
84 assertEquals("code", result.code);
85 assertEquals("foo", result.getMessage());
86 // Must contain part of a stack.
87 String stack = (String) result.details;
88 assertTrue(
89 stack.contains(
90 "at io.flutter.plugin.common.StandardMethodCodecTest.encodeErrorEnvelopeWithThrowableTest(StandardMethodCodecTest.java:"));
91 }
92 }

◆ encodeMethodTest()

void io.flutter.plugin.common.StandardMethodCodecTest.encodeMethodTest ( )
inline

Definition at line 23 of file StandardMethodCodecTest.java.

23 {
24 final Map<String, String> args = new HashMap<>();
25 args.put("testArg", "testValue");
26 MethodCall call = new MethodCall("testMethod", args);
27 final ByteBuffer buffer = StandardMethodCodec.INSTANCE.encodeMethodCall(call);
28 assertNotNull(buffer);
29 buffer.flip();
30 final MethodCall result = StandardMethodCodec.INSTANCE.decodeMethodCall(buffer);
31 assertEquals(call.method, result.method);
32 assertEquals(call.arguments, result.arguments);
33 }
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static ::testing::Matcher< GBytes * > MethodCall(const std::string &name, ::testing::Matcher< FlValue * > args)
def call(args)
Definition: dom.py:159

◆ encodeSuccessEnvelopeTest()

void io.flutter.plugin.common.StandardMethodCodecTest.encodeSuccessEnvelopeTest ( )
inline

Definition at line 36 of file StandardMethodCodecTest.java.

36 {
37 final Map<String, Integer> success = new HashMap<>();
38 success.put("result", 1);
39 final ByteBuffer buffer = StandardMethodCodec.INSTANCE.encodeSuccessEnvelope(success);
40 assertNotNull(buffer);
41 buffer.flip();
42 final Object result = StandardMethodCodec.INSTANCE.decodeEnvelope(buffer);
43 assertEquals(success, result);
44 }

◆ encodeSuccessEnvelopeUnsupportedObjectTest()

void io.flutter.plugin.common.StandardMethodCodecTest.encodeSuccessEnvelopeUnsupportedObjectTest ( )
inline

Definition at line 47 of file StandardMethodCodecTest.java.

47 {
48 final StandardMethodCodecTest joke = new StandardMethodCodecTest();
49 try {
50 final ByteBuffer buffer = StandardMethodCodec.INSTANCE.encodeSuccessEnvelope(joke);
51 fail("Should have failed to convert unsupported type.");
52 } catch (IllegalArgumentException e) {
53 // pass.
54 }
55 }

The documentation for this class was generated from the following file: