5#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_method_codec.h"
7#include "flutter/shell/platform/common/client_wrapper/include/flutter/method_result_functions.h"
8#include "flutter/shell/platform/common/client_wrapper/testing/test_codec_extensions.h"
9#include "gtest/gtest.h"
17bool MethodCallsAreEqual(
const MethodCall<>&
a,
const MethodCall<>&
b) {
18 if (
a.method_name() !=
b.method_name()) {
22 if ((!
a.arguments() ||
a.arguments()->IsNull()) &&
23 (!
b.arguments() ||
b.arguments()->IsNull())) {
27 if (!
a.arguments() || !
b.arguments()) {
30 return *
a.arguments() == *
b.arguments();
40 EXPECT_EQ(&codec_a, &codec_b);
47 ASSERT_NE(encoded.get(),
nullptr);
49 ASSERT_NE(decoded.get(),
nullptr);
60 ASSERT_NE(encoded.get(),
nullptr);
62 ASSERT_NE(decoded.get(),
nullptr);
69 ASSERT_NE(encoded.get(),
nullptr);
70 std::vector<uint8_t> bytes = {0x00, 0x00};
71 EXPECT_EQ(*encoded, bytes);
73 bool decoded_successfully =
false;
76 decoded_successfully =
true;
77 EXPECT_EQ(
result,
nullptr);
89 ASSERT_NE(encoded.get(),
nullptr);
90 std::vector<uint8_t> bytes = {0x00, 0x03, 0x2a, 0x00, 0x00, 0x00};
91 EXPECT_EQ(*encoded, bytes);
93 bool decoded_successfully =
false;
96 decoded_successfully =
true;
97 EXPECT_EQ(std::get<int32_t>(*
result), 42);
108 ASSERT_NE(encoded.get(),
nullptr);
109 std::vector<uint8_t> bytes = {0x01, 0x07, 0x09, 0x65, 0x72, 0x72, 0x6f,
110 0x72, 0x43, 0x6f, 0x64, 0x65, 0x00, 0x00};
111 EXPECT_EQ(*encoded, bytes);
113 bool decoded_successfully =
false;
116 [&decoded_successfully](
const std::string&
code,
119 decoded_successfully =
true;
120 EXPECT_EQ(
code,
"errorCode");
122 EXPECT_EQ(details,
nullptr);
138 ASSERT_NE(encoded.get(),
nullptr);
139 std::vector<uint8_t> bytes = {
140 0x01, 0x07, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f,
141 0x64, 0x65, 0x07, 0x10, 0x73, 0x6f, 0x6d, 0x65, 0x74, 0x68,
142 0x69, 0x6e, 0x67, 0x20, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64,
143 0x0c, 0x02, 0x07, 0x01, 0x61, 0x03, 0x2a, 0x00, 0x00, 0x00,
145 EXPECT_EQ(*encoded, bytes);
147 bool decoded_successfully =
false;
150 [&decoded_successfully](
const std::string&
code,
153 decoded_successfully =
true;
154 EXPECT_EQ(
code,
"errorCode");
155 EXPECT_EQ(
message,
"something failed");
156 const auto* details_list = std::get_if<EncodableList>(details);
157 ASSERT_NE(details_list,
nullptr);
158 EXPECT_EQ(std::get<std::string>((*details_list)[0]),
"a");
159 EXPECT_EQ(std::get<int32_t>((*details_list)[1]), 42);
174 ASSERT_NE(encoded.get(),
nullptr);
176 ASSERT_NE(decoded.get(),
nullptr);
178 const Point& decoded_point = std::any_cast<Point>(
179 std::get<CustomEncodableValue>(*decoded->arguments()));
180 EXPECT_EQ(point, decoded_point);
std::unique_ptr< MethodCall< T > > DecodeMethodCall(const uint8_t *message, size_t message_size) const
bool DecodeAndProcessResponseEnvelope(const uint8_t *response, size_t response_size, MethodResult< T > *result) const
std::unique_ptr< std::vector< uint8_t > > EncodeErrorEnvelope(const std::string &error_code, const std::string &error_message="", const T *error_details=nullptr) const
std::unique_ptr< std::vector< uint8_t > > EncodeMethodCall(const MethodCall< T > &method_call) const
std::unique_ptr< std::vector< uint8_t > > EncodeSuccessEnvelope(const T *result=nullptr) const
static const PointExtensionSerializer & GetInstance()
static const StandardMethodCodec & GetInstance(const StandardCodecSerializer *serializer=nullptr)
TEST(FrameTimingsRecorderTest, RecordVsync)
std::vector< EncodableValue > EncodableList
#define EXPECT_TRUE(handle)