5#include "flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h"
9#include "gtest/gtest.h"
18TEST(EncodableValueTest, Bool) {
21 EXPECT_FALSE(std::get<bool>(
value));
26TEST(EncodableValueTest, Int) {
29 EXPECT_EQ(std::get<int32_t>(
value), 42);
35TEST(EncodableValueTest, LongValue) {
42TEST(EncodableValueTest, Long) {
45 EXPECT_EQ(std::get<int64_t>(
value), 42);
50TEST(EncodableValueTest, Double) {
53 EXPECT_EQ(std::get<double>(
value), 3.14);
58TEST(EncodableValueTest, String) {
59 std::string hello(
"Hello, world!");
62 EXPECT_EQ(std::get<std::string>(
value), hello);
63 value = std::string(
"Goodbye");
64 EXPECT_EQ(std::get<std::string>(
value),
"Goodbye");
68TEST(EncodableValueTest, CString) {
69 const char* hello =
"Hello, world!";
72 EXPECT_EQ(std::get<std::string>(
value), hello);
74 EXPECT_EQ(std::get<std::string>(
value),
"Goodbye");
77TEST(EncodableValueTest, UInt8List) {
78 std::vector<uint8_t>
data = {0, 2};
81 auto& list_value = std::get<std::vector<uint8_t>>(
value);
83 EXPECT_EQ(list_value[0], 0);
84 EXPECT_EQ(list_value[1], 2);
86 ASSERT_EQ(list_value.size(), 3u);
87 EXPECT_EQ(
data.size(), 2u);
91TEST(EncodableValueTest, Int32List) {
92 std::vector<int32_t>
data = {-10, 2};
95 auto& list_value = std::get<std::vector<int32_t>>(
value);
97 EXPECT_EQ(list_value[0], -10);
98 EXPECT_EQ(list_value[1], 2);
100 ASSERT_EQ(list_value.size(), 3u);
101 EXPECT_EQ(
data.size(), 2u);
105TEST(EncodableValueTest, Int64List) {
106 std::vector<int64_t>
data = {-10, 2};
109 auto& list_value = std::get<std::vector<int64_t>>(
value);
111 EXPECT_EQ(list_value[0], -10);
112 EXPECT_EQ(list_value[1], 2);
114 ASSERT_EQ(list_value.size(), 3u);
115 EXPECT_EQ(
data.size(), 2u);
119TEST(EncodableValueTest, DoubleList) {
120 std::vector<double>
data = {-10.0, 2.0};
123 auto& list_value = std::get<std::vector<double>>(
value);
125 EXPECT_EQ(list_value[0], -10.0);
126 EXPECT_EQ(list_value[1], 2.0);
128 ASSERT_EQ(list_value.size(), 3u);
129 EXPECT_EQ(
data.size(), 2u);
141 auto& list_value = std::get<EncodableList>(
value);
142 EXPECT_EQ(std::get<int32_t>(list_value[0]), 1);
143 EXPECT_EQ(std::get<double>(list_value[1]), 2.0);
144 EXPECT_EQ(std::get<std::string>(list_value[2]),
"Three");
148 ASSERT_EQ(list_value.size(), 4u);
149 EXPECT_EQ(encodables.size(), 3u);
150 EXPECT_EQ(std::get<bool>(std::get<EncodableList>(
value)[3]),
true);
161 auto& map_value = std::get<EncodableMap>(
value);
163 std::holds_alternative<std::vector<int32_t>>(map_value[
EncodableValue()]),
165 EXPECT_EQ(std::get<int64_t>(map_value[
EncodableValue(1)]), INT64_C(10000));
166 EXPECT_EQ(std::get<int32_t>(map_value[
EncodableValue(
"two")]), 7);
170 ASSERT_EQ(map_value.size(), 4u);
171 EXPECT_EQ(encodables.size(), 3u);
172 EXPECT_EQ(std::get<bool>(map_value[
EncodableValue(
true)]),
false);
177TEST(EncodableValueTest, Comparison) {
225 for (
size_t i = 0;
i <
values.size(); ++
i) {
227 for (
size_t j = 0; j <
values.size(); ++j) {
236 EXPECT_NE(
a <
b,
b <
a) <<
"Indexes: " <<
i <<
", " << j;
247TEST(EncodableValueTest, DeepCopy) {
263 ASSERT_TRUE(std::holds_alternative<EncodableList>(
copy));
266 auto& root_list = std::get<EncodableList>(
copy);
267 auto& first_child = std::get<EncodableMap>(root_list[0]);
268 EXPECT_EQ(std::get<int32_t>(first_child[
EncodableValue(
"two")]), 7);
269 auto& second_child = std::get<EncodableList>(root_list[1]);
270 auto& innermost_map = std::get<EncodableMap>(second_child[2]);
271 EXPECT_EQ(std::get<std::string>(innermost_map[
EncodableValue(
"a")]),
"b");
279 first_child = std::get<EncodableMap>(original[0]);
280 EXPECT_EQ(std::get<int32_t>(first_child[
EncodableValue(
"two")]), 7);
281 second_child = std::get<EncodableList>(original[1]);
282 innermost_map = std::get<EncodableMap>(second_child[2]);
283 EXPECT_EQ(std::get<std::string>(innermost_map[
EncodableValue(
"a")]),
"b");
293 int x()
const {
return x_; }
294 int y()
const {
return y_; }
301TEST(EncodableValueTest, TypeIndexesCorrect) {
static void copy(void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
int64_t LongValue() const
TestCustomValue(int x, int y)
~TestCustomValue()=default
static float max(float r, float g, float b)
SK_API sk_sp< SkSurface > Null(int width, int height)
TEST(FrameTimingsRecorderTest, RecordVsync)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
std::vector< EncodableValue > EncodableList
std::map< EncodableValue, EncodableValue > EncodableMap
#define EXPECT_TRUE(handle)