Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / ui / gfx / test / gfx_util.cc
index 29afec2..2d670d4 100644 (file)
@@ -8,6 +8,20 @@
 #include <sstream>
 #include <string>
 
+#include "ui/gfx/geometry/box_f.h"
+#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/geometry/point3_f.h"
+#include "ui/gfx/geometry/point_f.h"
+#include "ui/gfx/geometry/quad_f.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/rect_f.h"
+#include "ui/gfx/geometry/size.h"
+#include "ui/gfx/geometry/size_f.h"
+#include "ui/gfx/geometry/vector2d.h"
+#include "ui/gfx/geometry/vector2d_f.h"
+#include "ui/gfx/geometry/vector3d_f.h"
+#include "ui/gfx/transform.h"
+
 namespace gfx {
 
 namespace {
@@ -48,6 +62,21 @@ bool FloatAlmostEqual(float a, float b) {
                                        << "\nWhich is: " << lhs.ToString();
 }
 
+::testing::AssertionResult AssertRectFloatEqual(const char* lhs_expr,
+                                                const char* rhs_expr,
+                                                const RectF& lhs,
+                                                const RectF& rhs) {
+  if (FloatAlmostEqual(lhs.x(), rhs.x()) &&
+      FloatAlmostEqual(lhs.y(), rhs.y()) &&
+      FloatAlmostEqual(lhs.width(), rhs.width()) &&
+      FloatAlmostEqual(lhs.height(), rhs.height())) {
+    return ::testing::AssertionSuccess();
+  }
+  return ::testing::AssertionFailure()
+         << "Value of: " << rhs_expr << "\n  Actual: " << rhs.ToString()
+         << "\nExpected: " << lhs_expr << "\nWhich is: " << lhs.ToString();
+}
+
 ::testing::AssertionResult AssertSkColorsEqual(const char* lhs_expr,
                                                const char* rhs_expr,
                                                SkColor lhs,
@@ -61,4 +90,56 @@ bool FloatAlmostEqual(float a, float b) {
                                        << "\nWhich is: " << ColorAsString(lhs);
 }
 
+void PrintTo(const BoxF& box, ::std::ostream* os) {
+  *os << box.ToString();
+}
+
+void PrintTo(const Point& point, ::std::ostream* os) {
+  *os << point.ToString();
+}
+
+void PrintTo(const Point3F& point, ::std::ostream* os) {
+  *os << point.ToString();
+}
+
+void PrintTo(const PointF& point, ::std::ostream* os) {
+  *os << point.ToString();
+}
+
+void PrintTo(const QuadF& quad, ::std::ostream* os) {
+  *os << quad.ToString();
+}
+
+void PrintTo(const Rect& rect, ::std::ostream* os) {
+  *os << rect.ToString();
+}
+
+void PrintTo(const RectF& rect, ::std::ostream* os) {
+  *os << rect.ToString();
+}
+
+void PrintTo(const Size& size, ::std::ostream* os) {
+  *os << size.ToString();
+}
+
+void PrintTo(const SizeF& size, ::std::ostream* os) {
+  *os << size.ToString();
+}
+
+void PrintTo(const Transform& transform, ::std::ostream* os) {
+  *os << transform.ToString();
+}
+
+void PrintTo(const Vector2d& vector, ::std::ostream* os) {
+  *os << vector.ToString();
+}
+
+void PrintTo(const Vector2dF& vector, ::std::ostream* os) {
+  *os << vector.ToString();
+}
+
+void PrintTo(const Vector3dF& vector, ::std::ostream* os) {
+  *os << vector.ToString();
+}
+
 }  // namespace gfx