Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f502732

Browse files
authored
[Linux] add GTest printer for FlValue (#32652)
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}
1 parent ec7f2ea commit f502732

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

shell/platform/linux/testing/fl_test.cc

+5
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,8 @@ FlEngine* make_mock_engine_with_project(FlDartProject* project) {
6262

6363
return static_cast<FlEngine*>(g_object_ref(engine));
6464
}
65+
66+
void PrintTo(FlValue* v, std::ostream* os) {
67+
g_autofree gchar* s = fl_value_to_string(v);
68+
*os << s;
69+
}

shell/platform/linux/testing/fl_test.h

+5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
#define FLUTTER_SHELL_PLATFORM_LINUX_FL_TEST_H_
77

88
#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"
9+
#include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h"
910

1011
#include <glib.h>
1112
#include <stdint.h>
13+
#include <ostream>
1214

1315
G_BEGIN_DECLS
1416

@@ -27,6 +29,9 @@ FlEngine* make_mock_engine();
2729
// platform messages.
2830
FlEngine* make_mock_engine_with_project(FlDartProject* project);
2931

32+
// GTest printer for FlValue.
33+
void PrintTo(FlValue* v, std::ostream* os);
34+
3035
G_END_DECLS
3136

3237
#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_TEST_H_

0 commit comments

Comments
 (0)