Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Unified Diff: ui/gfx/test/gfx_util.cc

Issue 368903003: Provide gtest printers for ui/gfx geometry types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add gfx_test_support dep to video_encode_accelerator_unittest Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/test/gfx_util.h ('k') | ui/gfx/transform.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/test/gfx_util.cc
diff --git a/ui/gfx/test/gfx_util.cc b/ui/gfx/test/gfx_util.cc
index 29afec288ca6864d14eb1e7dbb1ae4e3062bcc65..2d670d4a9444aff4aa5d9e87a1a649439d108273 100644
--- a/ui/gfx/test/gfx_util.cc
+++ b/ui/gfx/test/gfx_util.cc
@@ -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
« no previous file with comments | « ui/gfx/test/gfx_util.h ('k') | ui/gfx/transform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698