Make Skia object ostream operators work with unit tests (flutter/engine#51041)

Unit tests currently output basic hex dumps of skia objects even though we have ostream operators for many of the common ones. It looks like the operators were created in the wrong namespace (flutter/testing rather than the std namespace). Changing the namespace for the associated `assertions_skia` source files makes them compatible with unit tests that deal with these objects provided that the test files include that header and gn dependency, as verified with the `display_list_unittests` here.
This commit is contained in:
Jim Graham
2024-02-28 12:32:07 -08:00
committed by GitHub
parent 20a707ca00
commit 98c96670b4
4 changed files with 6 additions and 8 deletions

View File

@@ -128,6 +128,7 @@ if (enable_unittests) {
":display_list_fixtures",
"//flutter/display_list/testing:display_list_testing",
"//flutter/testing",
"//flutter/testing:skia",
]
if (!defined(defines)) {

View File

@@ -18,6 +18,7 @@
#include "flutter/display_list/utils/dl_receiver_utils.h"
#include "flutter/fml/logging.h"
#include "flutter/fml/math.h"
#include "flutter/testing/assertions_skia.h"
#include "flutter/testing/display_list_testing.h"
#include "flutter/testing/testing.h"

View File

@@ -4,8 +4,7 @@
#include "flutter/testing/assertions_skia.h"
namespace flutter {
namespace testing {
namespace std {
std::ostream& operator<<(std::ostream& os, const SkClipOp& o) {
switch (o) {
@@ -100,5 +99,4 @@ std::ostream& operator<<(std::ostream& os, const SkSamplingOptions& s) {
}
}
} // namespace testing
} // namespace flutter
} // namespace std

View File

@@ -16,8 +16,7 @@
#include "third_party/skia/include/core/SkRRect.h"
#include "third_party/skia/include/core/SkSamplingOptions.h"
namespace flutter {
namespace testing {
namespace std {
extern std::ostream& operator<<(std::ostream& os, const SkClipOp& o);
extern std::ostream& operator<<(std::ostream& os, const SkMatrix& m);
@@ -33,7 +32,6 @@ extern std::ostream& operator<<(std::ostream& os, const SkColor4f& r);
extern std::ostream& operator<<(std::ostream& os, const SkPaint& r);
extern std::ostream& operator<<(std::ostream& os, const SkSamplingOptions& s);
} // namespace testing
} // namespace flutter
} // namespace std
#endif // FLUTTER_TESTING_ASSERTIONS_SKIA_H_