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

Unified Diff: third_party/WebKit/Source/core/layout/CollapsedBorderValueTest.cpp

Issue 2858143003: Move condition in CollapsedBorderValue::Width() into constructor (Closed)
Patch Set: - Created 3 years, 7 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 | « third_party/WebKit/Source/core/layout/CollapsedBorderValue.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/CollapsedBorderValueTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/CollapsedBorderValueTest.cpp b/third_party/WebKit/Source/core/layout/CollapsedBorderValueTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..18518b2d2bde60062edac6ebdcdfbb2f43dde770
--- /dev/null
+++ b/third_party/WebKit/Source/core/layout/CollapsedBorderValueTest.cpp
@@ -0,0 +1,131 @@
+// 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 "core/layout/CollapsedBorderValue.h"
+
+#include "core/style/ComputedStyle.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+TEST(CollapsedBorderValueTest, Default) {
+ CollapsedBorderValue v;
+ EXPECT_EQ(0u, v.Width());
+ EXPECT_EQ(kBorderStyleNone, v.Style());
+ EXPECT_FALSE(v.Exists());
+ EXPECT_EQ(kBorderPrecedenceOff, v.Precedence());
+ EXPECT_FALSE(v.IsVisible());
+
+ EXPECT_TRUE(v.IsSameIgnoringColor(v));
+ EXPECT_TRUE(v.VisuallyEquals(v));
+ EXPECT_TRUE(v.IsSameIgnoringColor(CollapsedBorderValue()));
+ EXPECT_TRUE(v.VisuallyEquals(CollapsedBorderValue()));
+}
+
+TEST(CollapsedBorderValueTest, SolidZeroWidth) {
+ auto style = ComputedStyle::Create();
+ style->SetBorderLeftWidth(0);
+ style->SetBorderLeftStyle(kBorderStyleSolid);
+ CollapsedBorderValue v(style->BorderLeft(), Color(255, 0, 0),
+ kBorderPrecedenceCell);
+ EXPECT_TRUE(v.Exists());
+ EXPECT_EQ(0u, v.Width());
+ EXPECT_FALSE(v.IsTransparent());
+ EXPECT_FALSE(v.IsVisible());
+
+ EXPECT_TRUE(v.IsSameIgnoringColor(v));
+ EXPECT_TRUE(v.VisuallyEquals(v));
+ EXPECT_FALSE(v.IsSameIgnoringColor(CollapsedBorderValue()));
+ EXPECT_FALSE(v.IsSameIgnoringColor(
+ CollapsedBorderValue(ComputedStyle::Create()->BorderLeft(),
+ Color(0, 255, 0), kBorderPrecedenceCell)));
+ EXPECT_TRUE(v.VisuallyEquals(CollapsedBorderValue()));
+}
+
+TEST(CollapsedBorderValueTest, SolidNonZeroWidthTransparent) {
+ auto style = ComputedStyle::Create();
+ style->SetBorderLeftWidth(5);
+ style->SetBorderLeftStyle(kBorderStyleSolid);
+ CollapsedBorderValue v(style->BorderLeft(), Color(), kBorderPrecedenceCell);
+ EXPECT_TRUE(v.Exists());
+ EXPECT_EQ(5u, v.Width());
+ EXPECT_TRUE(v.IsTransparent());
+ EXPECT_FALSE(v.IsVisible());
+
+ EXPECT_TRUE(v.IsSameIgnoringColor(v));
+ EXPECT_TRUE(v.VisuallyEquals(v));
+ EXPECT_FALSE(v.IsSameIgnoringColor(CollapsedBorderValue()));
+ EXPECT_TRUE(v.IsSameIgnoringColor(CollapsedBorderValue(
+ style->BorderLeft(), Color(0, 255, 0), kBorderPrecedenceCell)));
+ EXPECT_TRUE(v.VisuallyEquals(CollapsedBorderValue()));
+}
+
+TEST(CollapsedBorderValueTest, None) {
+ auto style = ComputedStyle::Create();
+ style->SetBorderLeftWidth(5);
+ style->SetBorderLeftStyle(kBorderStyleNone);
+ CollapsedBorderValue v(style->BorderLeft(), Color(255, 0, 0),
+ kBorderPrecedenceCell);
+ EXPECT_TRUE(v.Exists());
+ EXPECT_EQ(0u, v.Width());
+ EXPECT_FALSE(v.IsTransparent());
+ EXPECT_FALSE(v.IsVisible());
+
+ EXPECT_TRUE(v.IsSameIgnoringColor(v));
+ EXPECT_TRUE(v.VisuallyEquals(v));
+ EXPECT_FALSE(v.IsSameIgnoringColor(CollapsedBorderValue()));
+ EXPECT_TRUE(v.IsSameIgnoringColor(
+ CollapsedBorderValue(ComputedStyle::Create()->BorderLeft(),
+ Color(0, 255, 0), kBorderPrecedenceCell)));
+ EXPECT_TRUE(v.VisuallyEquals(CollapsedBorderValue()));
+}
+
+TEST(CollapsedBorderValueTest, Hidden) {
+ auto style = ComputedStyle::Create();
+ style->SetBorderLeftWidth(5);
+ style->SetBorderLeftStyle(kBorderStyleHidden);
+ CollapsedBorderValue v(style->BorderLeft(), Color(255, 0, 0),
+ kBorderPrecedenceCell);
+ EXPECT_TRUE(v.Exists());
+ EXPECT_EQ(0u, v.Width());
+ EXPECT_FALSE(v.IsTransparent());
+ EXPECT_FALSE(v.IsVisible());
+
+ EXPECT_TRUE(v.IsSameIgnoringColor(v));
+ EXPECT_TRUE(v.VisuallyEquals(v));
+ EXPECT_FALSE(v.IsSameIgnoringColor(CollapsedBorderValue()));
+ EXPECT_FALSE(v.IsSameIgnoringColor(
+ CollapsedBorderValue(ComputedStyle::Create()->BorderLeft(),
+ Color(0, 255, 0), kBorderPrecedenceCell)));
+ EXPECT_TRUE(v.VisuallyEquals(CollapsedBorderValue()));
+}
+
+TEST(CollapsedBorderValueTest, SolidNonZeroWidthNonTransparent) {
+ auto style = ComputedStyle::Create();
+ style->SetBorderLeftWidth(5);
+ style->SetBorderLeftStyle(kBorderStyleSolid);
+ CollapsedBorderValue v(style->BorderLeft(), Color(255, 0, 0),
+ kBorderPrecedenceCell);
+ EXPECT_TRUE(v.Exists());
+ EXPECT_EQ(5u, v.Width());
+ EXPECT_FALSE(v.IsTransparent());
+ EXPECT_TRUE(v.IsVisible());
+
+ EXPECT_TRUE(v.IsSameIgnoringColor(v));
+ EXPECT_TRUE(v.VisuallyEquals(v));
+ EXPECT_FALSE(v.IsSameIgnoringColor(CollapsedBorderValue()));
+ EXPECT_FALSE(v.VisuallyEquals(CollapsedBorderValue()));
+
+ EXPECT_TRUE(v.IsSameIgnoringColor(CollapsedBorderValue(
+ style->BorderLeft(), Color(0, 255, 0), kBorderPrecedenceCell)));
+ EXPECT_FALSE(v.VisuallyEquals(CollapsedBorderValue(
+ style->BorderLeft(), Color(0, 255, 0), kBorderPrecedenceCell)));
+
+ EXPECT_FALSE(v.IsSameIgnoringColor(CollapsedBorderValue(
+ style->BorderLeft(), Color(255, 0, 0), kBorderPrecedenceTable)));
+ EXPECT_TRUE(v.VisuallyEquals(CollapsedBorderValue(
+ style->BorderLeft(), Color(255, 0, 0), kBorderPrecedenceTable)));
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/CollapsedBorderValue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698