[go: nahoru, domu]

Skip to content

Commit

Permalink
[Linux] add GTest printer for FlValue (flutter#32652)
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
jpnurmi committed Apr 13, 2022
1 parent ec7f2ea commit f502732
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions shell/platform/linux/testing/fl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ FlEngine* make_mock_engine_with_project(FlDartProject* project) {

return static_cast<FlEngine*>(g_object_ref(engine));
}

void PrintTo(FlValue* v, std::ostream* os) {
g_autofree gchar* s = fl_value_to_string(v);
*os << s;
}
5 changes: 5 additions & 0 deletions shell/platform/linux/testing/fl_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <glib.h>
#include <stdint.h>
#include <ostream>

G_BEGIN_DECLS

Expand All @@ -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_

0 comments on commit f502732

Please sign in to comment.