Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[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}
  • Loading branch information
jpnurmi committed Apr 13, 2022
commit 8ce3830be9fb4c921b77d019e3c62fe42349b572
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_