From 8ce3830be9fb4c921b77d019e3c62fe42349b572 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 12 Apr 2022 11:14:53 +0200 Subject: [PATCH] [Linux] add GTest printer for FlValue Improves test failure messages when matching FlValue arguments. For example, before: Expected arg #2: has setting ("platformBrightness", 0x32f0980) Actual: 0x7f81ec005990, 0x32f0900 And after: Expected arg #2: has setting ("platformBrightness", dark) Actual: 0x27bded0, {textScaleFactor: 0.0, alwaysUse24HourFormat: false, platformBrightness: light} --- shell/platform/linux/testing/fl_test.cc | 5 +++++ shell/platform/linux/testing/fl_test.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/shell/platform/linux/testing/fl_test.cc b/shell/platform/linux/testing/fl_test.cc index dc75794d6f9b3..3af19052fc09c 100644 --- a/shell/platform/linux/testing/fl_test.cc +++ b/shell/platform/linux/testing/fl_test.cc @@ -62,3 +62,8 @@ FlEngine* make_mock_engine_with_project(FlDartProject* project) { return static_cast(g_object_ref(engine)); } + +void PrintTo(FlValue* v, std::ostream* os) { + g_autofree gchar* s = fl_value_to_string(v); + *os << s; +} diff --git a/shell/platform/linux/testing/fl_test.h b/shell/platform/linux/testing/fl_test.h index bf954033b20da..9fcb3ac679af2 100644 --- a/shell/platform/linux/testing/fl_test.h +++ b/shell/platform/linux/testing/fl_test.h @@ -6,9 +6,11 @@ #define FLUTTER_SHELL_PLATFORM_LINUX_FL_TEST_H_ #include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h" +#include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h" #include #include +#include G_BEGIN_DECLS @@ -27,6 +29,9 @@ FlEngine* make_mock_engine(); // platform messages. FlEngine* make_mock_engine_with_project(FlDartProject* project); +// GTest printer for FlValue. +void PrintTo(FlValue* v, std::ostream* os); + G_END_DECLS #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_TEST_H_