Flutter Engine
The Flutter Engine
test_codec_extensions.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_TESTING_TEST_CODEC_EXTENSIONS_H_
6#define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_TESTING_TEST_CODEC_EXTENSIONS_H_
7
8#include "flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h"
9#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_codec_serializer.h"
10
11namespace flutter {
12
13// A representation of a point, for custom type testing of a simple type.
14class Point {
15 public:
16 Point(int x, int y) : x_(x), y_(y) {}
17 ~Point() = default;
18
19 int x() const { return x_; }
20 int y() const { return y_; }
21
22 bool operator==(const Point& other) const {
23 return x_ == other.x_ && y_ == other.y_;
24 }
25
26 private:
27 int x_;
28 int y_;
29};
30
31// A typed binary data object with extra fields, for custom type testing of a
32// variable-length type that includes types handled by the core standard codec.
33class SomeData {
34 public:
35 SomeData(const std::string& label, const std::vector<uint8_t>& data)
36 : label_(label), data_(data) {}
37 ~SomeData() = default;
38
39 const std::string& label() const { return label_; }
40 const std::vector<uint8_t>& data() const { return data_; }
41
42 private:
43 std::string label_;
44 std::vector<uint8_t> data_;
45};
46
47// Codec extension for Point.
49 public:
52
54
55 // |TestCodecSerializer|
57 ByteStreamReader* stream) const override;
58
59 // |TestCodecSerializer|
61 ByteStreamWriter* stream) const override;
62
63 private:
64 static constexpr uint8_t kPointType = 128;
65};
66
67// Codec extension for SomeData.
69 public:
72
74
75 // |TestCodecSerializer|
77 ByteStreamReader* stream) const override;
78
79 // |TestCodecSerializer|
81 ByteStreamWriter* stream) const override;
82
83 private:
84 static constexpr uint8_t kSomeDataType = 129;
85};
86
87} // namespace flutter
88
89#endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_TESTING_TEST_CODEC_EXTENSIONS_H_
GLenum type
static const PointExtensionSerializer & GetInstance()
EncodableValue ReadValueOfType(uint8_t type, ByteStreamReader *stream) const override
void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const override
bool operator==(const Point &other) const
~Point()=default
void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const override
static const SomeDataExtensionSerializer & GetInstance()
EncodableValue ReadValueOfType(uint8_t type, ByteStreamReader *stream) const override
SomeData(const std::string &label, const std::vector< uint8_t > &data)
const std::string & label() const
const std::vector< uint8_t > & data() const
~SomeData()=default
uint8_t value