libui: PrintTo and comparisons for values for tests
Define `PrintTo` and (except for Region) ensure there is an appropriate
`operator==`. The Google Test framework will uses `PrintTo` to print out
values if available, and uses operator == to check if values match
expected values.
The following value types were modified:
* Rect
* FloatRect
* Region
* Transform
With these definitions, the Composition Engine tests no longer need
custom matchers to print/compare values (except for Region).
For Region it seemed unwise to define a general `operator==` as equality
of Regions might mean different things to different callers. Instead
this change just adds a `Region::hasSameRects(const Region& other)`
function to do the fast check that the tests were doing. As such a
matcher helper is still needed which calls that function, though now it
is much more trivial to write.
Bug: None
Test: libcompositionengine_test
Change-Id: I160cda695d99257966634e767ee1164bc6105e30
diff --git a/libs/ui/Transform.cpp b/libs/ui/Transform.cpp
index 85abb38..06b6bfe 100644
--- a/libs/ui/Transform.cpp
+++ b/libs/ui/Transform.cpp
@@ -49,6 +49,15 @@
return isZero(fabs(f) - 1.0f);
}
+bool Transform::operator==(const Transform& other) const {
+ return mMatrix[0][0] == other.mMatrix[0][0] && mMatrix[0][1] == other.mMatrix[0][1] &&
+ mMatrix[0][2] == other.mMatrix[0][2] && mMatrix[1][0] == other.mMatrix[1][0] &&
+ mMatrix[1][1] == other.mMatrix[1][1] && mMatrix[1][2] == other.mMatrix[1][2] &&
+ mMatrix[2][0] == other.mMatrix[2][0] && mMatrix[2][1] == other.mMatrix[2][1] &&
+ mMatrix[2][2] == other.mMatrix[2][2];
+ ;
+}
+
Transform Transform::operator * (const Transform& rhs) const
{
if (CC_LIKELY(mType == IDENTITY))