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

Unified Diff: ui/gfx/paint_vector_icon_unittest.cc

Issue 2732493002: Vector icons: fix R_MOVE_TO after CLOSE (Closed)
Patch Set: move include Created 3 years, 10 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/paint_vector_icon.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/paint_vector_icon_unittest.cc
diff --git a/ui/gfx/paint_vector_icon_unittest.cc b/ui/gfx/paint_vector_icon_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6786bf12d0187affcaf2952c4352264efdd1f08e
--- /dev/null
+++ b/ui/gfx/paint_vector_icon_unittest.cc
@@ -0,0 +1,63 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/gfx/paint_vector_icon.h"
+
+#include <gtest/gtest.h>
+#include <vector>
+
+#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/core/SkPath.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/vector_icon_types.h"
+
+namespace gfx {
+
+namespace {
+
+class MockCanvas : public SkCanvas {
+ public:
+ MockCanvas(int width, int height) : SkCanvas(width, height) {}
+
+ // SkCanvas overrides:
+ void onDrawPath(const SkPath& path, const SkPaint& paint) override {
+ paths_.push_back(path);
+ }
+
+ const std::vector<SkPath>& paths() const { return paths_; }
+
+ private:
+ std::vector<SkPath> paths_;
+
+ DISALLOW_COPY_AND_ASSIGN(MockCanvas);
+};
+
+// Tests that a relative move to command (R_MOVE_TO) after a close command
+// (CLOSE) uses the correct starting point. See crbug.com/697497
+TEST(VectorIconTest, RelativeMoveToAfterClose) {
+ MockCanvas mock(100, 100);
+ Canvas canvas(&mock, 1.0f);
+
+ const PathElement elements[] = {
+ MOVE_TO, 4, 5,
+ LINE_TO, 10, 11,
+ CLOSE,
+ // This move should use (4, 5) as the start point rather than (10, 11).
+ R_MOVE_TO, 20, 21,
+ R_LINE_TO, 50, 51,
+ END,
+ };
+ const VectorIcon icon = {elements, nullptr};
+
+ PaintVectorIcon(&canvas, icon, 100, SK_ColorMAGENTA);
+ ASSERT_EQ(1U, mock.paths().size());
+ SkPoint last_point;
+ EXPECT_TRUE(mock.paths()[0].getLastPt(&last_point));
+ EXPECT_EQ(SkIntToScalar(74), last_point.x());
+ EXPECT_EQ(SkIntToScalar(77), last_point.y());
+}
+
+} // namespace
+
+} // namespace gfx
« no previous file with comments | « ui/gfx/paint_vector_icon.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698