5#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_message_codec.h"
10#include "flutter/shell/platform/common/client_wrapper/testing/test_codec_extensions.h"
11#include "gmock/gmock.h"
12#include "gtest/gtest.h"
18class MockStandardCodecSerializer :
public StandardCodecSerializer {
22 (
const EncodableValue&
value, ByteStreamWriter*
stream),
24 MOCK_METHOD(EncodableValue,
39 const std::vector<uint8_t>& expected_encoding,
42 custom_comparator =
nullptr) {
47 EXPECT_EQ(*encoded, expected_encoding);
50 if (custom_comparator) {
53 EXPECT_EQ(
value, *decoded);
64 const std::vector<uint8_t>& expected_encoding_prefix,
65 size_t expected_encoding_length) {
71 EXPECT_EQ(encoded->size(), expected_encoding_length);
72 ASSERT_GT(encoded->size(), expected_encoding_prefix.size());
74 encoded->begin(), encoded->begin() + expected_encoding_prefix.size(),
75 expected_encoding_prefix.begin(), expected_encoding_prefix.end()));
79 EXPECT_EQ(
value, *decoded);
87 EXPECT_EQ(&codec_a, &codec_b);
91 std::vector<uint8_t> bytes = {0x00};
96 std::vector<uint8_t> bytes = {};
97 const MockStandardCodecSerializer serializer;
104 EXPECT_CALL(serializer, ReadValueOfType(::testing::_, ::testing::_)).Times(0);
108 std::vector<uint8_t> bytes = {0x01};
113 std::vector<uint8_t> bytes = {0x02};
118 std::vector<uint8_t> bytes = {0x03, 0x78, 0x56, 0x34, 0x12};
123 std::vector<uint8_t> bytes = {0x04, 0xef, 0xcd, 0xab, 0x90,
124 0x78, 0x56, 0x34, 0x12};
129 std::vector<uint8_t> bytes = {0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
130 0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40};
135 std::vector<uint8_t> bytes = {0x07, 0x0b, 0x68, 0x65, 0x6c, 0x6c, 0x6f,
136 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64};
141 std::vector<uint8_t> bytes = {0x07, 0x05, 0x68, 0xe2, 0x98, 0xba, 0x77};
146 std::vector<uint8_t> bytes = {0x07, 0x06, 0x68, 0xf0, 0x9f, 0x98, 0x82, 0x77};
151 std::vector<uint8_t> bytes = {0x07, 0x00};
156 std::vector<uint8_t> bytes = {
157 0x0c, 0x05, 0x00, 0x07, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x06,
158 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x85, 0xeb, 0x51, 0xb8, 0x1e,
159 0x09, 0x40, 0x03, 0x2f, 0x00, 0x00, 0x00, 0x0c, 0x02, 0x03, 0x2a,
160 0x00, 0x00, 0x00, 0x07, 0x06, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64,
176 std::vector<uint8_t> bytes = {0x0c, 0x00};
181 std::vector<uint8_t> bytes_prefix = {0x0d, 0x04};
194 std::vector<uint8_t> bytes = {0x08, 0x04, 0xba, 0x5e, 0xba, 0x11};
200 std::vector<uint8_t> bytes = {0x09, 0x03, 0x00, 0x00, 0x78, 0x56, 0x34, 0x12,
201 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00};
207 std::vector<uint8_t> bytes = {0x0a, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208 0xef, 0xcd, 0xab, 0x90, 0x78, 0x56, 0x34, 0x12,
209 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
215 std::vector<uint8_t> bytes = {0x0e, 0x02, 0x00, 0x00, 0xd8, 0x0f,
216 0x49, 0x40, 0x00, 0x00, 0x7a, 0x44};
222 std::vector<uint8_t> bytes = {0x0b, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
223 0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40,
224 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x8f, 0x40};
226 std::vector<double>{3.14159265358979311599796346854, 1000.0});
231 std::vector<uint8_t> bytes = {0x80, 0x09, 0x00, 0x00, 0x00,
232 0x10, 0x00, 0x00, 0x00};
234 const Point& a_point =
235 std::any_cast<Point>(std::get<CustomEncodableValue>(
a));
236 const Point& b_point =
237 std::any_cast<Point>(std::get<CustomEncodableValue>(
b));
238 return a_point == b_point;
245 std::vector<uint8_t> bytes = {
247 0x06, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
249 0x74, 0x65, 0x73, 0x74
254 std::any_cast<SomeData>(std::get<CustomEncodableValue>(
a));
256 std::any_cast<SomeData>(std::get<CustomEncodableValue>(
b));
260 SomeData(
"test", {0x00, 0x01, 0x02, 0x03, 0x04, 0x05})),
262 some_data_comparator);
static bool equal(const SkBitmap &a, const SkBitmap &b)
std::unique_ptr< T > DecodeMessage(const uint8_t *binary_message, const size_t message_size) const
std::unique_ptr< std::vector< uint8_t > > EncodeMessage(const T &message) const
static const PointExtensionSerializer & GetInstance()
static const SomeDataExtensionSerializer & GetInstance()
const std::string & label() const
const std::vector< uint8_t > & data() const
static const StandardMessageCodec & GetInstance(const StandardCodecSerializer *serializer=nullptr)
Dart_NativeFunction function
TEST(FrameTimingsRecorderTest, RecordVsync)
static void CheckEncodeDecodeWithEncodePrefix(const EncodableValue &value, const std::vector< uint8_t > &expected_encoding_prefix, size_t expected_encoding_length)
static void CheckEncodeDecode(const EncodableValue &value, const std::vector< uint8_t > &expected_encoding, const StandardCodecSerializer *serializer=nullptr, const std::function< bool(const EncodableValue &a, const EncodableValue &b)> &custom_comparator=nullptr)
std::vector< EncodableValue > EncodableList
std::map< EncodableValue, EncodableValue > EncodableMap
#define EXPECT_TRUE(handle)