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

Side by Side 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, 9 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 unified diff | Download patch
« no previous file with comments | « ui/gfx/paint_vector_icon.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/gfx/paint_vector_icon.h"
6
7 #include <gtest/gtest.h>
8 #include <vector>
9
10 #include "third_party/skia/include/core/SkCanvas.h"
11 #include "third_party/skia/include/core/SkPath.h"
12 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/vector_icon_types.h"
14
15 namespace gfx {
16
17 namespace {
18
19 class MockCanvas : public SkCanvas {
20 public:
21 MockCanvas(int width, int height) : SkCanvas(width, height) {}
22
23 // SkCanvas overrides:
24 void onDrawPath(const SkPath& path, const SkPaint& paint) override {
25 paths_.push_back(path);
26 }
27
28 const std::vector<SkPath>& paths() const { return paths_; }
29
30 private:
31 std::vector<SkPath> paths_;
32
33 DISALLOW_COPY_AND_ASSIGN(MockCanvas);
34 };
35
36 // Tests that a relative move to command (R_MOVE_TO) after a close command
37 // (CLOSE) uses the correct starting point. See crbug.com/697497
38 TEST(VectorIconTest, RelativeMoveToAfterClose) {
39 MockCanvas mock(100, 100);
40 Canvas canvas(&mock, 1.0f);
41
42 const PathElement elements[] = {
43 MOVE_TO, 4, 5,
44 LINE_TO, 10, 11,
45 CLOSE,
46 // This move should use (4, 5) as the start point rather than (10, 11).
47 R_MOVE_TO, 20, 21,
48 R_LINE_TO, 50, 51,
49 END,
50 };
51 const VectorIcon icon = {elements, nullptr};
52
53 PaintVectorIcon(&canvas, icon, 100, SK_ColorMAGENTA);
54 ASSERT_EQ(1U, mock.paths().size());
55 SkPoint last_point;
56 EXPECT_TRUE(mock.paths()[0].getLastPt(&last_point));
57 EXPECT_EQ(SkIntToScalar(74), last_point.x());
58 EXPECT_EQ(SkIntToScalar(77), last_point.y());
59 }
60
61 } // namespace
62
63 } // namespace gfx
OLDNEW
« 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