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

Side by Side Diff: third_party/WebKit/Source/modules/csspaint/PaintRenderingContext2DTest.cpp

Issue 1778413003: Implement PaintRenderingContext2D off BaseRenderingContext2D (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
OLDNEW
(Empty)
1 // Copyright 2016 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 "modules/csspaint/PaintRenderingContext2D.h"
6
7 #include "platform/graphics/ImageBuffer.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace blink {
11 namespace {
12
13 static const int s_width = 50;
14 static const int s_height = 75;
15
16 class PaintRenderingContext2DTest : public ::testing::Test {
17 protected:
18 void SetUp() override;
19
20 RefPtrWillBePersistent<PaintRenderingContext2D> m_ctx;
21 };
22
23 void PaintRenderingContext2DTest::SetUp()
24 {
25 m_ctx = PaintRenderingContext2D::create(ImageBuffer::create(IntSize(s_width, s_height)));
26 }
27
28 void trySettingStrokeStyle(PaintRenderingContext2D* ctx, const String& expected, const String& value)
29 {
30 StringOrCanvasGradientOrCanvasPattern result, arg, dummy;
31 dummy.setString("red");
32 arg.setString(value);
33 ctx->setStrokeStyle(dummy);
34 ctx->setStrokeStyle(arg);
35 ctx->strokeStyle(result);
36 EXPECT_EQ(expected, result.getAsString());
37 }
38
39 TEST_F(PaintRenderingContext2DTest, testParseColorOrCurrentColor)
40 {
41 trySettingStrokeStyle(m_ctx.get(), "#0000ff", "blue");
42 trySettingStrokeStyle(m_ctx.get(), "#000000", "currentColor");
43 }
44
45 TEST_F(PaintRenderingContext2DTest, testWidthAndHeight)
46 {
47 EXPECT_EQ(s_width, m_ctx->width());
48 EXPECT_EQ(s_height, m_ctx->height());
49 }
50
51 TEST_F(PaintRenderingContext2DTest, testBasicState)
52 {
53 const double shadowBlurBefore = 2;
54 const double shadowBlurAfter = 3;
55
56 const String lineJoinBefore = "bevel";
57 const String lineJoinAfter = "round";
58
59 m_ctx->setShadowBlur(shadowBlurBefore);
60 m_ctx->setLineJoin(lineJoinBefore);
61 EXPECT_EQ(shadowBlurBefore, m_ctx->shadowBlur());
62 EXPECT_EQ(lineJoinBefore, m_ctx->lineJoin());
63
64 m_ctx->save();
65
66 m_ctx->setShadowBlur(shadowBlurAfter);
67 m_ctx->setLineJoin(lineJoinAfter);
68 EXPECT_EQ(shadowBlurAfter, m_ctx->shadowBlur());
69 EXPECT_EQ(lineJoinAfter, m_ctx->lineJoin());
70
71 m_ctx->restore();
72
73 EXPECT_EQ(shadowBlurBefore, m_ctx->shadowBlur());
74 EXPECT_EQ(lineJoinBefore, m_ctx->lineJoin());
75 }
76
77 } // namespace
78 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/csspaint/PaintRenderingContext2D.idl ('k') | third_party/WebKit/Source/modules/modules.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698